Add PM2 deployment support
This commit is contained in:
@@ -20,6 +20,36 @@ afterEach(async () => {
|
||||
})
|
||||
|
||||
describe('AuthService', () => {
|
||||
it('creates the initial administrator only when the database is empty', async () => {
|
||||
const directory = await mkdtemp(join(tmpdir(), 'product-issue-auth-'))
|
||||
directories.push(directory)
|
||||
const database = openDatabase(join(directory, 'database.sqlite'))
|
||||
databases.push(database)
|
||||
const auth = new AuthService(database, 'secret', 60 * 60 * 1_000)
|
||||
|
||||
await expect(
|
||||
auth.createInitialAdmin({
|
||||
email: 'first@example.com',
|
||||
displayName: 'First admin',
|
||||
password: 'first secure password'
|
||||
})
|
||||
).resolves.toBe(true)
|
||||
await expect(
|
||||
auth.createInitialAdmin({
|
||||
email: 'second@example.com',
|
||||
displayName: 'Second admin',
|
||||
password: 'second secure password'
|
||||
})
|
||||
).resolves.toBe(false)
|
||||
|
||||
await expect(
|
||||
auth.login('first@example.com', 'first secure password')
|
||||
).resolves.toMatchObject({ displayName: 'First admin' })
|
||||
await expect(
|
||||
auth.login('second@example.com', 'second secure password')
|
||||
).resolves.toBeUndefined()
|
||||
})
|
||||
|
||||
it('invalidates existing sessions when an administrator is reset', async () => {
|
||||
const directory = await mkdtemp(join(tmpdir(), 'product-issue-auth-'))
|
||||
directories.push(directory)
|
||||
|
||||
Reference in New Issue
Block a user