mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 21:49:36 +02:00
feat(core): Add feature flag for granular credential sharing work (#39293)
This commit is contained in:
parent
4d8c29adbe
commit
fc68bb6a8f
|
|
@ -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);
|
||||
},
|
||||
);
|
||||
});
|
||||
10
packages/cli/src/constants/credential-sharing.ts
Normal file
10
packages/cli/src/constants/credential-sharing.ts
Normal 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');
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user