mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 02:21:51 +08:00
chore(server): data mocking and seeding (#10864)
This commit is contained in:
@@ -191,7 +191,7 @@ test('should use specified throttler for unauthenticated user', async t => {
|
||||
test('should not protect unspecified routes', async t => {
|
||||
const { app } = t.context;
|
||||
|
||||
await app.signup('u1@affine.pro');
|
||||
await app.signupV1('u1@affine.pro');
|
||||
const res = await app.GET('/nonthrottled/default').expect(200);
|
||||
|
||||
const headers = rateLimitHeaders(res);
|
||||
@@ -204,7 +204,7 @@ test('should not protect unspecified routes', async t => {
|
||||
test('should use default throttler for authenticated user when not specified', async t => {
|
||||
const { app } = t.context;
|
||||
|
||||
await app.signup('u1@affine.pro');
|
||||
await app.signupV1('u1@affine.pro');
|
||||
const res = await app.GET('/throttled/default').expect(200);
|
||||
|
||||
const headers = rateLimitHeaders(res);
|
||||
@@ -216,7 +216,7 @@ test('should use default throttler for authenticated user when not specified', a
|
||||
test('should use same throttler for multiple routes', async t => {
|
||||
const { app } = t.context;
|
||||
|
||||
await app.signup('u1@affine.pro');
|
||||
await app.signupV1('u1@affine.pro');
|
||||
let res = await app.GET('/throttled/default').expect(200);
|
||||
|
||||
let headers = rateLimitHeaders(res);
|
||||
@@ -235,7 +235,7 @@ test('should use same throttler for multiple routes', async t => {
|
||||
test('should use different throttler if specified', async t => {
|
||||
const { app } = t.context;
|
||||
|
||||
await app.signup('u1@affine.pro');
|
||||
await app.signupV1('u1@affine.pro');
|
||||
let res = await app.GET('/throttled/default').expect(200);
|
||||
|
||||
let headers = rateLimitHeaders(res);
|
||||
@@ -254,7 +254,7 @@ test('should use different throttler if specified', async t => {
|
||||
test('should skip throttler for authenticated if `authenticated` throttler used', async t => {
|
||||
const { app } = t.context;
|
||||
|
||||
await app.signup('u1@affine.pro');
|
||||
await app.signupV1('u1@affine.pro');
|
||||
const res = await app.GET('/throttled/authenticated').expect(200);
|
||||
|
||||
const headers = rateLimitHeaders(res);
|
||||
@@ -278,7 +278,7 @@ test('should apply `default` throttler for unauthenticated user if `authenticate
|
||||
test('should skip throttler for authenticated user when specified', async t => {
|
||||
const { app } = t.context;
|
||||
|
||||
await app.signup('u1@affine.pro');
|
||||
await app.signupV1('u1@affine.pro');
|
||||
const res = await app.GET('/throttled/skip').expect(200);
|
||||
|
||||
const headers = rateLimitHeaders(res);
|
||||
@@ -291,7 +291,7 @@ test('should skip throttler for authenticated user when specified', async t => {
|
||||
test('should use specified throttler for authenticated user', async t => {
|
||||
const { app } = t.context;
|
||||
|
||||
await app.signup('u1@affine.pro');
|
||||
await app.signupV1('u1@affine.pro');
|
||||
const res = await app.GET('/throttled/strict').expect(200);
|
||||
|
||||
const headers = rateLimitHeaders(res);
|
||||
@@ -306,7 +306,7 @@ test('should separate anonymous and authenticated user throttlers', async t => {
|
||||
const unauthenticatedUserRes = await app
|
||||
.GET('/nonthrottled/default')
|
||||
.expect(200);
|
||||
await app.signup('u1@affine.pro');
|
||||
await app.signupV1('u1@affine.pro');
|
||||
const authenticatedUserRes = await app.GET('/throttled/default').expect(200);
|
||||
|
||||
const authenticatedResHeaders = rateLimitHeaders(authenticatedUserRes);
|
||||
|
||||
Reference in New Issue
Block a user