suite: plugin-mod-security 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-mod-security
            data:
              modSecurityUrl: some-url
              timeoutMillis: 1000
              maxBodySize: 1024
    asserts:
      - documentIndex: &middlewareDoc 0
        equal:
          path: spec
          value:
            plugin:
              traefik-modsecurity-plugin:
                modSecurityUrl: some-url
                timeoutMillis: 1000
                maxBodySize: 1024

  - it: should pass with pluginName set
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: plugin-mod-security
            data:
              pluginName: traefik-mod-security-test
              modSecurityUrl: some-url
    asserts:
      - documentIndex: *middlewareDoc
        equal:
          path: spec
          value:
            plugin:
              traefik-mod-security-test:
                modSecurityUrl: some-url

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