mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2026-07-17 23:41:11 +00:00
feat: add simple e2e tests
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import {LoginFixture, LogoutFixture} from "../fixtures/auth.fixtures";
|
||||
|
||||
test('should be able to login to app with forward-auth', async ({ page }) => {
|
||||
const loginFixture = new LoginFixture(page);
|
||||
await page.goto('http://whoami.127.0.0.1.sslip.io');
|
||||
// redirect to tinyauth
|
||||
await expect(page.getByText('Welcome back, please login')).toBeVisible()
|
||||
await loginFixture.run('user1', 'password')
|
||||
// redirect to app
|
||||
await expect(page.getByText('whoami.127.0.0.1.sslip.io')).toBeVisible()
|
||||
});
|
||||
|
||||
test('non authorized user should not be able to access app', async ({ page }) => {
|
||||
const loginFixture = new LoginFixture(page);
|
||||
await page.goto('http://whoami.127.0.0.1.sslip.io');
|
||||
// redirect to tinyauth
|
||||
await expect(page.getByText('Welcome back, please login')).toBeVisible()
|
||||
// user2 is not authorized to access app
|
||||
await loginFixture.run('user2', 'password')
|
||||
// redirect to app
|
||||
await expect(page.getByText('The user with username user2 is not authorized to access the resource whoami.')).toBeVisible()
|
||||
})
|
||||
|
||||
test('allowed path should skip authentication', async ({ page }) => {
|
||||
await page.goto('http://whoami.127.0.0.1.sslip.io/foo');
|
||||
await expect(page.getByText('whoami.127.0.0.1.sslip.io')).toBeVisible()
|
||||
})
|
||||
Reference in New Issue
Block a user