Bind Reddit and Matrix session identities
This commit is contained in:
1 parent
34ae532cdd
commit
492efe0f8a
12 files changed
+234
-55
No files matched your search
@@ -1,5 +1,8 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { createSessionExportDownload } from '../extensions/reddit-session-exporter/session-export.js';
|
||||
import {
|
||||
assertMatchingSessionIdentity,
|
||||
createSessionExportDownload,
|
||||
} from '../extensions/reddit-session-exporter/session-export.js';
|
||||
|
||||
describe('createSessionExportDownload', () => {
|
||||
it('creates a JSON data URL that Chrome can download from a service worker', () => {
|
||||
@@ -49,3 +52,19 @@ describe('createSessionExportDownload', () => {
|
||||
expect(() => createSessionExportDownload([], null)).toThrow(/Reddit Chat/i);
|
||||
});
|
||||
});
|
||||
|
||||
describe('assertMatchingSessionIdentity', () => {
|
||||
it('accepts a Matrix user bound to the current Reddit account ID', () => {
|
||||
expect(() => assertMatchingSessionIdentity(
|
||||
{ username: 'bot-account', accountId: 'bot' },
|
||||
'@t2_bot:reddit.com',
|
||||
)).not.toThrow();
|
||||
});
|
||||
|
||||
it('rejects a stale Matrix capture from another Reddit account', () => {
|
||||
expect(() => assertMatchingSessionIdentity(
|
||||
{ username: 'bot-account', accountId: 't2_bot' },
|
||||
'@t2_other:reddit.com',
|
||||
)).toThrow(/Reload Reddit Chat after switching accounts/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user