'use strict'; // Pages and the API require an Authelia identity in an allowed group (#37). const { test, expect, SSO } = require('./fixtures'); test.describe('without an SSO identity', () => { test.use({ extraHTTPHeaders: {} }); test('pages show the sign-in error', async ({ page, problems }) => { const res = await page.goto('/'); expect(res.status()).toBe(401); await expect(page.getByText(/Sign in through Authelia SSO/)).toBeVisible(); problems.length = 0; // the 401 itself is the expected outcome }); test('the API refuses requests', async ({ request }) => { expect((await request.get('/api/workers')).status()).toBe(401); }); }); test.describe('signed in outside the allowed groups', () => { test.use({ extraHTTPHeaders: { ...SSO, 'Remote-Groups': 'guests' } }); test('the API refuses requests', async ({ request }) => { expect((await request.get('/api/workers')).status()).toBe(403); }); });