@@ -46,12 +46,13 @@ func TestValidatePolicy(t *testing.T) {
46
46
policy : & v1.Policy {
47
47
Spec : v1.PolicySpec {
48
48
OIDC : & v1.OIDC {
49
- AuthEndpoint : "https://foo.bar/auth" ,
50
- TokenEndpoint : "https://foo.bar/token" ,
51
- JWKSURI : "https://foo.bar/certs" ,
52
- ClientID : "random-string" ,
53
- ClientSecret : "random-secret" ,
54
- Scope : "openid" ,
49
+ AuthEndpoint : "https://foo.bar/auth" ,
50
+ TokenEndpoint : "https://foo.bar/token" ,
51
+ JWKSURI : "https://foo.bar/certs" ,
52
+ ClientID : "random-string" ,
53
+ ClientSecret : "random-secret" ,
54
+ Scope : "openid" ,
55
+ ZoneSyncLeeway : createPointerFromInt (10 ),
55
56
},
56
57
},
57
58
},
@@ -191,6 +192,24 @@ func TestValidatePolicyFails(t *testing.T) {
191
192
enableAppProtect : false ,
192
193
msg : "WAF policy with AP disabled" ,
193
194
},
195
+ {
196
+ policy : & v1.Policy {
197
+ Spec : v1.PolicySpec {
198
+ OIDC : & v1.OIDC {
199
+ AuthEndpoint : "https://foo.bar/auth" ,
200
+ TokenEndpoint : "https://foo.bar/token" ,
201
+ JWKSURI : "https://foo.bar/certs" ,
202
+ ClientID : "random-string" ,
203
+ ClientSecret : "random-secret" ,
204
+ Scope : "openid" ,
205
+ ZoneSyncLeeway : createPointerFromInt (- 1 ),
206
+ },
207
+ },
208
+ },
209
+ isPlus : true ,
210
+ enableOIDC : true ,
211
+ msg : "OIDC policy with invalid ZoneSyncLeeway" ,
212
+ },
194
213
}
195
214
for _ , test := range tests {
196
215
err := ValidatePolicy (test .policy , test .isPlus , test .enableOIDC , test .enableAppProtect )
@@ -852,13 +871,14 @@ func TestValidateOIDCValid(t *testing.T) {
852
871
}{
853
872
{
854
873
oidc : & v1.OIDC {
855
- AuthEndpoint : "https://accounts.google.com/o/oauth2/v2/auth" ,
856
- TokenEndpoint : "https://oauth2.
B72
googleapis.com/token" ,
857
- JWKSURI : "https://www.googleapis.com/oauth2/v3/certs" ,
858
- ClientID : "random-string" ,
859
- ClientSecret : "random-secret" ,
860
- Scope : "openid" ,
861
- RedirectURI : "/foo" ,
874
+ AuthEndpoint : "https://accounts.google.com/o/oauth2/v2/auth" ,
875
+ TokenEndpoint : "https://oauth2.googleapis.com/token" ,
876
+ JWKSURI : "https://www.googleapis.com/oauth2/v3/certs" ,
877
+ ClientID : "random-string" ,
878
+ ClientSecret : "random-secret" ,
879
+ Scope : "openid" ,
880
+ RedirectURI : "/foo" ,
881
+ ZoneSyncLeeway : createPointerFromInt (20 ),
862
882
},
863
883
msg : "verify full oidc" ,
864
884
},
@@ -992,6 +1012,18 @@ func TestValidateOIDCInvalid(t *testing.T) {
992
1012
},
993
1013
msg : "invalid chars in clientID" ,
994
1014
},
1015
+ {
1016
+ oidc : & v1.OIDC {
1017
+ AuthEndpoint : "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/auth" ,
1018
+ TokenEndpoint : "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/token" ,
1019
+ JWKSURI : "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/certs" ,
1020
+ ClientID : "foobar" ,
1021
+ ClientSecret : "secret" ,
1022
+ Scope : "openid" ,
1023
+ ZoneSyncLeeway : createPointerFromInt (- 1 ),
1024
+ },
1025
+ msg : "invalid zoneSyncLeeway value" ,
1026
+ },
995
1027
}
996
1028
997
1029
for _ , test := range tests {
0 commit comments