mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(editor): Extract SAML, OIDC, and LDAP from Settings Store into SSO Store (no-changelog) (#16276)
This commit is contained in:
@@ -3,12 +3,18 @@ import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
import { useSourceControlStore } from '@/stores/sourceControl.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useRootStore } from '@n8n/stores/useRootStore';
|
||||
import { initializeAuthenticatedFeatures, initializeCore } from '@/init';
|
||||
import { state, initializeAuthenticatedFeatures, initializeCore } from '@/init';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { setActivePinia } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useVersionsStore } from '@/stores/versions.store';
|
||||
import { AxiosError } from 'axios';
|
||||
import merge from 'lodash/merge';
|
||||
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
||||
import { STORES } from '@n8n/stores';
|
||||
import { useSSOStore } from '@/stores/sso.store';
|
||||
import { UserManagementAuthenticationMethod } from '@/Interface';
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
|
||||
const showMessage = vi.fn();
|
||||
|
||||
@@ -31,9 +37,17 @@ describe('Init', () => {
|
||||
let usersStore: ReturnType<typeof useUsersStore>;
|
||||
let nodeTypesStore: ReturnType<typeof useNodeTypesStore>;
|
||||
let versionsStore: ReturnType<typeof useVersionsStore>;
|
||||
let ssoStore: ReturnType<typeof useSSOStore>;
|
||||
|
||||
beforeEach(() => {
|
||||
setActivePinia(createTestingPinia());
|
||||
setActivePinia(
|
||||
createTestingPinia({
|
||||
initialState: {
|
||||
[STORES.SETTINGS]: merge({}, SETTINGS_STORE_DEFAULT_STATE),
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
settingsStore = useSettingsStore();
|
||||
cloudPlanStore = useCloudPlanStore();
|
||||
sourceControlStore = useSourceControlStore();
|
||||
@@ -41,9 +55,14 @@ describe('Init', () => {
|
||||
usersStore = useUsersStore();
|
||||
versionsStore = useVersionsStore();
|
||||
versionsStore = useVersionsStore();
|
||||
ssoStore = useSSOStore();
|
||||
});
|
||||
|
||||
describe('initializeCore()', () => {
|
||||
beforeEach(() => {
|
||||
state.initialized = false;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
@@ -63,6 +82,28 @@ describe('Init', () => {
|
||||
|
||||
expect(settingsStoreSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should initialize ssoStore with settings SSO configuration', async () => {
|
||||
const saml = { loginEnabled: true, loginLabel: '' };
|
||||
const ldap = { loginEnabled: false, loginLabel: '' };
|
||||
const oidc = { loginEnabled: false, loginUrl: '', callbackUrl: '' };
|
||||
|
||||
settingsStore.userManagement.authenticationMethod = UserManagementAuthenticationMethod.Saml;
|
||||
settingsStore.settings.sso = { saml, ldap, oidc };
|
||||
settingsStore.isEnterpriseFeatureEnabled[EnterpriseEditionFeature.Saml] = true;
|
||||
|
||||
await initializeCore();
|
||||
|
||||
expect(ssoStore.initialize).toHaveBeenCalledWith({
|
||||
authenticationMethod: UserManagementAuthenticationMethod.Saml,
|
||||
config: { saml, ldap, oidc },
|
||||
features: {
|
||||
saml: true,
|
||||
ldap: false,
|
||||
oidc: false,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('initializeAuthenticatedFeatures()', () => {
|
||||
|
||||
Reference in New Issue
Block a user