mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-23 23:37:56 +00:00
fix(console): single feature patch (#10476)
# 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>
This commit is contained in:
@@ -16,6 +16,7 @@ export function apiAuth(): Cypress.Chainable<API> {
|
||||
oauthBaseURL: `${backendUrl}/oauth/v2`,
|
||||
oidcBaseURL: `${backendUrl}/oidc/v1`,
|
||||
samlBaseURL: `${backendUrl}/saml/v2`,
|
||||
featuresBaseURL: `${backendUrl}/v2/features`,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
59
e2e/cypress/support/api/features.ts
Normal file
59
e2e/cypress/support/api/features.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
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 || '',
|
||||
},
|
||||
});
|
||||
}
|
@@ -10,6 +10,7 @@ export interface API extends Token {
|
||||
oidcBaseURL: string;
|
||||
oauthBaseURL: string;
|
||||
samlBaseURL: string;
|
||||
featuresBaseURL: string;
|
||||
}
|
||||
|
||||
export interface SystemAPI extends Token {
|
||||
|
Reference in New Issue
Block a user