2023-07-27 07:31:52 +02:00
|
|
|
|
/*
|
2024-02-13 16:59:27 +01:00
|
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2021-03-12 15:10:15 +01:00
|
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
|
|
|
|
|
import * as assert from 'assert';
|
2024-01-08 09:43:52 +01:00
|
|
|
|
import { channel, clip, cookie, galleryPost, page, play, post, signup, simpleGet, uploadFile } from '../utils.js';
|
2023-03-18 01:01:10 +01:00
|
|
|
|
import type { SimpleGetResponse } from '../utils.js';
|
2023-06-25 01:34:18 +02:00
|
|
|
|
import type * as misskey from 'misskey-js';
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
|
|
|
|
// Request Accept
|
|
|
|
|
const ONLY_AP = 'application/activity+json';
|
|
|
|
|
const PREFER_AP = 'application/activity+json, */*';
|
|
|
|
|
const PREFER_HTML = 'text/html, */*';
|
|
|
|
|
const UNSPECIFIED = '*/*';
|
|
|
|
|
|
2023-02-12 08:40:12 +01:00
|
|
|
|
// Response Content-Type
|
2021-03-12 15:10:15 +01:00
|
|
|
|
const AP = 'application/activity+json; charset=utf-8';
|
|
|
|
|
const HTML = 'text/html; charset=utf-8';
|
2023-03-09 18:37:44 +01:00
|
|
|
|
const JSON_UTF8 = 'application/json; charset=utf-8';
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('Webリソース', () => {
|
2024-01-03 05:41:28 +01:00
|
|
|
|
let alice: misskey.entities.SignupResponse;
|
2024-03-03 12:15:35 +01:00
|
|
|
|
let aliceUploadedFile: misskey.entities.DriveFile | null;
|
|
|
|
|
let alicesPost: misskey.entities.Note;
|
|
|
|
|
let alicePage: misskey.entities.Page;
|
|
|
|
|
let alicePlay: misskey.entities.Flash;
|
|
|
|
|
let aliceClip: misskey.entities.Clip;
|
|
|
|
|
let aliceGalleryPost: misskey.entities.GalleryPost;
|
|
|
|
|
let aliceChannel: misskey.entities.Channel;
|
2023-03-18 01:01:10 +01:00
|
|
|
|
|
2024-01-03 05:41:28 +01:00
|
|
|
|
let bob: misskey.entities.SignupResponse;
|
2023-08-21 10:21:57 +02:00
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
type Request = {
|
|
|
|
|
path: string,
|
2023-03-18 01:01:10 +01:00
|
|
|
|
accept?: string,
|
|
|
|
|
cookie?: string,
|
|
|
|
|
};
|
|
|
|
|
const ok = async (param: Request & {
|
|
|
|
|
type?: string,
|
|
|
|
|
}):Promise<SimpleGetResponse> => {
|
|
|
|
|
const { path, accept, cookie, type } = param;
|
|
|
|
|
const res = await simpleGet(path, accept, cookie);
|
|
|
|
|
assert.strictEqual(res.status, 200);
|
|
|
|
|
assert.strictEqual(res.type, type ?? HTML);
|
|
|
|
|
return res;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const notOk = async (param: Request & {
|
|
|
|
|
status?: number,
|
|
|
|
|
code?: string,
|
2023-06-25 01:34:18 +02:00
|
|
|
|
}): Promise<SimpleGetResponse> => {
|
2023-03-18 01:01:10 +01:00
|
|
|
|
const { path, accept, cookie, status, code } = param;
|
|
|
|
|
const res = await simpleGet(path, accept, cookie);
|
|
|
|
|
assert.notStrictEqual(res.status, 200);
|
|
|
|
|
if (status != null) {
|
|
|
|
|
assert.strictEqual(res.status, status);
|
|
|
|
|
}
|
|
|
|
|
if (code != null) {
|
|
|
|
|
assert.strictEqual(res.body.error.code, code);
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
};
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
|
|
|
|
const notFound = async (param: Request): Promise<SimpleGetResponse> => {
|
2023-03-18 01:01:10 +01:00
|
|
|
|
return await notOk({
|
|
|
|
|
...param,
|
|
|
|
|
status: 404,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const metaTag = (res: SimpleGetResponse, key: string, superkey = 'name'): string => {
|
|
|
|
|
return res.body.window.document.querySelector('meta[' + superkey + '="' + key + '"]')?.content;
|
|
|
|
|
};
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2022-09-17 20:27:08 +02:00
|
|
|
|
beforeAll(async () => {
|
2021-03-12 15:10:15 +01:00
|
|
|
|
alice = await signup({ username: 'alice' });
|
2024-03-03 12:15:35 +01:00
|
|
|
|
aliceUploadedFile = (await uploadFile(alice)).body;
|
2021-03-12 15:10:15 +01:00
|
|
|
|
alicesPost = await post(alice, {
|
2022-05-21 15:21:41 +02:00
|
|
|
|
text: 'test',
|
2021-03-12 15:10:15 +01:00
|
|
|
|
});
|
2023-03-18 01:01:10 +01:00
|
|
|
|
alicePage = await page(alice, {});
|
|
|
|
|
alicePlay = await play(alice, {});
|
|
|
|
|
aliceClip = await clip(alice, {});
|
|
|
|
|
aliceGalleryPost = await galleryPost(alice, {
|
2024-03-03 12:15:35 +01:00
|
|
|
|
fileIds: [aliceUploadedFile!.id],
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
|
|
|
|
aliceChannel = await channel(alice, {});
|
2023-08-21 10:21:57 +02:00
|
|
|
|
|
2023-11-26 02:01:06 +01:00
|
|
|
|
bob = await signup({ username: 'bob' });
|
2023-03-03 03:13:12 +01:00
|
|
|
|
}, 1000 * 60 * 2);
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe.each([
|
|
|
|
|
{ path: '/', type: HTML },
|
|
|
|
|
{ path: '/docs/ja-JP/about', type: HTML }, // "指定されたURLに該当するページはありませんでした。"
|
|
|
|
|
// fastify-static gives charset=UTF-8 instead of utf-8 and that's okay
|
2023-06-25 01:34:18 +02:00
|
|
|
|
{ path: '/api-doc', type: 'text/html; charset=UTF-8' },
|
|
|
|
|
{ path: '/api.json', type: JSON_UTF8 },
|
|
|
|
|
{ path: '/api-console', type: HTML },
|
|
|
|
|
{ path: '/_info_card_', type: HTML },
|
|
|
|
|
{ path: '/bios', type: HTML },
|
|
|
|
|
{ path: '/cli', type: HTML },
|
|
|
|
|
{ path: '/flush', type: HTML },
|
2023-03-18 01:01:10 +01:00
|
|
|
|
{ path: '/robots.txt', type: 'text/plain; charset=UTF-8' },
|
2023-06-25 01:34:18 +02:00
|
|
|
|
{ path: '/favicon.ico', type: 'image/vnd.microsoft.icon' },
|
2023-03-18 01:01:10 +01:00
|
|
|
|
{ path: '/opensearch.xml', type: 'application/opensearchdescription+xml' },
|
2023-06-25 01:34:18 +02:00
|
|
|
|
{ path: '/apple-touch-icon.png', type: 'image/png' },
|
|
|
|
|
{ path: '/twemoji/2764.svg', type: 'image/svg+xml' },
|
|
|
|
|
{ path: '/twemoji/2764-fe0f-200d-1f525.svg', type: 'image/svg+xml' },
|
|
|
|
|
{ path: '/twemoji-badge/2764.png', type: 'image/png' },
|
2023-03-18 01:01:10 +01:00
|
|
|
|
{ path: '/twemoji-badge/2764-fe0f-200d-1f525.png', type: 'image/png' },
|
2023-06-25 01:34:18 +02:00
|
|
|
|
{ path: '/fluent-emoji/2764.png', type: 'image/png' },
|
|
|
|
|
{ path: '/fluent-emoji/2764-fe0f-200d-1f525.png', type: 'image/png' },
|
2023-03-18 01:01:10 +01:00
|
|
|
|
])('$path', (p) => {
|
|
|
|
|
test('がGETできる。', async () => await ok({ ...p }));
|
|
|
|
|
|
|
|
|
|
// 注意: Webページが200で取得できても、実際のHTMLが正しく表示できるとは限らない
|
|
|
|
|
// 例えば、 /@xxx/pages/yyy に存在しないIDを渡した場合、HTTPレスポンスではエラーを区別できない
|
|
|
|
|
// こういったアサーションはフロントエンドE2EやAPI Endpointのテストで担保する。
|
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe.each([
|
2023-06-25 01:34:18 +02:00
|
|
|
|
{ path: '/twemoji/2764.png' },
|
|
|
|
|
{ path: '/twemoji/2764-fe0f-200d-1f525.png' },
|
|
|
|
|
{ path: '/twemoji-badge/2764.svg' },
|
2023-03-18 01:01:10 +01:00
|
|
|
|
{ path: '/twemoji-badge/2764-fe0f-200d-1f525.svg' },
|
2023-06-25 01:34:18 +02:00
|
|
|
|
{ path: '/fluent-emoji/2764.svg' },
|
|
|
|
|
{ path: '/fluent-emoji/2764-fe0f-200d-1f525.svg' },
|
2023-03-18 01:01:10 +01:00
|
|
|
|
])('$path', ({ path }) => {
|
|
|
|
|
test('はGETできない。', async () => await notFound({ path }));
|
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe.each([
|
2023-06-25 01:34:18 +02:00
|
|
|
|
{ ext: 'rss', type: 'application/rss+xml; charset=utf-8' },
|
|
|
|
|
{ ext: 'atom', type: 'application/atom+xml; charset=utf-8' },
|
|
|
|
|
{ ext: 'json', type: 'application/json; charset=utf-8' },
|
2023-03-18 01:01:10 +01:00
|
|
|
|
])('/@:username.$ext', ({ ext, type }) => {
|
|
|
|
|
const path = (username: string): string => `/@${username}.${ext}`;
|
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('がGETできる。', async () => await ok({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path: path(alice.username),
|
|
|
|
|
type,
|
|
|
|
|
}));
|
|
|
|
|
|
2023-11-26 02:01:06 +01:00
|
|
|
|
test('がGETできる。(ノートが存在しない場合でも。)', async () => await ok({
|
|
|
|
|
path: path(bob.username),
|
|
|
|
|
type,
|
|
|
|
|
}));
|
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('は存在しないユーザーはGETできない。', async () => await notOk({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path: path('nonexisting'),
|
2023-06-25 01:34:18 +02:00
|
|
|
|
status: 404,
|
2023-03-18 01:01:10 +01:00
|
|
|
|
}));
|
2024-06-22 05:51:02 +02:00
|
|
|
|
|
|
|
|
|
describe(' has entry such ', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
post(alice, { text: "**a**" })
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('MFMを含まない。', async () => {
|
|
|
|
|
const content = await simpleGet(path(alice.username), "*/*", undefined, res => res.text());
|
|
|
|
|
const _body: unknown = content.body;
|
|
|
|
|
// JSONフィードのときは改めて文字列化する
|
|
|
|
|
const body: string = typeof (_body) === "object" ? JSON.stringify(_body) : _body as string;
|
|
|
|
|
|
|
|
|
|
if (body.includes("**a**")) {
|
|
|
|
|
throw new Error("MFM shouldn't be included");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe.each([{ path: '/api/foo' }])('$path', ({ path }) => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('はGETできない。', async () => await notOk({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path,
|
2023-06-25 01:34:18 +02:00
|
|
|
|
status: 404,
|
2023-03-18 01:01:10 +01:00
|
|
|
|
code: 'UNKNOWN_API_ENDPOINT',
|
|
|
|
|
}));
|
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe.each([{ path: '/queue' }])('$path', ({ path }) => {
|
2023-08-21 10:21:57 +02:00
|
|
|
|
test('はログインしないとGETできない。', async () => await notOk({
|
|
|
|
|
path,
|
|
|
|
|
status: 401,
|
|
|
|
|
}));
|
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('はadminでなければGETできない。', async () => await notOk({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path,
|
2023-08-21 10:21:57 +02:00
|
|
|
|
cookie: cookie(bob),
|
|
|
|
|
status: 403,
|
2023-03-18 01:01:10 +01:00
|
|
|
|
}));
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
|
|
|
|
test('はadminならGETできる。', async () => await ok({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path,
|
|
|
|
|
cookie: cookie(alice),
|
2023-06-25 01:34:18 +02:00
|
|
|
|
}));
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe.each([{ path: '/streaming' }])('$path', ({ path }) => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('はGETできない。', async () => await notOk({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path,
|
2023-06-25 01:34:18 +02:00
|
|
|
|
status: 503,
|
2023-03-18 01:01:10 +01:00
|
|
|
|
}));
|
|
|
|
|
});
|
2021-03-12 16:18:46 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/@:username', () => {
|
|
|
|
|
const path = (username: string): string => `/@${username}`;
|
|
|
|
|
|
|
|
|
|
describe.each([
|
|
|
|
|
{ accept: PREFER_HTML },
|
|
|
|
|
{ accept: UNSPECIFIED },
|
|
|
|
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
|
|
|
|
test('はHTMLとしてGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(alice.username),
|
|
|
|
|
accept,
|
2023-03-18 01:01:10 +01:00
|
|
|
|
type: HTML,
|
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// TODO ogタグの検証
|
|
|
|
|
// TODO profile.noCrawleの検証
|
|
|
|
|
// TODO twitter:creatorの検証
|
|
|
|
|
// TODO <link rel="me" ...>の検証
|
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('はHTMLとしてGETできる。(存在しないIDでも。)', async () => await ok({
|
|
|
|
|
path: path('xxxxxxxxxx'),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
type: HTML,
|
|
|
|
|
}));
|
2024-11-09 02:54:44 +01:00
|
|
|
|
test.todo('HTMLとしてGETできる。(リモートユーザーでもリダイレクトせず)');
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-05-05 12:02:30 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe.each([
|
|
|
|
|
{ accept: ONLY_AP },
|
|
|
|
|
{ accept: PREFER_AP },
|
|
|
|
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
|
|
|
|
test('はActivityPubとしてGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(alice.username),
|
|
|
|
|
accept,
|
2023-03-18 01:01:10 +01:00
|
|
|
|
type: AP,
|
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(res.body.type, 'Person');
|
|
|
|
|
});
|
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('は存在しないIDのときActivityPubとしてGETできない。', async () => await notFound({
|
|
|
|
|
path: path('xxxxxxxxxx'),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
accept,
|
|
|
|
|
}));
|
2024-11-09 02:54:44 +01:00
|
|
|
|
test.todo('はオリジナルにリダイレクトされる。(リモートユーザー)');
|
2023-03-09 18:37:44 +01:00
|
|
|
|
});
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
2023-03-09 18:37:44 +01:00
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
describe.each([
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// 実際のハンドルはフロントエンド(index.vue)で行われる
|
|
|
|
|
{ sub: 'home' },
|
|
|
|
|
{ sub: 'notes' },
|
|
|
|
|
{ sub: 'activity' },
|
|
|
|
|
{ sub: 'achievements' },
|
|
|
|
|
{ sub: 'reactions' },
|
|
|
|
|
{ sub: 'clips' },
|
|
|
|
|
{ sub: 'pages' },
|
|
|
|
|
{ sub: 'gallery' },
|
|
|
|
|
])('/@:username/$sub', ({ sub }) => {
|
|
|
|
|
const path = (username: string): string => `/@${username}/${sub}`;
|
|
|
|
|
|
|
|
|
|
test('はHTMLとしてGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(alice.username),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/@:user/pages/:page', () => {
|
|
|
|
|
const path = (username: string, pagename: string): string => `/@${username}/pages/${pagename}`;
|
2021-03-13 05:21:33 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
test('はHTMLとしてGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(alice.username, alicePage.name),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:page-id'), alicePage.id);
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// TODO ogタグの検証
|
|
|
|
|
// TODO profile.noCrawleの検証
|
|
|
|
|
// TODO twitter:creatorの検証
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
|
|
|
|
test('はGETできる。(存在しないIDでも。)', async () => await ok({
|
|
|
|
|
path: path(alice.username, 'xxxxxxxxxx'),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
}));
|
|
|
|
|
});
|
2021-10-24 14:10:45 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/users/:id', () => {
|
|
|
|
|
const path = (id: string): string => `/users/${id}`;
|
|
|
|
|
|
|
|
|
|
describe.each([
|
|
|
|
|
{ accept: PREFER_HTML },
|
|
|
|
|
{ accept: UNSPECIFIED },
|
|
|
|
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
|
|
|
|
test('は/@:usernameにリダイレクトする', async () => {
|
|
|
|
|
const res = await simpleGet(path(alice.id), accept);
|
|
|
|
|
assert.strictEqual(res.status, 302);
|
|
|
|
|
assert.strictEqual(res.location, `/@${alice.username}`);
|
|
|
|
|
});
|
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('は存在しないユーザーはGETできない。', async () => await notFound({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path: path('xxxxxxxx'),
|
|
|
|
|
}));
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-10-24 14:10:45 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe.each([
|
|
|
|
|
{ accept: ONLY_AP },
|
|
|
|
|
{ accept: PREFER_AP },
|
|
|
|
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
|
|
|
|
test('はActivityPubとしてGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(alice.id),
|
|
|
|
|
accept,
|
2023-03-18 01:01:10 +01:00
|
|
|
|
type: AP,
|
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(res.body.type, 'Person');
|
|
|
|
|
});
|
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('は存在しないIDのときActivityPubとしてGETできない。', async () => await notOk({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path: path('xxxxxxxx'),
|
|
|
|
|
accept,
|
|
|
|
|
status: 404,
|
|
|
|
|
}));
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/users/inbox', () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('がGETできる。(POST専用だけど4xx/5xxにならずHTMLが返ってくる)', async () => await ok({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path: '/inbox',
|
|
|
|
|
}));
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// test.todo('POSTできる?');
|
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/users/:id/inbox', () => {
|
|
|
|
|
const path = (id: string): string => `/users/${id}/inbox`;
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('がGETできる。(POST専用だけど4xx/5xxにならずHTMLが返ってくる)', async () => await ok({
|
2023-03-18 01:01:10 +01:00
|
|
|
|
path: path(alice.id),
|
|
|
|
|
}));
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// test.todo('POSTできる?');
|
2021-03-12 15:10:15 +01:00
|
|
|
|
});
|
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/users/:id/outbox', () => {
|
|
|
|
|
const path = (id: string): string => `/users/${id}/outbox`;
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
test('がGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(alice.id),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
type: AP,
|
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(res.body.type, 'OrderedCollection');
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/notes/:id', () => {
|
|
|
|
|
const path = (noteId: string): string => `/notes/${noteId}`;
|
|
|
|
|
|
|
|
|
|
describe.each([
|
|
|
|
|
{ accept: PREFER_HTML },
|
|
|
|
|
{ accept: UNSPECIFIED },
|
|
|
|
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
|
|
|
|
test('はHTMLとしてGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(alicesPost.id),
|
|
|
|
|
accept,
|
2023-03-18 01:01:10 +01:00
|
|
|
|
type: HTML,
|
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
2023-06-25 01:34:18 +02:00
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:note-id'), alicesPost.id);
|
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// TODO ogタグの検証
|
|
|
|
|
// TODO profile.noCrawleの検証
|
|
|
|
|
// TODO twitter:creatorの検証
|
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('はHTMLとしてGETできる。(存在しないIDでも。)', async () => await ok({
|
|
|
|
|
path: path('xxxxxxxxxx'),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
}));
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe.each([
|
|
|
|
|
{ accept: ONLY_AP },
|
|
|
|
|
{ accept: PREFER_AP },
|
|
|
|
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
|
|
|
|
test('はActivityPubとしてGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(alicesPost.id),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
accept,
|
|
|
|
|
type: AP,
|
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(res.body.type, 'Note');
|
|
|
|
|
});
|
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('は存在しないIDのときActivityPubとしてGETできない。', async () => await notFound({
|
|
|
|
|
path: path('xxxxxxxxxx'),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
accept,
|
|
|
|
|
}));
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/play/:id', () => {
|
|
|
|
|
const path = (playid: string): string => `/play/${playid}`;
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
test('がGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(alicePlay.id),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:flash-id'), alicePlay.id);
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// TODO ogタグの検証
|
|
|
|
|
// TODO profile.noCrawleの検証
|
|
|
|
|
// TODO twitter:creatorの検証
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-06-25 01:34:18 +02:00
|
|
|
|
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
|
|
|
|
path: path('xxxxxxxxxx'),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
}));
|
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/clips/:clip', () => {
|
|
|
|
|
const path = (clip: string): string => `/clips/${clip}`;
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
test('がGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(aliceClip.id),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:clip-id'), aliceClip.id);
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// TODO ogタグの検証
|
|
|
|
|
// TODO profile.noCrawleの検証
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
|
|
|
|
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
|
|
|
|
path: path('xxxxxxxxxx'),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
}));
|
2021-03-12 15:10:15 +01:00
|
|
|
|
});
|
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/gallery/:post', () => {
|
|
|
|
|
const path = (post: string): string => `/gallery/${post}`;
|
|
|
|
|
|
|
|
|
|
test('がGETできる。', async () => {
|
2023-06-25 01:34:18 +02:00
|
|
|
|
const res = await ok({
|
|
|
|
|
path: path(aliceGalleryPost.id),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
|
|
|
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// FIXME: misskey:gallery-post-idみたいなmetaタグの設定がない
|
|
|
|
|
// TODO profile.noCrawleの検証
|
|
|
|
|
// TODO twitter:creatorの検証
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
|
|
|
|
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
|
|
|
|
path: path('xxxxxxxxxx'),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
}));
|
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
describe('/channels/:channel', () => {
|
|
|
|
|
const path = (channel: string): string => `/channels/${channel}`;
|
|
|
|
|
|
|
|
|
|
test('はGETできる。', async () => {
|
|
|
|
|
const res = await ok({
|
2023-06-25 01:34:18 +02:00
|
|
|
|
path: path(aliceChannel.id),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
});
|
2021-03-12 15:10:15 +01:00
|
|
|
|
|
2023-03-18 01:01:10 +01:00
|
|
|
|
// FIXME: misskey関連のmetaタグの設定がない
|
|
|
|
|
// TODO ogタグの検証
|
2022-09-17 20:27:08 +02:00
|
|
|
|
});
|
2023-06-25 01:34:18 +02:00
|
|
|
|
|
|
|
|
|
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
|
|
|
|
path: path('xxxxxxxxxx'),
|
2023-03-18 01:01:10 +01:00
|
|
|
|
}));
|
2021-03-12 15:10:15 +01:00
|
|
|
|
});
|
|
|
|
|
});
|