Fix an issue in TestE2EFullIntegration groups assertions.
The group claims read from the session cache file are loaded as `[]interface{}` (slice of empty interfaces) so when we previously did a `groups, _ := idTokenClaims[oidc.DownstreamGroupsClaim].([]string)`, then `groups` would always end up nil. The solution I tried here was to convert the expected value to also be `[]interface{}` so that `require.Equal(t, ...)` does the right thing. This bug only showed up in our acceptance environnment against Okta, since we don't have any other integration test coverage with IDPs that pass a groups claim. Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
parent
b95f2c97b9
commit
6a0dc1e2bb
@ -292,14 +292,12 @@ func TestE2EFullIntegration(t *testing.T) {
|
|||||||
require.NotNil(t, token)
|
require.NotNil(t, token)
|
||||||
|
|
||||||
idTokenClaims := token.IDToken.Claims
|
idTokenClaims := token.IDToken.Claims
|
||||||
username := idTokenClaims[oidc.DownstreamUsernameClaim].(string)
|
require.Equal(t, env.SupervisorTestUpstream.Username, idTokenClaims[oidc.DownstreamUsernameClaim])
|
||||||
groups, _ := idTokenClaims[oidc.DownstreamGroupsClaim].([]string)
|
|
||||||
|
|
||||||
require.Equal(t, env.SupervisorTestUpstream.Username, username)
|
// The groups claim in the file ends up as an []interface{}, so adjust our expectation to match.
|
||||||
if len(env.SupervisorTestUpstream.ExpectedGroups) == 0 {
|
expectedGroups := make([]interface{}, 0, len(env.SupervisorTestUpstream.ExpectedGroups))
|
||||||
// We only put a groups claim in our downstream ID token if we got groups from the upstream.
|
for _, g := range env.SupervisorTestUpstream.ExpectedGroups {
|
||||||
require.Nil(t, groups)
|
expectedGroups = append(expectedGroups, g)
|
||||||
} else {
|
|
||||||
require.Equal(t, env.SupervisorTestUpstream.ExpectedGroups, groups)
|
|
||||||
}
|
}
|
||||||
|
require.Equal(t, expectedGroups, idTokenClaims[oidc.DownstreamGroupsClaim])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user