mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-10 17:53:36 +02:00
fix: Return all toggles when env var is set and flag is on
Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
parent
0f5b080b13
commit
6fa4adb67a
@ -82,6 +82,7 @@ exports[`should create default config 1`] = `
|
|||||||
"proPlanAutoCharge": false,
|
"proPlanAutoCharge": false,
|
||||||
"projectStatusApi": false,
|
"projectStatusApi": false,
|
||||||
"proxyReturnAllToggles": false,
|
"proxyReturnAllToggles": false,
|
||||||
|
"proxyReturnAllTogglesKillSwitch": false,
|
||||||
"responseTimeWithAppNameKillSwitch": false,
|
"responseTimeWithAppNameKillSwitch": false,
|
||||||
"showProjectApiAccess": false,
|
"showProjectApiAccess": false,
|
||||||
"strictSchemaValidation": false,
|
"strictSchemaValidation": false,
|
||||||
@ -104,6 +105,7 @@ exports[`should create default config 1`] = `
|
|||||||
"proPlanAutoCharge": false,
|
"proPlanAutoCharge": false,
|
||||||
"projectStatusApi": false,
|
"projectStatusApi": false,
|
||||||
"proxyReturnAllToggles": false,
|
"proxyReturnAllToggles": false,
|
||||||
|
"proxyReturnAllTogglesKillSwitch": false,
|
||||||
"responseTimeWithAppNameKillSwitch": false,
|
"responseTimeWithAppNameKillSwitch": false,
|
||||||
"showProjectApiAccess": false,
|
"showProjectApiAccess": false,
|
||||||
"strictSchemaValidation": false,
|
"strictSchemaValidation": false,
|
||||||
|
@ -20,7 +20,6 @@ import {
|
|||||||
import { Context } from 'unleash-client';
|
import { Context } from 'unleash-client';
|
||||||
import { enrichContextWithIp } from '../../proxy';
|
import { enrichContextWithIp } from '../../proxy';
|
||||||
import { corsOriginMiddleware } from '../../middleware';
|
import { corsOriginMiddleware } from '../../middleware';
|
||||||
import * as process from 'process';
|
|
||||||
|
|
||||||
interface ApiUserRequest<
|
interface ApiUserRequest<
|
||||||
PARAM = any,
|
PARAM = any,
|
||||||
@ -146,10 +145,13 @@ export default class ProxyController extends Controller {
|
|||||||
res: Response<ProxyFeaturesSchema>,
|
res: Response<ProxyFeaturesSchema>,
|
||||||
) {
|
) {
|
||||||
let toggles;
|
let toggles;
|
||||||
if (
|
const releaseFlag = this.flagResolver.isEnabled(
|
||||||
this.flagResolver.isEnabled('proxyReturnAllToggles') &&
|
'proxyReturnAllTogglesKillSwitch',
|
||||||
Boolean(process.env.RETURN_ALL_TOGGLES)
|
);
|
||||||
) {
|
const featureflag = this.flagResolver.isEnabled(
|
||||||
|
'proxyReturnAllToggles',
|
||||||
|
);
|
||||||
|
if (releaseFlag && featureflag) {
|
||||||
toggles = await this.services.proxyService.getAllProxyFeatures(
|
toggles = await this.services.proxyService.getAllProxyFeatures(
|
||||||
req.user,
|
req.user,
|
||||||
ProxyController.createContext(req),
|
ProxyController.createContext(req),
|
||||||
|
@ -26,8 +26,12 @@ const flags = {
|
|||||||
process.env.UNLEASH_RESPONSE_TIME_WITH_APP_NAME_KILL_SWITCH,
|
process.env.UNLEASH_RESPONSE_TIME_WITH_APP_NAME_KILL_SWITCH,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
|
proxyReturnAllTogglesKillSwitch: parseEnvVarBoolean(
|
||||||
|
process.env.UNLEASH_EXPERIMENTAL_PROXY_RETURN_ALL_TOGGLES_KILL_SWITCH,
|
||||||
|
false,
|
||||||
|
),
|
||||||
proxyReturnAllToggles: parseEnvVarBoolean(
|
proxyReturnAllToggles: parseEnvVarBoolean(
|
||||||
process.env.UNLEASH_EXPERIMENTAL_PROXY_RETURN_ALL_TOGGLES,
|
process.env.UNLEASH_PROXY_RETURN_ALL_TOGGLES,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
maintenanceMode: parseEnvVarBoolean(
|
maintenanceMode: parseEnvVarBoolean(
|
||||||
|
@ -934,8 +934,8 @@ test('Should not recursively set off timers on events', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should return all features when specified', async () => {
|
test('should return all features when specified', async () => {
|
||||||
|
app.config.experimental.flags.proxyReturnAllTogglesKillSwitch = true;
|
||||||
app.config.experimental.flags.proxyReturnAllToggles = true;
|
app.config.experimental.flags.proxyReturnAllToggles = true;
|
||||||
process.env.RETURN_ALL_TOGGLES = 'true';
|
|
||||||
const frontendToken = await createApiToken(ApiTokenType.FRONTEND);
|
const frontendToken = await createApiToken(ApiTokenType.FRONTEND);
|
||||||
await createFeatureToggle({
|
await createFeatureToggle({
|
||||||
name: 'enabledFeature1',
|
name: 'enabledFeature1',
|
||||||
@ -972,6 +972,7 @@ test('should return all features when specified', async () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
await app.request
|
await app.request
|
||||||
.get('/api/frontend')
|
.get('/api/frontend')
|
||||||
.set('Authorization', frontendToken.secret)
|
.set('Authorization', frontendToken.secret)
|
||||||
@ -1001,11 +1002,11 @@ test('should return all features when specified', async () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
process.env.RETURN_ALL_TOGGLES = 'false';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return all features when env var is set only', async () => {
|
test('should return all features when both feature flags are set only', async () => {
|
||||||
app.config.experimental.flags.proxyReturnAllToggles = true;
|
app.config.experimental.flags.proxyReturnAllTogglesKillSwitch = true;
|
||||||
|
app.config.experimental.flags.proxyReturnAllToggles = false;
|
||||||
const frontendToken = await createApiToken(ApiTokenType.FRONTEND);
|
const frontendToken = await createApiToken(ApiTokenType.FRONTEND);
|
||||||
await createFeatureToggle({
|
await createFeatureToggle({
|
||||||
name: 'enabledFeature1',
|
name: 'enabledFeature1',
|
||||||
|
Loading…
Reference in New Issue
Block a user