diff --git a/src/lib/proxy/proxy-repository.ts b/src/lib/proxy/proxy-repository.ts index 55463c7279..2411ccfe41 100644 --- a/src/lib/proxy/proxy-repository.ts +++ b/src/lib/proxy/proxy-repository.ts @@ -98,7 +98,7 @@ export class ProxyRepository private async featuresForToken(): Promise { return mapFeaturesForClient( await this.services.featureToggleServiceV2.getClientFeatures({ - project: await this.projectNamesForToken(), + project: await this.projectIdsForToken(), environment: this.token.environment, }), ); @@ -110,10 +110,10 @@ export class ProxyRepository ); } - private async projectNamesForToken(): Promise { + private async projectIdsForToken(): Promise { if (this.token.projects.includes(ALL_PROJECTS)) { const allProjects = await this.stores.projectStore.getAll(); - return allProjects.map((project) => project.name); + return allProjects.map((project) => project.id); } return this.token.projects; diff --git a/src/test/e2e/api/proxy/proxy.e2e.test.ts b/src/test/e2e/api/proxy/proxy.e2e.test.ts index 817e3e441c..485f29d8a9 100644 --- a/src/test/e2e/api/proxy/proxy.e2e.test.ts +++ b/src/test/e2e/api/proxy/proxy.e2e.test.ts @@ -38,7 +38,7 @@ export const createApiToken = ( ): Promise => { return app.services.apiTokenService.createApiTokenWithProjects({ type, - projects: ['default'], + projects: ['*'], environment: 'default', username: `${type}-token-${randomId()}`, ...overrides, @@ -82,12 +82,12 @@ const createFeatureToggle = async ({ ); }; -const createProject = async (id: string): Promise => { +const createProject = async (id: string, name: string): Promise => { const user = await db.stores.userStore.insert({ name: randomId(), email: `${randomId()}@example.com`, }); - await app.services.projectService.createProject({ id, name: id }, user); + await app.services.projectService.createProject({ id, name }, user); }; test('should require a frontend token or an admin token', async () => { @@ -527,9 +527,11 @@ test('should filter features by constraints', async () => { test('should filter features by project', async () => { const projectA = 'projectA'; const projectB = 'projectB'; - await createProject(projectA); - await createProject(projectB); - const frontendTokenDefault = await createApiToken(ApiTokenType.FRONTEND); + await createProject(projectA, randomId()); + await createProject(projectB, randomId()); + const frontendTokenDefault = await createApiToken(ApiTokenType.FRONTEND, { + projects: ['default'], + }); const frontendTokenProjectA = await createApiToken(ApiTokenType.FRONTEND, { projects: [projectA], });