mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-29 23:13:02 +00:00
# Which Problems Are Solved This PR fixes an issue where all features where patched, instead of a single one. This led to instance overrides which were not intended. With this change, an update is executed whenever a toggle is hit, only containing the respective feature, not all. # How the Problems Are Solved The console application was overriding the feature settings as an entire request. A toggle change is now only changing the desired and targeted feature using partial patches. # Additional Context Closes #10459 --------- Co-authored-by: Elio Bischof <elio@zitadel.com>
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import { API } from './types';
|
|
|
|
export function getInstanceFeatures(api: API) {
|
|
return cy.request({
|
|
method: 'GET',
|
|
url: `${api.featuresBaseURL}/instance`,
|
|
headers: {
|
|
authorization: `Bearer ${api.token}`,
|
|
},
|
|
body: {},
|
|
});
|
|
}
|
|
|
|
export function setInstanceFeature(api: API, feature: string, enabled: boolean, additionalConfig?: Record<string, any>) {
|
|
const body: Record<string, any> = {
|
|
[feature]: enabled,
|
|
...additionalConfig,
|
|
};
|
|
|
|
return cy.request({
|
|
method: 'PUT',
|
|
url: `${api.featuresBaseURL}/instance`,
|
|
headers: {
|
|
authorization: `Bearer ${api.token}`,
|
|
},
|
|
body,
|
|
});
|
|
}
|
|
|
|
export function resetInstanceFeatures(api: API) {
|
|
return cy.request({
|
|
method: 'DELETE',
|
|
url: `${api.featuresBaseURL}/instance`,
|
|
headers: {
|
|
authorization: `Bearer ${api.token}`,
|
|
},
|
|
});
|
|
}
|
|
|
|
export function ensureFeatureState(api: API, feature: string, enabled: boolean, additionalConfig?: Record<string, any>) {
|
|
return getInstanceFeatures(api).then((response) => {
|
|
const currentState = response.body?.[feature]?.enabled;
|
|
|
|
if (currentState !== enabled) {
|
|
return setInstanceFeature(api, feature, enabled, additionalConfig);
|
|
}
|
|
|
|
return cy.wrap(response);
|
|
});
|
|
}
|
|
|
|
export function ensureLoginV2FeatureState(api: API, required: boolean, baseUri?: string) {
|
|
return setInstanceFeature(api, 'loginV2', required, {
|
|
loginV2: {
|
|
required,
|
|
baseUri: baseUri || '',
|
|
},
|
|
});
|
|
}
|