1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-14 00:35:52 +02:00
Files
misskey/packages/backend/test/e2e/well-known.ts
かっこかり 6d15fe32d0 enhance(backend/test): Migrate tests to vitest (#16935)
* wip

* update fake-timers and migrate

* fix

* remove jest-mock

* fix

* fix

* fix

* fix

* attempt to fix unit tests

* attempt to fix e2e tests

* fix federation test [ci skip]

* attempt to fix e2e tests

* fix typecheck

* fix unit tests

* fix

* attempt to fix e2e

* fix

* Revert "attempt to fix e2e"

This reverts commit b7b7b05d85.

* attempt to fix e2e

* revert attempt to fix e2e

* update deps

* update vitest

* migrate

* attempt to fix e2e

* update

* fix

* remove vite swc plugin as oxc parser can handle decorators

* attempt to fix drive/files/create test

* Revert "attempt to fix drive/files/create test"

This reverts commit 4715153375.

* fix: エンドポイントにまつわるテストをunitからe2eに移動

* attempt to fix e2e

* remove swc

* attempt to fix e2e

* Revert "attempt to fix e2e"

This reverts commit 9fb86a4076.

* add logs for debug

* attempt to fix e2e

* Partially revert "attempt to fix e2e"

This reverts commit fb0008c85a.

* attempt to fix test

* fix: attempt to fix test

* Revert "fix: attempt to fix test"

This reverts commit ed2f5c40e8.

* Revert "attempt to fix test"

This reverts commit d7329c46f1.

* attempt to fix e2e

* fix: surpass eventemitter warning by increasing defaultMaxListeners

* attempt to fix e2e

* fix

* fix e2e not ending properly

* exp: add hanging-process reporter for investigation

* Revert "exp: add hanging-process reporter for investigation"

This reverts commit 26851f8282.

* update changelog
2026-04-20 14:57:29 +09:00

106 lines
3.3 KiB
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
process.env.NODE_ENV = 'test';
import * as assert from 'assert';
import { beforeAll, describe, test } from 'vitest';
import { api, host, origin, relativeFetch, signup } from '../utils.js';
import type * as misskey from 'misskey-js';
describe('.well-known', () => {
let alice: misskey.entities.User;
beforeAll(async () => {
alice = await signup({ username: 'alice' });
await api('admin/update-meta', { federation: 'all' }, alice as misskey.entities.SignupResponse);
}, 1000 * 60 * 2);
test('nodeinfo', async () => {
const res = await relativeFetch('.well-known/nodeinfo');
assert.ok(res.ok);
assert.strictEqual(res.headers.get('Access-Control-Allow-Origin'), '*');
const nodeInfo = await res.json();
assert.deepStrictEqual(nodeInfo, {
links: [{
rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1',
href: `${origin}/nodeinfo/2.1`,
}, {
rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0',
href: `${origin}/nodeinfo/2.0`,
}],
});
});
test('webfinger', async () => {
const preflight = await relativeFetch(`.well-known/webfinger?resource=acct:alice@${host}`, {
method: 'options',
headers: {
'Access-Control-Request-Method': 'GET',
Origin: 'http://example.com',
},
});
assert.ok(preflight.ok);
assert.strictEqual(preflight.headers.get('Access-Control-Allow-Headers'), 'Accept');
const res = await relativeFetch(`.well-known/webfinger?resource=acct:alice@${host}`);
assert.ok(res.ok);
assert.strictEqual(res.headers.get('Access-Control-Allow-Origin'), '*');
assert.strictEqual(res.headers.get('Access-Control-Expose-Headers'), 'Vary');
assert.strictEqual(res.headers.get('Vary'), 'Accept');
const webfinger = await res.json();
assert.deepStrictEqual(webfinger, {
subject: `acct:alice@${host}`,
links: [{
rel: 'self',
type: 'application/activity+json',
href: `${origin}/users/${alice.id}`,
}, {
rel: 'http://webfinger.net/rel/profile-page',
type: 'text/html',
href: `${origin}/@alice`,
}, {
rel: 'http://ostatus.org/schema/1.0/subscribe',
template: `${origin}/authorize-follow?acct={uri}`,
}],
});
});
test('host-meta', async () => {
const res = await relativeFetch('.well-known/host-meta');
assert.ok(res.ok);
assert.strictEqual(res.headers.get('Access-Control-Allow-Origin'), '*');
});
test('host-meta.json', async () => {
const res = await relativeFetch('.well-known/host-meta.json');
assert.ok(res.ok);
assert.strictEqual(res.headers.get('Access-Control-Allow-Origin'), '*');
const hostMeta = await res.json();
assert.deepStrictEqual(hostMeta, {
links: [{
rel: 'lrdd',
type: 'application/jrd+json',
template: `${origin}/.well-known/webfinger?resource={uri}`,
}],
});
});
test('oauth-authorization-server', async () => {
const res = await relativeFetch('.well-known/oauth-authorization-server');
assert.ok(res.ok);
assert.strictEqual(res.headers.get('Access-Control-Allow-Origin'), '*');
const serverInfo = await res.json() as any;
assert.strictEqual(serverInfo.issuer, origin);
assert.strictEqual(serverInfo.authorization_endpoint, `${origin}/oauth/authorize`);
assert.strictEqual(serverInfo.token_endpoint, `${origin}/oauth/token`);
});
});