suite: ip-allow-list middleware test
templates:
  - common.yaml
release:
  name: test-release-name
  namespace: test-release-namespace
tests:
  - it: should pass with all set
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: ip-allow-list
            data:
              sourceRange:
                - some-source-range
              ipStrategy:
                depth: 1
                excludedIPs:
                  - some-excluded-ip
    asserts:
      - documentIndex: &middlewareDoc 0
        isKind:
          of: Middleware
      - documentIndex: *middlewareDoc
        equal:
          path: spec
          value:
            ipAllowList:
              sourceRange:
                - some-source-range
              ipStrategy:
                depth: 1
                excludedIPs:
                  - some-excluded-ip

  - it: should fail with invalid sourceRange
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: ip-allow-list
            data:
              sourceRange: some-source-range
    asserts:
      - failedTemplate:
          errorMessage: Middleware (ip-allow-list) - Expected [sourceRange] to be a list, but got [string]

  - it: should fail with invalid ipStrategy.excludedIPs
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: ip-allow-list
            data:
              sourceRange:
                - some-source-range
              ipStrategy:
                excludedIPs: some-excluded-ip
    asserts:
      - failedTemplate:
          errorMessage: Middleware (ip-allow-list) - Expected [ipStrategy.excludedIPs] to be a list, but got [string]
