@@ -26,54 +26,13 @@ const (
26
26
)
27
27
28
28
var _ = Describe ("Reconciliation" , func () {
29
- jwtConfigJSON := fmt .Sprintf (`{"authentications": [{"issuer": "%s", "jwksUri": "%s"}]}` , jwtIssuer , jwksUri )
30
- jwtV1beta1 := []* gatewayv1beta1.Authenticator {
31
- {
32
- Handler : & gatewayv1beta1.Handler {
33
- Name : gatewayv1beta1 .AccessStrategyJwt ,
34
- Config : & runtime.RawExtension {
35
- Raw : []byte (jwtConfigJSON ),
36
- },
37
- },
38
- },
39
- }
40
- jwtV1beta1Rule := GetRuleFor (path , []gatewayv1beta1.HttpMethod {http .MethodGet }, []* gatewayv1beta1.Mutator {}, jwtV1beta1 )
41
-
42
- jwtV2alpha1 := gatewayv2alpha1.Rule {
43
- Path : path ,
44
- Methods : []gatewayv2alpha1.HttpMethod {http .MethodGet },
45
- Jwt : & gatewayv2alpha1.JwtConfig {
46
- Authentications : []* gatewayv2alpha1.JwtAuthentication {
47
- {
48
- Issuer : jwtIssuer ,
49
- JwksUri : jwksUri ,
50
- },
51
- },
52
- },
53
- }
54
-
55
- noAuthV1beta1 := []* gatewayv1beta1.Authenticator {
56
- {
57
- Handler : & gatewayv1beta1.Handler {
58
- Name : gatewayv1beta1 .AccessStrategyNoAuth ,
59
- },
60
- },
61
- }
62
- noAuthV1beta1Rule := GetRuleFor (path , []gatewayv1beta1.HttpMethod {http .MethodGet }, []* gatewayv1beta1.Mutator {}, noAuthV1beta1 )
63
-
64
- noAuthV2alpha1Rule := gatewayv2alpha1.Rule {
65
- Path : path ,
66
- Methods : []gatewayv2alpha1.HttpMethod {http .MethodGet },
67
- NoAuth : ptr .To (true ),
68
- }
69
29
70
30
It ("with v1beta1 no_auth and v2alpha1 noAuth should provide only Istio VS" , func () {
71
31
// given
72
-
73
- rulesV1beta1 := []gatewayv1beta1.Rule {noAuthV1beta1Rule }
32
+ rulesV1beta1 := []gatewayv1beta1.Rule {getNoAuthV1beta1Rule ()}
74
33
v1beta1ApiRule := GetAPIRuleFor (rulesV1beta1 )
75
34
76
- rulesV2alpha1 := []gatewayv2alpha1.Rule {noAuthV2alpha1Rule }
35
+ rulesV2alpha1 := []gatewayv2alpha1.Rule {getNoAuthV2alpha1Rule () }
77
36
v2alpha1ApiRule := getV2alpha1APIRuleFor ("test-apirule" , "some-namespace" , rulesV2alpha1 )
78
37
79
38
service := GetService (ServiceName )
@@ -99,10 +58,10 @@ var _ = Describe("Reconciliation", func() {
99
58
It ("with v1beta1 jwt and v2alpha1 jwt should provide VirtualService, AuthorizationPolicy and RequestAuthentication" , func () {
100
59
// given
101
60
102
- rulesV1beta1 := []gatewayv1beta1.Rule {jwtV1beta1Rule }
61
+ rulesV1beta1 := []gatewayv1beta1.Rule {getJwtV1beta1Rule () }
103
62
v1beta1ApiRule := GetAPIRuleFor (rulesV1beta1 )
104
63
105
- rulesV2alpha1 := []gatewayv2alpha1.Rule {jwtV2alpha1 }
64
+ rulesV2alpha1 := []gatewayv2alpha1.Rule {getJwtV2alpha1Rule () }
106
65
v2alpha1ApiRule := getV2alpha1APIRuleFor ("test-apirule" , "some-namespace" , rulesV2alpha1 )
107
66
108
67
service := GetService (ServiceName )
@@ -174,3 +133,53 @@ func getV2alpha1APIRuleFor(name, namespace string, rules []gatewayv2alpha1.Rule)
174
133
}
175
134
176
135
}
136
+
137
+ func getJwtV1beta1Rule () gatewayv1beta1.Rule {
138
+ jwtConfigJSON := fmt .Sprintf (`{"authentications": [{"issuer": "%s", "jwksUri": "%s"}]}` , jwtIssuer , jwksUri )
139
+ jwtV1beta1 := []* gatewayv1beta1.Authenticator {
140
+ {
141
+ Handler : & gatewayv1beta1.Handler {
142
+ Name : gatewayv1beta1 .AccessStrategyJwt ,
143
+ Config : & runtime.RawExtension {
144
+ Raw : []byte (jwtConfigJSON ),
145
+ },
146
+ },
147
+ },
148
+ }
149
+ return GetRuleFor (path , []gatewayv1beta1.HttpMethod {http .MethodGet }, []* gatewayv1beta1.Mutator {}, jwtV1beta1 )
150
+ }
151
+
152
+ func getNoAuthV1beta1Rule () gatewayv1beta1.Rule {
153
+
154
+ noAuthV1beta1 := []* gatewayv1beta1.Authenticator {
155
+ {
156
+ Handler : & gatewayv1beta1.Handler {
157
+ Name : gatewayv1beta1 .AccessStrategyNoAuth ,
158
+ },
159
+ },
160
+ }
161
+ return GetRuleFor (path , []gatewayv1beta1.HttpMethod {http .MethodGet }, []* gatewayv1beta1.Mutator {}, noAuthV1beta1 )
162
+ }
163
+
164
+ func getJwtV2alpha1Rule () gatewayv2alpha1.Rule {
165
+ return gatewayv2alpha1.Rule {
166
+ Path : path ,
167
+ Methods : []gatewayv2alpha1.HttpMethod {http .MethodGet },
168
+ Jwt : & gatewayv2alpha1.JwtConfig {
169
+ Authentications : []* gatewayv2alpha1.JwtAuthentication {
170
+ {
171
+ Issuer : jwtIssuer ,
172
+ JwksUri : jwksUri ,
173
+ },
174
+ },
175
+ },
176
+ }
177
+ }
178
+
179
+ func getNoAuthV2alpha1Rule () gatewayv2alpha1.Rule {
180
+ return gatewayv2alpha1.Rule {
181
+ Path : path ,
182
+ Methods : []gatewayv2alpha1.HttpMethod {http .MethodGet },
183
+ NoAuth : ptr .To (true ),
184
+ }
185
+ }
0 commit comments