refactor to not close fastify
This commit is contained in:
parent
357c65b356
commit
4f35af5590
|
@ -123,7 +123,6 @@ async function discoverClientInformation(logger: Logger, httpRequestService: Htt
|
||||||
name,
|
name,
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
|
||||||
logger.error('Failed to fetch client information', { err });
|
logger.error('Failed to fetch client information', { err });
|
||||||
throw new AuthorizationError('Failed to fetch client information', 'server_error');
|
throw new AuthorizationError('Failed to fetch client information', 'server_error');
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,32 +148,34 @@ describe('OAuth', () => {
|
||||||
let alice: misskey.entities.MeSignup;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: misskey.entities.MeSignup;
|
let bob: misskey.entities.MeSignup;
|
||||||
|
|
||||||
|
let sender: (reply: FastifyReply) => void;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
app = await startServer();
|
app = await startServer();
|
||||||
alice = await signup({ username: 'alice' });
|
alice = await signup({ username: 'alice' });
|
||||||
bob = await signup({ username: 'bob' });
|
bob = await signup({ username: 'bob' });
|
||||||
|
|
||||||
|
fastify = Fastify();
|
||||||
|
fastify.get('/', async (request, reply) => {
|
||||||
|
sender(reply);
|
||||||
|
});
|
||||||
|
await fastify.listen({ port: clientPort });
|
||||||
}, 1000 * 60 * 2);
|
}, 1000 * 60 * 2);
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
process.env.MISSKEY_TEST_CHECK_IP_RANGE = '';
|
process.env.MISSKEY_TEST_CHECK_IP_RANGE = '';
|
||||||
fastify = Fastify();
|
sender = (reply): void => {
|
||||||
fastify.get('/', async (request, reply) => {
|
|
||||||
reply.send(`
|
reply.send(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<link rel="redirect_uri" href="/redirect" />
|
<link rel="redirect_uri" href="/redirect" />
|
||||||
<div class="h-app"><div class="p-name">Misklient
|
<div class="h-app"><div class="p-name">Misklient
|
||||||
`);
|
`);
|
||||||
});
|
};
|
||||||
await fastify.listen({ port: clientPort });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await app.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await fastify.close();
|
await fastify.close();
|
||||||
fastify.server.unref();
|
await app.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Full flow', async () => {
|
test('Full flow', async () => {
|
||||||
|
@ -835,11 +837,7 @@ describe('OAuth', () => {
|
||||||
|
|
||||||
for (const [title, replyFunc] of Object.entries(tests)) {
|
for (const [title, replyFunc] of Object.entries(tests)) {
|
||||||
test(title, async () => {
|
test(title, async () => {
|
||||||
await fastify.close();
|
sender = replyFunc;
|
||||||
|
|
||||||
fastify = Fastify();
|
|
||||||
fastify.get('/', async (request, reply) => replyFunc(reply));
|
|
||||||
await fastify.listen({ port: clientPort });
|
|
||||||
|
|
||||||
const client = new AuthorizationCode(clientConfig);
|
const client = new AuthorizationCode(clientConfig);
|
||||||
|
|
||||||
|
@ -855,16 +853,12 @@ describe('OAuth', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
test('No item', async () => {
|
test('No item', async () => {
|
||||||
await fastify.close();
|
sender = (reply): void => {
|
||||||
|
|
||||||
fastify = Fastify();
|
|
||||||
fastify.get('/', async (request, reply) => {
|
|
||||||
reply.send(`
|
reply.send(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<div class="h-app"><div class="p-name">Misklient
|
<div class="h-app"><div class="p-name">Misklient
|
||||||
`);
|
`);
|
||||||
});
|
};
|
||||||
await fastify.listen({ port: clientPort });
|
|
||||||
|
|
||||||
const client = new AuthorizationCode(clientConfig);
|
const client = new AuthorizationCode(clientConfig);
|
||||||
|
|
||||||
|
@ -896,14 +890,10 @@ describe('OAuth', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Missing name', async () => {
|
test('Missing name', async () => {
|
||||||
await fastify.close();
|
sender = (reply): void => {
|
||||||
|
|
||||||
fastify = Fastify();
|
|
||||||
fastify.get('/', async (request, reply) => {
|
|
||||||
reply.header('Link', '</redirect>; rel="redirect_uri"');
|
reply.header('Link', '</redirect>; rel="redirect_uri"');
|
||||||
reply.send();
|
reply.send();
|
||||||
});
|
};
|
||||||
await fastify.listen({ port: clientPort });
|
|
||||||
|
|
||||||
const client = new AuthorizationCode(clientConfig);
|
const client = new AuthorizationCode(clientConfig);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue