/
scenario_jwt_custom_label_selector.go
46 lines (37 loc) · 2.02 KB
/
scenario_jwt_custom_label_selector.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package istiojwt
import (
"fmt"
"github.com/cucumber/godog"
"github.com/kyma-project/api-gateway/tests/integration/pkg/manifestprocessor"
)
func initCustomLabelSelector(ctx *godog.ScenarioContext, ts *testsuite) {
scenario := ts.createScenario("istio-jwt-custom-label-selector.yaml", "istio-jwt-custom-label-selector")
ctx.Step(`CustomLabelSelector: There is a helloworld service with custom label selector name "([^"]*)"$`, scenario.thereIsHelloworldCustomLabelService)
ctx.Step(`CustomLabelSelector: There is an endpoint secured with JWT on path "([^"]*)"`, scenario.thereIsAnJwtSecuredPath)
ctx.Step(`CustomLabelSelector: The APIRule is applied$`, scenario.theAPIRuleIsApplied)
ctx.Step(`CustomLabelSelector: Calling the "([^"]*)" endpoint without a token should result in status between (\d+) and (\d+)$`, scenario.callingTheEndpointWithoutTokenShouldResultInStatusBetween)
ctx.Step(`CustomLabelSelector: Calling the "([^"]*)" endpoint with a valid "([^"]*)" token should result in status between (\d+) and (\d+)$`, scenario.callingTheEndpointWithValidTokenShouldResultInStatusBetween)
ctx.Step(`CustomLabelSelector: Teardown helloworld service$`, scenario.teardownHelloworldCustomLabelService)
}
func (s *scenario) thereIsHelloworldCustomLabelService(labelName string) error {
s.ManifestTemplate["CustomLabelName"] = labelName
resources, err := manifestprocessor.ParseFromFileWithTemplate("testing-helloworld-custom-label-app.yaml", s.ApiResourceDirectory, s.ManifestTemplate)
if err != nil {
return err
}
_, err = s.resourceManager.CreateResources(s.k8sClient, resources...)
s.Url = fmt.Sprintf("https://helloworld-%s.%s", s.TestID, s.Domain)
return err
}
func (s *scenario) teardownHelloworldCustomLabelService() error {
resources, err := manifestprocessor.ParseFromFileWithTemplate("testing-helloworld-custom-label-app.yaml", s.ApiResourceDirectory, s.ManifestTemplate)
if err != nil {
return err
}
err = s.resourceManager.DeleteResources(s.k8sClient, resources...)
if err != nil {
return err
}
s.Url = ""
return nil
}