From 65cdd9f3a92382b62cc6c3cc545cb90309357709 Mon Sep 17 00:00:00 2001 From: Fredrik Oseberg Date: Fri, 14 Jan 2022 11:09:16 +0100 Subject: [PATCH] fix: move /api/admin/features --- src/lib/routes/admin-api/feature.ts | 2 +- src/test/e2e/api/admin/feature.e2e.test.ts | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/lib/routes/admin-api/feature.ts b/src/lib/routes/admin-api/feature.ts index ea9562529b..7340a09297 100644 --- a/src/lib/routes/admin-api/feature.ts +++ b/src/lib/routes/admin-api/feature.ts @@ -41,7 +41,6 @@ class FeatureController extends Controller { this.service = featureToggleServiceV2; if (!config.disableLegacyFeaturesApi) { - this.get('/', this.getAllToggles); this.post('/', this.createToggle, CREATE_FEATURE); this.get('/:featureName', this.getToggle); this.put('/:featureName', this.updateToggle, UPDATE_FEATURE); @@ -58,6 +57,7 @@ class FeatureController extends Controller { this.post('/:featureName/stale/off', this.staleOff, UPDATE_FEATURE); } + this.get('/', this.getAllToggles); this.post('/validate', this.validate, NONE); this.get('/:featureName/tags', this.listTags); this.post('/:featureName/tags', this.addTag, UPDATE_FEATURE); diff --git a/src/test/e2e/api/admin/feature.e2e.test.ts b/src/test/e2e/api/admin/feature.e2e.test.ts index bf9da6dbce..98f22fcba8 100644 --- a/src/test/e2e/api/admin/feature.e2e.test.ts +++ b/src/test/e2e/api/admin/feature.e2e.test.ts @@ -693,10 +693,6 @@ test('should not hit endpoints if disable configuration is set', async () => { }, ); - await appWithDisabledLegacyFeatures.request - .get('/api/admin/features') - .expect(404); - await appWithDisabledLegacyFeatures.request .get('/api/admin/features/featureX') .expect('Content-Type', /json/) @@ -745,3 +741,16 @@ test('should hit validate and tags endpoint if legacy api is disabled', async () .send({ name: 'validateThis' }) .expect(200); }); + +test('should have access to the get all features endpoint even if api is disabled', async () => { + const appWithDisabledLegacyFeatures = await setupAppWithCustomConfig( + db.stores, + { + disableLegacyFeaturesApi: true, + }, + ); + + await appWithDisabledLegacyFeatures.request + .get('/api/admin/features') + .expect(200); +});