-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds caching support for Identity Center resources (#47880)
* Adds caching support for Identity Center resources Adds support for caching (and watching) some IdentityCenter resource types. Specifically: - identitycenterv1.Account - identitycenterv1.AccountAsssignment - identitycenterv1.PrincipalAssignment Also breaks the cache's `genericcollection` out into its own file as an attempt to reduce clutter in the main collections source file. * Update identitycenter_events.go * Update identitycenter_events.go * Speed up tests
- Loading branch information
Showing
18 changed files
with
1,435 additions
and
568 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,7 @@ type testPack struct { | |
staticHostUsers services.StaticHostUser | ||
autoUpdateService services.AutoUpdateService | ||
provisioningStates services.ProvisioningStates | ||
identityCenter services.IdentityCenter | ||
} | ||
|
||
// testFuncs are functions to support testing an object in a cache. | ||
|
@@ -387,6 +388,13 @@ func newPackWithoutCache(dir string, opts ...packOption) (*testPack, error) { | |
return nil, trace.Wrap(err) | ||
} | ||
|
||
p.identityCenter, err = local.NewIdentityCenterService(local.IdentityCenterServiceConfig{ | ||
Backend: p.backend, | ||
}) | ||
if err != nil { | ||
return nil, trace.Wrap(err) | ||
} | ||
|
||
return p, nil | ||
} | ||
|
||
|
@@ -438,6 +446,7 @@ func newPack(dir string, setupConfig func(c Config) Config, opts ...packOption) | |
StaticHostUsers: p.staticHostUsers, | ||
AutoUpdateService: p.autoUpdateService, | ||
ProvisioningStates: p.provisioningStates, | ||
IdentityCenter: p.identityCenter, | ||
MaxRetryPeriod: 200 * time.Millisecond, | ||
EventsC: p.eventsC, | ||
})) | ||
|
@@ -848,6 +857,7 @@ func TestCompletenessInit(t *testing.T) { | |
AutoUpdateService: p.autoUpdateService, | ||
ProvisioningStates: p.provisioningStates, | ||
MaxRetryPeriod: 200 * time.Millisecond, | ||
IdentityCenter: p.identityCenter, | ||
EventsC: p.eventsC, | ||
})) | ||
require.NoError(t, err) | ||
|
@@ -929,6 +939,7 @@ func TestCompletenessReset(t *testing.T) { | |
StaticHostUsers: p.staticHostUsers, | ||
AutoUpdateService: p.autoUpdateService, | ||
ProvisioningStates: p.provisioningStates, | ||
IdentityCenter: p.identityCenter, | ||
MaxRetryPeriod: 200 * time.Millisecond, | ||
EventsC: p.eventsC, | ||
})) | ||
|
@@ -1137,6 +1148,7 @@ func TestListResources_NodesTTLVariant(t *testing.T) { | |
StaticHostUsers: p.staticHostUsers, | ||
AutoUpdateService: p.autoUpdateService, | ||
ProvisioningStates: p.provisioningStates, | ||
IdentityCenter: p.identityCenter, | ||
MaxRetryPeriod: 200 * time.Millisecond, | ||
EventsC: p.eventsC, | ||
neverOK: true, // ensure reads are never healthy | ||
|
@@ -1230,6 +1242,7 @@ func initStrategy(t *testing.T) { | |
StaticHostUsers: p.staticHostUsers, | ||
AutoUpdateService: p.autoUpdateService, | ||
ProvisioningStates: p.provisioningStates, | ||
IdentityCenter: p.identityCenter, | ||
MaxRetryPeriod: 200 * time.Millisecond, | ||
EventsC: p.eventsC, | ||
})) | ||
|
@@ -3002,7 +3015,7 @@ func testResources153[T types.Resource153](t *testing.T, p *testPack, funcs test | |
} | ||
|
||
assert.Empty(collect, cmp.Diff(expected, out, cmpOpts...)) | ||
}, 2*time.Second, 250*time.Millisecond) | ||
}, 2*time.Second, 10*time.Millisecond) | ||
} | ||
|
||
// Check that the resource is now in the backend. | ||
|
@@ -3426,71 +3439,74 @@ func TestCacheWatchKindExistsInEvents(t *testing.T) { | |
} | ||
|
||
events := map[string]types.Resource{ | ||
types.KindCertAuthority: &types.CertAuthorityV2{}, | ||
types.KindClusterName: &types.ClusterNameV2{}, | ||
types.KindClusterAuditConfig: types.DefaultClusterAuditConfig(), | ||
types.KindClusterNetworkingConfig: types.DefaultClusterNetworkingConfig(), | ||
types.KindClusterAuthPreference: types.DefaultAuthPreference(), | ||
types.KindSessionRecordingConfig: types.DefaultSessionRecordingConfig(), | ||
types.KindUIConfig: &types.UIConfigV1{}, | ||
types.KindStaticTokens: &types.StaticTokensV2{}, | ||
types.KindToken: &types.ProvisionTokenV2{}, | ||
types.KindUser: &types.UserV2{}, | ||
types.KindRole: &types.RoleV6{Version: types.V4}, | ||
types.KindNamespace: &types.Namespace{}, | ||
types.KindNode: &types.ServerV2{}, | ||
types.KindProxy: &types.ServerV2{}, | ||
types.KindAuthServer: &types.ServerV2{}, | ||
types.KindReverseTunnel: &types.ReverseTunnelV2{}, | ||
types.KindTunnelConnection: &types.TunnelConnectionV2{}, | ||
types.KindAccessRequest: &types.AccessRequestV3{}, | ||
types.KindAppServer: &types.AppServerV3{}, | ||
types.KindApp: &types.AppV3{}, | ||
types.KindWebSession: &types.WebSessionV2{SubKind: types.KindWebSession}, | ||
types.KindAppSession: &types.WebSessionV2{SubKind: types.KindAppSession}, | ||
types.KindSnowflakeSession: &types.WebSessionV2{SubKind: types.KindSnowflakeSession}, | ||
types.KindSAMLIdPSession: &types.WebSessionV2{SubKind: types.KindSAMLIdPServiceProvider}, | ||
types.KindWebToken: &types.WebTokenV3{}, | ||
types.KindRemoteCluster: &types.RemoteClusterV3{}, | ||
types.KindKubeServer: &types.KubernetesServerV3{}, | ||
types.KindDatabaseService: &types.DatabaseServiceV1{}, | ||
types.KindDatabaseServer: &types.DatabaseServerV3{}, | ||
types.KindDatabase: &types.DatabaseV3{}, | ||
types.KindNetworkRestrictions: &types.NetworkRestrictionsV4{}, | ||
types.KindLock: &types.LockV2{}, | ||
types.KindWindowsDesktopService: &types.WindowsDesktopServiceV3{}, | ||
types.KindWindowsDesktop: &types.WindowsDesktopV3{}, | ||
types.KindDynamicWindowsDesktop: &types.DynamicWindowsDesktopV1{}, | ||
types.KindInstaller: &types.InstallerV1{}, | ||
types.KindKubernetesCluster: &types.KubernetesClusterV3{}, | ||
types.KindSAMLIdPServiceProvider: &types.SAMLIdPServiceProviderV1{}, | ||
types.KindUserGroup: &types.UserGroupV1{}, | ||
types.KindOktaImportRule: &types.OktaImportRuleV1{}, | ||
types.KindOktaAssignment: &types.OktaAssignmentV1{}, | ||
types.KindIntegration: &types.IntegrationV1{}, | ||
types.KindDiscoveryConfig: newDiscoveryConfig(t, "discovery-config"), | ||
types.KindHeadlessAuthentication: &types.HeadlessAuthentication{}, | ||
types.KindUserLoginState: newUserLoginState(t, "user-login-state"), | ||
types.KindAuditQuery: newAuditQuery(t, "audit-query"), | ||
types.KindSecurityReport: newSecurityReport(t, "security-report"), | ||
types.KindSecurityReportState: newSecurityReport(t, "security-report-state"), | ||
types.KindAccessList: newAccessList(t, "access-list", clock), | ||
types.KindAccessListMember: newAccessListMember(t, "access-list", "member"), | ||
types.KindAccessListReview: newAccessListReview(t, "access-list", "review"), | ||
types.KindKubeWaitingContainer: newKubeWaitingContainer(t), | ||
types.KindNotification: types.Resource153ToLegacy(newUserNotification(t, "test")), | ||
types.KindGlobalNotification: types.Resource153ToLegacy(newGlobalNotification(t, "test")), | ||
types.KindAccessMonitoringRule: types.Resource153ToLegacy(newAccessMonitoringRule(t)), | ||
types.KindCrownJewel: types.Resource153ToLegacy(newCrownJewel(t, "test")), | ||
types.KindDatabaseObject: types.Resource153ToLegacy(newDatabaseObject(t, "test")), | ||
types.KindAccessGraphSettings: types.Resource153ToLegacy(newAccessGraphSettings(t)), | ||
types.KindSPIFFEFederation: types.Resource153ToLegacy(newSPIFFEFederation("test")), | ||
types.KindStaticHostUser: types.Resource153ToLegacy(newStaticHostUser(t, "test")), | ||
types.KindAutoUpdateConfig: types.Resource153ToLegacy(newAutoUpdateConfig(t)), | ||
types.KindAutoUpdateVersion: types.Resource153ToLegacy(newAutoUpdateVersion(t)), | ||
types.KindAutoUpdateAgentRollout: types.Resource153ToLegacy(newAutoUpdateAgentRollout(t)), | ||
types.KindUserTask: types.Resource153ToLegacy(newUserTasks(t)), | ||
types.KindProvisioningPrincipalState: types.Resource153ToLegacy(newProvisioningPrincipalState("[email protected]")), | ||
types.KindCertAuthority: &types.CertAuthorityV2{}, | ||
types.KindClusterName: &types.ClusterNameV2{}, | ||
types.KindClusterAuditConfig: types.DefaultClusterAuditConfig(), | ||
types.KindClusterNetworkingConfig: types.DefaultClusterNetworkingConfig(), | ||
types.KindClusterAuthPreference: types.DefaultAuthPreference(), | ||
types.KindSessionRecordingConfig: types.DefaultSessionRecordingConfig(), | ||
types.KindUIConfig: &types.UIConfigV1{}, | ||
types.KindStaticTokens: &types.StaticTokensV2{}, | ||
types.KindToken: &types.ProvisionTokenV2{}, | ||
types.KindUser: &types.UserV2{}, | ||
types.KindRole: &types.RoleV6{Version: types.V4}, | ||
types.KindNamespace: &types.Namespace{}, | ||
types.KindNode: &types.ServerV2{}, | ||
types.KindProxy: &types.ServerV2{}, | ||
types.KindAuthServer: &types.ServerV2{}, | ||
types.KindReverseTunnel: &types.ReverseTunnelV2{}, | ||
types.KindTunnelConnection: &types.TunnelConnectionV2{}, | ||
types.KindAccessRequest: &types.AccessRequestV3{}, | ||
types.KindAppServer: &types.AppServerV3{}, | ||
types.KindApp: &types.AppV3{}, | ||
types.KindWebSession: &types.WebSessionV2{SubKind: types.KindWebSession}, | ||
types.KindAppSession: &types.WebSessionV2{SubKind: types.KindAppSession}, | ||
types.KindSnowflakeSession: &types.WebSessionV2{SubKind: types.KindSnowflakeSession}, | ||
types.KindSAMLIdPSession: &types.WebSessionV2{SubKind: types.KindSAMLIdPServiceProvider}, | ||
types.KindWebToken: &types.WebTokenV3{}, | ||
types.KindRemoteCluster: &types.RemoteClusterV3{}, | ||
types.KindKubeServer: &types.KubernetesServerV3{}, | ||
types.KindDatabaseService: &types.DatabaseServiceV1{}, | ||
types.KindDatabaseServer: &types.DatabaseServerV3{}, | ||
types.KindDatabase: &types.DatabaseV3{}, | ||
types.KindNetworkRestrictions: &types.NetworkRestrictionsV4{}, | ||
types.KindLock: &types.LockV2{}, | ||
types.KindWindowsDesktopService: &types.WindowsDesktopServiceV3{}, | ||
types.KindWindowsDesktop: &types.WindowsDesktopV3{}, | ||
types.KindDynamicWindowsDesktop: &types.DynamicWindowsDesktopV1{}, | ||
types.KindInstaller: &types.InstallerV1{}, | ||
types.KindKubernetesCluster: &types.KubernetesClusterV3{}, | ||
types.KindSAMLIdPServiceProvider: &types.SAMLIdPServiceProviderV1{}, | ||
types.KindUserGroup: &types.UserGroupV1{}, | ||
types.KindOktaImportRule: &types.OktaImportRuleV1{}, | ||
types.KindOktaAssignment: &types.OktaAssignmentV1{}, | ||
types.KindIntegration: &types.IntegrationV1{}, | ||
types.KindDiscoveryConfig: newDiscoveryConfig(t, "discovery-config"), | ||
types.KindHeadlessAuthentication: &types.HeadlessAuthentication{}, | ||
types.KindUserLoginState: newUserLoginState(t, "user-login-state"), | ||
types.KindAuditQuery: newAuditQuery(t, "audit-query"), | ||
types.KindSecurityReport: newSecurityReport(t, "security-report"), | ||
types.KindSecurityReportState: newSecurityReport(t, "security-report-state"), | ||
types.KindAccessList: newAccessList(t, "access-list", clock), | ||
types.KindAccessListMember: newAccessListMember(t, "access-list", "member"), | ||
types.KindAccessListReview: newAccessListReview(t, "access-list", "review"), | ||
types.KindKubeWaitingContainer: newKubeWaitingContainer(t), | ||
types.KindNotification: types.Resource153ToLegacy(newUserNotification(t, "test")), | ||
types.KindGlobalNotification: types.Resource153ToLegacy(newGlobalNotification(t, "test")), | ||
types.KindAccessMonitoringRule: types.Resource153ToLegacy(newAccessMonitoringRule(t)), | ||
types.KindCrownJewel: types.Resource153ToLegacy(newCrownJewel(t, "test")), | ||
types.KindDatabaseObject: types.Resource153ToLegacy(newDatabaseObject(t, "test")), | ||
types.KindAccessGraphSettings: types.Resource153ToLegacy(newAccessGraphSettings(t)), | ||
types.KindSPIFFEFederation: types.Resource153ToLegacy(newSPIFFEFederation("test")), | ||
types.KindStaticHostUser: types.Resource153ToLegacy(newStaticHostUser(t, "test")), | ||
types.KindAutoUpdateConfig: types.Resource153ToLegacy(newAutoUpdateConfig(t)), | ||
types.KindAutoUpdateVersion: types.Resource153ToLegacy(newAutoUpdateVersion(t)), | ||
types.KindAutoUpdateAgentRollout: types.Resource153ToLegacy(newAutoUpdateAgentRollout(t)), | ||
types.KindUserTask: types.Resource153ToLegacy(newUserTasks(t)), | ||
types.KindProvisioningPrincipalState: types.Resource153ToLegacy(newProvisioningPrincipalState("[email protected]")), | ||
types.KindIdentityCenterAccount: types.Resource153ToLegacy(newIdentityCenterAccount("some_account")), | ||
types.KindIdentityCenterAccountAssignment: types.Resource153ToLegacy(newIdentityCenterAccountAssignment("some_account_assignment")), | ||
types.KindIdentityCenterPrincipalAssignment: types.Resource153ToLegacy(newIdentityCenterPrincipalAssignment("some_principal_assignment")), | ||
} | ||
|
||
for name, cfg := range cases { | ||
|
Oops, something went wrong.