fix: fall back to the password form when a tenant has no Go Loose credentials

Deploying to the development cluster showed a case the tests had not: the API
answers 503, not 404, when a host is a known tenant whose client credentials
have not been supplied. Only 404 was treated as "no Go Loose login", so the
sign-in screen offered the button, and following it dead-ended on an error page
with no way for the person to sign in at all.

Both answers mean the same thing to the browser, so both now select the password
form. A successful answer still short-circuits as the single sign-on case.
This commit is contained in:
Daniel Noulet 2026-10-05 23:07:06 +02:00
parent 570345e4b5
commit 0fcff1f520
2 changed files with 31 additions and 7 deletions

View file

@ -128,6 +128,22 @@ describe('useAuthSession Go Loose bootstrap', () => {
expect(location.assign).not.toHaveBeenCalled()
})
it('falls back to password sign-in when the tenant has no client credentials', async () => {
// A 503 is what a configured tenant without Go Loose credentials returns. It is
// just as unusable as a 404, and treating it as "available" left the sign-in
// button leading to an error page with no way in.
const location = setHost('nmbs.guess-dev.urpi.be')
vi.stubGlobal(
'fetch',
vi.fn(() => json({ error: 'Go Loose login is not configured for tenant "nmbs"' }, 503)),
)
renderProbe()
await waitFor(() => expect(screen.getByText('false|false')).toBeInTheDocument())
expect(location.assign).not.toHaveBeenCalled()
})
it('falls back to password sign-in when the API reports no Go Loose login', async () => {
const location = setHost('nmbs.guess-dev.urpi.be')
vi.stubGlobal(