suite: plugin-real-ip 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: plugin-real-ip
            data:
              excludednets:
                - some-excluded-net
                - some-other-excluded-net
    asserts:
      - documentIndex: &middlewareDoc 0
        equal:
          path: spec
          value:
            plugin:
              traefik-real-ip:
                excludednets:
                  - some-excluded-net
                  - some-other-excluded-net

  - it: should pass with pluginName set
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: plugin-real-ip
            data:
              pluginName: traefik-real-ip-test
              excludednets:
                - some-excluded-net
                - some-other-excluded-net
    asserts:
      - documentIndex: *middlewareDoc
        equal:
          path: spec
          value:
            plugin:
              traefik-real-ip-test:
                excludednets:
                  - some-excluded-net
                  - some-other-excluded-net

  - it: should fail with missing excludednets
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: plugin-real-ip
            data:
              foo: bar
    asserts:
      - failedTemplate:
          errorMessage: Middleware (real-ip) - Expected [excludednets] to be set
