b90ff252d1
Public archive with sidebar navigation, project pages, month archive, search and entry pages with image blocks. Admin area for brands, projects, post types, users, api clients, media and the entry editor with drag and drop images, preview per audience, scheduling and publish checks. Read and write API with bearer tokens, audience scoping, idempotent creation, OpenAPI document and editorial guide. Magic link login with configurable allowed domains, whole app behind the session gate. 456 tests including design rule checks.
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { internalTarget, loginPath, overviewTarget } from '~/lib/auth-routes'
|
|
|
|
describe('internalTarget', () => {
|
|
it('behält ein Ziel innerhalb der Verwaltung', () => {
|
|
expect(internalTarget('/admin/posts/neu', overviewTarget)).toBe('/admin/posts/neu')
|
|
})
|
|
|
|
it('fällt auf die Verwaltungsübersicht zurück', () => {
|
|
expect(internalTarget(undefined, overviewTarget)).toBe('/')
|
|
expect(internalTarget('', overviewTarget)).toBe('/')
|
|
expect(internalTarget('/search', overviewTarget)).toBe('/search')
|
|
})
|
|
|
|
it('lässt keine fremde Adresse durch', () => {
|
|
expect(internalTarget('//example.test/admin', overviewTarget)).toBe('/')
|
|
expect(internalTarget('https://example.test/admin', overviewTarget)).toBe('/')
|
|
expect(internalTarget('/admin\\@example.test', overviewTarget)).toBe('/')
|
|
})
|
|
})
|
|
|
|
describe('loginPath', () => {
|
|
it('bleibt ohne Ziel schlicht', () => {
|
|
expect(loginPath()).toBe('/login')
|
|
expect(loginPath('/')).toBe('/login')
|
|
})
|
|
|
|
it('hängt ein erlaubtes Ziel an', () => {
|
|
expect(loginPath('/admin/posts/neu')).toBe('/login?next=%2Fadmin%2Fposts%2Fneu')
|
|
})
|
|
|
|
it('verwirft ein fremdes Ziel', () => {
|
|
expect(loginPath('https://example.test')).toBe('/login')
|
|
})
|
|
})
|