-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/fms
- Loading branch information
Showing
120 changed files
with
3,796 additions
and
213 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
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
MONGODB_URI=$MONGODB_URI | ||
ENVIRONMENT_NAME=$ENVIRONMENT_NAME | ||
SENTRY_KEY=$SENTRY_KEY# Prod | ||
AUTH_PROVIDER=$AUTH_PROVIDER# Prod, defaults to dev | ||
AADB2C_TENANT_ID=$AADB2C_TENANT_ID# Prod | ||
AADB2C_EXTENSION_APP_ID=$AADB2C_EXTENSION_APP_ID# Prod | ||
AADB2C_CLIENT_SECRET=$AADB2C_CLIENT_SECRET# Prod | ||
AADB2C_TENANT_NAME=$AADB2C_TENANT_NAME# Prod | ||
AADB2C_SIGN_IN_POLICY=$AADB2C_SIGN_IN_POLICY# Prod | ||
AADB2C_CLIENT_ID=$AADB2C_CLIENT_ID# Prod | ||
AADB2C_ISSUER=$AADB2C_ISSUER# Prod | ||
MONGODB_ENCR_KMS_PROVIDER=$MONGODB_ENCR_KMS_PROVIDER# Optional, defaults to "local" | ||
MONGODB_ENCR_KMS_PROVIDER=$MONGODB_ENCR_KMS_PROVIDER# Prod, defaults to "local" | ||
MONGODB_ENCR_KV_NAMESPACE=$MONGODB_ENCR_KV_NAMESPACE# Prod | ||
MONGODB_ENCR_KMS_PROVIDER_CREDS=$MONGODB_ENCR_KMS_PROVIDER_CREDS# Prod | ||
MONGODB_ENCR_MASTER_KEY=$MONGODB_ENCR_MASTER_KEY# Prod | ||
|
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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
### Development Tokens | ||
|
||
This file contains some development tokens that can be used to directly call the | ||
API with pre-defined claims. The test users are equivalent to the users used in | ||
[E2Es](../spa-e2e/README.md) and the test users registered in the development | ||
application of our AAD. | ||
application of our AAD. In dev environments, the users are preregistered in the | ||
in-memory store of the | ||
[DevUserService](../../libs/api/users/src/lib/infra/service/dev-user.service.ts). | ||
|
||
<!-- IF YOU CHANGE OR ADD ANY USER, MAKE SURE TO KEEP apps/spa-e2e/src/test-users.ts IN SYNC! --> | ||
|
||
| **Username** | **ID** (`oid`) | **First name** (`first_name`) | **Last name** (`last_name`) | **Emails** (`emails`) | **Organization** (`organization`) | Token | | ||
| ------------ | ------------------------------------ | ----------------------------- | --------------------------- | ----------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| testuser | c0cc4404-7907-4480-86d3-ba4bfc513c6d | Test | User | [email protected] | testorganization (dff7584efe2c174eee8bae45) | `eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJvaWQiOiIxMjM0IiwiZW1haWxzIjpbInRlc3R1c2VyQHRlc3QuY29tIl0sImdpdmVuX25hbWUiOiJUZXN0IiwiZmFtaWx5X25hbWUiOiJVc2VyIDEifQ.` | | ||
| **Username** | **ID** (`oid`) | **Organization ID** (`extension_OrganizationId`) | **First name** (`first_name`) | **Last name** (`last_name`) | **Emails** (`emails`) | **Role** (`extension_Role`) | Token | | ||
| ------------ | ------------------------------------ | ------------------------------------------------ | ----------------------------- | --------------------------- | --------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| testuser | fbdd030c-bae9-4213-9e04-732b1cc8f5b8 | dff7584efe2c174eee8bae45 | Test | User | [email protected] | User | `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvaWQiOiJmYmRkMDMwYy1iYWU5LTQyMTMtOWUwNC03MzJiMWNjOGY1YjgiLCJnaXZlbl9uYW1lIjoiVGVzdCIsImZhbWlseV9uYW1lIjoiVXNlciIsImV4dGVuc2lvbl9Pcmdhbml6YXRpb25JZCI6ImRmZjc1ODRlZmUyYzE3NGVlZThiYWU0NSIsImV4dGVuc2lvbl9Sb2xlIjoidXNlciIsImVtYWlscyI6WyJ0ZXN0dXNlckBrb3JkaXMtbGVpdHN0ZWxsZS5kZSJdfQ.o94xdOASK5h-sg8BpS82YBOYmgGFS0oUaO0txhPmzXY` | | ||
| testadmin | f60157a8-3054-48e1-937c-82302526c1ed | dff7584efe2c174eee8bae45 | Test | Admin | [email protected] | Admin | `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvaWQiOiJmNjAxNTdhOC0zMDU0LTQ4ZTEtOTM3Yy04MjMwMjUyNmMxZWQiLCJnaXZlbl9uYW1lIjoiVGVzdCIsImZhbWlseV9uYW1lIjoiQWRtaW4iLCJleHRlbnNpb25fT3JnYW5pemF0aW9uSWQiOiJkZmY3NTg0ZWZlMmMxNzRlZWU4YmFlNDUiLCJleHRlbnNpb25fUm9sZSI6ImFkbWluIiwiZW1haWxzIjpbInRlc3RhZG1pbkBrb3JkaXMtbGVpdHN0ZWxsZS5kZSJdfQ._YRyk7zWpXtrTNdRkwydlESkPta8UJYnpa_N7TLM3hw` | | ||
| testorgadmin | d8e3e5f2-fb05-4c47-b869-5a558e1f57e5 | dff7584efe2c174eee8bae45 | Test | Org Admin | [email protected] | Organization Admin | `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvaWQiOiJkOGUzZTVmMi1mYjA1LTRjNDctYjg2OS01YTU1OGUxZjU3ZTUiLCJnaXZlbl9uYW1lIjoiVGVzdCIsImZhbWlseV9uYW1lIjoiT3JnIEFkbWluIiwiZXh0ZW5zaW9uX09yZ2FuaXphdGlvbklkIjoiZGZmNzU4NGVmZTJjMTc0ZWVlOGJhZTQ1IiwiZXh0ZW5zaW9uX1JvbGUiOiJvcmdhbml6YXRpb25fYWRtaW4iLCJlbWFpbHMiOlsidGVzdG9yZ2FkbWluQGtvcmRpcy1sZWl0c3RlbGxlLmRlIl19.-AKJ8UJltumkThrJ3tU76ciyHfKOp3uMrNvO_HvgH3M` | | ||
|
||
The claims will be mapped to the | ||
[AuthUser](../../libs/shared/model/src/lib/auth-user.model.ts) Model in the | ||
|
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/* | ||
* Returns a css selector for our test id attribute. | ||
*/ | ||
export function testIdSelector(testId: string): string { | ||
return `[data-testid="${testId}"]`; | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
import { test } from '@playwright/test'; | ||
|
||
export const testUsernames = ['testuser'] as const; | ||
export type TestUsernames = (typeof testUsernames)[number]; | ||
import { TEST_USERS } from '@kordis/shared/test-helpers'; | ||
|
||
export type TestUsernames = (typeof TEST_USERS)[number]['userName']; | ||
|
||
export function getAuthStoragePath(username: TestUsernames): string { | ||
return `playwright/.auth/${username}.json`; | ||
} | ||
|
||
/* | ||
* Use this function to set the session to a given test user. Each testuser has different claims. You should carefully choose the testuser for your test, to avoid weird states in parallel running tests. | ||
* @see libs/shared/test-helpers/src/lib/test-users.test-helper.ts | ||
* @see apps/api/dev-tokens.md | ||
* @param username The username of the testuser | ||
* */ | ||
export function asUser(username: TestUsernames): void { | ||
test.use({ storageState: getAuthStoragePath(username) }); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { createMock } from '@golevelup/ts-jest'; | ||
import { SpectatorRouting, createRoutingFactory } from '@ngneat/spectator/jest'; | ||
import { ReplaySubject, of } from 'rxjs'; | ||
|
||
import { AUTH_SERVICE, DevAuthService } from '@kordis/spa/auth'; | ||
import { GraphqlService } from '@kordis/spa/graphql'; | ||
|
||
import { AppComponent } from './app.component'; | ||
|
||
// https://github.com/getsentry/sentry-javascript/issues/9448 | ||
jest.mock('@sentry/angular-ivy', () => ({ | ||
TraceClassDecorator: () => () => {}, | ||
})); | ||
|
||
describe('AppComponent', () => { | ||
let spectator: SpectatorRouting<AppComponent>; | ||
const gqlService = createMock<GraphqlService>(); | ||
const isAuthenticatedStatusSubject$ = new ReplaySubject<boolean>(1); | ||
|
||
const createComponent = createRoutingFactory({ | ||
component: AppComponent, | ||
providers: [ | ||
{ | ||
provide: AUTH_SERVICE, | ||
useValue: createMock<DevAuthService>({ | ||
isAuthenticated$: isAuthenticatedStatusSubject$.asObservable(), | ||
}), | ||
}, | ||
{ | ||
provide: GraphqlService, | ||
useValue: gqlService, | ||
}, | ||
], | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should logout user on deactivated subscription event', () => { | ||
gqlService.subscribe$.mockImplementationOnce(() => | ||
of({ | ||
data: { | ||
currentUserDeactivated: { | ||
userId: 'test', | ||
}, | ||
}, | ||
}), | ||
); | ||
isAuthenticatedStatusSubject$.next(true); | ||
spectator = createComponent(); | ||
const authService = spectator.inject(AUTH_SERVICE, true); | ||
const logoutSpy = jest.spyOn(authService, 'logout'); | ||
expect(logoutSpy).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should not logout on deactivated subscription event while not authenticated', () => { | ||
gqlService.subscribe$.mockImplementationOnce(() => | ||
of({ | ||
data: { | ||
currentUserDeactivated: { | ||
userId: 'test', | ||
}, | ||
}, | ||
}), | ||
); | ||
isAuthenticatedStatusSubject$.next(false); | ||
spectator = createComponent(); | ||
const authService = spectator.inject(AUTH_SERVICE, true); | ||
const logoutSpy = jest.spyOn(authService, 'logout'); | ||
expect(logoutSpy).not.toHaveBeenCalled(); | ||
}); | ||
}); |
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
Oops, something went wrong.