suite: stripPrefix 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: strip-prefix
            data:
              forceSlash: true
              prefix:
                - /some-prefix
                - /some-other-prefix
    asserts:
      - documentIndex: &middlewareDoc 0
        isKind:
          of: Middleware
      - documentIndex: *middlewareDoc
        equal:
          path: spec
          value:
            stripPrefix:
              forceSlash: true
              prefix:
                - /some-prefix
                - /some-other-prefix

  - it: should fail with missing prefix
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: strip-prefix
            data:
              prefix: []
    asserts:
      - failedTemplate:
          errorMessage: Middleware (strip-prefix) - Expected [prefix] to be set

  - it: should fail with invalid forceSlash
    set:
      ingressMiddlewares:
        traefik:
          my-middleware1:
            enabled: true
            type: strip-prefix
            data:
              prefix:
                - /some-prefix
              forceSlash: some-value
    asserts:
      - failedTemplate:
          errorMessage: Middleware (strip-prefix) - Expected [forceSlash] to be a boolean, but got [string]
