mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-10-28 19:49:05 +01:00
feat: restore old behavior of automatically creating client secret
This commit is contained in:
@@ -25,6 +25,28 @@ test('Update general configuration', async ({ page }) => {
|
||||
await page.waitForURL('/settings/apps');
|
||||
});
|
||||
|
||||
test('Disable automatic client secret creation', async ({ page }) => {
|
||||
await page.getByRole('tab', { name: 'OIDC' }).click();
|
||||
const autoCreateSecret = page.getByRole('switch', {
|
||||
name: 'Automatically create client secrets'
|
||||
});
|
||||
await expect(autoCreateSecret).toBeChecked();
|
||||
await autoCreateSecret.click();
|
||||
await saveUnsavedChanges(page);
|
||||
|
||||
await page.reload();
|
||||
await page.getByRole('tab', { name: 'OIDC' }).click();
|
||||
await expect(autoCreateSecret).not.toBeChecked();
|
||||
|
||||
const response = await page.request.post('/api/oidc/clients', {
|
||||
data: { name: 'No Automatic Secret' }
|
||||
});
|
||||
expect(response.status()).toBe(201);
|
||||
const createdClient = await response.json();
|
||||
expect(createdClient.createdSecret).toBeUndefined();
|
||||
expect(createdClient.credentials.secrets ?? []).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('Save configuration from every editable tab together', async ({ page }) => {
|
||||
await page.getByLabel('Application Name', { exact: true }).fill('Combined Settings');
|
||||
await page.getByRole('tab', { name: 'User Creation' }).click();
|
||||
|
||||
@@ -40,6 +40,13 @@ test.describe('Create OIDC client', () => {
|
||||
);
|
||||
|
||||
const resolvedClientId = (await page.getByTestId('client-id').innerText()).trim();
|
||||
const createdSecret = (
|
||||
await page
|
||||
.getByRole('tabpanel', { name: 'General', exact: true })
|
||||
.getByTestId('client-secret')
|
||||
.innerText()
|
||||
).trim();
|
||||
expect(createdSecret).toMatch(/^\w{32}$/);
|
||||
|
||||
if (clientId) {
|
||||
expect(resolvedClientId).toBe(clientId);
|
||||
@@ -55,6 +62,15 @@ test.describe('Create OIDC client', () => {
|
||||
|
||||
const res = await page.request.get(`/api/oidc/clients/${resolvedClientId}/logo`);
|
||||
expect(res.ok()).toBeTruthy();
|
||||
|
||||
// The generated value is available on the creation page and is forgotten after a reload
|
||||
await page.reload();
|
||||
await expect(page.getByText(createdSecret, { exact: true })).toHaveCount(0);
|
||||
await page.getByRole('tab', { name: 'Credentials' }).click();
|
||||
await expect(page.getByTestId('client-secret-row')).toHaveCount(1);
|
||||
await expect(page.getByTestId('client-secret')).toHaveText(
|
||||
`${createdSecret.slice(0, 4)}••••••••`
|
||||
);
|
||||
}
|
||||
|
||||
test('with auto-generated client ID', async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user