This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add testcontainers to project Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * tmp Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * remove coverage Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: add tests for app Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: move test deps to a dedicated module Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: fix project file Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: testing package Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix tests Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: demo app Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: run e2e in the cloud Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: install browsers Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: testing in ci Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * build keycloak in the ci step Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * add docker login Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * move keycloak image to cd Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * add testcontainer token Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * remove testcontainers run Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * write token directly into the ci Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: add domain name Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: add logging to the test Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: just run the e2e test Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * remove tc Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * add verbose option Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * call it with npx Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * set start timeout instead of healthcheck Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * use another port Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * set logger on keycloak level Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: build keycloak Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: ci Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * debug failing test Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * add container step Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * login into registry Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix typo Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: tests Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * remove logging in error Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * fix: catch error Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> * ci Signed-off-by: Mirko Mollik <mirkomollik@gmail.com> --------- Signed-off-by: Mirko Mollik <mirkomollik@gmail.com>
- Loading branch information
Showing
73 changed files
with
1,646 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('has title', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
// Expect h1 to contain a substring. | ||
expect(await page.locator('h1').innerText()).toContain('Welcome'); | ||
expect(true).toBeTruthy(); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"backendUrlPP": "http://localhost:3001", | ||
"credentialId": "Identity", | ||
"oidcUrl": "http://host.docker.internal:8080/realms/wallet", | ||
"oidcClientId": "relying-party", | ||
"oidcClientSecret": "hA0mbfpKl8wdMrUxr2EjKtL5SGsKFW5D" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"backendUrl": "http://localhost:3002", | ||
"credentialId": "Identity", | ||
"oidcUrl": "http://host.docker.internal:8080/realms/wallet", | ||
"oidcClientId": "relying-party", | ||
"oidcClientSecret": "hA0mbfpKl8wdMrUxr2EjKtL5SGsKFW5D" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { | ||
Keycloak, | ||
HolderBackend, | ||
KeycloakGlobalThis, | ||
BackendGlobalThis, | ||
HolderFrontend, | ||
} from '@credhub/testing'; | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const username = 'mirko@gmx.de'; | ||
const password = 'mirko'; | ||
let keycloak: Keycloak; | ||
let backend: HolderBackend; | ||
let frontend: HolderFrontend; | ||
let hostname: string; | ||
|
||
test.beforeAll(async () => { | ||
//start keycloak | ||
keycloak = await Keycloak.init(); | ||
(globalThis as KeycloakGlobalThis).keycloak = keycloak; | ||
|
||
//start backend | ||
backend = await HolderBackend.init(); | ||
(globalThis as BackendGlobalThis).backend = backend; | ||
|
||
//start frontend | ||
frontend = await HolderFrontend.init(); | ||
|
||
hostname = `http://localhost:${frontend.instance.getMappedPort(80)}`; | ||
|
||
const testUserEmail = 'test@test.de'; | ||
const testUserPassword = 'password'; | ||
// create a new user | ||
await keycloak.createUser( | ||
`http://localhost:${keycloak.instance.getMappedPort(8080)}`, | ||
'wallet', | ||
testUserEmail, | ||
testUserPassword | ||
); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await frontend.stop(); | ||
await backend.stop(); | ||
await keycloak.stop(); | ||
}); | ||
|
||
test('register', async ({ page }) => { | ||
await page.goto(hostname); | ||
|
||
//click on the button | ||
await page.click('text=Login'); | ||
|
||
await page.click('text=Register'); | ||
|
||
//fill the form | ||
await page.fill('input[name=email]', username); | ||
await page.fill('input[name=password]', password); | ||
await page.fill('input[name=password-confirm]', password); | ||
await page.click('input[type=submit]'); | ||
|
||
await page.waitForSelector('text=Credentials'); | ||
expect(true).toBeTruthy(); | ||
}); | ||
|
||
test('login', async ({ page }) => { | ||
await page.goto(hostname); | ||
|
||
//click on the button | ||
await page.click('text=Login'); | ||
|
||
//login into keycloak | ||
await page.fill('input[name=username]', username); | ||
await page.fill('input[name=password]', password); | ||
await page.click('id=kc-login'); | ||
|
||
//wait for the password input field | ||
// await page.waitForSelector('input[name=password]'); | ||
// await page.click('text=Sign In'); | ||
|
||
await page.waitForSelector('text=Credentials'); | ||
|
||
expect(true).toBeTruthy(); | ||
}); | ||
|
||
test('logout', async ({ page }) => { | ||
await page.goto(hostname); | ||
|
||
//click on the button | ||
await page.click('text=Login'); | ||
|
||
//login into keycloak | ||
await page.fill('input[name=username]', username); | ||
await page.fill('input[name=password]', password); | ||
await page.click('id=kc-login'); | ||
|
||
await page.waitForSelector('text=Credentials'); | ||
await page.goto(`${hostname}/settings`); | ||
|
||
await page.click('id=logout'); | ||
|
||
await page.waitForSelector('text=Login'); | ||
//expect to see the login button | ||
expect(true).toBeTruthy(); | ||
}); | ||
|
||
//TODO: does not work yet | ||
// test('delete account', async ({ page }) => { | ||
// await page.goto('http://localhost:4200'); | ||
|
||
// page.on('dialog', async (dialog) => dialog.accept()); | ||
|
||
// //click on the button | ||
// await page.click('text=Login'); | ||
|
||
// //login into keycloak | ||
// await page.fill('input[name=username]', username); | ||
// await page.fill('input[name=password]', password); | ||
// await page.click('id=kc-login'); | ||
|
||
// await page.waitForSelector('text=Credentials'); | ||
// await page.goto('http://localhost:4200/settings'); | ||
|
||
// await page.waitForSelector('id=delete-account'); | ||
|
||
// await page.click('id=delete-account'); | ||
|
||
// await page.waitForSelector('text=Login'); | ||
|
||
// //click on the button | ||
// await page.click('text=Login'); | ||
|
||
// //login into keycloak | ||
// await page.fill('input[name=username]', username); | ||
// await page.fill('input[name=password]', password); | ||
// await page.click('id=kc-login'); | ||
|
||
// //Invalid username or password. should be seen as an error | ||
// await page.waitForSelector('text=Invalid username or password.'); | ||
// expect(true).toBeTruthy(); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.