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,
|
||||
"projectStatusApi": false,
|
||||
"proxyReturnAllToggles": false,
|
||||
"proxyReturnAllTogglesKillSwitch": false,
|
||||
"responseTimeWithAppNameKillSwitch": false,
|
||||
"showProjectApiAccess": false,
|
||||
"strictSchemaValidation": false,
|
||||
@ -104,6 +105,7 @@ exports[`should create default config 1`] = `
|
||||
"proPlanAutoCharge": false,
|
||||
"projectStatusApi": false,
|
||||
"proxyReturnAllToggles": false,
|
||||
"proxyReturnAllTogglesKillSwitch": false,
|
||||
"responseTimeWithAppNameKillSwitch": false,
|
||||
"showProjectApiAccess": false,
|
||||
"strictSchemaValidation": false,
|
||||
|
@ -20,7 +20,6 @@ import {
|
||||
import { Context } from 'unleash-client';
|
||||
import { enrichContextWithIp } from '../../proxy';
|
||||
import { corsOriginMiddleware } from '../../middleware';
|
||||
import * as process from 'process';
|
||||
|
||||
interface ApiUserRequest<
|
||||
PARAM = any,
|
||||
@ -146,10 +145,13 @@ export default class ProxyController extends Controller {
|
||||
res: Response<ProxyFeaturesSchema>,
|
||||
) {
|
||||
let toggles;
|
||||
if (
|
||||
this.flagResolver.isEnabled('proxyReturnAllToggles') &&
|
||||
Boolean(process.env.RETURN_ALL_TOGGLES)
|
||||
) {
|
||||
const releaseFlag = this.flagResolver.isEnabled(
|
||||
'proxyReturnAllTogglesKillSwitch',
|
||||
);
|
||||
const featureflag = this.flagResolver.isEnabled(
|
||||
'proxyReturnAllToggles',
|
||||
);
|
||||
if (releaseFlag && featureflag) {
|
||||
toggles = await this.services.proxyService.getAllProxyFeatures(
|
||||
req.user,
|
||||
ProxyController.createContext(req),
|
||||
|
@ -26,8 +26,12 @@ const flags = {
|
||||
process.env.UNLEASH_RESPONSE_TIME_WITH_APP_NAME_KILL_SWITCH,
|
||||
false,
|
||||
),
|
||||
proxyReturnAllTogglesKillSwitch: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_PROXY_RETURN_ALL_TOGGLES_KILL_SWITCH,
|
||||
false,
|
||||
),
|
||||
proxyReturnAllToggles: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_PROXY_RETURN_ALL_TOGGLES,
|
||||
process.env.UNLEASH_PROXY_RETURN_ALL_TOGGLES,
|
||||
false,
|
||||
),
|
||||
maintenanceMode: parseEnvVarBoolean(
|
||||
|
@ -934,8 +934,8 @@ test('Should not recursively set off timers on events', async () => {
|
||||
});
|
||||
|
||||
test('should return all features when specified', async () => {
|
||||
app.config.experimental.flags.proxyReturnAllTogglesKillSwitch = true;
|
||||
app.config.experimental.flags.proxyReturnAllToggles = true;
|
||||
process.env.RETURN_ALL_TOGGLES = 'true';
|
||||
const frontendToken = await createApiToken(ApiTokenType.FRONTEND);
|
||||
await createFeatureToggle({
|
||||
name: 'enabledFeature1',
|
||||
@ -972,6 +972,7 @@ test('should return all features when specified', async () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await app.request
|
||||
.get('/api/frontend')
|
||||
.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 () => {
|
||||
app.config.experimental.flags.proxyReturnAllToggles = true;
|
||||
test('should return all features when both feature flags are set only', async () => {
|
||||
app.config.experimental.flags.proxyReturnAllTogglesKillSwitch = true;
|
||||
app.config.experimental.flags.proxyReturnAllToggles = false;
|
||||
const frontendToken = await createApiToken(ApiTokenType.FRONTEND);
|
||||
await createFeatureToggle({
|
||||
name: 'enabledFeature1',
|
||||
|
Loading…
Reference in New Issue
Block a user