feat(core): Add feature flag for granular credential sharing work (#39293)

This commit is contained in:
MHMD 2026-09-22 13:22:12 +00:00 committed by GitHub
parent 4d8c29adbe
commit fc68bb6a8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,34 @@
import { isCredSharingEnabled } from '@/constants/credential-sharing';
describe('isCredSharingEnabled', () => {
const originalEnv = process.env;
beforeEach(() => {
process.env = { ...originalEnv };
});
afterAll(() => {
process.env = originalEnv;
});
it('should return true when N8N_ENV_FEAT_CRED_SHARING is "true"', () => {
process.env.N8N_ENV_FEAT_CRED_SHARING = 'true';
expect(isCredSharingEnabled()).toBe(true);
});
it('should return false when N8N_ENV_FEAT_CRED_SHARING is unset', () => {
delete process.env.N8N_ENV_FEAT_CRED_SHARING;
expect(isCredSharingEnabled()).toBe(false);
});
it.each(['false', 'TRUE', '1', ''])(
'should return false when N8N_ENV_FEAT_CRED_SHARING is %p',
(value) => {
process.env.N8N_ENV_FEAT_CRED_SHARING = value;
expect(isCredSharingEnabled()).toBe(false);
},
);
});

View File

@ -0,0 +1,10 @@
import { isEnvFeatureEnabled } from '@n8n/backend-common';
/**
* More granular credential sharing (personal-space credentials usable in any
* project their owner works in, the can-see/can-use split, and related
* behavior) is opt-in while it lands on master in incremental pieces.
*/
export function isCredSharingEnabled(): boolean {
return isEnvFeatureEnabled('N8N_ENV_FEAT_CRED_SHARING');
}