feat: display all accessible oidc clients in the dashboard (#832)

Co-authored-by: Kyle Mendell <ksm@ofkm.us>
This commit is contained in:
Elias Schneider
2025-08-17 22:47:34 +02:00
committed by GitHub
parent 3fa2f9a162
commit 3188e92257
28 changed files with 306 additions and 110 deletions

View File

@@ -1,16 +1,17 @@
import test, { expect } from '@playwright/test';
import authUtil from 'utils/auth.util';
import { oidcClients } from '../data';
import { cleanupBackend } from '../utils/cleanup.util';
test.beforeEach(() => cleanupBackend());
test('Dashboard shows all authorized clients in the correct order', async ({ page }) => {
test('Dashboard shows all clients in the correct order', async ({ page }) => {
const client1 = oidcClients.tailscale;
const client2 = oidcClients.nextcloud;
await page.goto('/settings/apps');
await expect(page.getByTestId('authorized-oidc-client-card')).toHaveCount(2);
await expect(page.getByTestId('authorized-oidc-client-card')).toHaveCount(4);
// Should be first
const card1 = page.getByTestId('authorized-oidc-client-card').first();
@@ -22,6 +23,20 @@ test('Dashboard shows all authorized clients in the correct order', async ({ pag
await expect(card2.getByText(new URL(client2.launchURL).hostname)).toBeVisible();
});
test('Dashboard shows only clients where user has access', async ({ page }) => {
await authUtil.changeUser(page, 'craig');
const notVisibleClient = oidcClients.immich;
await page.goto('/settings/apps');
const cards = page.getByTestId('authorized-oidc-client-card');
await expect(cards).toHaveCount(3);
const cardTexts = await cards.allTextContents();
expect(cardTexts.some((text) => text.includes(notVisibleClient.name))).toBe(false);
});
test('Revoke authorized client', async ({ page }) => {
const client = oidcClients.tailscale;
@@ -40,7 +55,7 @@ test('Revoke authorized client', async ({ page }) => {
`The access to ${client.name} has been successfully revoked.`
);
await expect(page.getByTestId('authorized-oidc-client-card')).toHaveCount(1);
await expect(page.getByTestId('authorized-oidc-client-card')).toHaveCount(4);
});
test('Launch authorized client', async ({ page }) => {

View File

@@ -9,4 +9,12 @@ async function authenticate(page: Page) {
await page.getByRole('button', { name: 'Authenticate' }).click();
}
export default { authenticate };
async function changeUser(page: Page, username: keyof typeof passkeyUtil.passkeys) {
await page.context().clearCookies();
await page.goto('/login');
await (await passkeyUtil.init(page)).addPasskey(username);
await page.getByRole('button', { name: 'Authenticate' }).click();
}
export default { authenticate, changeUser };

View File

@@ -67,4 +67,4 @@ async function addPasskey(
});
}
export default { init };
export default { init, passkeys };