mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
refactor
This commit is contained in:
parent
cd47064483
commit
173b7eaabc
2 changed files with 9 additions and 7 deletions
|
|
@ -6,7 +6,6 @@
|
|||
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { mockDeep } from 'vitest-mock-extended';
|
||||
import { Hono } from 'hono';
|
||||
import { createMiddleware } from 'hono/factory';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import type { AuthenticationResponseJSON } from '@simplewebauthn/server';
|
||||
import { MiUser } from '@/models/User.js';
|
||||
|
|
@ -20,6 +19,7 @@ import { RateLimiterService } from '@/server/api/RateLimiterService.js';
|
|||
import { WebAuthnService } from '@/core/WebAuthnService.js';
|
||||
import { SigninService } from '@/server/api/SigninService.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { dummyContextMiddleware } from '../utils.js';
|
||||
import type { ApiEnv } from '@/server/api/ApiServerTypes.js';
|
||||
|
||||
class FakeLimiter {
|
||||
|
|
@ -34,12 +34,6 @@ class FakeSigninService {
|
|||
}
|
||||
}
|
||||
|
||||
const dummyContextMiddleware = createMiddleware<ApiEnv>(async (ctx, next) => {
|
||||
ctx.set('ip', '0.0.0.0');
|
||||
ctx.set('ips', ['0.0.0.0']);
|
||||
await next();
|
||||
});
|
||||
|
||||
describe('SigninWithPasskeyApiService', () => {
|
||||
let app: TestingModule;
|
||||
let honoApp: Hono<ApiEnv>;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import { DataSource } from 'typeorm';
|
|||
import { type Response } from 'node-fetch';
|
||||
import { serve, type ServerType } from '@hono/node-server';
|
||||
import { Hono } from 'hono';
|
||||
import { createMiddleware } from 'hono/factory';
|
||||
import type { ApiEnv } from '@/server/api/ApiServerTypes.js';
|
||||
import { entities } from '@/postgres.js';
|
||||
import { loadConfig } from '@/config.js';
|
||||
import type * as misskey from 'misskey-js';
|
||||
|
|
@ -721,3 +723,9 @@ export async function captureWebhook<T = SystemWebhookPayload>(postAction: () =>
|
|||
|
||||
return JSON.parse(result) as T;
|
||||
}
|
||||
|
||||
export const dummyContextMiddleware = createMiddleware<ApiEnv>(async (ctx, next) => {
|
||||
ctx.set('ip', '0.0.0.0');
|
||||
ctx.set('ips', ['0.0.0.0']);
|
||||
await next();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue