test:
  hostport: httpbin.org:80
  #  hostport: localhost:5000
  #  uri: http://${test.hostport}
  uri: lb://testservice

server:
  error:
    include-message: always

spring:
  profiles:
    group:
      - logging

  cloud:
    gateway:
      globalcors:
        cors-configurations:
          '[/**]':
            maxAge: 10
            allowedOrigins: "*"
            allowedMethods:
            - GET
      default-filters:
      - AddResponseHeader=X-Response-Default-Foo, Default-Bar
      - PrefixPath=/httpbin

      # TODO: breakup configuration for individual tests (though some are reused)
      routes:
      # =====================================
      - host_example_to_httpbin=${test.uri}, Host=**.example.org

      # =====================================
      - id: host_foo_path_headers_to_httpbin
        uri: ${test.uri}
        predicates:
        - Host=**.foo.org
        - Path=/headers
        - Method=GET
        - Header=X-Request-Id, \d+
        - Query=foo, ba.
        - Query=baz
        - Cookie=chocolate, ch.p
        - After=1900-01-20T17:42:47.789-07:00[America/Denver]
        filters:
        - AddResponseHeader=X-Response-Foo, Bar

      # =====================================
      - id: add_request_header_test
        uri: ${test.uri}
        predicates:
        - Host=**.addrequestheader.org
        - Path=/headers
        filters:
        - AddRequestHeader=X-Request-Foo, Bar

      # =====================================
      - id: add_request_parameter_test
        uri: ${test.uri}
        predicates:
        - Host=**.addrequestparameter.org
        - Path=/get
        filters:
        - AddRequestParameter=foo, bar

      # =====================================
      - id: add_response_header_test
        uri: ${test.uri}
        predicates:
        - Host=**.addresponseheader.org
        - Path=/headers
        filters:
        - AddResponseHeader=X-Request-Foo, Bar

      - id: cache_request_body_test
        uri: ${test.uri}
        predicates:
          - Host=**.cacherequestbody.org
        filters:
          - name: CacheRequestBody
            args:
              bodyClass: java.lang.String

        # =====================================
      - id: circuitbreaker_exception_fallback_test
        uri: ${test.uri}
        predicates:
          - Host=**.circuitbreakerexceptionfallback.org
        filters:
          - name: CircuitBreaker
            args:
              name: fallbackcmd
              fallbackUri: forward:/circuitbreakerExceptionFallback

        # =====================================
      - id: circuitbreaker_fallback_test
        uri: ${test.uri}
        predicates:
          - Host=**.circuitbreakerfallback.org
        filters:
          - name: CircuitBreaker
            args:
              name: fallbackcmd
              fallbackUri: forward:/circuitbreakerFallbackController

        # =====================================
      - id: circuitbreaker_fallback_test_variables
        uri: ${test.uri}
        predicates:
          - Path=/delay/{*segments}
          - Host={host}.circuitbreakervariables.org
        filters:
          - name: CircuitBreaker
            args:
              name: fallbackvarscmd
              fallbackUri: forward:/circuitbreakerUriFallbackController/{segments}/{host}
        # =====================================
      - id: circuitbreaker_fallback_test_path
        uri: ${test.uri}
        predicates:
          - Path=/status/**
          - Host=**.circuitbreakerfallbackpath.org
        filters:
          - name: CircuitBreaker
            args:
              name: fallbackcmd
              statusCodes:
                - 200
              fallbackUri: forward:/headers

      # =====================================
      - id: circuitbreaker_fallback_test_statuscode
        uri: ${test.uri}
        predicates:
          - Host=**.circuitbreakerstatuscode.org
        filters:
          - name: CircuitBreaker
            args:
              name: fallbackcmd
              statusCodes:
                - 500
                - "NOT_FOUND"
              fallbackUri: forward:/statusCodeFallbackController

        # =====================================
      - id: circuitbreaker_resume_without_error
        uri: ${test.uri}
        predicates:
          - Host=**.circuitbreakerresumewithouterror.org
        filters:
          - name: CircuitBreaker
            args:
              name: resumewithouterror
              statusCodes:
                - 500
                - "NOT_FOUND"
              resume-without-error: true

        # =====================================
      - id: change_uri_test
        uri: ${test.uri}
        predicates:
          - Host=**.changeuri.org
          - Header=X-CF-Forwarded-Url
        filters:
          - RequestHeaderToRequestUri=X-CF-Forwarded-Url

        # =====================================
      - id: cloudfoundry_routeservice_test
        uri: ${test.uri}
        predicates:
          - CloudFoundryRouteService=
        filters:
          - RequestHeaderToRequestUri=X-CF-Forwarded-Url

        # =====================================
      - id: cookie_regex_test
        uri: ${test.uri}
        predicates:
          - Host=**.cookieregex.org
          - Cookie=mycookie, hello.*

      # =====================================
      - id: dedupe_response_header_test
        uri: ${test.uri}
        predicates:
          - Host=**.deduperesponseheader.org
          - Path=/headers
        filters:
          - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin, RETAIN_FIRST
          - DedupeResponseHeader=Scout-Cookie, RETAIN_LAST
          - DedupeResponseHeader=Next-Week-Lottery-Numbers, RETAIN_UNIQUE
          - AddResponseHeader=Access-Control-Allow-Credentials, false
          - AddResponseHeader=Access-Control-Allow-Credentials, true
          - AddResponseHeader=Access-Control-Allow-Origin, *
          - AddResponseHeader=Access-Control-Allow-Origin, https://musk.mars
          - AddResponseHeader=Scout-Cookie, S'mores
          - AddResponseHeader=Scout-Cookie, Thin Mints
          - AddResponseHeader=Next-Week-Lottery-Numbers, 42
          - AddResponseHeader=Next-Week-Lottery-Numbers, 2
          - AddResponseHeader=Next-Week-Lottery-Numbers, 2
          - AddResponseHeader=Next-Week-Lottery-Numbers, 4

      # =====================================
      - id: forward_test
        uri: forward:/localcontroller
        predicates:
        - Host=**.forward.org

        # =====================================
      - id: header_test
        uri: ${test.uri}
        predicates:
          - Header=Foo, .*


        # =====================================
      - id: without_pattern
        uri: ${test.uri}
        predicates:
          - name: Host
            args:
              pattern: 'hostpatternarg.org'

      # =====================================
      - id: host_backwards_compatible_test
        uri: ${test.uri}
        predicates:
        - name: Host
          args:
            pattern: '**.hostpatternarg.org'

      # =====================================
      - id: host_backwards_compatible_shortcut_test
        uri: ${test.uri}
        predicates:
        - Host=**.hostpatternshortcut.org

      # =====================================
      - id: host_multi_test
        uri: ${test.uri}
        predicates:
        - Host=**.hostmulti1.org,**.hostmulti2.org

      # =====================================
      - id: load_balancer_client_test
        uri: lb://testservice
        predicates:
        - Host=**.loadbalancerclient.org

      # =====================================
      - id: load_balancer_client_empty_test
        uri: lb://serviceshouldnotexistanywhere
        predicates:
        - Host=**.loadbalancerclientempty.org

      # =====================================
      - id: method_test
        uri: ${test.uri}
        predicates:
        - Method=GET
        - Host=**.method.org

      # =====================================
      - id: not_between_test
        uri: ${test.uri}
        predicates:
        - Host=**.notbetween.org
        - Between=1000-03-13T10:39:37.518-04:00[America/New_York],1002-03-13T10:39:37.518-04:00[America/New_York]

      # =====================================
      - id: path_test
        uri: ${test.uri}
        predicates:
        - Path=/{org}/{scope}/function,false
        - Host=**.path.org
        filters:
        - SetPath=/anything/{org}{scope}

      # =====================================
      - id: path_test_two
        uri: ${test.uri}
        predicates:
        - Path=/{org}/{scope}/function,true
        - Host=**.path.org
        filters:
        - SetStatus=404

        # =====================================
      - id: path_multi
        uri: ${test.uri}
        predicates:
        - Host=**.pathmulti.org
        - Path=/anything/multi1{num},/anything/multi2{num}
        filters:
        - SetPath=/anything/multi{num}

      # =====================================
      - id: path_regex
        uri: ${test.uri}
        predicates:
          - Host=**.pathregex.org
          - Path=/regex/{digits:\d+}
        filters:
          - SetPath=/anything/{digits}

        # =====================================
      - id: redirect_to_include_query_params_test
        uri: ${test.uri}
        predicates:
          - Host=queryparams.redirectto.org
        filters:
          - RedirectTo=302, https://example.org, true

      # =====================================
      - id: redirect_to_test
        uri: ${test.uri}
        predicates:
        - Host=**.redirectto.org
        filters:
        - RedirectTo=302, https://example.org

      # =====================================
      - id: remove_request_header_test
        uri: ${test.uri}
        predicates:
        - Host=**.removerequestheader.org
        - Path=/headers
        filters:
        - RemoveRequestHeader=X-Request-Foo

      # =====================================
      - id: remove_response_header_test
        uri: ${test.uri}
        predicates:
        - Host=**.removereresponseheader.org
        - Path=/headers
        filters:
        - RemoveResponseHeader=X-Request-Foo
        - AddResponseHeader=X-Request-Foo, Bar

        # =====================================
      - id: request_header_size_test
        uri: ${test.uri}
        predicates:
          - Host=**.requestheadersize.org
        filters:
          - RequestHeaderSize=46

        # =====================================
      - id: rewrite_location_response_header_test
        uri: ${test.uri}
        predicates:
          - Host=**.rewritelocationresponseheader.org
          - Path=/headers
        filters:
          - RewriteLocationResponseHeader
          - AddResponseHeader=Location, https://backend.org:443/v1/some/object/id

        # =====================================
      - id: rewrite_request_parameter_test
        uri: ${test.uri}
        predicates:
          - Host=**.rewriterequestparameter.org
        filters:
          - RewriteRequestParameter=campaign,fall2023

        # =====================================
      - id: rewrite_response_header_test
        uri: ${test.uri}
        predicates:
          - Host=**.rewriteresponseheader.org
          - Path=/headers
        filters:
          - RewriteResponseHeader=X-Request-Foo, password=[^&]+, password=***
          - AddResponseHeader=X-Request-Foo, /42?user=ford&password=omg!what&flag=true

        # =====================================
      - id: sccb_failure_test
        uri: ${test.uri}
        predicates:
          - Host=**.sccbfailure.org
        filters:
          - CircuitBreaker=failcmd

        # =====================================
      - id: sccb_success_test
        uri: ${test.uri}
        predicates:
          - Host=**.sccbsuccess.org
        filters:
          - CircuitBreaker=successcmd

        # =====================================
      - id: sccb_timeout_test
        uri: ${test.uri}
        predicates:
          - Host=**.sccbtimeout.org
        filters:
          - CircuitBreaker=timeoutcmd

      # =====================================
      - id: secure_headers_test
        uri: ${test.uri}
        predicates:
        - Host=**.secureheaders.org
        - Path=/headers
        filters:
        - SecureHeaders

        # =====================================
      - id: set_request_host_header_test
        uri: ${test.uri}
        predicates:
          - Host=**.setrequesthostheader.org
          - Path=/headers
        filters:
          - SetRequestHostHeader=otherhost.io

      # =====================================
      - id: set_path_test
        uri: ${test.uri}
        predicates:
        - Host=**.setpath.org
        - Path=/foo/{segment}
        filters:
        - SetPath=/{segment}

        # =====================================
      - id: set_path_host_test
        uri: ${test.uri}
        predicates:
        - Host={subdomain}.setpathhost.org
        filters:
        - SetPath=/{subdomain}

      # =====================================
      - id: set_response_header_test
        uri: ${test.uri}
        predicates:
        - Host=**.setreresponseheader.org
        - Path=/headers
        filters:
        - SetResponseHeader=X-Response-Foo, Bar
        - AddResponseHeader=X-Response-Foo, Bar2
        - AddResponseHeader=X-Response-Foo, Bar1

      # =====================================
      - id: set_status_int_test
        uri: ${test.uri}
        predicates:
        - Host=**.setstatusint.org
        - Path=/headers
        filters:
        - name: SetStatus
          args:
            status: 401

      # =====================================
      - id: set_status_string_test
        uri: ${test.uri}
        predicates:
        - Host=**.setstatusstring.org
        - Path=/headers
        filters:
        - SetStatus=BAD_REQUEST

        # =====================================
      - id: strip_prefix_test
        uri: ${test.uri}
        predicates:
          - Host=**.stripprefix.org
          - Path=/foo/**
        filters:
          - StripPrefix=2

        # =====================================
      - id: strip_prefix_default_test
        uri: ${test.uri}
        predicates:
          - Host=**.stripprefixdefault.org
          - Path=/foo/**
        filters:
          - StripPrefix

      # =====================================
      - id: rewrite_path_test
        uri: ${test.uri}
        predicates:
        - Host=**.baz.org
        - RemoteAddr=127.0.0.1/24
        filters:
        # $\ is being used as an escape
        - RewritePath=/foo/(?<segment>.*), /$\{segment}
        - AddRequestHeader=X-Request-Foo, Bar
        - AddRequestHeader=X-Request-Baz, Bat

        # =====================================
      - id: route_with_metadata
        uri: ${test.uri}
        order: 10000
        predicates:
          - name: Path
            args:
              pattern: /route_with_metadata
        metadata:
          optionName: "OptionValue"
          compositeObject:
            name: "value"
          iAmNumber: 1

      # =====================================
      - id: weight_high_test
        uri: ${test.uri}
        predicates:
        - Host=**.weighthigh.org
        - Weight=group1, 8

      # =====================================
      # should be last and not follow alphabetical order
      - id: default_path_to_httpbin
        uri: ${test.uri}
        order: 10000
        predicates:
        - name: Path
          args:
            pattern: /**

management:
  endpoints:
    web:
      exposure:
        include: "*"
