Verify Reddit identity before Matrix capture
This commit is contained in:
1 parent
2fd92bf82c
commit
2c533fa52a
3 files changed
+48
-14
No files matched your search
@@ -1,8 +1,22 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { AccountAuthContext } from '../src/services/account-auth-context.js';
|
||||
import {
|
||||
AccountAuthContext,
|
||||
authenticateCurrentAccount,
|
||||
} from '../src/services/account-auth-context.js';
|
||||
import { createMockLogger } from './mockLogger.js';
|
||||
|
||||
describe('AccountAuthContext', () => {
|
||||
it('does not attempt Matrix capture until Reddit identity is authoritative', async () => {
|
||||
const refreshMatrixCredentials = vi.fn();
|
||||
|
||||
await expect(authenticateCurrentAccount({
|
||||
getRedditUsername: vi.fn().mockResolvedValue(null),
|
||||
refreshMatrixCredentials,
|
||||
})).resolves.toBeNull();
|
||||
|
||||
expect(refreshMatrixCredentials).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('fails closed until Reddit and Matrix resolve to one authenticated account', async () => {
|
||||
const auth = new AccountAuthContext(createMockLogger());
|
||||
const authenticate = vi.fn().mockResolvedValue({
|
||||
|
||||
Reference in new issue
Block a user