mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-05 07:37:12 +00:00
Add integration tests for JWTAuthenticators
- paired with changes to e2e_test.go, adds Status.Condition assertions around JWTAuthenticators
This commit is contained in:
committed by
Ryan Richard
parent
1a633adde6
commit
73e4d3144b
@@ -417,12 +417,11 @@ func (c *jwtCacheFillerController) validateProviderJWKSURL(provider *coreosoidc.
|
||||
return pJSON.JWKSURL, conditions, fmt.Errorf("%s", msg)
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("jwks_uri (%s) is a valid URL", parsedJWKSURL)
|
||||
conditions = append(conditions, &metav1.Condition{
|
||||
Type: typeJWKSURLValid,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: reasonSuccess,
|
||||
Message: msg,
|
||||
Message: "jwks_uri is a valid URL",
|
||||
})
|
||||
return pJSON.JWKSURL, conditions, nil
|
||||
}
|
||||
@@ -474,12 +473,11 @@ func (c *jwtCacheFillerController) validateIssuer(issuer string, conditions []*m
|
||||
return nil, conditions, false
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("spec.issuer (%s) is a valid URL", issuer)
|
||||
conditions = append(conditions, &metav1.Condition{
|
||||
Type: typeIssuerURLValid,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: reasonSuccess,
|
||||
Message: msg,
|
||||
Message: "issuer is a valid URL",
|
||||
})
|
||||
return issuerURL, conditions, true
|
||||
}
|
||||
|
||||
@@ -291,14 +291,14 @@ func TestController(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
happyIssuerURLValid := func(issuer string, time metav1.Time, observedGeneration int64) metav1.Condition {
|
||||
happyIssuerURLValid := func(time metav1.Time, observedGeneration int64) metav1.Condition {
|
||||
return metav1.Condition{
|
||||
Type: "IssuerURLValid",
|
||||
Status: "True",
|
||||
ObservedGeneration: observedGeneration,
|
||||
LastTransitionTime: time,
|
||||
Reason: "Success",
|
||||
Message: fmt.Sprintf("spec.issuer (%s) is a valid URL", issuer),
|
||||
Message: "issuer is a valid URL",
|
||||
}
|
||||
}
|
||||
sadIssuerURLValidInvalid := func(issuer string, time metav1.Time, observedGeneration int64) metav1.Condition {
|
||||
@@ -393,16 +393,14 @@ func TestController(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
happyJWKSURLValid := func(issuer string, time metav1.Time, observedGeneration int64) metav1.Condition {
|
||||
parsed, err := url.Parse(issuer)
|
||||
require.NoError(t, err)
|
||||
happyJWKSURLValid := func(time metav1.Time, observedGeneration int64) metav1.Condition {
|
||||
return metav1.Condition{
|
||||
Type: "JWKSURLValid",
|
||||
Status: "True",
|
||||
ObservedGeneration: observedGeneration,
|
||||
LastTransitionTime: time,
|
||||
Reason: "Success",
|
||||
Message: fmt.Sprintf("jwks_uri (https://%s/jwks.json) is a valid URL", parsed.Host),
|
||||
Message: "jwks_uri is a valid URL",
|
||||
}
|
||||
}
|
||||
unknownJWKSURLValid := func(time metav1.Time, observedGeneration int64) metav1.Condition {
|
||||
@@ -440,8 +438,8 @@ func TestController(t *testing.T) {
|
||||
return status.SortConditionsByType([]metav1.Condition{
|
||||
happyAuthenticatorValid(someTime, observedGeneration),
|
||||
happyDiscoveryURLValid(someTime, observedGeneration),
|
||||
happyIssuerURLValid(issuer, someTime, observedGeneration),
|
||||
happyJWKSURLValid(issuer, someTime, observedGeneration),
|
||||
happyIssuerURLValid(someTime, observedGeneration),
|
||||
happyJWKSURLValid(someTime, observedGeneration),
|
||||
happyReadyCondition(someTime, observedGeneration),
|
||||
happyTLSConfigurationValid(someTime, observedGeneration),
|
||||
})
|
||||
@@ -784,7 +782,7 @@ func TestController(t *testing.T) {
|
||||
wantStatusConditions: status.ReplaceConditions(
|
||||
allHappyConditionsSuccess(goodIssuer, frozenMetav1Now, 0),
|
||||
[]metav1.Condition{
|
||||
happyIssuerURLValid(someOtherLocalhostIssuer, frozenMetav1Now, 0),
|
||||
happyIssuerURLValid(frozenMetav1Now, 0),
|
||||
sadReadyCondition(frozenMetav1Now, 0),
|
||||
sadDiscoveryURLValidConnectionRefused(someOtherLocalhostIssuer, frozenMetav1Now, 0),
|
||||
unknownAuthenticatorValid(frozenMetav1Now, 0),
|
||||
@@ -812,7 +810,7 @@ func TestController(t *testing.T) {
|
||||
wantStatusConditions: status.ReplaceConditions(
|
||||
allHappyConditionsSuccess(goodIssuer, frozenMetav1Now, 0),
|
||||
[]metav1.Condition{
|
||||
happyIssuerURLValid(badIssuerInvalidJWKSURI, frozenMetav1Now, 0),
|
||||
happyIssuerURLValid(frozenMetav1Now, 0),
|
||||
sadReadyCondition(frozenMetav1Now, 0),
|
||||
unknownAuthenticatorValid(frozenMetav1Now, 0),
|
||||
sadJWKSURLValidParseURI("https://.café .com/café/café/café/coffee/jwks.json", frozenMetav1Now, 0),
|
||||
@@ -834,7 +832,7 @@ func TestController(t *testing.T) {
|
||||
wantStatusConditions: status.ReplaceConditions(
|
||||
allHappyConditionsSuccess(goodIssuer, frozenMetav1Now, 0),
|
||||
[]metav1.Condition{
|
||||
happyIssuerURLValid(badIssuerInvalidJWKSURIScheme, frozenMetav1Now, 0),
|
||||
happyIssuerURLValid(frozenMetav1Now, 0),
|
||||
sadReadyCondition(frozenMetav1Now, 0),
|
||||
unknownAuthenticatorValid(frozenMetav1Now, 0),
|
||||
sadJWKSURLValidScheme("http://.café.com/café/café/café/coffee/jwks.json", frozenMetav1Now, 0),
|
||||
|
||||
Reference in New Issue
Block a user