mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
feat(core): Add redaction enforcement feature-flag helpers (no-changelog) (#30253)
This commit is contained in:
parent
0bde73c42f
commit
2b7e313430
|
|
@ -0,0 +1,26 @@
|
|||
import {
|
||||
N8N_ENV_FEAT_REDACTION_ENFORCEMENT,
|
||||
isRedactionEnforcementEnabled,
|
||||
} from '../redaction-enforcement.feature-flag';
|
||||
|
||||
describe('isRedactionEnforcementEnabled', () => {
|
||||
const original = process.env[N8N_ENV_FEAT_REDACTION_ENFORCEMENT];
|
||||
|
||||
afterEach(() => {
|
||||
if (original === undefined) {
|
||||
delete process.env[N8N_ENV_FEAT_REDACTION_ENFORCEMENT];
|
||||
} else {
|
||||
process.env[N8N_ENV_FEAT_REDACTION_ENFORCEMENT] = original;
|
||||
}
|
||||
});
|
||||
|
||||
it('returns false when the flag is unset', () => {
|
||||
delete process.env[N8N_ENV_FEAT_REDACTION_ENFORCEMENT];
|
||||
expect(isRedactionEnforcementEnabled()).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true when the flag is 'true'", () => {
|
||||
process.env[N8N_ENV_FEAT_REDACTION_ENFORCEMENT] = 'true';
|
||||
expect(isRedactionEnforcementEnabled()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
export const N8N_ENV_FEAT_REDACTION_ENFORCEMENT = 'N8N_ENV_FEAT_REDACTION_ENFORCEMENT';
|
||||
|
||||
export function isRedactionEnforcementEnabled(): boolean {
|
||||
return process.env[N8N_ENV_FEAT_REDACTION_ENFORCEMENT] === 'true';
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import type { FrontendSettings } from '@n8n/api-types';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { setActivePinia } from 'pinia';
|
||||
|
||||
import { useSettingsStore } from '@/app/stores/settings.store';
|
||||
|
||||
import { useRedactionEnforcementFeatureFlag } from './useRedactionEnforcementFeatureFlag';
|
||||
|
||||
describe('useRedactionEnforcementFeatureFlag', () => {
|
||||
const setup = (flagValue?: string) => {
|
||||
setActivePinia(createTestingPinia());
|
||||
const settingsStore = useSettingsStore();
|
||||
settingsStore.settings = {
|
||||
envFeatureFlags:
|
||||
flagValue === undefined ? {} : { N8N_ENV_FEAT_REDACTION_ENFORCEMENT: flagValue },
|
||||
} as unknown as FrontendSettings;
|
||||
return useRedactionEnforcementFeatureFlag();
|
||||
};
|
||||
|
||||
it('is disabled when the flag is unset', () => {
|
||||
expect(setup().isEnabled.value).toBe(false);
|
||||
});
|
||||
|
||||
it("is enabled when the flag is 'true'", () => {
|
||||
expect(setup('true').isEnabled.value).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import { computed } from 'vue';
|
||||
|
||||
import { useEnvFeatureFlag } from '@/features/shared/envFeatureFlag/useEnvFeatureFlag';
|
||||
|
||||
export const useRedactionEnforcementFeatureFlag = () => {
|
||||
const { check } = useEnvFeatureFlag();
|
||||
|
||||
const isEnabled = computed(() => check.value('REDACTION_ENFORCEMENT'));
|
||||
|
||||
return { isEnabled };
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user