diff --git a/web/packages/teleport/src/services/user/user.test.ts b/web/packages/teleport/src/services/user/user.test.ts index 7b65e467e6a0c..53c6d26d0a04e 100644 --- a/web/packages/teleport/src/services/user/user.test.ts +++ b/web/packages/teleport/src/services/user/user.test.ts @@ -21,7 +21,7 @@ import cfg from 'teleport/config'; import user from './user'; import { makeTraits } from './makeUser'; -import { ExcludeUserField, PasswordState, User } from './types'; +import { Acl, ExcludeUserField, PasswordState, User } from './types'; test('undefined values in context response gives proper default values', async () => { const mockContext = { @@ -49,233 +49,243 @@ test('undefined values in context response gives proper default values', async ( jest.spyOn(api, 'get').mockResolvedValue(mockContext); const response = await user.fetchUserContext(false); + + const acl: Acl = { + accessList: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + accessMonitoringRule: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + authConnectors: { + list: true, + read: true, + edit: true, + create: true, + remove: true, + }, + // Test that undefined acl booleans are set to default false. + trustedClusters: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + nodes: { + create: false, + edit: false, + list: false, + read: false, + remove: false, + }, + plugins: { + create: false, + edit: false, + list: false, + read: false, + remove: false, + }, + integrations: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + use: false, + }, + roles: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + lock: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + recordedSessions: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + desktops: { + create: false, + edit: false, + list: false, + read: false, + remove: false, + }, + events: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + externalAuditStorage: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + users: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + activeSessions: { + create: false, + edit: false, + list: false, + read: false, + remove: false, + }, + appServers: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + kubeServers: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + license: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + download: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + tokens: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + accessRequests: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + billing: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + dbServers: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + db: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + connectionDiagnostic: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + deviceTrust: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + samlIdpServiceProvider: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + auditQuery: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + securityReport: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + accessGraph: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + discoverConfigs: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + bots: { + list: false, + read: false, + edit: false, + create: false, + remove: false, + }, + clipboardSharingEnabled: true, + desktopSessionRecordingEnabled: true, + directorySharingEnabled: true, + }; + expect(response).toEqual({ username: 'foo', authType: 'local', - acl: { - accessList: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - accessMonitoringRule: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - authConnectors: { - list: true, - read: true, - edit: true, - create: true, - remove: true, - }, - // Test that undefined acl booleans are set to default false. - trustedClusters: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - nodes: { - create: false, - edit: false, - list: false, - read: false, - remove: false, - }, - plugins: { - create: false, - edit: false, - list: false, - read: false, - remove: false, - }, - integrations: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - use: false, - }, - roles: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - lock: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - recordedSessions: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - desktops: { - create: false, - edit: false, - list: false, - read: false, - remove: false, - }, - events: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - externalAuditStorage: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - users: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - activeSessions: { - create: false, - edit: false, - list: false, - read: false, - remove: false, - }, - appServers: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - kubeServers: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - license: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - download: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - tokens: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - accessRequests: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - billing: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - dbServers: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - db: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - connectionDiagnostic: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - deviceTrust: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - samlIdpServiceProvider: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - auditQuery: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - securityReport: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - accessGraph: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - bots: { - list: false, - read: false, - edit: false, - create: false, - remove: false, - }, - clipboardSharingEnabled: true, - desktopSessionRecordingEnabled: true, - directorySharingEnabled: true, - }, + acl, cluster: { clusterId: 'aws', lastConnected: new Date('2020-09-26T17:30:23.512Z'),