This commit is contained in:
parent
e29fe18b93
commit
a30b029803
|
@ -3,64 +3,58 @@ import * as Misskey from 'misskey-js';
|
||||||
import { createAccount, resolveRemoteUser, sleep, type LoginUser } from '../../utils.js';
|
import { createAccount, resolveRemoteUser, sleep, type LoginUser } from '../../utils.js';
|
||||||
|
|
||||||
describe('API ap/show', () => {
|
describe('API ap/show', () => {
|
||||||
let alice: LoginUser, bob: LoginUser;
|
let alice: LoginUser, bob: LoginUser;
|
||||||
let bobInA: Misskey.entities.UserDetailedNotMe;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
[alice, bob] = await Promise.all([
|
[alice, bob] = await Promise.all([
|
||||||
createAccount('a.test'),
|
createAccount('a.test'),
|
||||||
createAccount('b.test'),
|
createAccount('b.test'),
|
||||||
]);
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
// 事前に bob を a.test に解決してキャッシュ・同一性を取る
|
describe('User resolution', () => {
|
||||||
bobInA = await resolveRemoteUser('b.test', bob.id, alice);
|
test('resolve by acct (bob@b.test)', async () => {
|
||||||
});
|
const res = await alice.client.request('ap/show', { uri: `${bob.username}@b.test` });
|
||||||
|
strictEqual(res.type, 'User');
|
||||||
|
strictEqual(res.object.uri, `https://b.test/users/${bob.id}`);
|
||||||
|
});
|
||||||
|
|
||||||
describe('User resolution', () => {
|
test('resolve by canonical user URL (https://b.test/users/:id)', async () => {
|
||||||
test('resolve by acct (bob@b.test)', async () => {
|
const res = await alice.client.request('ap/show', { uri: `https://b.test/users/${bob.id}` });
|
||||||
const res = await alice.client.request('ap/show', { uri: `${bob.username}@b.test` });
|
strictEqual(res.type, 'User');
|
||||||
strictEqual(res.type, 'User');
|
strictEqual(res.object.uri, `https://b.test/users/${bob.id}`);
|
||||||
strictEqual(res.object.id, bobInA.id);
|
});
|
||||||
strictEqual(res.object.uri, `https://b.test/users/${bob.id}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('resolve by canonical user URL (https://b.test/users/:id)', async () => {
|
test('resolve by cross-origin non-canonical URL (https://a.test/@bob@b.test)', async () => {
|
||||||
const res = await alice.client.request('ap/show', { uri: `https://b.test/users/${bob.id}` });
|
const res = await alice.client.request('ap/show', { uri: `https://a.test/@${bob.username}@b.test` });
|
||||||
strictEqual(res.type, 'User');
|
strictEqual(res.type, 'User');
|
||||||
strictEqual(res.object.id, bobInA.id);
|
// 非正規URLから正規IDに追従して同一ユーザーになること
|
||||||
strictEqual(res.object.uri, `https://b.test/users/${bob.id}`);
|
strictEqual(res.object.uri, `https://b.test/users/${bob.id}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('resolve by cross-origin non-canonical URL (https://a.test/@bob@b.test)', async () => {
|
test('onlyUriFetch=true with acct string returns generic fetch error', async () => {
|
||||||
const res = await alice.client.request('ap/show', { uri: `https://a.test/@${bob.username}@b.test` });
|
await rejects(
|
||||||
strictEqual(res.type, 'User');
|
async () => await alice.client.request('ap/show', { uri: `${bob.username}@b.test`, onlyUriFetch: true }),
|
||||||
// 非正規URLから正規IDに追従して同一ユーザーになること
|
(err: any) => {
|
||||||
strictEqual(res.object.id, bobInA.id);
|
strictEqual(err.code, 'URI_IS_ACCT_LIKE_BUT_THIS_IS_ONLY_URI_FETCH_MODE');
|
||||||
strictEqual(res.object.uri, `https://b.test/users/${bob.id}`);
|
return true;
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('onlyUriFetch=true with acct string returns generic fetch error', async () => {
|
describe('Note resolution', () => {
|
||||||
await rejects(
|
test('resolve by note URL (https://b.test/notes/:id)', async () => {
|
||||||
async () => await alice.client.request('ap/show', { uri: `${bob.username}@b.test`, onlyUriFetch: true }),
|
const note = (await bob.client.request('notes/create', { text: 'hello from Bob' })).createdNote;
|
||||||
(err: any) => {
|
// 伝搬待ち
|
||||||
strictEqual(err.code, 'URI_IS_ACCT_LIKE_BUT_THIS_IS_ONLY_URI_FETCH_MODE');
|
await sleep();
|
||||||
return true;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Note resolution', () => {
|
const res = await alice.client.request('ap/show', { uri: `https://b.test/notes/${note.id}` });
|
||||||
test('resolve by note URL (https://b.test/notes/:id)', async () => {
|
strictEqual(res.type, 'Note');
|
||||||
const note = (await bob.client.request('notes/create', { text: 'hello from Bob' })).createdNote;
|
strictEqual(res.object.uri, `https://b.test/notes/${note.id}`);
|
||||||
// 伝搬待ち
|
// 投稿者が a.test 側で解決済みの Bob になること
|
||||||
await sleep();
|
strictEqual(res.object.user.username, bob.username);
|
||||||
|
strictEqual(res.object.user.host, 'b.test');
|
||||||
const res = await alice.client.request('ap/show', { uri: `https://b.test/notes/${note.id}` });
|
});
|
||||||
strictEqual(res.type, 'Note');
|
});
|
||||||
strictEqual(res.object.uri, `https://b.test/notes/${note.id}`);
|
|
||||||
// 投稿者が a.test 側で解決済みの Bob になること
|
|
||||||
strictEqual(res.object.userId, bobInA.id);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue