-
Notifications
You must be signed in to change notification settings - Fork 22
/
scenario_audience.go
24 lines (19 loc) · 1.16 KB
/
scenario_audience.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package istiojwt
import (
"fmt"
"strings"
"github.com/cucumber/godog"
)
func initAudience(ctx *godog.ScenarioContext, ts *testsuite) {
scenario := ts.createScenario("istio-jwt-audiences.yaml", "istio-jwt-audiences")
ctx.Step(`Audiences: There is a httpbin service$`, scenario.thereIsAHttpbinService)
ctx.Step(`Audiences: There is an endpoint secured with JWT on path "([^"]*)" requiring audiences '(\[.*\])'$`, scenario.thereIsAnEndpointWithAudiences)
ctx.Step(`Audiences: There is an endpoint secured with JWT on path "([^"]*)" requiring audience '(\[.*\])' or '(\[.*\])'$`, scenario.emptyStep)
ctx.Step(`Audiences: The APIRule is applied$`, scenario.theAPIRuleIsApplied)
ctx.Step(`Audiences: Calling the "([^"]*)" endpoint with a valid "([^"]*)" token with "([^"]*)" "([^"]*)" and "([^"]*)" should result in status between (\d+) and (\d+)`, scenario.callingTheEndpointWithAValidToken)
ctx.Step(`Audiences: Teardown httpbin service$`, scenario.teardownHttpbinService)
}
func (s *scenario) thereIsAnEndpointWithAudiences(path string, audiences string) error {
s.ManifestTemplate[fmt.Sprintf("%s%s", strings.TrimPrefix(path, "/"), "Audiences")] = audiences
return nil
}