dh-auth-library 1.0.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 (35) hide show
  1. package/README.md +39 -0
  2. package/dist/auth/api/apiAuthentication.d.ts +10 -0
  3. package/dist/auth/api/apiTokenHelper.d.ts +17 -0
  4. package/dist/auth/api/index.d.ts +3 -0
  5. package/dist/auth/api/sessionHandlerResolvers.d.ts +6 -0
  6. package/dist/auth/getLoginHandler.d.ts +3 -0
  7. package/dist/auth/index.d.ts +6 -0
  8. package/dist/auth/loginhandlers/adLoginHandler.d.ts +6 -0
  9. package/dist/auth/loginhandlers/digidGemachtigdeLoginHandler.d.ts +6 -0
  10. package/dist/auth/loginhandlers/digidLoginHandler.d.ts +6 -0
  11. package/dist/auth/loginhandlers/eHerkenningBewindvoerderLoginHandler.d.ts +6 -0
  12. package/dist/auth/loginhandlers/eHerkenningLoginHandler.d.ts +6 -0
  13. package/dist/auth/loginhandlers/index.d.ts +6 -0
  14. package/dist/auth/loginhandlers/localhostLoginHandler.d.ts +6 -0
  15. package/dist/auth/pages/adLoginPage.d.ts +23 -0
  16. package/dist/auth/pages/digidLoginPage.d.ts +15 -0
  17. package/dist/auth/pages/eHerkenningLoginPage.d.ts +22 -0
  18. package/dist/auth/pages/index.d.ts +4 -0
  19. package/dist/auth/pages/loginOverzichtPage.d.ts +16 -0
  20. package/dist/auth/sessionHandler.d.ts +13 -0
  21. package/dist/auth/utils/index.d.ts +1 -0
  22. package/dist/auth/utils/sessionFileHelper.d.ts +14 -0
  23. package/dist/constants/accountTypes.d.ts +34 -0
  24. package/dist/constants/accounts.d.ts +12 -0
  25. package/dist/constants/authTypes.d.ts +1 -0
  26. package/dist/constants/index.d.ts +6 -0
  27. package/dist/constants/loginHandler.d.ts +5 -0
  28. package/dist/constants/testAccounts.d.ts +38 -0
  29. package/dist/constants/testProfiles.d.ts +27 -0
  30. package/dist/index.cjs.js +860 -0
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.es.js +806 -0
  33. package/dist/sha-B5xpXfPW.mjs +911 -0
  34. package/dist/sha-Eh0BcCJ_.js +911 -0
  35. package/package.json +54 -0
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # NL Portal Playwright Libraries
2
+
3
+ A Playwright library for testing NL Portal implementaties.
4
+ test
5
+
6
+ it is published an npm package too and should be imported like that
7
+
8
+ ---
9
+
10
+ ## 📦 Purpose
11
+
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
15
+
16
+ ---
17
+
18
+ ## 🧱 Structure
19
+
20
+ 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
24
+
25
+ ---
26
+
27
+ ## Auth
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
32
+
33
+
34
+ ## Publishing to npm
35
+
36
+ 1 - npm version minor/major/patch (npm version minor) -> this will update the package json version
37
+ 2 - npm pack --dry-run (just for checking if it is all okay)
38
+ 3 - npm login (follow the login instructions)
39
+ 4 - npm publish
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The api's will use an existing session and use that token for the requests.
3
+ * The reason for this is that the token life-span is short and the UI always does a token-refresh.
4
+ * By using the UI session and stealing that token it will always be valid.
5
+ */
6
+ export declare const burgerApiTest: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & import("./apiTokenHelper").ApiFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
7
+ export declare const bedrijfApiTest: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & import("./apiTokenHelper").ApiFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
8
+ export declare const vestigingApiTest: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & import("./apiTokenHelper").ApiFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
9
+ export declare const digidGemachtigdeApiTest: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & import("./apiTokenHelper").ApiFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
10
+ export declare const eHerkenningBewindvoerderApiTest: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & import("./apiTokenHelper").ApiFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
@@ -0,0 +1,17 @@
1
+ import { test as base } from '@playwright/test';
2
+ import { SessionHandler, urls } from 'nl-portal-playwright-libraries';
3
+ export type ApiFixtures = {
4
+ urls: typeof urls;
5
+ token: string;
6
+ };
7
+ /**
8
+ * The token is often being refreshed so the easiest is to open a browser using the current session
9
+ * The UI will automatically refresh the token and that is the token we will return
10
+ *
11
+ * That token can be used to perform some api requests for a short time
12
+ * Per specfile it is not problem but this should be done in every specfile to assure a valid token
13
+ *
14
+ * @param baseTest
15
+ * @param handlerResolver
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>;
@@ -0,0 +1,3 @@
1
+ export * from './apiAuthentication';
2
+ export * from './apiTokenHelper';
3
+ export * from './sessionHandlerResolvers';
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,3 @@
1
+ import { AuthType } from '../constants/authTypes';
2
+ import { LoginHandler } from '../constants/loginHandler';
3
+ export declare function getLoginHandler(authType: AuthType): LoginHandler;
@@ -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,6 @@
1
+ import { Page } from '@playwright/test';
2
+ import { Account } from 'nl-portal-playwright-libraries';
3
+ import { LoginHandler } from '../../constants/loginHandler';
4
+ export declare class ADLoginHandler implements LoginHandler {
5
+ loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { Page } from '@playwright/test';
2
+ import { Account } from 'nl-portal-playwright-libraries';
3
+ import { LoginHandler } from '../../constants/loginHandler';
4
+ export declare class DigidGemachtigdeLoginHandler implements LoginHandler {
5
+ loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { Page } from '@playwright/test';
2
+ import { Account } from 'nl-portal-playwright-libraries';
3
+ import { LoginHandler } from '../../constants/loginHandler';
4
+ export declare class DigidLoginHandler implements LoginHandler {
5
+ loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { Page } from '@playwright/test';
2
+ import { Account } from 'nl-portal-playwright-libraries';
3
+ import { LoginHandler } from '../../constants/loginHandler';
4
+ export declare class EHerkenningBewindvoerderLoginHandler implements LoginHandler {
5
+ loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { Page } from '@playwright/test';
2
+ import { Account } from 'nl-portal-playwright-libraries';
3
+ import { LoginHandler } from '../../constants/loginHandler';
4
+ export declare class EHerkenningLoginHandler implements LoginHandler {
5
+ loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
6
+ }
@@ -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,6 @@
1
+ import { Page } from '@playwright/test';
2
+ import { Account } from 'nl-portal-playwright-libraries';
3
+ import { LoginHandler } from '../../constants/loginHandler';
4
+ export declare class LocalhostLoginHandler implements LoginHandler {
5
+ loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
6
+ }
@@ -0,0 +1,23 @@
1
+ import { Locator, Page } from '@playwright/test';
2
+ import { Account, BasePage } from 'nl-portal-playwright-libraries';
3
+ export declare class ADLoginPage extends BasePage {
4
+ gebruikersnaamInput: Locator;
5
+ wachtwoordInput: Locator;
6
+ volgendeInput: Locator;
7
+ aanmeldenInput: Locator;
8
+ kanAuthAppNietGebruikenLink: Locator;
9
+ gebruikVerificatieCode: Locator;
10
+ codeInput: Locator;
11
+ verifierenInput: Locator;
12
+ constructor(page: Page);
13
+ openPage(path: string): Promise<void>;
14
+ /**
15
+ * Login with the AD account so we can get behind the firewall
16
+ *
17
+ * @param account
18
+ * @param fileName
19
+ */
20
+ loginWithADAccountAndCreateSession(account: Account, fileName: string): Promise<void>;
21
+ tryAgainUntilSuccesful(): Promise<void>;
22
+ getGzacUrl(): string;
23
+ }
@@ -0,0 +1,15 @@
1
+ import { Page } from '@playwright/test';
2
+ import { LoginOverzichtPage } from './loginOverzichtPage';
3
+ import { Account } from 'nl-portal-playwright-libraries';
4
+ export declare class DigidLoginPage extends LoginOverzichtPage {
5
+ constructor(page: Page);
6
+ loginAndCreateNewSession(account: Account, fileName: string): Promise<void>;
7
+ loginAndCreateNewGemachtigdeSession(account: Account, fileName: string): Promise<void>;
8
+ /**
9
+ * Indien er al een AD sessie is maar voor de verkeerde omgeving
10
+ * Je krijgt dan een speciaal scherm waar je moet bevestigen voordat je door kan
11
+ */
12
+ handleAnySpecialADLoginScreen(): Promise<void>;
13
+ loginWithDigid(account?: Account, gemachtigde?: boolean): Promise<import("@playwright/test").Response>;
14
+ loginAlsDigidGemachtigde(): Promise<void>;
15
+ }
@@ -0,0 +1,22 @@
1
+ import { Page } from '@playwright/test';
2
+ import { LoginOverzichtPage } from './loginOverzichtPage';
3
+ import { Account } from 'nl-portal-playwright-libraries';
4
+ export declare class EHerkenningLoginPage extends LoginOverzichtPage {
5
+ private readonly dropdownSelectIdentityProvider;
6
+ private readonly buttonConfirmIdentityProviderSelection;
7
+ private readonly textfieldUsername;
8
+ private readonly textfieldPassword;
9
+ private readonly inloggenKnop;
10
+ private readonly verderKnop;
11
+ private readonly verderLink;
12
+ private readonly inputBsn;
13
+ private readonly buttonZoek;
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>;
22
+ }
@@ -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,16 @@
1
+ import { Locator, Page } from '@playwright/test';
2
+ import { BasePage } from 'nl-portal-playwright-libraries';
3
+ export declare class LoginOverzichtPage extends BasePage {
4
+ digidLoginKnop: Locator;
5
+ digidMachtigenLoginKnop: Locator;
6
+ eHerkenningLoginKnop: Locator;
7
+ eHerkenningMachtigingLoginKnop: Locator;
8
+ constructor(page: Page);
9
+ klikOpDigidLoginOptie(): Promise<void>;
10
+ klikOpDigidMachtigenLoginOptie(): Promise<void>;
11
+ klikOpEHerkenningLoginOptie(): Promise<void>;
12
+ klikOpProfessioneelBewindvoerderLoginOptie(): Promise<void>;
13
+ valideerDatHetLoginOverzichtZichtbaarIs(): Promise<void>;
14
+ accepteerCookies(): Promise<void>;
15
+ reloadPage(): Promise<void>;
16
+ }
@@ -0,0 +1,13 @@
1
+ import { Account, SessionHandler } from 'nl-portal-playwright-libraries';
2
+ import { AuthType } from '../constants/authTypes';
3
+ import { LoginHandler } from '../constants/loginHandler';
4
+ export declare const MAX_SESSION_TIME_IN_MINUTES = 10;
5
+ /**
6
+ * This class creates the correct SessionHandler
7
+ * It will also perform the process of setting op the session
8
+ *
9
+ * @param authType type of login
10
+ * @param account with login details
11
+ * @param loginHandler that will handle the login itself
12
+ */
13
+ export declare function createSessionHandler(authType: AuthType, account: Account, loginHandler: LoginHandler): SessionHandler;
@@ -0,0 +1 @@
1
+ export { SessionFileHelper } from './sessionFileHelper';
@@ -0,0 +1,14 @@
1
+ import { Browser } from '@playwright/test';
2
+ /**
3
+ * Easy way to create the filenames for the sessions
4
+ */
5
+ export declare class SessionFileHelper {
6
+ static getLocalhostFileName(browser: Browser): string;
7
+ static getLocalhostFileNameBedrijf(browser: Browser): string;
8
+ static getDigidFileName(browser: Browser): string;
9
+ static getDigidGemachtigdeFileName(browser: Browser): string;
10
+ static getEHerkenningFileName(browser: Browser): string;
11
+ static getEHerkenningVestigingFileName(browser: Browser): string;
12
+ static getEHerkenningBewindvoerderFileName(browser: Browser): string;
13
+ static getADFileName(browser: Browser): string;
14
+ }
@@ -0,0 +1,34 @@
1
+ import { AuthType } from './authTypes';
2
+ export type AccountType = 'burger' | 'bedrijf' | 'vestiging' | 'digid-gemachtigde';
3
+ export interface TestProfile {
4
+ accountType: AccountType;
5
+ authType: AuthType;
6
+ id: string;
7
+ }
8
+ export declare const profiles: {
9
+ burger: {
10
+ accountType: "burger";
11
+ authType: "digid";
12
+ id: string;
13
+ };
14
+ bedrijf: {
15
+ accountType: "bedrijf";
16
+ authType: "eherkenning";
17
+ id: string;
18
+ };
19
+ vestiging: {
20
+ accountType: "vestiging";
21
+ authType: "eherkenning_vestiging";
22
+ id: string;
23
+ };
24
+ gemachtigde: {
25
+ accountType: "digid-gemachtigde";
26
+ authType: "digid_gemachtigde";
27
+ id: string;
28
+ };
29
+ bewindvoerder: {
30
+ accountType: "bedrijf";
31
+ authType: "eherkenning_bewindvoerder";
32
+ id: string;
33
+ };
34
+ };
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1 @@
1
+ export type AuthType = 'localhost_burger' | 'localhost_bedrijf' | 'digid' | 'digid_gemachtigde' | 'eherkenning' | 'eherkenning_vestiging' | 'eherkenning_bewindvoerder' | 'ad-session';
@@ -0,0 +1,6 @@
1
+ export * from './accounts';
2
+ export * from './accountTypes';
3
+ export * from './authTypes';
4
+ export * from './loginHandler';
5
+ export * from './testAccounts';
6
+ export * from './testProfiles';
@@ -0,0 +1,5 @@
1
+ import { Page } from '@playwright/test';
2
+ import { Account } from 'nl-portal-playwright-libraries';
3
+ export interface LoginHandler {
4
+ loginAndCreateSessionStorage(page: Page, account: Account, file: string): Promise<void>;
5
+ }
@@ -0,0 +1,38 @@
1
+ export declare const TestAccounts: {
2
+ zgwdigiduser1: {
3
+ id: string;
4
+ type: "burger";
5
+ };
6
+ zgwdigiduser2: {
7
+ id: string;
8
+ type: "burger";
9
+ };
10
+ zgwdigiduser3: {
11
+ id: string;
12
+ type: "burger";
13
+ };
14
+ zgwdigiduser4: {
15
+ id: string;
16
+ type: "burger";
17
+ };
18
+ zgwdigiduser5: {
19
+ id: string;
20
+ type: "burger";
21
+ };
22
+ testautomatisering: {
23
+ id: string;
24
+ type: "burger";
25
+ };
26
+ localhostaccount: {
27
+ id: string;
28
+ type: "burger";
29
+ };
30
+ kvkAccount: {
31
+ id: string;
32
+ type: "bedrijf";
33
+ };
34
+ kvkVestiging: {
35
+ id: string;
36
+ type: "vestiging";
37
+ };
38
+ };
@@ -0,0 +1,27 @@
1
+ export declare const testProfiles: {
2
+ readonly burger: {
3
+ readonly accountType: "burger";
4
+ readonly authType: "digid";
5
+ readonly id: "999994499";
6
+ };
7
+ readonly bedrijf: {
8
+ readonly accountType: "bedrijf";
9
+ readonly authType: "eherkenning";
10
+ readonly id: "90002768";
11
+ };
12
+ readonly vestiging: {
13
+ readonly accountType: "vestiging";
14
+ readonly authType: "eherkenning_vestiging";
15
+ readonly id: "990000262129";
16
+ };
17
+ readonly gemachtigde: {
18
+ readonly accountType: "digid-gemachtigde";
19
+ readonly authType: "digid_gemachtigde";
20
+ readonly id: "";
21
+ };
22
+ readonly bewindvoerder: {
23
+ readonly accountType: "bedrijf";
24
+ readonly authType: "eherkenning_bewindvoerder";
25
+ readonly id: "999994499";
26
+ };
27
+ };