dh-auth-library 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +23 -12
  2. package/dist/auth/api/apiAuthentication.js +13 -0
  3. package/dist/auth/api/apiTokenHelper.d.ts +2 -2
  4. package/dist/auth/api/apiTokenHelper.js +68 -0
  5. package/dist/auth/api/index.d.ts +0 -1
  6. package/dist/auth/api/index.js +2 -0
  7. package/dist/auth/api/sessionHandlerResolvers.d.ts +3 -6
  8. package/dist/auth/api/sessionHandlerResolvers.js +5 -0
  9. package/dist/auth/getLoginHandler.js +25 -0
  10. package/dist/auth/index.js +6 -0
  11. package/dist/auth/loginhandlers/adLoginHandler.js +7 -0
  12. package/dist/auth/loginhandlers/digidGemachtigdeLoginHandler.js +7 -0
  13. package/dist/auth/loginhandlers/digidLoginHandler.js +7 -0
  14. package/dist/auth/loginhandlers/eHerkenningBewindvoerderLoginHandler.js +7 -0
  15. package/dist/auth/loginhandlers/eHerkenningLoginHandler.js +7 -0
  16. package/dist/auth/loginhandlers/index.js +6 -0
  17. package/dist/auth/loginhandlers/localhostLoginHandler.js +7 -0
  18. package/dist/auth/pages/adLoginPage.js +94 -0
  19. package/dist/auth/pages/digidLoginPage.d.ts +1 -1
  20. package/dist/auth/pages/digidLoginPage.js +73 -0
  21. package/dist/auth/pages/eHerkenningLoginPage.d.ts +6 -7
  22. package/dist/auth/pages/eHerkenningLoginPage.js +94 -0
  23. package/dist/auth/pages/index.js +4 -0
  24. package/dist/auth/pages/loginOverzichtPage.js +70 -0
  25. package/dist/auth/sessionHandler.d.ts +1 -1
  26. package/dist/auth/sessionHandler.js +88 -0
  27. package/dist/auth/utils/index.js +1 -0
  28. package/dist/auth/utils/sessionFileHelper.d.ts +9 -8
  29. package/dist/auth/utils/sessionFileHelper.js +33 -0
  30. package/dist/constants/accountTypes.d.ts +7 -29
  31. package/dist/constants/accountTypes.js +1 -0
  32. package/dist/constants/accounts.js +40 -0
  33. package/dist/constants/authTypes.d.ts +3 -0
  34. package/dist/constants/authTypes.js +1 -0
  35. package/dist/constants/index.d.ts +1 -4
  36. package/dist/constants/index.js +3 -0
  37. package/dist/constants/loginHandler.js +1 -0
  38. package/dist/constants/testAccounts.js +39 -0
  39. package/dist/constants/testProfiles.js +27 -0
  40. package/dist/index.js +2 -0
  41. package/package.json +7 -11
  42. package/dist/index.cjs.js +0 -860
  43. package/dist/index.es.js +0 -806
  44. package/dist/sha-B5xpXfPW.mjs +0 -911
  45. package/dist/sha-Eh0BcCJ_.js +0 -911
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
- # NL Portal Playwright Libraries
1
+ # DH Authorizatoin Library
2
2
 
3
- A Playwright library for testing NL Portal implementaties.
4
- test
3
+ A Playwright library for all login implementations in Den Haag
5
4
 
6
5
  it is published an npm package too and should be imported like that
7
6
 
@@ -9,27 +8,39 @@ it is published an npm package too and should be imported like that
9
8
 
10
9
  ## 📦 Purpose
11
10
 
12
- This repository contains the base objects that are needed for testing nl-portal implementations
13
- It is the base for the nl-portal-playwright-template but could also be used directly if wanted
14
- The template however will be the easiest way to setup your testautomation
11
+ Within DenHaag we will have several different repositories which will all have to use certain
12
+ types of login like AD, digid and eHerkenning.
13
+
14
+ In order to prevent each repo to have it's own implementation we created this library which
15
+ will take care of all login logic and even maintains the sessions during the testrun
15
16
 
16
17
  ---
17
18
 
18
19
  ## 🧱 Structure
19
20
 
20
21
  packages/
21
- ├── auth/ # Login en storage-state helpers for api requests and UI tests on localhost, digid and eherkenning
22
- ├── core/ # Constains most util classes
23
- ├── nl-portal/ # NL Portal pages, base_fixture and some utils that help with testing and testdata
22
+ ├── auth/ # Contains all classes for handling login and sessions
23
+ ├── constants/ # Constains accounts and types that can be used
24
24
 
25
25
  ---
26
26
 
27
27
  ## Auth
28
28
 
29
- The auth directory does contain fixtures for digid and eherkenning but you will still need to to create
30
- your own login pages with login logic for this.
31
- The login logic should be added to the session_helper.ts and session_manager.ts
29
+ # api
30
+
31
+ Has the authentication logic for api calls for nl-portal
32
+
33
+ # loginhandlers
34
+
35
+ Has all the login handlers that are needed for the nl-portal-playwright-libraries
36
+
37
+ # pages
38
+
39
+ Has all the login pages and the login overview page
40
+
41
+ # utils
32
42
 
43
+ Has the sessionFileHelper which takes care of the filename for each session
33
44
 
34
45
  ## Publishing to npm
35
46
 
@@ -0,0 +1,13 @@
1
+ import { baseTest as base } from 'nl-portal-playwright-libraries';
2
+ import { getApiTokenFromSession } from './apiTokenHelper';
3
+ import { getBedrijfSessionHandler, getBurgerSessionHandler, getDigidGemachtigdeSessionHandler, getEHerkenningBewindvoerderSessionHandler, getVestigingSessionHandler, } from './sessionHandlerResolvers';
4
+ /**
5
+ * The api's will use an existing session and use that token for the requests.
6
+ * The reason for this is that the token life-span is short and the UI always does a token-refresh.
7
+ * By using the UI session and stealing that token it will always be valid.
8
+ */
9
+ export const burgerApiTest = getApiTokenFromSession(base, getBurgerSessionHandler);
10
+ export const bedrijfApiTest = getApiTokenFromSession(base, getBedrijfSessionHandler);
11
+ export const vestigingApiTest = getApiTokenFromSession(base, getVestigingSessionHandler);
12
+ export const digidGemachtigdeApiTest = getApiTokenFromSession(base, getDigidGemachtigdeSessionHandler);
13
+ export const eHerkenningBewindvoerderApiTest = getApiTokenFromSession(base, getEHerkenningBewindvoerderSessionHandler);
@@ -12,6 +12,6 @@ export type ApiFixtures = {
12
12
  * Per specfile it is not problem but this should be done in every specfile to assure a valid token
13
13
  *
14
14
  * @param baseTest
15
- * @param handlerResolver
15
+ * @param handler
16
16
  */
17
- export declare function getApiTokenFromSession(baseTest: typeof base, handlerResolver: () => SessionHandler): import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & ApiFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
17
+ export declare function getApiTokenFromSession(baseTest: typeof base, handler: SessionHandler): import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & ApiFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
@@ -0,0 +1,68 @@
1
+ import { SessionManager, urls } from 'nl-portal-playwright-libraries';
2
+ /**
3
+ * The token is often being refreshed so the easiest is to open a browser using the current session
4
+ * The UI will automatically refresh the token and that is the token we will return
5
+ *
6
+ * That token can be used to perform some api requests for a short time
7
+ * Per specfile it is not problem but this should be done in every specfile to assure a valid token
8
+ *
9
+ * @param baseTest
10
+ * @param handler
11
+ */
12
+ export function getApiTokenFromSession(baseTest, handler) {
13
+ return baseTest.extend({
14
+ // eslint-disable-next-line no-empty-pattern
15
+ urls: async ({}, use) => {
16
+ await use(urls);
17
+ },
18
+ token: async ({ browser }, use) => {
19
+ const storageState = await SessionManager.getOrCreateSession(browser, handler);
20
+ const context = await browser.newContext(storageState ? { storageState } : {});
21
+ const page = await context.newPage();
22
+ try {
23
+ await page.goto('/');
24
+ // Wait until the oidc token exists in sessionStorage
25
+ await page.waitForFunction(() => {
26
+ const key = Object.keys(sessionStorage).find((k) => k.startsWith('oidc'));
27
+ if (!key) {
28
+ return false;
29
+ }
30
+ const raw = sessionStorage.getItem(key);
31
+ if (!raw) {
32
+ return false;
33
+ }
34
+ try {
35
+ return !!JSON.parse(raw)?.access_token;
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ });
41
+ // Retrieve the token
42
+ const token = await page.evaluate(() => {
43
+ const key = Object.keys(sessionStorage).find((k) => k.startsWith('oidc'));
44
+ if (!key) {
45
+ return null;
46
+ }
47
+ const raw = sessionStorage.getItem(key);
48
+ if (!raw) {
49
+ return null;
50
+ }
51
+ try {
52
+ return JSON.parse(raw)?.access_token ?? null;
53
+ }
54
+ catch {
55
+ return null;
56
+ }
57
+ });
58
+ if (!token) {
59
+ throw new Error('❌ Token not found in sessionStorage');
60
+ }
61
+ await use(token);
62
+ }
63
+ finally {
64
+ await context.close();
65
+ }
66
+ },
67
+ });
68
+ }
@@ -1,3 +1,2 @@
1
- export * from './apiAuthentication';
2
1
  export * from './apiTokenHelper';
3
2
  export * from './sessionHandlerResolvers';
@@ -0,0 +1,2 @@
1
+ export * from './apiTokenHelper';
2
+ export * from './sessionHandlerResolvers';
@@ -1,6 +1,3 @@
1
- export declare function getBurgerSessionHandler(): import("nl-portal-playwright-libraries").SessionHandler;
2
- export declare function getBedrijfSessionHandler(): import("nl-portal-playwright-libraries").SessionHandler;
3
- export declare function getVestigingSessionHandler(): import("nl-portal-playwright-libraries").SessionHandler;
4
- export declare function getDigidGemachtigdeSessionHandler(): import("nl-portal-playwright-libraries").SessionHandler;
5
- export declare function getEHerkenningBewindvoerderSessionHandler(): import("nl-portal-playwright-libraries").SessionHandler;
6
- export declare function getAdSessionHandler(): import("nl-portal-playwright-libraries").SessionHandler;
1
+ import { Account } from 'nl-portal-playwright-libraries';
2
+ import { AuthType } from '../../constants/authTypes';
3
+ export declare function getSessionHandler(authType: AuthType, account: Account): import("nl-portal-playwright-libraries").SessionHandler;
@@ -0,0 +1,5 @@
1
+ import { createSessionHandler } from '../sessionHandler';
2
+ import { getLoginHandler } from '../getLoginHandler';
3
+ export function getSessionHandler(authType, account) {
4
+ return createSessionHandler(authType, account, getLoginHandler(authType));
5
+ }
@@ -0,0 +1,25 @@
1
+ import { isRunningOnLocalhost } from 'nl-portal-playwright-libraries';
2
+ import { LocalhostLoginHandler } from './loginhandlers/localhostLoginHandler';
3
+ import { DigidLoginHandler } from './loginhandlers/digidLoginHandler';
4
+ import { EHerkenningLoginHandler } from './loginhandlers/eHerkenningLoginHandler';
5
+ import { DigidGemachtigdeLoginHandler } from './loginhandlers/digidGemachtigdeLoginHandler';
6
+ import { EHerkenningBewindvoerderLoginHandler } from './loginhandlers/eHerkenningBewindvoerderLoginHandler';
7
+ import { ADLoginHandler } from './loginhandlers/adLoginHandler';
8
+ export function getLoginHandler(authType) {
9
+ switch (authType) {
10
+ case 'digid':
11
+ return isRunningOnLocalhost() ? new LocalhostLoginHandler() : new DigidLoginHandler();
12
+ case 'digid_gemachtigde':
13
+ return new DigidGemachtigdeLoginHandler();
14
+ case 'eherkenning':
15
+ return isRunningOnLocalhost() ? new LocalhostLoginHandler() : new EHerkenningLoginHandler();
16
+ case 'eherkenning_vestiging':
17
+ return new EHerkenningLoginHandler();
18
+ case 'eherkenning_bewindvoerder':
19
+ return new EHerkenningBewindvoerderLoginHandler();
20
+ case 'ad-session':
21
+ return new ADLoginHandler();
22
+ default:
23
+ throw new Error(`Unsupported auth type: ${authType}. If needed please create a new LoginHandler and register it here in getLoginHandler().`);
24
+ }
25
+ }
@@ -0,0 +1,6 @@
1
+ export { getLoginHandler } from './getLoginHandler';
2
+ export { createSessionHandler, MAX_SESSION_TIME_IN_MINUTES } from './sessionHandler';
3
+ export * from './api/index';
4
+ export * from './loginhandlers/index';
5
+ export * from './pages/index';
6
+ export * from './utils/index';
@@ -0,0 +1,7 @@
1
+ import { ADLoginPage } from '../pages/adLoginPage';
2
+ export class ADLoginHandler {
3
+ async loginAndCreateSessionStorage(page, account, file) {
4
+ const loginPage = new ADLoginPage(page);
5
+ await loginPage.loginWithADAccountAndCreateSession(account, file);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ import { DigidLoginPage } from '../pages/digidLoginPage';
2
+ export class DigidGemachtigdeLoginHandler {
3
+ async loginAndCreateSessionStorage(page, account, file) {
4
+ const loginPage = new DigidLoginPage(page);
5
+ await loginPage.loginAndCreateNewGemachtigdeSession(account, file);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ import { DigidLoginPage } from '../pages/digidLoginPage';
2
+ export class DigidLoginHandler {
3
+ async loginAndCreateSessionStorage(page, account, file) {
4
+ const loginPage = new DigidLoginPage(page);
5
+ await loginPage.loginAndCreateNewSession(account, file);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ import { EHerkenningLoginPage } from '../pages/eHerkenningLoginPage';
2
+ export class EHerkenningBewindvoerderLoginHandler {
3
+ async loginAndCreateSessionStorage(page, account, file) {
4
+ const loginPage = new EHerkenningLoginPage(page);
5
+ await loginPage.loginAlsProfessioneelBewindvoerder(account, file);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ import { EHerkenningLoginPage } from '../pages/eHerkenningLoginPage';
2
+ export class EHerkenningLoginHandler {
3
+ async loginAndCreateSessionStorage(page, account, file) {
4
+ const loginPage = new EHerkenningLoginPage(page);
5
+ await loginPage.loginWithEHerkenningVestigingAndCreateSession(file, account);
6
+ }
7
+ }
@@ -0,0 +1,6 @@
1
+ export * from './adLoginHandler';
2
+ export * from './digidGemachtigdeLoginHandler';
3
+ export * from './digidLoginHandler';
4
+ export * from './eHerkenningBewindvoerderLoginHandler';
5
+ export * from './eHerkenningLoginHandler';
6
+ export * from './localhostLoginHandler';
@@ -0,0 +1,7 @@
1
+ import { LocalLoginPage } from 'nl-portal-playwright-libraries';
2
+ export class LocalhostLoginHandler {
3
+ async loginAndCreateSessionStorage(page, account, file) {
4
+ const loginPage = new LocalLoginPage(page);
5
+ await loginPage.loginAndCreateNewSession(account, file);
6
+ }
7
+ }
@@ -0,0 +1,94 @@
1
+ import { TOTP } from 'totp-generator';
2
+ import { BasePage } from 'nl-portal-playwright-libraries';
3
+ const gzacUrlProd = 'https://alg-zgw.denhaag.nl';
4
+ const gzacUrlAcp = 'https://alg-zgw.acc.denhaag.nl';
5
+ const gzacUrlTest = 'https://alg-zgw.test.denhaag.nl';
6
+ export class ADLoginPage extends BasePage {
7
+ gebruikersnaamInput;
8
+ wachtwoordInput;
9
+ volgendeInput;
10
+ aanmeldenInput;
11
+ kanAuthAppNietGebruikenLink;
12
+ gebruikVerificatieCode;
13
+ codeInput;
14
+ verifierenInput;
15
+ constructor(page) {
16
+ super(page);
17
+ this.gebruikersnaamInput = page.locator("//input[@type='email']");
18
+ this.wachtwoordInput = page.locator("//input[@name='passwd']");
19
+ this.volgendeInput = page.locator("//input[@type='submit']");
20
+ this.aanmeldenInput = page.locator("//input[@type='submit']");
21
+ this.kanAuthAppNietGebruikenLink = page.locator("//*[@id='signInAnotherWay']");
22
+ this.gebruikVerificatieCode = page.locator("//div[@id='idDiv_SAOTCS_Proofs']//div[contains(@role,'listitem')][2]");
23
+ this.codeInput = page.locator("//input[@name='otc']");
24
+ this.verifierenInput = page.locator("//input[@type='submit']");
25
+ }
26
+ async openPage(path) {
27
+ await this.page.goto(path);
28
+ }
29
+ /**
30
+ * Login with the AD account so we can get behind the firewall
31
+ *
32
+ * @param account
33
+ * @param fileName
34
+ */
35
+ async loginWithADAccountAndCreateSession(account, fileName) {
36
+ const adLoginPage = new ADLoginPage(this.page);
37
+ await this.page.goto(this.getGzacUrl());
38
+ await adLoginPage.gebruikersnaamInput.waitFor();
39
+ await adLoginPage.gebruikersnaamInput.fill(account.username);
40
+ await adLoginPage.volgendeInput.click();
41
+ await adLoginPage.wachtwoordInput.fill(account.password);
42
+ await adLoginPage.aanmeldenInput.click();
43
+ await this.page.waitForTimeout(1000);
44
+ try {
45
+ const foutMeldingIsSHowing = await this.page.getByText('Uw account is niet geverifieerd. Probeer het opnieuw').isVisible();
46
+ if (foutMeldingIsSHowing) {
47
+ await this.tryAgainUntilSuccesful();
48
+ }
49
+ }
50
+ catch (_error) {
51
+ //Ignore
52
+ }
53
+ await adLoginPage.kanAuthAppNietGebruikenLink.click();
54
+ await adLoginPage.gebruikVerificatieCode.click();
55
+ const token = await TOTP.generate(`${process.env.AD_SECRET}`);
56
+ await adLoginPage.codeInput.fill(token.otp);
57
+ await adLoginPage.verifierenInput.click();
58
+ await adLoginPage.page.waitForTimeout(5000);
59
+ adLoginPage.page.on('domcontentloaded', () => { });
60
+ await adLoginPage.page.context().storageState({ path: fileName });
61
+ }
62
+ async tryAgainUntilSuccesful() {
63
+ let maxNumberOfTries = 6;
64
+ let foutMeldingIsSHowing = true;
65
+ while (foutMeldingIsSHowing) {
66
+ await this.page.waitForTimeout(10000); // wait 10 seconds before continuing
67
+ maxNumberOfTries--;
68
+ if (maxNumberOfTries == 0) {
69
+ return;
70
+ }
71
+ try {
72
+ await this.page.goBack();
73
+ await this.page.waitForTimeout(1000);
74
+ await this.page.locator("//div[contains(@role,'listitem')]").first().click();
75
+ await this.page.waitForTimeout(1000);
76
+ foutMeldingIsSHowing = await this.page.getByText('Uw account is niet geverifieerd. Probeer het opnieuw').isVisible();
77
+ }
78
+ catch (_error) {
79
+ //Ignore
80
+ }
81
+ }
82
+ }
83
+ getGzacUrl() {
84
+ const baseUrl = this.getBaseUrl();
85
+ if (/klantportaal-zgw.denhaag.nl./.exec(baseUrl))
86
+ return gzacUrlProd;
87
+ if (/.acc./.exec(baseUrl))
88
+ return gzacUrlAcp;
89
+ if (/.test./.exec(baseUrl))
90
+ return gzacUrlTest;
91
+ else
92
+ throw new Error('Cannot find current environment for baseUrl: ' + baseUrl);
93
+ }
94
+ }
@@ -10,6 +10,6 @@ export declare class DigidLoginPage extends LoginOverzichtPage {
10
10
  * Je krijgt dan een speciaal scherm waar je moet bevestigen voordat je door kan
11
11
  */
12
12
  handleAnySpecialADLoginScreen(): Promise<void>;
13
- loginWithDigid(account?: Account, gemachtigde?: boolean): Promise<import("@playwright/test").Response>;
13
+ loginWithDigid(account: Account, gemachtigde?: boolean): Promise<import("@playwright/test").Response>;
14
14
  loginAlsDigidGemachtigde(): Promise<void>;
15
15
  }
@@ -0,0 +1,73 @@
1
+ import process from 'node:process';
2
+ import { LoginOverzichtPage } from './loginOverzichtPage';
3
+ export class DigidLoginPage extends LoginOverzichtPage {
4
+ constructor(page) {
5
+ super(page);
6
+ }
7
+ async loginAndCreateNewSession(account, fileName) {
8
+ await this.openPage();
9
+ await this.handleAnySpecialADLoginScreen();
10
+ try {
11
+ await this.klikOpDigidLoginOptie();
12
+ }
13
+ catch (_error) {
14
+ await this.openPage();
15
+ await this.handleAnySpecialADLoginScreen();
16
+ await this.klikOpDigidLoginOptie();
17
+ }
18
+ // It is possible that the digid session is still valid but the klantportaal session not.
19
+ // In that case we are in the klantportaal now and we can just replace the current storageState
20
+ if (!this.page.url().match(/authn/)) {
21
+ await this.loginWithDigid(account);
22
+ await this.accepteerCookies();
23
+ }
24
+ await this.page.context().storageState({ path: fileName });
25
+ }
26
+ async loginAndCreateNewGemachtigdeSession(account, fileName) {
27
+ await this.openPage();
28
+ await this.handleAnySpecialADLoginScreen();
29
+ try {
30
+ await this.klikOpDigidMachtigenLoginOptie();
31
+ }
32
+ catch (_error) {
33
+ await this.openPage();
34
+ await this.klikOpDigidMachtigenLoginOptie();
35
+ }
36
+ await this.loginWithDigid(account, true);
37
+ await this.accepteerCookies();
38
+ await this.page.context().storageState({ path: fileName });
39
+ }
40
+ /**
41
+ * Indien er al een AD sessie is maar voor de verkeerde omgeving
42
+ * Je krijgt dan een speciaal scherm waar je moet bevestigen voordat je door kan
43
+ */
44
+ async handleAnySpecialADLoginScreen() {
45
+ try {
46
+ await this.page.locator(`//div[contains(@data-test-id,'${process.env.AD_USER}')]`).first().waitFor({ timeout: 1000 });
47
+ await this.page.locator(`//div[contains(@data-test-id,'${process.env.AD_USER}')]`).first().click();
48
+ }
49
+ catch (_error) {
50
+ // Ignore
51
+ }
52
+ }
53
+ async loginWithDigid(account, gemachtigde) {
54
+ await this.page.getByLabel('Inlogoptie 5 van 5: Inloggen').click();
55
+ await this.page.getByLabel('Testen betrouwbaarheidsniveau').selectOption('25');
56
+ await this.page.getByLabel('DigiD gebruikersnaam').fill(account.username);
57
+ await this.page.getByLabel('Wachtwoord', { exact: true }).fill(account.password);
58
+ const responsePromise = this.page.waitForResponse(/callback/, { timeout: 60000 });
59
+ await this.page.getByRole('button', { name: 'Inloggen' }).click();
60
+ if (gemachtigde) {
61
+ await this.page.getByRole('button', { name: 'Kies' }).click();
62
+ }
63
+ return await responsePromise;
64
+ }
65
+ async loginAlsDigidGemachtigde() {
66
+ const gemachtigde = {
67
+ username: `${process.env.DIGID_GEMACHTIGDE_USER}`,
68
+ password: `${process.env.DIGID_GEMACHTIGDE_PASSWORD}`,
69
+ };
70
+ await this.klikOpDigidMachtigenLoginOptie();
71
+ await this.loginWithDigid(gemachtigde, true);
72
+ }
73
+ }
@@ -12,11 +12,10 @@ export declare class EHerkenningLoginPage extends LoginOverzichtPage {
12
12
  private readonly inputBsn;
13
13
  private readonly buttonZoek;
14
14
  constructor(page: Page);
15
- probeerInTeLoggenMetEHerkenning(account?: Account): Promise<void>;
16
- loginWithEHerkenningAndCreateSession(fileName: string, account?: Account): Promise<void>;
17
- loginWithEHerkenning(account?: Account): Promise<void>;
18
- loginWithEHerkenningVestigingAndCreateSession(fileName: string, account?: Account): Promise<void>;
19
- loginWithEHerkenningVestiging(account?: Account): Promise<void>;
20
- loginAlsProfessioneelBewindvoerder(gemachtigde?: Account, file?: string): Promise<void>;
21
- valideerDatNietGemachtigdBerichtZichtbaarIs(): Promise<void>;
15
+ probeerInTeLoggenMetEHerkenning(account: Account): Promise<void>;
16
+ loginWithEHerkenningAndCreateSession(fileName: string, account: Account): Promise<void>;
17
+ loginWithEHerkenning(account: Account): Promise<void>;
18
+ loginWithEHerkenningVestigingAndCreateSession(fileName: string, account: Account): Promise<void>;
19
+ loginWithEHerkenningVestiging(account: Account): Promise<void>;
20
+ loginAlsProfessioneelBewindvoerder(gemachtigde: Account, file?: string): Promise<void>;
22
21
  }
@@ -0,0 +1,94 @@
1
+ import { LoginOverzichtPage } from './loginOverzichtPage';
2
+ export class EHerkenningLoginPage extends LoginOverzichtPage {
3
+ dropdownSelectIdentityProvider;
4
+ buttonConfirmIdentityProviderSelection;
5
+ textfieldUsername;
6
+ textfieldPassword;
7
+ inloggenKnop;
8
+ verderKnop;
9
+ verderLink;
10
+ inputBsn;
11
+ buttonZoek;
12
+ constructor(page) {
13
+ super(page);
14
+ this.dropdownSelectIdentityProvider = page.locator('#identity_provider');
15
+ this.buttonConfirmIdentityProviderSelection = page.locator("//*[@name='commit']");
16
+ this.textfieldUsername = page.locator('#account_username');
17
+ this.textfieldPassword = page.locator('#account_password');
18
+ this.inloggenKnop = page.getByRole('button', { name: /Inloggen|Log in/ });
19
+ this.verderKnop = page.getByRole('button', { name: /Verder|Continue|Ga verder/ });
20
+ this.inputBsn = page.locator('#bsn-input');
21
+ this.buttonZoek = page.locator('#search-submit');
22
+ this.verderLink = page.getByRole('link', { name: /Verder|Continue|Ga verder/ });
23
+ }
24
+ async probeerInTeLoggenMetEHerkenning(account) {
25
+ await this.dropdownSelectIdentityProvider.selectOption('Digidentity AD 1.13 (preproduction)');
26
+ await this.page.locator('#remember').click();
27
+ await this.buttonConfirmIdentityProviderSelection.click();
28
+ await this.textfieldUsername.fill(account.username);
29
+ await this.verderKnop.click();
30
+ await this.textfieldPassword.fill(account.password);
31
+ await this.inloggenKnop.click();
32
+ }
33
+ async loginWithEHerkenningAndCreateSession(fileName, account) {
34
+ await this.openPage();
35
+ try {
36
+ await this.klikOpEHerkenningLoginOptie();
37
+ }
38
+ catch (_error) {
39
+ await this.openPage();
40
+ await this.klikOpEHerkenningLoginOptie();
41
+ }
42
+ await this.loginWithEHerkenning(account);
43
+ await this.page.context().storageState({ path: fileName });
44
+ }
45
+ async loginWithEHerkenning(account) {
46
+ await this.probeerInTeLoggenMetEHerkenning(account);
47
+ await this.page.waitForTimeout(2000);
48
+ if (await this.verderKnop.isVisible()) {
49
+ await this.verderKnop.click();
50
+ }
51
+ await this.accepteerCookies();
52
+ }
53
+ async loginWithEHerkenningVestigingAndCreateSession(fileName, account) {
54
+ await this.openPage();
55
+ try {
56
+ await this.klikOpEHerkenningLoginOptie();
57
+ }
58
+ catch (_error) {
59
+ await this.openPage();
60
+ await this.klikOpEHerkenningLoginOptie();
61
+ }
62
+ await this.loginWithEHerkenningVestiging(account);
63
+ await this.page.context().storageState({ path: fileName });
64
+ }
65
+ async loginWithEHerkenningVestiging(account) {
66
+ await this.probeerInTeLoggenMetEHerkenning(account);
67
+ await this.page.waitForTimeout(2000);
68
+ if (await this.verderKnop.isVisible()) {
69
+ await this.verderKnop.click();
70
+ }
71
+ await this.accepteerCookies();
72
+ }
73
+ async loginAlsProfessioneelBewindvoerder(gemachtigde, file) {
74
+ await this.openPage();
75
+ await this.klikOpProfessioneelBewindvoerderLoginOptie();
76
+ try {
77
+ await this.probeerInTeLoggenMetEHerkenning(gemachtigde);
78
+ }
79
+ catch (_error) {
80
+ await this.openPage();
81
+ await this.probeerInTeLoggenMetEHerkenning(gemachtigde);
82
+ }
83
+ if (gemachtigde.bsn != null) {
84
+ await this.verderLink.click();
85
+ await this.inputBsn.fill(gemachtigde.bsn);
86
+ }
87
+ await this.buttonZoek.click();
88
+ await this.verderLink.click();
89
+ await this.accepteerCookies();
90
+ if (file) {
91
+ await this.page.context().storageState({ path: file });
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,4 @@
1
+ export { ADLoginPage } from './adLoginPage';
2
+ export { DigidLoginPage } from './digidLoginPage';
3
+ export { EHerkenningLoginPage } from './eHerkenningLoginPage';
4
+ export { LoginOverzichtPage } from './loginOverzichtPage';
@@ -0,0 +1,70 @@
1
+ import { expect } from '@playwright/test';
2
+ import { BasePage } from 'nl-portal-playwright-libraries';
3
+ export class LoginOverzichtPage extends BasePage {
4
+ digidLoginKnop;
5
+ digidMachtigenLoginKnop;
6
+ eHerkenningLoginKnop;
7
+ eHerkenningMachtigingLoginKnop;
8
+ constructor(page) {
9
+ super(page);
10
+ this.digidLoginKnop = page.locator('#oidc-digid');
11
+ this.digidMachtigenLoginKnop = page.locator('#digid-machtigen');
12
+ this.eHerkenningLoginKnop = page.locator('#oidc-eHerkenning');
13
+ this.eHerkenningMachtigingLoginKnop = page.locator('#eherkenning-bewindvoering');
14
+ }
15
+ async klikOpDigidLoginOptie() {
16
+ await this.digidLoginKnop.waitFor();
17
+ await this.page.waitForTimeout(2000);
18
+ await this.digidLoginKnop.click();
19
+ }
20
+ async klikOpDigidMachtigenLoginOptie() {
21
+ await this.digidMachtigenLoginKnop.waitFor();
22
+ await this.page.waitForTimeout(2000);
23
+ await this.digidMachtigenLoginKnop.click();
24
+ }
25
+ async klikOpEHerkenningLoginOptie() {
26
+ await this.eHerkenningLoginKnop.waitFor();
27
+ await this.page.waitForTimeout(2000);
28
+ try {
29
+ await this.eHerkenningLoginKnop.click();
30
+ }
31
+ catch (_error) {
32
+ await this.reloadPage();
33
+ await this.eHerkenningLoginKnop.waitFor();
34
+ await this.page.waitForTimeout(2000);
35
+ await this.eHerkenningLoginKnop.click();
36
+ }
37
+ }
38
+ async klikOpProfessioneelBewindvoerderLoginOptie() {
39
+ await this.eHerkenningMachtigingLoginKnop.waitFor();
40
+ await this.page.waitForTimeout(2000);
41
+ try {
42
+ await this.eHerkenningMachtigingLoginKnop.click();
43
+ }
44
+ catch (_error) {
45
+ await this.reloadPage();
46
+ await this.eHerkenningMachtigingLoginKnop.waitFor();
47
+ await this.page.waitForTimeout(2000);
48
+ await this.eHerkenningMachtigingLoginKnop.click();
49
+ }
50
+ }
51
+ async valideerDatHetLoginOverzichtZichtbaarIs() {
52
+ await expect(this.page.getByRole('heading', { name: 'Inloggen voor mijzelf' })).toBeVisible();
53
+ }
54
+ async accepteerCookies() {
55
+ try {
56
+ await this.page.locator('#ppms_cm_agree-to-all').click();
57
+ }
58
+ catch (_ignore) {
59
+ // can be ignored if popup doesn't show
60
+ }
61
+ }
62
+ async reloadPage() {
63
+ try {
64
+ await this.page.reload();
65
+ }
66
+ catch (_error) {
67
+ // Ignore
68
+ }
69
+ }
70
+ }
@@ -1,6 +1,6 @@
1
1
  import { Account, SessionHandler } from 'nl-portal-playwright-libraries';
2
- import { AuthType } from '../constants/authTypes';
3
2
  import { LoginHandler } from '../constants/loginHandler';
3
+ import { AuthType } from '../constants';
4
4
  export declare const MAX_SESSION_TIME_IN_MINUTES = 10;
5
5
  /**
6
6
  * This class creates the correct SessionHandler