refactor(oidb): replace 3 positional helpers with one named runOidb
bridge-oidb.ts used to expose three thin functions —
makeOidbRequest / sendOidbAndCheck / sendOidbAndDecode — and every
action file repeated the same five-step envelope assembly with long
positional argument lists. Collapse them into one `runOidb(bridge,
call)` taking an OidbCall object: cmd / oidbCmd / subCmd / request
{ schema, value, isUid? } / response? { schema }.
Behavioural contract is preserved:
- No `response`: verify success + gotResponse, peek envelope retCode
iff response data is present (fire-and-check semantics).
- With `response`: require responseData, decode through the base
schema, validate retCode, return the inner body typed as TResp.
Migration touches 51 call sites across 9 source files (bridge-contacts,
actions/{group-file, group-admin, profile, group-message, friend,
interaction, misc}, web-actions/cookies) plus 9 test files that used
to assert on positional `.mock.calls[0]![4]` indices and now read
through `.mock.calls[0]![1].request.value` / `.cmd` / `.oidbCmd`.
Net effect: callers now name what each piece is for, and adding
cross-cutting OIDB behaviour (retry / timeout / per-cmd logging) is a
single-site change inside runOidb instead of a sweep across 9 files.
This commit is contained in:
19 files changed
+637
-549
No files matched your search
@@ -1,9 +1,7 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
runOidb: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
// element-builder reaches into protoEncode with element-specific schemas
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
runOidb: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
import * as oidb from '../../src/bridge/bridge-oidb';
|
||||
@@ -12,32 +10,32 @@ import { mockBridge } from './_helpers';
|
||||
|
||||
describe('actions/friend', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndCheck).mockClear();
|
||||
vi.mocked(oidb.runOidb).mockClear();
|
||||
});
|
||||
|
||||
it('setFriendAddRequest: numeric input is treated as UIN and resolved', async () => {
|
||||
const bridge = mockBridge();
|
||||
await friend.setFriendAddRequest(bridge as any, '10001', true);
|
||||
expect(bridge.resolveUserUid).toHaveBeenCalledWith(10001);
|
||||
const payload: any = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4];
|
||||
expect(payload).toMatchObject({ accept: 3, targetUid: 'resolved-uid' });
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.request.value).toMatchObject({ accept: 3, targetUid: 'resolved-uid' });
|
||||
});
|
||||
|
||||
it('setFriendAddRequest: non-numeric flag is forwarded as-is', async () => {
|
||||
const bridge = mockBridge();
|
||||
await friend.setFriendAddRequest(bridge as any, 'flag-abc', false);
|
||||
expect(bridge.resolveUserUid).not.toHaveBeenCalled();
|
||||
const payload: any = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4];
|
||||
expect(payload).toMatchObject({ accept: 5, targetUid: 'flag-abc' });
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.request.value).toMatchObject({ accept: 5, targetUid: 'flag-abc' });
|
||||
});
|
||||
|
||||
it('deleteFriend resolves UID, calls 0x126b_0, and triggers a friend-list refresh', async () => {
|
||||
const bridge = mockBridge();
|
||||
await friend.deleteFriend(bridge as any, 10001, true);
|
||||
expect(bridge.resolveUserUid).toHaveBeenCalledWith(10001);
|
||||
const call = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]!;
|
||||
expect(call[1]).toBe('OidbSvcTrpcTcp.0x126b_0');
|
||||
expect((call[4] as any).field1.block).toBe(true);
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.cmd).toBe('OidbSvcTrpcTcp.0x126b_0');
|
||||
expect((call.request.value as any).field1.block).toBe(true);
|
||||
expect(bridge.fetchFriendList).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -52,8 +50,8 @@ describe('actions/friend', () => {
|
||||
it('setFriendRemark resolves UID and sends 0xb6e_2', async () => {
|
||||
const bridge = mockBridge();
|
||||
await friend.setFriendRemark(bridge as any, 10001, 'best-friend');
|
||||
const call = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]!;
|
||||
expect(call[1]).toBe('OidbSvcTrpcTcp.0xb6e_2');
|
||||
expect(call[4]).toMatchObject({ targetUid: 'resolved-uid', remark: 'best-friend' });
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.cmd).toBe('OidbSvcTrpcTcp.0xb6e_2');
|
||||
expect(call.request.value).toMatchObject({ targetUid: 'resolved-uid', remark: 'best-friend' });
|
||||
});
|
||||
});
|
||||
@@ -3,9 +3,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
// Stub the OIDB shim so we can assert WHICH command + payload each
|
||||
// action constructs without booting a real Bridge / native pipe.
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
runOidb: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
import * as oidb from '../../src/bridge/bridge-oidb';
|
||||
@@ -14,20 +12,19 @@ import { mockBridge } from './_helpers';
|
||||
|
||||
describe('actions/group-admin', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndCheck).mockClear();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockClear();
|
||||
vi.mocked(oidb.runOidb).mockClear();
|
||||
});
|
||||
|
||||
it('muteGroupMember resolves UID and dispatches 0x1253_1', async () => {
|
||||
const bridge = mockBridge();
|
||||
await admin.muteGroupMember(bridge as any, 12345, 67890, 600);
|
||||
expect(bridge.resolveUserUid).toHaveBeenCalledWith(67890, 12345);
|
||||
expect(oidb.sendOidbAndCheck).toHaveBeenCalledOnce();
|
||||
const args = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]!;
|
||||
expect(args[1]).toBe('OidbSvcTrpcTcp.0x1253_1');
|
||||
expect(args[2]).toBe(0x1253);
|
||||
expect(args[3]).toBe(1);
|
||||
expect(args[4]).toMatchObject({
|
||||
expect(oidb.runOidb).toHaveBeenCalledOnce();
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.cmd).toBe('OidbSvcTrpcTcp.0x1253_1');
|
||||
expect(call.oidbCmd).toBe(0x1253);
|
||||
expect(call.subCmd).toBe(1);
|
||||
expect(call.request.value).toMatchObject({
|
||||
groupUin: 12345,
|
||||
type: 1,
|
||||
body: { targetUid: 'resolved-uid', duration: 600 },
|
||||
@@ -37,13 +34,13 @@ describe('actions/group-admin', () => {
|
||||
it('muteGroupAll flips the muteState flag based on enable', async () => {
|
||||
const bridge = mockBridge();
|
||||
await admin.muteGroupAll(bridge as any, 12345, true);
|
||||
expect(vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4]).toMatchObject({
|
||||
expect(vi.mocked(oidb.runOidb).mock.calls[0]![1].request.value).toMatchObject({
|
||||
groupUin: 12345,
|
||||
muteState: { state: 0xFFFFFFFF },
|
||||
});
|
||||
|
||||
await admin.muteGroupAll(bridge as any, 12345, false);
|
||||
expect(vi.mocked(oidb.sendOidbAndCheck).mock.calls[1]![4]).toMatchObject({
|
||||
expect(vi.mocked(oidb.runOidb).mock.calls[1]![1].request.value).toMatchObject({
|
||||
muteState: { state: 0 },
|
||||
});
|
||||
});
|
||||
@@ -52,7 +49,7 @@ describe('actions/group-admin', () => {
|
||||
const bridge = mockBridge();
|
||||
await admin.kickGroupMember(bridge as any, 12345, 67890, true, 'bad behaviour');
|
||||
expect(bridge.resolveUserUid).toHaveBeenCalledWith(67890, 12345);
|
||||
expect(vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4]).toMatchObject({
|
||||
expect(vi.mocked(oidb.runOidb).mock.calls[0]![1].request.value).toMatchObject({
|
||||
groupUin: 12345,
|
||||
targetUid: 'resolved-uid',
|
||||
rejectAddRequest: true,
|
||||
@@ -68,7 +65,7 @@ describe('actions/group-admin', () => {
|
||||
|
||||
await admin.kickGroupMembers(bridge as any, 12345, [11, 22], false);
|
||||
expect(bridge.resolveUserUid).toHaveBeenCalledTimes(2);
|
||||
const payload: any = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4];
|
||||
const payload: any = vi.mocked(oidb.runOidb).mock.calls[0]![1].request.value;
|
||||
expect(payload.targetUids).toEqual(['uid-a', 'uid-b']);
|
||||
expect(payload.rejectAddRequest).toBe(0);
|
||||
});
|
||||
@@ -76,15 +73,15 @@ describe('actions/group-admin', () => {
|
||||
it('leaveGroup sends 0x1097_1 with the groupUin', async () => {
|
||||
const bridge = mockBridge();
|
||||
await admin.leaveGroup(bridge as any, 12345);
|
||||
const call = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]!;
|
||||
expect(call[1]).toBe('OidbSvcTrpcTcp.0x1097_1');
|
||||
expect(call[4]).toMatchObject({ groupUin: 12345 });
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.cmd).toBe('OidbSvcTrpcTcp.0x1097_1');
|
||||
expect(call.request.value).toMatchObject({ groupUin: 12345 });
|
||||
});
|
||||
|
||||
it('setGroupAdmin resolves UID and sends 0x1096_1', async () => {
|
||||
const bridge = mockBridge();
|
||||
await admin.setGroupAdmin(bridge as any, 12345, 67890, true);
|
||||
expect(vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4]).toMatchObject({
|
||||
expect(vi.mocked(oidb.runOidb).mock.calls[0]![1].request.value).toMatchObject({
|
||||
groupUin: 12345, uid: 'resolved-uid', isAdmin: true,
|
||||
});
|
||||
});
|
||||
@@ -98,7 +95,7 @@ describe('actions/group-admin', () => {
|
||||
await admin.setGroupAddOption(bridge as any, 1, 2);
|
||||
await admin.setGroupSearch(bridge as any, 1);
|
||||
|
||||
const cmds = vi.mocked(oidb.sendOidbAndCheck).mock.calls.map(call => call[1]);
|
||||
const cmds = vi.mocked(oidb.runOidb).mock.calls.map(call => call[1].cmd);
|
||||
expect(cmds).toEqual([
|
||||
'OidbSvcTrpcTcp.0x8fc_3',
|
||||
'OidbSvcTrpcTcp.0x89a_15',
|
||||
@@ -114,23 +111,23 @@ describe('actions/group-admin', () => {
|
||||
await admin.setGroupAddRequest(bridge as any, 12345, 5, 1, true, 'ok', false);
|
||||
await admin.setGroupAddRequest(bridge as any, 12345, 5, 1, false, 'no', true);
|
||||
|
||||
const cmds = vi.mocked(oidb.sendOidbAndCheck).mock.calls.map(call => call[1]);
|
||||
const cmds = vi.mocked(oidb.runOidb).mock.calls.map(call => call[1].cmd);
|
||||
expect(cmds).toEqual([
|
||||
'OidbSvcTrpcTcp.0x10c8_1',
|
||||
'OidbSvcTrpcTcp.0x10c8_2',
|
||||
]);
|
||||
|
||||
const firstBody: any = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4];
|
||||
const firstBody: any = vi.mocked(oidb.runOidb).mock.calls[0]![1].request.value;
|
||||
expect(firstBody.accept).toBe(1);
|
||||
expect(firstBody.body.message).toBe('ok');
|
||||
|
||||
const secondBody: any = vi.mocked(oidb.sendOidbAndCheck).mock.calls[1]![4];
|
||||
const secondBody: any = vi.mocked(oidb.runOidb).mock.calls[1]![1].request.value;
|
||||
expect(secondBody.accept).toBe(2);
|
||||
});
|
||||
|
||||
it('getGroupAtAllRemain decodes the response and converts BigInts', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
canAtAll: 1,
|
||||
groupRemain: 12n,
|
||||
uinRemain: 5n,
|
||||
@@ -145,7 +142,7 @@ describe('actions/group-admin', () => {
|
||||
|
||||
it('getGroupAtAllRemain throws when the response is empty', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce(null);
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce(null);
|
||||
await expect(admin.getGroupAtAllRemain(bridge as any, 12345)).rejects.toThrow(/empty/);
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
runOidb: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
vi.mock('../../src/bridge/highway/highway-client', () => ({
|
||||
@@ -27,15 +25,15 @@ import { mockBridge } from './_helpers';
|
||||
|
||||
describe('actions/group-file', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndCheck).mockClear();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockClear();
|
||||
vi.mocked(oidb.runOidb).mockReset();
|
||||
vi.mocked(oidb.runOidb).mockResolvedValue({});
|
||||
vi.mocked(highwayClient.fetchHighwaySession).mockClear();
|
||||
vi.mocked(highwayClient.uploadHighwayHttp).mockClear();
|
||||
});
|
||||
|
||||
it('fetchGroupFileCount returns { fileCount, maxCount } from the OIDB response', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
count: { fileCount: 42, maxCount: 1000 },
|
||||
});
|
||||
const out = await groupFile.fetchGroupFileCount(bridge as any, 12345);
|
||||
@@ -44,14 +42,14 @@ describe('actions/group-file', () => {
|
||||
|
||||
it('fetchGroupFileCount falls back to defaults on partial response', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ count: {} });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ count: {} });
|
||||
const out = await groupFile.fetchGroupFileCount(bridge as any, 12345);
|
||||
expect(out).toEqual({ fileCount: 0, maxCount: 10000 });
|
||||
});
|
||||
|
||||
it('uploadGroupFile skips highway when boolFileExist is true', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
upload: {
|
||||
retCode: 0,
|
||||
fileId: 'fid-xyz',
|
||||
@@ -66,7 +64,7 @@ describe('actions/group-file', () => {
|
||||
|
||||
it('uploadGroupFile runs highway PUT when boolFileExist is false', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
upload: {
|
||||
retCode: 0,
|
||||
fileId: 'fid-xyz',
|
||||
@@ -84,14 +82,14 @@ describe('actions/group-file', () => {
|
||||
|
||||
it('uploadGroupFile throws on missing upload response', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({});
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({});
|
||||
await expect(groupFile.uploadGroupFile(bridge as any, 12345, '/path/file.bin'))
|
||||
.rejects.toThrow(/response missing/);
|
||||
});
|
||||
|
||||
it('uploadGroupFile bubbles up OIDB retCode errors', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
upload: { retCode: 999, retMsg: 'quota exceeded' },
|
||||
});
|
||||
await expect(groupFile.uploadGroupFile(bridge as any, 12345, '/path/file.bin'))
|
||||
@@ -112,7 +110,7 @@ describe('actions/group-file', () => {
|
||||
vi.mocked(bridge.resolveUserUid)
|
||||
.mockResolvedValueOnce('target-uid') // target user
|
||||
.mockResolvedValueOnce('self-uid-resolved'); // self fallback
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
upload: { retCode: 0, uuid: 'fid', fileAddon: 'hash', boolFileExist: true },
|
||||
});
|
||||
const out = await groupFile.uploadPrivateFile(bridge as any, 67890, '/path/file');
|
||||
@@ -122,7 +120,7 @@ describe('actions/group-file', () => {
|
||||
|
||||
it('fetchGroupFiles paginates files + folders out of OIDB items', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
list: {
|
||||
retCode: 0,
|
||||
isEnd: true,
|
||||
@@ -141,7 +139,7 @@ describe('actions/group-file', () => {
|
||||
|
||||
it('fetchGroupFileUrl builds the https URL from downloadDns + hex-encoded path', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
download: {
|
||||
retCode: 0,
|
||||
downloadDns: 'cdn.example.com',
|
||||
@@ -154,7 +152,7 @@ describe('actions/group-file', () => {
|
||||
|
||||
it('fetchGroupFileUrl throws when response is missing dns or url', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
download: { retCode: 0 },
|
||||
});
|
||||
await expect(groupFile.fetchGroupFileUrl(bridge as any, 12345, 'fid-xyz'))
|
||||
@@ -163,29 +161,29 @@ describe('actions/group-file', () => {
|
||||
|
||||
it('deleteGroupFile / moveGroupFile dispatch the right sub-commands', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode)
|
||||
vi.mocked(oidb.runOidb)
|
||||
.mockResolvedValueOnce({ delete: { retCode: 0 } })
|
||||
.mockResolvedValueOnce({ move: { retCode: 0 } });
|
||||
await groupFile.deleteGroupFile(bridge as any, 12345, 'fid');
|
||||
await groupFile.moveGroupFile(bridge as any, 12345, 'fid', '/a', '/b');
|
||||
expect(vi.mocked(oidb.sendOidbAndDecode).mock.calls.map(c => c[3])).toEqual([3, 5]);
|
||||
expect(vi.mocked(oidb.runOidb).mock.calls.map(c => c[1].subCmd)).toEqual([3, 5]);
|
||||
});
|
||||
|
||||
it('createGroupFileFolder / deleteGroupFileFolder / renameGroupFileFolder dispatch 0x6d7 family', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode)
|
||||
vi.mocked(oidb.runOidb)
|
||||
.mockResolvedValueOnce({ create: { retcode: 0 } })
|
||||
.mockResolvedValueOnce({ delete: { retcode: 0 } })
|
||||
.mockResolvedValueOnce({ rename: { retcode: 0 } });
|
||||
await groupFile.createGroupFileFolder(bridge as any, 1, 'folder');
|
||||
await groupFile.deleteGroupFileFolder(bridge as any, 1, 'fid');
|
||||
await groupFile.renameGroupFileFolder(bridge as any, 1, 'fid', 'newname');
|
||||
expect(vi.mocked(oidb.sendOidbAndDecode).mock.calls.map(c => c[2])).toEqual([0x6D7, 0x6D7, 0x6D7]);
|
||||
expect(vi.mocked(oidb.runOidb).mock.calls.map(c => c[1].oidbCmd)).toEqual([0x6D7, 0x6D7, 0x6D7]);
|
||||
});
|
||||
|
||||
it('fetch*UrlByNode builds https://domain/path?rkey from the NTV2 response', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValue({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValue({
|
||||
respHead: { retCode: 0 },
|
||||
download: {
|
||||
info: { domain: 'media.example.com', urlPath: '/path/x' },
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
runOidb: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
import * as oidb from '../../src/bridge/bridge-oidb';
|
||||
@@ -12,7 +10,7 @@ import { mockBridge } from './_helpers';
|
||||
|
||||
describe('actions/group-message', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndCheck).mockClear();
|
||||
vi.mocked(oidb.runOidb).mockClear();
|
||||
});
|
||||
|
||||
it('recallGroupMessage sends to SsoGroupRecallMsg with the group sequence', async () => {
|
||||
@@ -61,7 +59,7 @@ describe('actions/group-message', () => {
|
||||
const bridge = mockBridge();
|
||||
await msg.setGroupEssence(bridge as any, 12345, 5, 7, true);
|
||||
await msg.setGroupEssence(bridge as any, 12345, 5, 7, false);
|
||||
const cmds = vi.mocked(oidb.sendOidbAndCheck).mock.calls.map(c => c[1]);
|
||||
const cmds = vi.mocked(oidb.runOidb).mock.calls.map(c => c[1].cmd);
|
||||
expect(cmds).toEqual(['OidbSvcTrpcTcp.0xeac_1', 'OidbSvcTrpcTcp.0xeac_2']);
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
runOidb: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
import * as oidb from '../../src/bridge/bridge-oidb';
|
||||
@@ -12,43 +10,43 @@ import { mockBridge } from './_helpers';
|
||||
|
||||
describe('actions/interaction', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndCheck).mockClear();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockClear();
|
||||
vi.mocked(oidb.runOidb).mockReset();
|
||||
vi.mocked(oidb.runOidb).mockResolvedValue({});
|
||||
});
|
||||
|
||||
it('sendPoke group: groupUin set, friendUin=0', async () => {
|
||||
const bridge = mockBridge();
|
||||
await inter.sendPoke(bridge as any, true, 12345, 67890);
|
||||
const payload: any = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4];
|
||||
expect(payload).toMatchObject({ uin: 67890, groupUin: 12345, friendUin: 0 });
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.request.value).toMatchObject({ uin: 67890, groupUin: 12345, friendUin: 0 });
|
||||
});
|
||||
|
||||
it('sendPoke friend: friendUin set, groupUin=0, targetUin defaults to peer', async () => {
|
||||
const bridge = mockBridge();
|
||||
await inter.sendPoke(bridge as any, false, 67890);
|
||||
const payload: any = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4];
|
||||
expect(payload).toMatchObject({ uin: 67890, groupUin: 0, friendUin: 67890 });
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.request.value).toMatchObject({ uin: 67890, groupUin: 0, friendUin: 67890 });
|
||||
});
|
||||
|
||||
it('sendLike forwards target + count to 0x7e5_104', async () => {
|
||||
const bridge = mockBridge();
|
||||
await inter.sendLike(bridge as any, 10001, 3);
|
||||
const call = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]!;
|
||||
expect(call[1]).toBe('OidbSvcTrpcTcp.0x7e5_104');
|
||||
expect(call[4]).toMatchObject({ targetUin: 10001, count: 3 });
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.cmd).toBe('OidbSvcTrpcTcp.0x7e5_104');
|
||||
expect(call.request.value).toMatchObject({ targetUin: 10001, count: 3 });
|
||||
});
|
||||
|
||||
it('setGroupReaction picks _1 for set and _2 for unset', async () => {
|
||||
const bridge = mockBridge();
|
||||
await inter.setGroupReaction(bridge as any, 12345, 99, '128516', true);
|
||||
await inter.setGroupReaction(bridge as any, 12345, 99, '128516', false);
|
||||
const cmds = vi.mocked(oidb.sendOidbAndCheck).mock.calls.map(c => c[1]);
|
||||
const cmds = vi.mocked(oidb.runOidb).mock.calls.map(c => c[1].cmd);
|
||||
expect(cmds).toEqual(['OidbSvcTrpcTcp.0x9082_1', 'OidbSvcTrpcTcp.0x9082_2']);
|
||||
});
|
||||
|
||||
it('getEmojiLikes decodes user list, base64-encodes cookie, and reports isLast', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
inner: { userInfo: { uin: 10001 } },
|
||||
cookie: new Uint8Array([0xCA, 0xFE]),
|
||||
});
|
||||
@@ -60,7 +58,7 @@ describe('actions/interaction', () => {
|
||||
|
||||
it('getEmojiLikes reports isLast=true when no cookie comes back', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({});
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({});
|
||||
const out = await inter.getEmojiLikes(bridge as any, 12345, 99, '128516');
|
||||
expect(out.users).toEqual([]);
|
||||
expect(out.isLast).toBe(true);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
runOidb: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
import * as oidb from '../../src/bridge/bridge-oidb';
|
||||
@@ -12,12 +10,13 @@ import { mockBridge } from './_helpers';
|
||||
|
||||
describe('actions/misc', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockClear();
|
||||
vi.mocked(oidb.runOidb).mockReset();
|
||||
vi.mocked(oidb.runOidb).mockResolvedValue({});
|
||||
});
|
||||
|
||||
it('translateEn2Zh returns dstWords when present', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
translateResp: { dstWords: ['你好', '世界'] },
|
||||
});
|
||||
const out = await misc.translateEn2Zh(bridge as any, ['hello', 'world']);
|
||||
@@ -26,7 +25,7 @@ describe('actions/misc', () => {
|
||||
|
||||
it('translateEn2Zh throws on empty response', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({});
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({});
|
||||
await expect(misc.translateEn2Zh(bridge as any, ['hello']))
|
||||
.rejects.toThrow(/empty/);
|
||||
});
|
||||
@@ -61,7 +60,7 @@ describe('actions/misc', () => {
|
||||
|
||||
it('clickInlineKeyboardButton returns shaped result', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
result: 1, errMsg: 'ok', promptText: 'hi',
|
||||
});
|
||||
const out = await misc.clickInlineKeyboardButton(bridge as any, 1, 2, 'btn', 'data', 100);
|
||||
@@ -71,7 +70,7 @@ describe('actions/misc', () => {
|
||||
it('sendGroupSign dispatches to 0xEB7_1', async () => {
|
||||
const bridge = mockBridge();
|
||||
await misc.sendGroupSign(bridge as any, 12345);
|
||||
const call = vi.mocked(oidb.sendOidbAndDecode).mock.calls[0]!;
|
||||
expect(call[1]).toBe('OidbSvcTrpcTcp.0xEB7_1');
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.cmd).toBe('OidbSvcTrpcTcp.0xEB7_1');
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,7 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
runOidb: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
vi.mock('../../src/bridge/highway/highway-client', () => ({
|
||||
@@ -24,8 +22,8 @@ import { mockBridge } from './_helpers';
|
||||
|
||||
describe('actions/profile', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndCheck).mockClear();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockClear();
|
||||
vi.mocked(oidb.runOidb).mockReset();
|
||||
vi.mocked(oidb.runOidb).mockResolvedValue({});
|
||||
vi.mocked(highwayClient.fetchHighwaySession).mockClear();
|
||||
vi.mocked(highwayClient.uploadHighwayHttp).mockClear();
|
||||
});
|
||||
@@ -40,30 +38,30 @@ describe('actions/profile', () => {
|
||||
it('setProfile is a no-op when both arguments are undefined', async () => {
|
||||
const bridge = mockBridge();
|
||||
await profile.setProfile(bridge as any);
|
||||
expect(oidb.sendOidbAndCheck).not.toHaveBeenCalled();
|
||||
expect(oidb.runOidb).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('setProfile only sends non-undefined fields', async () => {
|
||||
const bridge = mockBridge();
|
||||
await profile.setProfile(bridge as any, 'New Nick');
|
||||
expect(oidb.sendOidbAndCheck).toHaveBeenCalledOnce();
|
||||
const body: any = vi.mocked(oidb.sendOidbAndCheck).mock.calls[0]![4];
|
||||
expect(body.stringProfiles).toEqual([{ fieldId: 20002, value: 'New Nick' }]);
|
||||
expect(oidb.runOidb).toHaveBeenCalledOnce();
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect((call.request.value as any).stringProfiles).toEqual([{ fieldId: 20002, value: 'New Nick' }]);
|
||||
});
|
||||
|
||||
it('setSelfLongNick wraps the long nick in profile tag 102', async () => {
|
||||
const bridge = mockBridge();
|
||||
await profile.setSelfLongNick(bridge as any, 'hello world');
|
||||
const call = vi.mocked(oidb.sendOidbAndDecode).mock.calls[0]!;
|
||||
expect((call[4] as any).profile).toEqual({ tag: 102, value: 'hello world' });
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect((call.request.value as any).profile).toEqual({ tag: 102, value: 'hello world' });
|
||||
});
|
||||
|
||||
it('setInputStatus resolves UID first and sends 0xcd4_1', async () => {
|
||||
const bridge = mockBridge();
|
||||
await profile.setInputStatus(bridge as any, 10001, 1);
|
||||
expect(bridge.resolveUserUid).toHaveBeenCalledWith(10001);
|
||||
const call = vi.mocked(oidb.sendOidbAndDecode).mock.calls[0]!;
|
||||
expect(call[1]).toBe('OidbSvcTrpcTcp.0xcd4_1');
|
||||
const call = vi.mocked(oidb.runOidb).mock.calls[0]![1];
|
||||
expect(call.cmd).toBe('OidbSvcTrpcTcp.0xcd4_1');
|
||||
});
|
||||
|
||||
it('setAvatar loads bytes and pushes through the highway upload path (cmd 90)', async () => {
|
||||
@@ -77,7 +75,7 @@ describe('actions/profile', () => {
|
||||
|
||||
it('getProfileLike (self): resolves self UID, returns formatted favorite + vote info', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
userLikeInfos: [{
|
||||
uid: 'u',
|
||||
time: 1700000000n,
|
||||
@@ -92,13 +90,13 @@ describe('actions/profile', () => {
|
||||
|
||||
it('getProfileLike throws on empty result', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ userLikeInfos: [] });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ userLikeInfos: [] });
|
||||
await expect(profile.getProfileLike(bridge as any)).rejects.toThrow(/empty/);
|
||||
});
|
||||
|
||||
it('getUnidirectionalFriendList parses the embedded JSON body', async () => {
|
||||
const bridge = mockBridge();
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
jsonBody: JSON.stringify({ rpt_block_list: [{ uin: 10001 }, { uin: 10002 }] }),
|
||||
});
|
||||
const out = await profile.getUnidirectionalFriendList(bridge as any);
|
||||
|
||||
@@ -3,9 +3,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
// Mock the OIDB shim so we can control what `forceFetchClientKey` and
|
||||
// `getPSkey` see without standing up a Bridge.
|
||||
vi.mock('../../src/bridge/bridge-oidb', () => ({
|
||||
sendOidbAndDecode: vi.fn(async () => ({})),
|
||||
sendOidbAndCheck: vi.fn(async () => undefined),
|
||||
makeOidbRequest: vi.fn(() => new Uint8Array(0)),
|
||||
runOidb: vi.fn(async () => ({})),
|
||||
}));
|
||||
|
||||
// Mock the actual HTTP cookie fetch.
|
||||
@@ -31,10 +29,10 @@ import {
|
||||
const bridge = { identity: { uin: '10001' } } as any;
|
||||
|
||||
describe('cookies — forceFetchClientKey', () => {
|
||||
beforeEach(() => { vi.mocked(oidb.sendOidbAndDecode).mockReset(); });
|
||||
beforeEach(() => { vi.mocked(oidb.runOidb).mockReset(); });
|
||||
|
||||
it('returns clientKey + keyIndex + expireTime from the OIDB response', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
clientKey: 'ck-xyz', keyIndex: 42, expireTime: 3600,
|
||||
});
|
||||
const out = await forceFetchClientKey(bridge);
|
||||
@@ -42,17 +40,17 @@ describe('cookies — forceFetchClientKey', () => {
|
||||
});
|
||||
|
||||
it('falls back to default keyIndex/expireTime when the response omits them', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ clientKey: 'ck' });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ clientKey: 'ck' });
|
||||
const out = await forceFetchClientKey(bridge);
|
||||
expect(out).toEqual({ clientKey: 'ck', keyIndex: '19', expireTime: '1800' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('cookies — getPSkey', () => {
|
||||
beforeEach(() => { vi.mocked(oidb.sendOidbAndDecode).mockReset(); });
|
||||
beforeEach(() => { vi.mocked(oidb.runOidb).mockReset(); });
|
||||
|
||||
it('folds pskeyItems into a domain → pskey Map', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({
|
||||
pskeyItems: [
|
||||
{ domain: 'qun.qq.com', pskey: 'psk-a' },
|
||||
{ domain: 'qzone.qq.com', pskey: 'psk-b' },
|
||||
@@ -68,12 +66,12 @@ describe('cookies — getPSkey', () => {
|
||||
|
||||
describe('cookies — getCookies', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockReset();
|
||||
vi.mocked(oidb.runOidb).mockReset();
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockReset();
|
||||
});
|
||||
|
||||
it('builds the ptlogin2 jump URL with the right query params', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockResolvedValueOnce({
|
||||
p_skey: 'psk',
|
||||
skey: 'sk',
|
||||
@@ -90,7 +88,7 @@ describe('cookies — getCookies', () => {
|
||||
});
|
||||
|
||||
it('falls back to getPSkey when p_skey is missing in the cookie response', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode)
|
||||
vi.mocked(oidb.runOidb)
|
||||
.mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 }) // forceFetchClientKey
|
||||
.mockResolvedValueOnce({ // getPSkey
|
||||
pskeyItems: [{ domain: 'qun.qq.com', pskey: 'psk-from-oidb' }],
|
||||
@@ -102,7 +100,7 @@ describe('cookies — getCookies', () => {
|
||||
});
|
||||
|
||||
it('returns whatever cookies it got if getPSkey fallback throws', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode)
|
||||
vi.mocked(oidb.runOidb)
|
||||
.mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 })
|
||||
.mockRejectedValueOnce(new Error('pskey unavailable'));
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockResolvedValueOnce({ skey: 'sk' });
|
||||
@@ -114,23 +112,23 @@ describe('cookies — getCookies', () => {
|
||||
|
||||
describe('cookies — getSKey', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockReset();
|
||||
vi.mocked(oidb.runOidb).mockReset();
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockReset();
|
||||
});
|
||||
|
||||
it('returns skey from the qzone-targeted ptlogin2 jump', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockResolvedValueOnce({ skey: 'the-skey' });
|
||||
expect(await getSKey(bridge)).toBe('the-skey');
|
||||
});
|
||||
|
||||
it('throws when clientKey comes back empty', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ clientKey: '' });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ clientKey: '' });
|
||||
await expect(getSKey(bridge)).rejects.toThrow(/clientKey is empty/);
|
||||
});
|
||||
|
||||
it('throws when the jump response omits skey', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockResolvedValueOnce({});
|
||||
await expect(getSKey(bridge)).rejects.toThrow(/SKey is Empty/);
|
||||
});
|
||||
@@ -149,21 +147,21 @@ describe('cookies — pure helpers', () => {
|
||||
});
|
||||
|
||||
it('getCookiesStr: joins cookies with "; "', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockResolvedValueOnce({ p_skey: 'p', skey: 's' });
|
||||
const out = await getCookiesStr(bridge, 'qun.qq.com');
|
||||
expect(out).toBe('p_skey=p; skey=s');
|
||||
});
|
||||
|
||||
it('getCsrfToken: combines getSKey + getBknFromSKey', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockResolvedValueOnce({ skey: 'abc' });
|
||||
const csrf = await getCsrfToken(bridge);
|
||||
expect(csrf).toBe(getBknFromSKey('abc'));
|
||||
});
|
||||
|
||||
it('getCredentials: returns { cookies, token, csrf_token } with bkn(p_skey)', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(oidb.runOidb).mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 });
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockResolvedValueOnce({ p_skey: 'p', skey: 's' });
|
||||
|
||||
const out = await getCredentials(bridge, 'qun.qq.com');
|
||||
@@ -173,7 +171,7 @@ describe('cookies — pure helpers', () => {
|
||||
});
|
||||
|
||||
it('getCredentials: token is 0 when no skey/p_skey available', async () => {
|
||||
vi.mocked(oidb.sendOidbAndDecode)
|
||||
vi.mocked(oidb.runOidb)
|
||||
.mockResolvedValueOnce({ clientKey: 'ck', keyIndex: 19 })
|
||||
.mockRejectedValueOnce(new Error('no pskey'));
|
||||
vi.mocked(RequestUtil.HttpsGetCookies).mockResolvedValueOnce({});
|
||||
|
||||
Reference in new issue
Block a user