dh-auth-library 1.1.0 → 1.2.1
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.
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/{accountTypes.d.ts → testProfile.d.ts} +2 -1
- package/dist/index.cjs.js +562 -0
- package/dist/index.es.js +523 -0
- package/package.json +55 -50
- package/dist/auth/api/apiAuthentication.d.ts +0 -10
- package/dist/auth/api/apiAuthentication.js +0 -13
- package/dist/auth/api/apiTokenHelper.js +0 -68
- package/dist/auth/api/index.js +0 -2
- package/dist/auth/api/sessionHandlerResolvers.js +0 -5
- package/dist/auth/getLoginHandler.js +0 -25
- package/dist/auth/index.js +0 -6
- package/dist/auth/loginhandlers/adLoginHandler.js +0 -7
- package/dist/auth/loginhandlers/digidGemachtigdeLoginHandler.js +0 -7
- package/dist/auth/loginhandlers/digidLoginHandler.js +0 -7
- package/dist/auth/loginhandlers/eHerkenningBewindvoerderLoginHandler.js +0 -7
- package/dist/auth/loginhandlers/eHerkenningLoginHandler.js +0 -7
- package/dist/auth/loginhandlers/index.js +0 -6
- package/dist/auth/loginhandlers/localhostLoginHandler.js +0 -7
- package/dist/auth/pages/adLoginPage.js +0 -94
- package/dist/auth/pages/digidLoginPage.js +0 -73
- package/dist/auth/pages/eHerkenningLoginPage.js +0 -94
- package/dist/auth/pages/index.js +0 -4
- package/dist/auth/pages/loginOverzichtPage.js +0 -70
- package/dist/auth/sessionHandler.js +0 -88
- package/dist/auth/utils/index.js +0 -1
- package/dist/auth/utils/sessionFileHelper.js +0 -33
- package/dist/constants/accountTypes.js +0 -1
- package/dist/constants/accounts.d.ts +0 -12
- package/dist/constants/accounts.js +0 -40
- package/dist/constants/authTypes.js +0 -1
- package/dist/constants/index.js +0 -3
- package/dist/constants/loginHandler.js +0 -1
- package/dist/constants/testAccounts.d.ts +0 -38
- package/dist/constants/testAccounts.js +0 -39
- package/dist/constants/testProfiles.d.ts +0 -27
- package/dist/constants/testProfiles.js +0 -27
- package/dist/index.js +0 -2
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/auth/api/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/auth/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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';
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/auth/pages/index.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
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,88 +0,0 @@
|
|
|
1
|
-
import { getUrl, Url } from 'nl-portal-playwright-libraries';
|
|
2
|
-
import { SessionFileHelper } from './utils/sessionFileHelper';
|
|
3
|
-
export const MAX_SESSION_TIME_IN_MINUTES = 10;
|
|
4
|
-
/**
|
|
5
|
-
* This class creates the correct SessionHandler
|
|
6
|
-
* It will also perform the process of setting op the session
|
|
7
|
-
*
|
|
8
|
-
* @param authType type of login
|
|
9
|
-
* @param account with login details
|
|
10
|
-
* @param loginHandler that will handle the login itself
|
|
11
|
-
*/
|
|
12
|
-
export function createSessionHandler(authType, account, loginHandler) {
|
|
13
|
-
return {
|
|
14
|
-
// Get the file where the session will be stored
|
|
15
|
-
getFile: (browser) => {
|
|
16
|
-
switch (authType) {
|
|
17
|
-
case 'digid':
|
|
18
|
-
return SessionFileHelper.getDigidFileName(browser, account);
|
|
19
|
-
case 'digid_gemachtigde':
|
|
20
|
-
return SessionFileHelper.getDigidGemachtigdeFileName(browser, account);
|
|
21
|
-
case 'eherkenning':
|
|
22
|
-
return SessionFileHelper.getEHerkenningFileName(browser, account);
|
|
23
|
-
case 'eherkenning_vestiging':
|
|
24
|
-
return SessionFileHelper.getEHerkenningVestigingFileName(browser, account);
|
|
25
|
-
case 'eherkenning_bewindvoerder':
|
|
26
|
-
return SessionFileHelper.getEHerkenningBewindvoerderFileName(browser, account);
|
|
27
|
-
case 'ad-session':
|
|
28
|
-
return SessionFileHelper.getADFileName(browser, account);
|
|
29
|
-
default:
|
|
30
|
-
throw new Error(`Unsupported auth type: ${authType}`);
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* Setup the new session
|
|
35
|
-
* If needed the AD Session if used (Needed outside the firewall)
|
|
36
|
-
*
|
|
37
|
-
* @param browser
|
|
38
|
-
* @param file
|
|
39
|
-
*/
|
|
40
|
-
setupSession: async (browser, file) => {
|
|
41
|
-
const useADSession = process.env.WITH_AD_SESSION === 'true';
|
|
42
|
-
const page = await browser.newPage({
|
|
43
|
-
ignoreHTTPSErrors: true,
|
|
44
|
-
storageState: useADSession && authType !== 'ad-session' ?
|
|
45
|
-
SessionFileHelper.getADFileName(browser, { username: `${process.env.AD_USER}`, password: `${process.env.AD_PASSWORD}` }) : undefined,
|
|
46
|
-
});
|
|
47
|
-
console.log(`New session will be created: ${file}`);
|
|
48
|
-
try {
|
|
49
|
-
await loginHandler.loginAndCreateSessionStorage(page, account, file);
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
await page.close();
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* Refresh the current session by opening a page and storing that session
|
|
57
|
-
* The UI should have refreshed the session meanwhile
|
|
58
|
-
*
|
|
59
|
-
* This is being called from the nl-portal-base-library
|
|
60
|
-
*
|
|
61
|
-
* @param browser
|
|
62
|
-
* @param file
|
|
63
|
-
*/
|
|
64
|
-
refreshSession: async (browser, file) => {
|
|
65
|
-
const page = await browser.newPage({
|
|
66
|
-
ignoreHTTPSErrors: true,
|
|
67
|
-
storageState: file,
|
|
68
|
-
});
|
|
69
|
-
console.log(`Refresh of session started for : ${file}`);
|
|
70
|
-
await page.goto(getUrl(Url.PortalBaseUrl));
|
|
71
|
-
await page.waitForLoadState('networkidle');
|
|
72
|
-
if (page.url().match(/authn/)) {
|
|
73
|
-
console.log(`New session will be created as the current one is no longer valid: ${file}`);
|
|
74
|
-
try {
|
|
75
|
-
await loginHandler.loginAndCreateSessionStorage(page, account, file);
|
|
76
|
-
}
|
|
77
|
-
catch (_error) {
|
|
78
|
-
console.error(_error);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
console.log(`Current session was still valid and will be refreshed now: ${file}`);
|
|
83
|
-
await page.context().storageState({ path: file });
|
|
84
|
-
}
|
|
85
|
-
await page.close();
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
package/dist/auth/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SessionFileHelper } from './sessionFileHelper';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
import * as process from 'node:process';
|
|
3
|
-
const sessionsDir = process.env.SESSIONS_DIR ?? path.resolve(process.cwd(), 'sessions');
|
|
4
|
-
const environment = process.env.ENV ?? 'test';
|
|
5
|
-
/**
|
|
6
|
-
* Easy way to create the filenames for the sessions
|
|
7
|
-
*/
|
|
8
|
-
export class SessionFileHelper {
|
|
9
|
-
static getLocalhostFileName(browser, account) {
|
|
10
|
-
return path.join(sessionsDir, `${browser.browserType().name()}-${environment}-${account.username}.json`);
|
|
11
|
-
}
|
|
12
|
-
static getLocalhostFileNameBedrijf(browser, account) {
|
|
13
|
-
return path.join(sessionsDir, `${browser.browserType().name()}-${environment}-${account.username}.json`);
|
|
14
|
-
}
|
|
15
|
-
static getDigidFileName(browser, account) {
|
|
16
|
-
return path.join(sessionsDir, `${browser.browserType().name()}-digid-${environment}-${account.username}.json`);
|
|
17
|
-
}
|
|
18
|
-
static getDigidGemachtigdeFileName(browser, account) {
|
|
19
|
-
return path.join(sessionsDir, `${browser.browserType().name()}-digid-gemachtigde-${environment}-${account.username}.json`);
|
|
20
|
-
}
|
|
21
|
-
static getEHerkenningFileName(browser, account) {
|
|
22
|
-
return path.join(sessionsDir, `${browser.browserType().name()}-eherkenning-${environment}-${account.username}.json`);
|
|
23
|
-
}
|
|
24
|
-
static getEHerkenningVestigingFileName(browser, account) {
|
|
25
|
-
return path.join(sessionsDir, `${browser.browserType().name()}-eherkenning-vestiging-${environment}-${account.username}.json`);
|
|
26
|
-
}
|
|
27
|
-
static getEHerkenningBewindvoerderFileName(browser, account) {
|
|
28
|
-
return path.join(sessionsDir, `${browser.browserType().name()}-eherkenning-bewindvoerder-${environment}-${account.username}.json`);
|
|
29
|
-
}
|
|
30
|
-
static getADFileName(browser, account) {
|
|
31
|
-
return path.join(sessionsDir, `${browser.browserType().name()}-ad-${environment}-${account.username}.json`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Account } from 'nl-portal-playwright-libraries';
|
|
2
|
-
/**
|
|
3
|
-
* To use these accounts they should be available as environment variables
|
|
4
|
-
*/
|
|
5
|
-
export declare const localhostBurgerAccount: Account;
|
|
6
|
-
export declare const localhostBedrijfAccount: Account;
|
|
7
|
-
export declare const defaultDigidAccount: Account;
|
|
8
|
-
export declare const defaultDigidGemachtigdAccount: Account;
|
|
9
|
-
export declare const defaultEHerkenningAccount: Account;
|
|
10
|
-
export declare const defaultVestigingAccount: Account;
|
|
11
|
-
export declare const defaultProfessioneelBewindvoerderAccount: Account;
|
|
12
|
-
export declare const defaultADAccount: Account;
|