diff --git a/src/lib/routes/admin-api/public-signup.test.ts b/src/lib/routes/admin-api/public-signup.test.ts index 5b3b930814..eb70149fc9 100644 --- a/src/lib/routes/admin-api/public-signup.test.ts +++ b/src/lib/routes/admin-api/public-signup.test.ts @@ -73,27 +73,22 @@ describe('Public Signup API', () => { }); test('should create a token', async () => { - expect.assertions(4); const appName = '123!23'; stores.clientApplicationsStore.upsert({ appName }); stores.roleStore.create({ name: RoleName.VIEWER }); const bodyCreate = createBody(); - return request + const res = await request .post('/api/admin/invite-link/tokens') .send(bodyCreate) - .expect(201) - .expect(async (res) => { - const token = res.body; - expect(token.name).toBe(bodyCreate.name); - expect(token.secret).not.toBeNull(); - expect(token.expiresAt).toBe( - bodyCreate.expiresAt.toISOString(), - ); - const eventCount = await stores.eventStore.count(); - expect(eventCount).toBe(1); //PUBLIC_SIGNUP_TOKEN_CREATED - }); + .expect(201); + const token = res.body; + expect(token.name).toBe(bodyCreate.name); + expect(token.secret).not.toBeNull(); + expect(token.expiresAt).toBe(bodyCreate.expiresAt.toISOString()); + const eventCount = await stores.eventStore.count(); + expect(eventCount).toBe(1); //PUBLIC_SIGNUP_TOKEN_CREATED }); test('should get All', async () => { diff --git a/src/lib/server-impl.test.ts b/src/lib/server-impl.test.ts index 0e8e7c68c3..35a5410ed5 100644 --- a/src/lib/server-impl.test.ts +++ b/src/lib/server-impl.test.ts @@ -38,6 +38,7 @@ jest.mock('./db', () => ({ clientInstanceStore: { destroy: noop }, clientMetricsStore: { destroy: noop, on: noop }, eventStore, + publicSignupTokenStore: { destroy: noop, on: noop }, settingStore, }; }, diff --git a/src/lib/server-impl.ts b/src/lib/server-impl.ts index 02e7ad4f25..379389346c 100644 --- a/src/lib/server-impl.ts +++ b/src/lib/server-impl.ts @@ -62,7 +62,7 @@ async function createApp( if (typeof config.eventHook === 'function') { addEventHook(config.eventHook, stores.eventStore); } - metricsMonitor.startMonitoring( + await metricsMonitor.startMonitoring( config, stores, serverVersion, diff --git a/src/lib/services/public-signup-token-service.ts b/src/lib/services/public-signup-token-service.ts index a7e54829b2..ba289fadfc 100644 --- a/src/lib/services/public-signup-token-service.ts +++ b/src/lib/services/public-signup-token-service.ts @@ -1,7 +1,6 @@ import crypto from 'crypto'; import { Logger } from '../logger'; import { IUnleashConfig, IUnleashStores } from '../types'; -import { minutesToMilliseconds } from 'date-fns'; import { IPublicSignupTokenStore } from '../types/stores/public-signup-token-store'; import { PublicSignupTokenSchema } from '../openapi/spec/public-signup-token-schema'; import { IRoleStore } from '../types/stores/role-store'; @@ -30,8 +29,6 @@ export class PublicSignupTokenService { private timer: NodeJS.Timeout; - private activeTokens: PublicSignupTokenSchema[] = []; - constructor( { publicSignupTokenStore, @@ -51,15 +48,6 @@ export class PublicSignupTokenService { this.logger = config.getLogger( '/services/public-signup-token-service.ts', ); - this.fetchActiveTokens(); - this.timer = setInterval( - () => this.fetchActiveTokens(), - minutesToMilliseconds(1), - ).unref(); - } - - async fetchActiveTokens(): Promise { - this.activeTokens = await this.getAllActiveTokens(); } public async get(secret: string): Promise { @@ -129,7 +117,6 @@ export class PublicSignupTokenService { createdBy: createdBy, }; const token = await this.store.insert(newToken); - this.activeTokens.push(token); await this.eventStore.store( new PublicSignupTokenCreatedEvent({ diff --git a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap index 45ccd76e8f..ddcff34056 100644 --- a/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap +++ b/src/test/e2e/api/openapi/__snapshots__/openapi.e2e.test.ts.snap @@ -4623,7 +4623,7 @@ If the provided project does not exist, the list of events will be empty.", "200": { "description": "This response has no body.", }, - "404": { + "401": { "description": "This response has no body.", }, },