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.
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { beforeEach, describe, expect, it } from 'vitest'
|
|
import { magicLinkWindowSeconds } from '~/domain/magic-link'
|
|
import { forgetMagicLinkAttempts, registerMagicLinkAttempt } from '~/lib/magic-link-attempts'
|
|
|
|
const window = magicLinkWindowSeconds * 1000
|
|
|
|
describe('registerMagicLinkAttempt', () => {
|
|
beforeEach(() => {
|
|
forgetMagicLinkAttempts()
|
|
})
|
|
|
|
it('zählt die Anforderungen einer Adresse hoch', () => {
|
|
const now = 1_700_000_000_000
|
|
|
|
expect(registerMagicLinkAttempt('paul@nyo.de', now)).toBe(1)
|
|
expect(registerMagicLinkAttempt('paul@nyo.de', now + 1000)).toBe(2)
|
|
expect(registerMagicLinkAttempt('PAUL@nyo.de', now + 2000)).toBe(3)
|
|
})
|
|
|
|
it('zählt jede Adresse für sich', () => {
|
|
const now = 1_700_000_000_000
|
|
|
|
registerMagicLinkAttempt('paul@nyo.de', now)
|
|
registerMagicLinkAttempt('paul@nyo.de', now)
|
|
|
|
expect(registerMagicLinkAttempt('mia@nyo.de', now)).toBe(1)
|
|
})
|
|
|
|
it('vergisst Anforderungen außerhalb des Zeitfensters', () => {
|
|
const now = 1_700_000_000_000
|
|
|
|
registerMagicLinkAttempt('paul@nyo.de', now)
|
|
registerMagicLinkAttempt('paul@nyo.de', now + 1000)
|
|
|
|
expect(registerMagicLinkAttempt('paul@nyo.de', now + window + 1)).toBe(2)
|
|
expect(registerMagicLinkAttempt('paul@nyo.de', now + 2 * window + 2)).toBe(1)
|
|
})
|
|
})
|