From 57b055daa59227ab7a7d65306979ffec5f20225c Mon Sep 17 00:00:00 2001 From: pedro Date: Sat, 9 Mar 2024 20:30:36 +0100 Subject: [PATCH 01/10] WIP pilot tests: basic OIDC flow works --- tests/pilot-tests.spec.ts | 82 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/pilot-tests.spec.ts diff --git a/tests/pilot-tests.spec.ts b/tests/pilot-tests.spec.ts new file mode 100644 index 0000000..4ecd546 --- /dev/null +++ b/tests/pilot-tests.spec.ts @@ -0,0 +1,82 @@ +import { test, expect } from '@playwright/test'; +// TODO import domain WALLET y VERIFIER +// TODO env var + +// optional page (decrypt) +// src https://playwright.dev/docs/locators#matching-one-of-the-two-alternative-locators +async function accept_data_protection(page) { + // TODO cannot be, because of this inconsistency: Data Protection (user) vs Data protection (admin) + //const data_protection = await page.getByRole('heading', { name: 'Data protection', exact: true }) + const data_protection = await page.getByRole('heading', { name: 'Data protection' }) + if (await data_protection.isVisible()) { + await page.locator('#id_accept_privacy').check(); + await page.locator('#id_accept_legal').check(); + await page.locator('#id_accept_cookies').check(); + await page.getByRole('link', { name: 'Confirm' }).click(); + } +} + + +// useful for DEBUG +// await page.pause(); + +test('test', async ({ page }) => { + // TODO hardcoded domain WALLET + await page.goto('http://localhost/login/'); + await page.getByPlaceholder('Email address').click(); + await page.getByPlaceholder('Email address').fill('idhub_admin@pangea.org'); + await page.getByPlaceholder('Password').fill('1234'); + await page.getByRole('button', { name: 'Log in' }).click(); + + //const encryption_key_page = page.getByText('Encryption Key') + const encryption_key_page_admin = await page.getByRole('heading', { name: 'Encryption Key', exact: true }) + if (await encryption_key_page_admin.isVisible()) { + await page.getByPlaceholder('Key for encrypt the secrets').click(); + await page.getByPlaceholder('Key for encrypt the secrets').fill('1234'); + await page.getByRole('button', { name: 'Save' }).click(); + } + + await accept_data_protection(page); + + await page.getByRole('link', { name: ' Data' }).click(); + await page.getByRole('link', { name: 'Import data ' }).click(); + // src https://playwright.dev/docs/input#select-options + await page.getByLabel('Schema').selectOption('Financial Vulnerability Credential'); + // src https://playwright.dev/docs/input#upload-files + // TODO hardcoded URL + await page.getByLabel('File to import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); + //await page.setInputFiles('input[type="file"]', '/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); + await page.getByRole('button', { name: 'Save' }).click(); + await page.getByRole('link', { name: '', exact: true }).click(); + await page.getByPlaceholder('Email address').click(); + await page.getByPlaceholder('Email address').fill('user1@example.org'); + await page.getByPlaceholder('Password').click(); + await page.getByPlaceholder('Password').fill('1234'); + await page.getByRole('button', { name: 'Log in' }).click(); + + await accept_data_protection(page); + + await page.getByRole('link', { name: 'Identities (DIDs)' }).click(); + await page.getByRole('link', { name: 'Add Identity ' }).click(); + await page.getByPlaceholder('Label').click(); + await page.getByPlaceholder('Label').fill('default'); + await page.getByLabel('Type').selectOption('1'); + await page.getByRole('button', { name: 'Save' }).click(); + await page.getByRole('link', { name: 'Request a credential' }).click(); + await page.getByRole('button', { name: 'Request' }).click(); + // TODO hardcoded domain VERIFIER + await page.goto('http://idhub2/promotion/'); + await page.getByRole('link', { name: 'Contractar amb credencial' }).click(); + await page.getByRole('button', { name: 'Go' }).click(); + await page.getByRole('radio').first().check(); + await page.getByRole('checkbox').check(); + await page.getByRole('button', { name: 'Present' }).click(); + await page.pause(); + // TODO averiguar si devuelve código es final 1 (OIDC_REDIRECT=false) + + // TODO averiguar si hace redirección a 2 es final 2 (OIDC_REDIRECT=true) +}); + +// TODO test que hace la presentación de la credencial al revés + +// TODO test que hace la presentación de la credencial al revés From 5639bfcfaf27902068ecd46fd676494081e7a3f9 Mon Sep 17 00:00:00 2001 From: pedro Date: Fri, 15 Mar 2024 11:15:26 +0100 Subject: [PATCH 02/10] use IDHUB_{WALLET,VERIFIER} env vars --- tests/pilot-tests.spec.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/pilot-tests.spec.ts b/tests/pilot-tests.spec.ts index 4ecd546..a2db54a 100644 --- a/tests/pilot-tests.spec.ts +++ b/tests/pilot-tests.spec.ts @@ -1,3 +1,5 @@ +import { IDHUB_WALLET, IDHUB_VERIFIER } from '../src/constants/env_constants'; + import { test, expect } from '@playwright/test'; // TODO import domain WALLET y VERIFIER // TODO env var @@ -22,7 +24,7 @@ async function accept_data_protection(page) { test('test', async ({ page }) => { // TODO hardcoded domain WALLET - await page.goto('http://localhost/login/'); + await page.goto(IDHUB_WALLET + '/login/'); await page.getByPlaceholder('Email address').click(); await page.getByPlaceholder('Email address').fill('idhub_admin@pangea.org'); await page.getByPlaceholder('Password').fill('1234'); @@ -65,7 +67,7 @@ test('test', async ({ page }) => { await page.getByRole('link', { name: 'Request a credential' }).click(); await page.getByRole('button', { name: 'Request' }).click(); // TODO hardcoded domain VERIFIER - await page.goto('http://idhub2/promotion/'); + await page.goto(IDHUB_VERIFIER + '/promotion/'); await page.getByRole('link', { name: 'Contractar amb credencial' }).click(); await page.getByRole('button', { name: 'Go' }).click(); await page.getByRole('radio').first().check(); From ea2023fc0ea0dce0caa56efadb6b48fec0085ad5 Mon Sep 17 00:00:00 2001 From: pedro Date: Mon, 18 Mar 2024 21:47:41 +0100 Subject: [PATCH 03/10] test for oidc pilots (setem, xo9b) --- tests/{pilot-tests.spec.ts => pilot-oidc.spec.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{pilot-tests.spec.ts => pilot-oidc.spec.ts} (100%) diff --git a/tests/pilot-tests.spec.ts b/tests/pilot-oidc.spec.ts similarity index 100% rename from tests/pilot-tests.spec.ts rename to tests/pilot-oidc.spec.ts From aacfc290d4047b8b5cd8e2013ee05de12c1780d8 Mon Sep 17 00:00:00 2001 From: pedro Date: Mon, 18 Mar 2024 21:48:06 +0100 Subject: [PATCH 04/10] add testing for lafede pilot --- tests/pilot-lafede.spec.ts | 100 +++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/pilot-lafede.spec.ts diff --git a/tests/pilot-lafede.spec.ts b/tests/pilot-lafede.spec.ts new file mode 100644 index 0000000..3d66e5d --- /dev/null +++ b/tests/pilot-lafede.spec.ts @@ -0,0 +1,100 @@ +import { IDHUB_WALLET } from '../src/constants/env_constants'; + +import { test, expect } from '@playwright/test'; +// TODO import domain WALLET y VERIFIER +// TODO env var + +// optional page (decrypt) +// src https://playwright.dev/docs/locators#matching-one-of-the-two-alternative-locators +async function accept_data_protection(page) { + // TODO cannot be, because of this inconsistency: Data Protection (user) vs Data protection (admin) + //const data_protection = await page.getByRole('heading', { name: 'Data protection', exact: true }) + const data_protection = await page.getByRole('heading', { name: 'Data protection' }) + if (await data_protection.isVisible()) { + await page.locator('#id_accept_privacy').check(); + await page.locator('#id_accept_legal').check(); + await page.locator('#id_accept_cookies').check(); + await page.getByRole('link', { name: 'Confirm' }).click(); + } +} + + +// useful for DEBUG +// await page.pause(); + +test('test', async ({ page }) => { + // TODO hardcoded domain WALLET + await page.goto(IDHUB_WALLET + '/login/'); + await page.getByPlaceholder('Email address').click(); + await page.getByPlaceholder('Email address').fill('idhub_admin@pangea.org'); + await page.getByPlaceholder('Password').fill('1234'); + await page.getByRole('button', { name: 'Log in' }).click(); + + //const encryption_key_page = page.getByText('Encryption Key') + const encryption_key_page_admin = await page.getByRole('heading', { name: 'Encryption Key', exact: true }) + if (await encryption_key_page_admin.isVisible()) { + await page.getByPlaceholder('Key for encrypt the secrets').click(); + await page.getByPlaceholder('Key for encrypt the secrets').fill('1234'); + await page.getByRole('button', { name: 'Save' }).click(); + } + + await accept_data_protection(page); + + await page.getByRole('link', { name: ' Credentials' }).click(); + await page.getByRole('link', { name: 'Organization\'s wallet' }).click(); + await page.getByRole('link', { name: 'Configure credential issuance' }).click(); + await page.getByPlaceholder('Label').click(); + await page.getByPlaceholder('Label').fill('dni'); + await page.getByPlaceholder('Label').press('Tab'); + await page.getByPlaceholder('Password of certificate').fill('123456'); + //await page.getByLabel('File import').click(); + await page.getByLabel('File import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/signerDNIe004.pfx'); + await page.getByRole('button', { name: 'Upload' }).click(); + await page.getByRole('link', { name: ' Data' }).click(); + await page.getByRole('link', { name: 'Import data ' }).click(); + await page.getByLabel('Signature with Eidas1').selectOption('signerDNIe004.pfx'); + await page.getByLabel('Schema').selectOption('1'); + await page.getByText('ID HUB PANGEA idhub_admin@pangea.org Dashboard Users View users Add user Roles').click(); + //await page.getByLabel('File to import').click(); + await page.getByLabel('File to import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/course-credential.xlsx'); + await page.getByRole('button', { name: 'Save' }).click(); + + // await page.getByRole('link', { name: ' Data' }).click(); + // await page.getByRole('link', { name: 'Import data ' }).click(); + // // src https://playwright.dev/docs/input#select-options + // await page.getByLabel('Schema').selectOption('Financial Vulnerability Credential'); + // // src https://playwright.dev/docs/input#upload-files + // // TODO hardcoded URL + // await page.getByLabel('File to import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); + // //await page.setInputFiles('input[type="file"]', '/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); + // await page.getByRole('button', { name: 'Save' }).click(); + + await page.getByRole('link', { name: '', exact: true }).click(); + await page.getByPlaceholder('Email address').click(); + await page.getByPlaceholder('Email address').fill('user1@example.org'); + await page.getByPlaceholder('Password').click(); + await page.getByPlaceholder('Password').fill('1234'); + await page.getByRole('button', { name: 'Log in' }).click(); + + await accept_data_protection(page); + + await page.getByRole('link', { name: 'Identities (DIDs)' }).click(); + await page.getByRole('link', { name: 'Add Identity ' }).click(); + await page.getByPlaceholder('Label').click(); + await page.getByPlaceholder('Label').fill('default'); + await page.getByLabel('Type').selectOption('1'); + await page.getByRole('button', { name: 'Save' }).click(); + await page.getByRole('link', { name: 'Request a credential' }).click(); + await page.getByRole('button', { name: 'Request' }).click(); + // TODO take last (because is the latest!!) + await page.getByRole('link', { name: '' }).click(); + const downloadPromise = page.waitForEvent('download'); + await page.getByRole('link', { name: 'Download as PDF (Catalan)' }).click(); + const download = await downloadPromise; + const download1Promise = page.waitForEvent('download'); + await page.getByRole('link', { name: 'Download as JSON' }).click(); + const download1 = await download1Promise; + const download2Promise = page.waitForEvent('download'); + await page.getByRole('link', { name: 'Download as PDF (Spanish)' }).click(); + const download2 = await download2Promise; +}); From f06ace29b260ba6aec1a537db0ab878e17800f50 Mon Sep 17 00:00:00 2001 From: pedro Date: Tue, 26 Mar 2024 03:12:04 +0100 Subject: [PATCH 05/10] unify pilot tests oidc and sign_pdf did some improvements on reuse of logic --- tests/pilot-oidc.spec.ts | 84 --------------- ...lot-lafede.spec.ts => test-pilots.spec.ts} | 101 ++++++++++++++++-- 2 files changed, 93 insertions(+), 92 deletions(-) delete mode 100644 tests/pilot-oidc.spec.ts rename tests/{pilot-lafede.spec.ts => test-pilots.spec.ts} (58%) diff --git a/tests/pilot-oidc.spec.ts b/tests/pilot-oidc.spec.ts deleted file mode 100644 index a2db54a..0000000 --- a/tests/pilot-oidc.spec.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { IDHUB_WALLET, IDHUB_VERIFIER } from '../src/constants/env_constants'; - -import { test, expect } from '@playwright/test'; -// TODO import domain WALLET y VERIFIER -// TODO env var - -// optional page (decrypt) -// src https://playwright.dev/docs/locators#matching-one-of-the-two-alternative-locators -async function accept_data_protection(page) { - // TODO cannot be, because of this inconsistency: Data Protection (user) vs Data protection (admin) - //const data_protection = await page.getByRole('heading', { name: 'Data protection', exact: true }) - const data_protection = await page.getByRole('heading', { name: 'Data protection' }) - if (await data_protection.isVisible()) { - await page.locator('#id_accept_privacy').check(); - await page.locator('#id_accept_legal').check(); - await page.locator('#id_accept_cookies').check(); - await page.getByRole('link', { name: 'Confirm' }).click(); - } -} - - -// useful for DEBUG -// await page.pause(); - -test('test', async ({ page }) => { - // TODO hardcoded domain WALLET - await page.goto(IDHUB_WALLET + '/login/'); - await page.getByPlaceholder('Email address').click(); - await page.getByPlaceholder('Email address').fill('idhub_admin@pangea.org'); - await page.getByPlaceholder('Password').fill('1234'); - await page.getByRole('button', { name: 'Log in' }).click(); - - //const encryption_key_page = page.getByText('Encryption Key') - const encryption_key_page_admin = await page.getByRole('heading', { name: 'Encryption Key', exact: true }) - if (await encryption_key_page_admin.isVisible()) { - await page.getByPlaceholder('Key for encrypt the secrets').click(); - await page.getByPlaceholder('Key for encrypt the secrets').fill('1234'); - await page.getByRole('button', { name: 'Save' }).click(); - } - - await accept_data_protection(page); - - await page.getByRole('link', { name: ' Data' }).click(); - await page.getByRole('link', { name: 'Import data ' }).click(); - // src https://playwright.dev/docs/input#select-options - await page.getByLabel('Schema').selectOption('Financial Vulnerability Credential'); - // src https://playwright.dev/docs/input#upload-files - // TODO hardcoded URL - await page.getByLabel('File to import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); - //await page.setInputFiles('input[type="file"]', '/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); - await page.getByRole('button', { name: 'Save' }).click(); - await page.getByRole('link', { name: '', exact: true }).click(); - await page.getByPlaceholder('Email address').click(); - await page.getByPlaceholder('Email address').fill('user1@example.org'); - await page.getByPlaceholder('Password').click(); - await page.getByPlaceholder('Password').fill('1234'); - await page.getByRole('button', { name: 'Log in' }).click(); - - await accept_data_protection(page); - - await page.getByRole('link', { name: 'Identities (DIDs)' }).click(); - await page.getByRole('link', { name: 'Add Identity ' }).click(); - await page.getByPlaceholder('Label').click(); - await page.getByPlaceholder('Label').fill('default'); - await page.getByLabel('Type').selectOption('1'); - await page.getByRole('button', { name: 'Save' }).click(); - await page.getByRole('link', { name: 'Request a credential' }).click(); - await page.getByRole('button', { name: 'Request' }).click(); - // TODO hardcoded domain VERIFIER - await page.goto(IDHUB_VERIFIER + '/promotion/'); - await page.getByRole('link', { name: 'Contractar amb credencial' }).click(); - await page.getByRole('button', { name: 'Go' }).click(); - await page.getByRole('radio').first().check(); - await page.getByRole('checkbox').check(); - await page.getByRole('button', { name: 'Present' }).click(); - await page.pause(); - // TODO averiguar si devuelve código es final 1 (OIDC_REDIRECT=false) - - // TODO averiguar si hace redirección a 2 es final 2 (OIDC_REDIRECT=true) -}); - -// TODO test que hace la presentación de la credencial al revés - -// TODO test que hace la presentación de la credencial al revés diff --git a/tests/pilot-lafede.spec.ts b/tests/test-pilots.spec.ts similarity index 58% rename from tests/pilot-lafede.spec.ts rename to tests/test-pilots.spec.ts index 3d66e5d..d5f4443 100644 --- a/tests/pilot-lafede.spec.ts +++ b/tests/test-pilots.spec.ts @@ -1,4 +1,4 @@ -import { IDHUB_WALLET } from '../src/constants/env_constants'; +import { IDHUB_WALLET, IDHUB_VERIFIER } from '../src/constants/env_constants'; import { test, expect } from '@playwright/test'; // TODO import domain WALLET y VERIFIER @@ -18,18 +18,16 @@ async function accept_data_protection(page) { } } - -// useful for DEBUG -// await page.pause(); - -test('test', async ({ page }) => { - // TODO hardcoded domain WALLET +async function login(page) { await page.goto(IDHUB_WALLET + '/login/'); await page.getByPlaceholder('Email address').click(); await page.getByPlaceholder('Email address').fill('idhub_admin@pangea.org'); await page.getByPlaceholder('Password').fill('1234'); await page.getByRole('button', { name: 'Log in' }).click(); +} +// optional flow (only first time per idhub service start) +async function set_org_key(page) { //const encryption_key_page = page.getByText('Encryption Key') const encryption_key_page_admin = await page.getByRole('heading', { name: 'Encryption Key', exact: true }) if (await encryption_key_page_admin.isVisible()) { @@ -37,6 +35,85 @@ test('test', async ({ page }) => { await page.getByPlaceholder('Key for encrypt the secrets').fill('1234'); await page.getByRole('button', { name: 'Save' }).click(); } +} + +// useful for DEBUG +// await page.pause(); + +test('oidc_flow', async ({ page }) => { + + await login(page); + + const url = page.url(); + const hostname = new URL(url).hostname; + let vcred_schema; + let vcred_file; + // TODO vcred_file path is hardcoded: + // 1. make it relative + // 2. add file in e2e test directory (maybe already exists) + // see ./vc_excel/financial-vulnerability.xlsx (visto, no es el mismo) + if (/setem/.test(hostname)) { + vcred_schema='Membership Card' + vcred_file='/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/membership-card.xlsx' + } else { + vcred_schema='Financial Vulnerability Credential' + vcred_file='/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx' + } + + await set_org_key(page); + + await accept_data_protection(page); + + await page.getByRole('link', { name: ' Data' }).click(); + await page.getByRole('link', { name: 'Import data ' }).click(); + // src https://playwright.dev/docs/input#select-options + await page.getByLabel('Schema').selectOption(vcred_schema); + // src https://playwright.dev/docs/input#upload-files + // TODO hardcoded URL + await page.getByLabel('File to import').setInputFiles(vcred_file); + //await page.setInputFiles('input[type="file"]', '/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); + await page.getByRole('button', { name: 'Save' }).click(); + await page.getByRole('link', { name: '', exact: true }).click(); + await page.getByPlaceholder('Email address').click(); + await page.getByPlaceholder('Email address').fill('user1@example.org'); + await page.getByPlaceholder('Password').click(); + await page.getByPlaceholder('Password').fill('1234'); + await page.getByRole('button', { name: 'Log in' }).click(); + + await accept_data_protection(page); + + await page.getByRole('link', { name: 'Identities (DIDs)' }).click(); + await page.getByRole('link', { name: 'Add Identity ' }).click(); + await page.getByPlaceholder('Label').click(); + await page.getByPlaceholder('Label').fill('default'); + await page.pause(); + // TODO where? + // TODO report bug, if selected the wrong credential here, se queda colgado + await page.getByLabel('Type').selectOption('1'); + await page.getByRole('button', { name: 'Save' }).click(); + await page.getByRole('link', { name: 'Request a credential' }).click(); + await page.getByRole('button', { name: 'Request' }).click(); + // TODO hardcoded domain VERIFIER + await page.goto(IDHUB_VERIFIER + '/promotion/'); + await page.getByRole('link', { name: 'Contractar amb credencial' }).click(); + await page.getByRole('button', { name: 'Go' }).click(); + await page.getByRole('radio').first().check(); + await page.getByRole('checkbox').check(); + await page.getByRole('button', { name: 'Present' }).click(); + await page.pause(); + // TODO averiguar si devuelve código es final 1 (OIDC_REDIRECT=false) + + // TODO averiguar si hace redirección a 2 es final 2 (OIDC_REDIRECT=true) +}); + +// TODO test que hace la presentación de la credencial al revés + +// TODO test que hace la presentación de la credencial al revés + +test('sign_pdf', async ({ page }) => { + await login(page); + + await set_org_key(page); await accept_data_protection(page); @@ -53,6 +130,7 @@ test('test', async ({ page }) => { await page.getByRole('link', { name: ' Data' }).click(); await page.getByRole('link', { name: 'Import data ' }).click(); await page.getByLabel('Signature with Eidas1').selectOption('signerDNIe004.pfx'); + await page.pause(); await page.getByLabel('Schema').selectOption('1'); await page.getByText('ID HUB PANGEA idhub_admin@pangea.org Dashboard Users View users Add user Roles').click(); //await page.getByLabel('File to import').click(); @@ -87,7 +165,9 @@ test('test', async ({ page }) => { await page.getByRole('link', { name: 'Request a credential' }).click(); await page.getByRole('button', { name: 'Request' }).click(); // TODO take last (because is the latest!!) - await page.getByRole('link', { name: '' }).click(); + // src https://www.programsbuzz.com/article/playwright-select-first-or-last-element + // not tested + await page.getByRole('link', { name: '' }).last().click(); const downloadPromise = page.waitForEvent('download'); await page.getByRole('link', { name: 'Download as PDF (Catalan)' }).click(); const download = await downloadPromise; @@ -98,3 +178,8 @@ test('test', async ({ page }) => { await page.getByRole('link', { name: 'Download as PDF (Spanish)' }).click(); const download2 = await download2Promise; }); + +test('login', async ({ page }) => { + await login(page); + await page.pause(); +}); From d8b025c2e32ef0c503c063b2238d59a9b1d00439 Mon Sep 17 00:00:00 2001 From: pedro Date: Tue, 26 Mar 2024 18:39:37 +0100 Subject: [PATCH 06/10] oidc_flow: quit pause debug there no longer needed --- tests/test-pilots.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test-pilots.spec.ts b/tests/test-pilots.spec.ts index d5f4443..70a3f6e 100644 --- a/tests/test-pilots.spec.ts +++ b/tests/test-pilots.spec.ts @@ -86,7 +86,6 @@ test('oidc_flow', async ({ page }) => { await page.getByRole('link', { name: 'Add Identity ' }).click(); await page.getByPlaceholder('Label').click(); await page.getByPlaceholder('Label').fill('default'); - await page.pause(); // TODO where? // TODO report bug, if selected the wrong credential here, se queda colgado await page.getByLabel('Type').selectOption('1'); From 16c612762c5b5aec3202023e459c45870c0fb1c7 Mon Sep 17 00:00:00 2001 From: pedro Date: Tue, 2 Apr 2024 13:47:19 +0200 Subject: [PATCH 07/10] test-pilots: move pause page to the end --- tests/test-pilots.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-pilots.spec.ts b/tests/test-pilots.spec.ts index 70a3f6e..5d35e7f 100644 --- a/tests/test-pilots.spec.ts +++ b/tests/test-pilots.spec.ts @@ -129,7 +129,6 @@ test('sign_pdf', async ({ page }) => { await page.getByRole('link', { name: ' Data' }).click(); await page.getByRole('link', { name: 'Import data ' }).click(); await page.getByLabel('Signature with Eidas1').selectOption('signerDNIe004.pfx'); - await page.pause(); await page.getByLabel('Schema').selectOption('1'); await page.getByText('ID HUB PANGEA idhub_admin@pangea.org Dashboard Users View users Add user Roles').click(); //await page.getByLabel('File to import').click(); @@ -176,6 +175,7 @@ test('sign_pdf', async ({ page }) => { const download2Promise = page.waitForEvent('download'); await page.getByRole('link', { name: 'Download as PDF (Spanish)' }).click(); const download2 = await download2Promise; + await page.pause(); }); test('login', async ({ page }) => { From f09e5b4e65f632229f30d84b807661db98850a4f Mon Sep 17 00:00:00 2001 From: pedro Date: Wed, 3 Apr 2024 19:07:22 +0200 Subject: [PATCH 08/10] add ereuse pilot test it is still hardcoded but works on my computer :) (it requires some files not published) also converted oidc_flow as a function to be reused by pilots --- tests/test-pilots.spec.ts | 71 ++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/tests/test-pilots.spec.ts b/tests/test-pilots.spec.ts index 5d35e7f..d4751cc 100644 --- a/tests/test-pilots.spec.ts +++ b/tests/test-pilots.spec.ts @@ -40,7 +40,7 @@ async function set_org_key(page) { // useful for DEBUG // await page.pause(); -test('oidc_flow', async ({ page }) => { +async function oidc_flow(page) { await login(page); @@ -52,12 +52,16 @@ test('oidc_flow', async ({ page }) => { // 1. make it relative // 2. add file in e2e test directory (maybe already exists) // see ./vc_excel/financial-vulnerability.xlsx (visto, no es el mismo) + // TODO change hardcoded paths if (/setem/.test(hostname)) { vcred_schema='Membership Card' vcred_file='/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/membership-card.xlsx' - } else { + } else if (/xo9b/.test(hostname)) { vcred_schema='Financial Vulnerability Credential' vcred_file='/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx' + } else if (/ereuse/.test(hostname)) { + vcred_schema='Product and waste electronics operator claim' + vcred_file='/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/e-operator-claim.xlsx' } await set_org_key(page); @@ -92,18 +96,19 @@ test('oidc_flow', async ({ page }) => { await page.getByRole('button', { name: 'Save' }).click(); await page.getByRole('link', { name: 'Request a credential' }).click(); await page.getByRole('button', { name: 'Request' }).click(); - // TODO hardcoded domain VERIFIER - await page.goto(IDHUB_VERIFIER + '/promotion/'); - await page.getByRole('link', { name: 'Contractar amb credencial' }).click(); - await page.getByRole('button', { name: 'Go' }).click(); - await page.getByRole('radio').first().check(); - await page.getByRole('checkbox').check(); - await page.getByRole('button', { name: 'Present' }).click(); - await page.pause(); - // TODO averiguar si devuelve código es final 1 (OIDC_REDIRECT=false) + if (/xo9b/.test(hostname)) { + await page.goto(IDHUB_VERIFIER + '/promotion/'); + await page.getByRole('link', { name: 'Contractar amb credencial' }).click(); + await page.getByRole('button', { name: 'Go' }).click(); + await page.getByRole('radio').first().check(); + await page.getByRole('checkbox').check(); + await page.getByRole('button', { name: 'Present' }).click(); + } + + // TODO averiguar si devuelve código es final 1 (OIDC_REDIRECT=false) // TODO averiguar si hace redirección a 2 es final 2 (OIDC_REDIRECT=true) -}); +} // TODO test que hace la presentación de la credencial al revés @@ -178,7 +183,49 @@ test('sign_pdf', async ({ page }) => { await page.pause(); }); +test('oidc_flow', async ({ page }) => { + await oidc_flow(page); + await page.pause(); +}); + test('login', async ({ page }) => { await login(page); await page.pause(); }); + +test('ereuse_pilot', async ({ page }) => { + // TEMP reenable + await oidc_flow(page); + + // TODO hardcoded domain + await page.goto('https://devicehub.demo.pangea.org/'); + await page.getByPlaceholder('Email').fill('manufacturer@hp.es'); + await page.getByPlaceholder('Email').press('Tab'); + await page.getByPlaceholder('Password').fill('1234'); + await page.getByPlaceholder('Password').press('Enter'); + + await page.getByRole('button', { name: ' Snapshots' }).click(); + await page.getByRole('link', { name: ' Upload files' }).click(); + + // TODO hardcoded URL + await page.locator('#snapshot').setInputFiles('/home/music/org-extra/projects-2024/2024_17_tchain/2024-04-02__piloto-ereuse/snapshot-2022-6-9-10-21_usody@pangea.org_7928afeb-e6a4-464a-a842-0c3de0d01677.json'); + await page.getByRole('button', { name: 'Send' }).click(); + await page.getByRole('link', { name: ' Unassigned devices' }).click(); + + await page.getByRole('link', { name: ' Laptop hewlett-packard hp' }).click(); + await page.getByRole('button', { name: 'Digital Passports' }).click(); + + const page1Promise = page.waitForEvent('popup'); + await page.getByRole('link', { name: '169f2c6c0b60a529fce65ba619b2fa5ddc02207e0cbe8b7d64afe39bb247e02f:' }).click(); + const page1 = await page1Promise; + + await page1.getByRole('link', { name: 'Logout' }).click(); + await page1.getByRole('button', { name: 'Validate' }).click(); + await page1.getByRole('link', { name: 'Use a wallet' }).click(); + await page1.getByRole('button', { name: 'Go' }).click(); + await page1.getByRole('radio').check(); + await page1.getByRole('checkbox').check(); + await page1.getByRole('button', { name: 'Present' }).click(); + + await page.pause(); +}); From f9b0e141a6c1282dd1ae71ba115ed199d9b6a9b5 Mon Sep 17 00:00:00 2001 From: pedro Date: Wed, 3 Apr 2024 19:19:10 +0200 Subject: [PATCH 09/10] ereuse pilot: use public snapshot from repo --- tests/test-pilots.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test-pilots.spec.ts b/tests/test-pilots.spec.ts index d4751cc..4186516 100644 --- a/tests/test-pilots.spec.ts +++ b/tests/test-pilots.spec.ts @@ -208,7 +208,11 @@ test('ereuse_pilot', async ({ page }) => { await page.getByRole('link', { name: ' Upload files' }).click(); // TODO hardcoded URL - await page.locator('#snapshot').setInputFiles('/home/music/org-extra/projects-2024/2024_17_tchain/2024-04-02__piloto-ereuse/snapshot-2022-6-9-10-21_usody@pangea.org_7928afeb-e6a4-464a-a842-0c3de0d01677.json'); + // TODO this was the first we tried and work + //const snapshot_file='/home/music/org-extra/projects-2024/2024_17_tchain/2024-04-02__piloto-ereuse/snapshot-2022-6-9-10-21_usody@pangea.org_7928afeb-e6a4-464a-a842-0c3de0d01677.json' + // TODO this comes from here: https://gitea.pangea.org/trustchain-oc1-orchestral/devicehub-teal/src/branch/idhub/examples/snapshots/snapshot01.json + //const snapshot_file='/home/music/trustchain-oc1-orchestral-docker/devicehub-teal/examples/snapshots/snapshot01.json' + await page.locator('#snapshot').setInputFiles(snapshot_file); await page.getByRole('button', { name: 'Send' }).click(); await page.getByRole('link', { name: ' Unassigned devices' }).click(); From b61858f559be518b4e39202ae4dec305b22ff718 Mon Sep 17 00:00:00 2001 From: pedro Date: Thu, 4 Apr 2024 11:49:05 +0200 Subject: [PATCH 10/10] skip pilot tests by default to make them work, change: test.describe.skip to test.describe --- tests/test-pilots.spec.ts | 225 +++++++++++++++++++------------------- 1 file changed, 115 insertions(+), 110 deletions(-) diff --git a/tests/test-pilots.spec.ts b/tests/test-pilots.spec.ts index 4186516..987fc40 100644 --- a/tests/test-pilots.spec.ts +++ b/tests/test-pilots.spec.ts @@ -62,6 +62,8 @@ async function oidc_flow(page) { } else if (/ereuse/.test(hostname)) { vcred_schema='Product and waste electronics operator claim' vcred_file='/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/e-operator-claim.xlsx' + } else { + test.skip(); } await set_org_key(page); @@ -114,122 +116,125 @@ async function oidc_flow(page) { // TODO test que hace la presentación de la credencial al revés -test('sign_pdf', async ({ page }) => { - await login(page); +test.describe.skip('test-pilots', () => { + test('sign_pdf', async ({ page }) => { + await login(page); - await set_org_key(page); + await set_org_key(page); - await accept_data_protection(page); + await accept_data_protection(page); - await page.getByRole('link', { name: ' Credentials' }).click(); - await page.getByRole('link', { name: 'Organization\'s wallet' }).click(); - await page.getByRole('link', { name: 'Configure credential issuance' }).click(); - await page.getByPlaceholder('Label').click(); - await page.getByPlaceholder('Label').fill('dni'); - await page.getByPlaceholder('Label').press('Tab'); - await page.getByPlaceholder('Password of certificate').fill('123456'); - //await page.getByLabel('File import').click(); - await page.getByLabel('File import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/signerDNIe004.pfx'); - await page.getByRole('button', { name: 'Upload' }).click(); - await page.getByRole('link', { name: ' Data' }).click(); - await page.getByRole('link', { name: 'Import data ' }).click(); - await page.getByLabel('Signature with Eidas1').selectOption('signerDNIe004.pfx'); - await page.getByLabel('Schema').selectOption('1'); - await page.getByText('ID HUB PANGEA idhub_admin@pangea.org Dashboard Users View users Add user Roles').click(); - //await page.getByLabel('File to import').click(); - await page.getByLabel('File to import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/course-credential.xlsx'); - await page.getByRole('button', { name: 'Save' }).click(); + await page.getByRole('link', { name: ' Credentials' }).click(); + await page.getByRole('link', { name: 'Organization\'s wallet' }).click(); + await page.getByRole('link', { name: 'Configure credential issuance' }).click(); + await page.getByPlaceholder('Label').click(); + await page.getByPlaceholder('Label').fill('dni'); + await page.getByPlaceholder('Label').press('Tab'); + await page.getByPlaceholder('Password of certificate').fill('123456'); + //await page.getByLabel('File import').click(); + await page.getByLabel('File import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/signerDNIe004.pfx'); + await page.getByRole('button', { name: 'Upload' }).click(); + await page.getByRole('link', { name: ' Data' }).click(); + await page.getByRole('link', { name: 'Import data ' }).click(); + await page.getByLabel('Signature with Eidas1').selectOption('signerDNIe004.pfx'); + await page.getByLabel('Schema').selectOption('1'); + await page.getByText('ID HUB PANGEA idhub_admin@pangea.org Dashboard Users View users Add user Roles').click(); + //await page.getByLabel('File to import').click(); + await page.getByLabel('File to import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/course-credential.xlsx'); + await page.getByRole('button', { name: 'Save' }).click(); - // await page.getByRole('link', { name: ' Data' }).click(); - // await page.getByRole('link', { name: 'Import data ' }).click(); - // // src https://playwright.dev/docs/input#select-options - // await page.getByLabel('Schema').selectOption('Financial Vulnerability Credential'); - // // src https://playwright.dev/docs/input#upload-files - // // TODO hardcoded URL - // await page.getByLabel('File to import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); - // //await page.setInputFiles('input[type="file"]', '/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); - // await page.getByRole('button', { name: 'Save' }).click(); + // await page.getByRole('link', { name: ' Data' }).click(); + // await page.getByRole('link', { name: 'Import data ' }).click(); + // // src https://playwright.dev/docs/input#select-options + // await page.getByLabel('Schema').selectOption('Financial Vulnerability Credential'); + // // src https://playwright.dev/docs/input#upload-files + // // TODO hardcoded URL + // await page.getByLabel('File to import').setInputFiles('/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); + // //await page.setInputFiles('input[type="file"]', '/home/music/trustchain-oc1-orchestral-docker/IdHub/examples/excel_examples/financial-vulnerability.xlsx'); + // await page.getByRole('button', { name: 'Save' }).click(); - await page.getByRole('link', { name: '', exact: true }).click(); - await page.getByPlaceholder('Email address').click(); - await page.getByPlaceholder('Email address').fill('user1@example.org'); - await page.getByPlaceholder('Password').click(); - await page.getByPlaceholder('Password').fill('1234'); - await page.getByRole('button', { name: 'Log in' }).click(); + await page.getByRole('link', { name: '', exact: true }).click(); + await page.getByPlaceholder('Email address').click(); + await page.getByPlaceholder('Email address').fill('user1@example.org'); + await page.getByPlaceholder('Password').click(); + await page.getByPlaceholder('Password').fill('1234'); + await page.getByRole('button', { name: 'Log in' }).click(); - await accept_data_protection(page); + await accept_data_protection(page); - await page.getByRole('link', { name: 'Identities (DIDs)' }).click(); - await page.getByRole('link', { name: 'Add Identity ' }).click(); - await page.getByPlaceholder('Label').click(); - await page.getByPlaceholder('Label').fill('default'); - await page.getByLabel('Type').selectOption('1'); - await page.getByRole('button', { name: 'Save' }).click(); - await page.getByRole('link', { name: 'Request a credential' }).click(); - await page.getByRole('button', { name: 'Request' }).click(); - // TODO take last (because is the latest!!) - // src https://www.programsbuzz.com/article/playwright-select-first-or-last-element - // not tested - await page.getByRole('link', { name: '' }).last().click(); - const downloadPromise = page.waitForEvent('download'); - await page.getByRole('link', { name: 'Download as PDF (Catalan)' }).click(); - const download = await downloadPromise; - const download1Promise = page.waitForEvent('download'); - await page.getByRole('link', { name: 'Download as JSON' }).click(); - const download1 = await download1Promise; - const download2Promise = page.waitForEvent('download'); - await page.getByRole('link', { name: 'Download as PDF (Spanish)' }).click(); - const download2 = await download2Promise; - await page.pause(); + await page.getByRole('link', { name: 'Identities (DIDs)' }).click(); + await page.getByRole('link', { name: 'Add Identity ' }).click(); + await page.getByPlaceholder('Label').click(); + await page.getByPlaceholder('Label').fill('default'); + await page.getByLabel('Type').selectOption('1'); + await page.getByRole('button', { name: 'Save' }).click(); + await page.getByRole('link', { name: 'Request a credential' }).click(); + await page.getByRole('button', { name: 'Request' }).click(); + // TODO take last (because is the latest!!) + // src https://www.programsbuzz.com/article/playwright-select-first-or-last-element + // not tested + await page.getByRole('link', { name: '' }).last().click(); + const downloadPromise = page.waitForEvent('download'); + await page.getByRole('link', { name: 'Download as PDF (Catalan)' }).click(); + const download = await downloadPromise; + const download1Promise = page.waitForEvent('download'); + await page.getByRole('link', { name: 'Download as JSON' }).click(); + const download1 = await download1Promise; + const download2Promise = page.waitForEvent('download'); + await page.getByRole('link', { name: 'Download as PDF (Spanish)' }).click(); + const download2 = await download2Promise; + await page.pause(); + }); + + test('oidc_flow', async ({ page }) => { + await oidc_flow(page); + await page.pause(); + }); + + test('login', async ({ page }) => { + await login(page); + await page.pause(); + }); + + test('ereuse_pilot', async ({ page }) => { + // TEMP reenable + await oidc_flow(page); + + // TODO hardcoded domain + await page.goto('https://devicehub.demo.pangea.org/'); + await page.getByPlaceholder('Email').fill('manufacturer@hp.es'); + await page.getByPlaceholder('Email').press('Tab'); + await page.getByPlaceholder('Password').fill('1234'); + await page.getByPlaceholder('Password').press('Enter'); + + await page.getByRole('button', { name: ' Snapshots' }).click(); + await page.getByRole('link', { name: ' Upload files' }).click(); + + // TODO hardcoded URL + // TODO this was the first we tried and work + //const snapshot_file='/home/music/org-extra/projects-2024/2024_17_tchain/2024-04-02__piloto-ereuse/snapshot-2022-6-9-10-21_usody@pangea.org_7928afeb-e6a4-464a-a842-0c3de0d01677.json' + // TODO this comes from here: https://gitea.pangea.org/trustchain-oc1-orchestral/devicehub-teal/src/branch/idhub/examples/snapshots/snapshot01.json + //const snapshot_file='/home/music/trustchain-oc1-orchestral-docker/devicehub-teal/examples/snapshots/snapshot01.json' + await page.locator('#snapshot').setInputFiles(snapshot_file); + await page.getByRole('button', { name: 'Send' }).click(); + await page.getByRole('link', { name: ' Unassigned devices' }).click(); + + await page.getByRole('link', { name: ' Laptop hewlett-packard hp' }).click(); + await page.getByRole('button', { name: 'Digital Passports' }).click(); + + const page1Promise = page.waitForEvent('popup'); + await page.getByRole('link', { name: '169f2c6c0b60a529fce65ba619b2fa5ddc02207e0cbe8b7d64afe39bb247e02f:' }).click(); + const page1 = await page1Promise; + + await page1.getByRole('link', { name: 'Logout' }).click(); + await page1.getByRole('button', { name: 'Validate' }).click(); + await page1.getByRole('link', { name: 'Use a wallet' }).click(); + await page1.getByRole('button', { name: 'Go' }).click(); + await page1.getByRole('radio').check(); + await page1.getByRole('checkbox').check(); + await page1.getByRole('button', { name: 'Present' }).click(); + + await page.pause(); + }); }); -test('oidc_flow', async ({ page }) => { - await oidc_flow(page); - await page.pause(); -}); - -test('login', async ({ page }) => { - await login(page); - await page.pause(); -}); - -test('ereuse_pilot', async ({ page }) => { - // TEMP reenable - await oidc_flow(page); - - // TODO hardcoded domain - await page.goto('https://devicehub.demo.pangea.org/'); - await page.getByPlaceholder('Email').fill('manufacturer@hp.es'); - await page.getByPlaceholder('Email').press('Tab'); - await page.getByPlaceholder('Password').fill('1234'); - await page.getByPlaceholder('Password').press('Enter'); - - await page.getByRole('button', { name: ' Snapshots' }).click(); - await page.getByRole('link', { name: ' Upload files' }).click(); - - // TODO hardcoded URL - // TODO this was the first we tried and work - //const snapshot_file='/home/music/org-extra/projects-2024/2024_17_tchain/2024-04-02__piloto-ereuse/snapshot-2022-6-9-10-21_usody@pangea.org_7928afeb-e6a4-464a-a842-0c3de0d01677.json' - // TODO this comes from here: https://gitea.pangea.org/trustchain-oc1-orchestral/devicehub-teal/src/branch/idhub/examples/snapshots/snapshot01.json - //const snapshot_file='/home/music/trustchain-oc1-orchestral-docker/devicehub-teal/examples/snapshots/snapshot01.json' - await page.locator('#snapshot').setInputFiles(snapshot_file); - await page.getByRole('button', { name: 'Send' }).click(); - await page.getByRole('link', { name: ' Unassigned devices' }).click(); - - await page.getByRole('link', { name: ' Laptop hewlett-packard hp' }).click(); - await page.getByRole('button', { name: 'Digital Passports' }).click(); - - const page1Promise = page.waitForEvent('popup'); - await page.getByRole('link', { name: '169f2c6c0b60a529fce65ba619b2fa5ddc02207e0cbe8b7d64afe39bb247e02f:' }).click(); - const page1 = await page1Promise; - - await page1.getByRole('link', { name: 'Logout' }).click(); - await page1.getByRole('button', { name: 'Validate' }).click(); - await page1.getByRole('link', { name: 'Use a wallet' }).click(); - await page1.getByRole('button', { name: 'Go' }).click(); - await page1.getByRole('radio').check(); - await page1.getByRole('checkbox').check(); - await page1.getByRole('button', { name: 'Present' }).click(); - - await page.pause(); -});