mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-28 22:49:24 +09:00
fix test
This commit is contained in:
parent
66c0942d7e
commit
7751d80056
@ -33,39 +33,43 @@ async function getKeyPair(level: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('ap-request', () => {
|
describe('ap-request', () => {
|
||||||
describe.each(['00', '01'])('createSignedPost with verify', async (level) => {
|
describe.each(['00', '01'])('createSignedPost with verify', (level) => {
|
||||||
const keypair = await getKeyPair(level);
|
test('pass', async () => {
|
||||||
const key = { keyId: 'x', 'privateKeyPem': keypair.privateKey };
|
const keypair = await getKeyPair(level);
|
||||||
const url = 'https://example.com/inbox';
|
const key = { keyId: 'x', 'privateKeyPem': keypair.privateKey };
|
||||||
const activity = { a: 1 };
|
const url = 'https://example.com/inbox';
|
||||||
const body = JSON.stringify(activity);
|
const activity = { a: 1 };
|
||||||
const headers = {
|
const body = JSON.stringify(activity);
|
||||||
'User-Agent': 'UA',
|
const headers = {
|
||||||
};
|
'User-Agent': 'UA',
|
||||||
|
};
|
||||||
|
|
||||||
const req = createSignedPost({ level, key, url, body, additionalHeaders: headers });
|
const req = createSignedPost({ level, key, url, body, additionalHeaders: headers });
|
||||||
|
|
||||||
const parsed = parseRequestSignature(req.request);
|
const parsed = parseRequestSignature(req.request);
|
||||||
expect(parsed?.version).toBe('draft');
|
expect(parsed?.version).toBe('draft');
|
||||||
if (!parsed) return;
|
if (!parsed) return;
|
||||||
const verify = verifyDraftSignature(parsed?.value, keypair.publicKey);
|
const verify = verifyDraftSignature(parsed?.value, keypair.publicKey);
|
||||||
assert.deepStrictEqual(verify, true);
|
assert.deepStrictEqual(verify, true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.each(['00', '01'])('createSignedGet with verify', async (level) => {
|
describe.each(['00', '01'])('createSignedGet with verify', (level) => {
|
||||||
const keypair = await getKeyPair(level);
|
test('pass', async () => {
|
||||||
const key = { keyId: 'x', 'privateKeyPem': keypair.privateKey };
|
const keypair = await getKeyPair(level);
|
||||||
const url = 'https://example.com/outbox';
|
const key = { keyId: 'x', 'privateKeyPem': keypair.privateKey };
|
||||||
const headers = {
|
const url = 'https://example.com/outbox';
|
||||||
'User-Agent': 'UA',
|
const headers = {
|
||||||
};
|
'User-Agent': 'UA',
|
||||||
|
};
|
||||||
|
|
||||||
const req = createSignedGet({ level, key, url, additionalHeaders: headers });
|
const req = createSignedGet({ level, key, url, additionalHeaders: headers });
|
||||||
|
|
||||||
const parsed = parseRequestSignature(req.request);
|
const parsed = parseRequestSignature(req.request);
|
||||||
expect(parsed?.version).toBe('draft');
|
expect(parsed?.version).toBe('draft');
|
||||||
if (!parsed) return;
|
if (!parsed) return;
|
||||||
const verify = verifyDraftSignature(parsed?.value, keypair.publicKey);
|
const verify = verifyDraftSignature(parsed?.value, keypair.publicKey);
|
||||||
assert.deepStrictEqual(verify, true);
|
assert.deepStrictEqual(verify, true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user