unify pilot tests oidc and sign_pdf
did some improvements on reuse of logic
This commit is contained in:
parent
57ad58a5fc
commit
3cc8ba503f
|
@ -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
|
|
|
@ -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';
|
import { test, expect } from '@playwright/test';
|
||||||
// TODO import domain WALLET y VERIFIER
|
// TODO import domain WALLET y VERIFIER
|
||||||
|
@ -18,18 +18,16 @@ async function accept_data_protection(page) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function login(page) {
|
||||||
// useful for DEBUG
|
|
||||||
// await page.pause();
|
|
||||||
|
|
||||||
test('test', async ({ page }) => {
|
|
||||||
// TODO hardcoded domain WALLET
|
|
||||||
await page.goto(IDHUB_WALLET + '/login/');
|
await page.goto(IDHUB_WALLET + '/login/');
|
||||||
await page.getByPlaceholder('Email address').click();
|
await page.getByPlaceholder('Email address').click();
|
||||||
await page.getByPlaceholder('Email address').fill('idhub_admin@pangea.org');
|
await page.getByPlaceholder('Email address').fill('idhub_admin@pangea.org');
|
||||||
await page.getByPlaceholder('Password').fill('1234');
|
await page.getByPlaceholder('Password').fill('1234');
|
||||||
await page.getByRole('button', { name: 'Log in' }).click();
|
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 = page.getByText('Encryption Key')
|
||||||
const encryption_key_page_admin = await page.getByRole('heading', { name: 'Encryption Key', exact: true })
|
const encryption_key_page_admin = await page.getByRole('heading', { name: 'Encryption Key', exact: true })
|
||||||
if (await encryption_key_page_admin.isVisible()) {
|
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.getByPlaceholder('Key for encrypt the secrets').fill('1234');
|
||||||
await page.getByRole('button', { name: 'Save' }).click();
|
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);
|
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: ' Data' }).click();
|
||||||
await page.getByRole('link', { name: 'Import data ' }).click();
|
await page.getByRole('link', { name: 'Import data ' }).click();
|
||||||
await page.getByLabel('Signature with Eidas1').selectOption('signerDNIe004.pfx');
|
await page.getByLabel('Signature with Eidas1').selectOption('signerDNIe004.pfx');
|
||||||
|
await page.pause();
|
||||||
await page.getByLabel('Schema').selectOption('1');
|
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.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').click();
|
||||||
|
@ -87,7 +165,9 @@ test('test', async ({ page }) => {
|
||||||
await page.getByRole('link', { name: 'Request a credential' }).click();
|
await page.getByRole('link', { name: 'Request a credential' }).click();
|
||||||
await page.getByRole('button', { name: 'Request' }).click();
|
await page.getByRole('button', { name: 'Request' }).click();
|
||||||
// TODO take last (because is the latest!!)
|
// 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');
|
const downloadPromise = page.waitForEvent('download');
|
||||||
await page.getByRole('link', { name: 'Download as PDF (Catalan)' }).click();
|
await page.getByRole('link', { name: 'Download as PDF (Catalan)' }).click();
|
||||||
const download = await downloadPromise;
|
const download = await downloadPromise;
|
||||||
|
@ -98,3 +178,8 @@ test('test', async ({ page }) => {
|
||||||
await page.getByRole('link', { name: 'Download as PDF (Spanish)' }).click();
|
await page.getByRole('link', { name: 'Download as PDF (Spanish)' }).click();
|
||||||
const download2 = await download2Promise;
|
const download2 = await download2Promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('login', async ({ page }) => {
|
||||||
|
await login(page);
|
||||||
|
await page.pause();
|
||||||
|
});
|
Reference in New Issue