Skip to content

Commit 990bc03

Browse files
test(security): cover isEmailAllowed case-insensitive matching
1 parent 82db6c2 commit 990bc03

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @vitest-environment node
3+
*/
4+
import { describe, expect, it } from 'vitest'
5+
import { isEmailAllowed } from '@/lib/core/security/deployment'
6+
7+
describe('isEmailAllowed', () => {
8+
it('matches an exact email regardless of casing on either side', () => {
9+
expect(isEmailAllowed('user@acme.com', ['user@acme.com'])).toBe(true)
10+
expect(isEmailAllowed('User@Acme.com', ['user@acme.com'])).toBe(true)
11+
expect(isEmailAllowed('user@acme.com', ['USER@ACME.COM'])).toBe(true)
12+
expect(isEmailAllowed(' User@Acme.com ', ['user@acme.com'])).toBe(true)
13+
})
14+
15+
it('matches a domain pattern regardless of casing (covers IdP/session emails)', () => {
16+
expect(isEmailAllowed('User@Acme.com', ['@acme.com'])).toBe(true)
17+
expect(isEmailAllowed('user@acme.com', ['@Acme.com'])).toBe(true)
18+
})
19+
20+
it('rejects emails not on the allow-list', () => {
21+
expect(isEmailAllowed('user@evil.com', ['user@acme.com', '@acme.com'])).toBe(false)
22+
expect(isEmailAllowed('user@acme.com', [])).toBe(false)
23+
})
24+
})

0 commit comments

Comments
 (0)