Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger committed Oct 28, 2024
1 parent a9314a9 commit 96d8c26
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions lib/services/local/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,33 +595,40 @@ func TestIdentityService_GetMFADevices_SSO(t *testing.T) {
tests := []struct {
name string
connectorRef *types.ConnectorRef
expectSSODevice bool
expectSSODevice *types.SSOMFADevice
}{
{
name: "non-sso user",
connectorRef: nil,
expectSSODevice: false,
expectSSODevice: nil,
}, {
name: "sso user mfa disabled",
connectorRef: &types.ConnectorRef{
Type: "saml",
ID: samlConnectorNoMFA.GetName(),
},
expectSSODevice: false,
}, {
name: "saml user",
connectorRef: &types.ConnectorRef{
Type: "saml",
ID: samlConnector.GetName(),
},
expectSSODevice: true,
expectSSODevice: &types.SSOMFADevice{
ConnectorType: "saml",
ConnectorId: samlConnector.GetName(),
DisplayName: samlConnector.GetDisplay(),
},
}, {
name: "oidc user",
connectorRef: &types.ConnectorRef{
Type: "oidc",
ID: oidcConnector.GetName(),
},
expectSSODevice: true,
expectSSODevice: &types.SSOMFADevice{
ConnectorType: "oidc",
ConnectorId: oidcConnector.GetName(),
DisplayName: oidcConnector.GetDisplay(),
},
},
}
for _, test := range tests {
Expand All @@ -638,15 +645,13 @@ func TestIdentityService_GetMFADevices_SSO(t *testing.T) {
devs, err := identity.GetMFADevices(ctx, "alice", true /* withSecrets */)
require.NoError(t, err)

if !test.expectSSODevice {
if test.expectSSODevice == nil {
assert.Empty(t, devs)
return
}
expectSSODevice, err := types.NewMFADevice(test.connectorRef.ID, test.connectorRef.ID, clock.Now().UTC(), &types.MFADevice_Sso{
Sso: &types.SSOMFADevice{
ConnectorId: test.connectorRef.ID,
ConnectorType: test.connectorRef.Type,
},

expectSSODevice, err := types.NewMFADevice(test.expectSSODevice.ConnectorId, test.expectSSODevice.DisplayName, clock.Now().UTC(), &types.MFADevice_Sso{
Sso: test.expectSSODevice,
})
require.NoError(t, err)
assert.Equal(t, []*types.MFADevice{expectSSODevice}, devs)
Expand Down

0 comments on commit 96d8c26

Please sign in to comment.