Skip to content

Commit

Permalink
SONAR-21507 Show a warning for Bitbucket Authentication in case of in…
Browse files Browse the repository at this point in the history
…secure config
  • Loading branch information
vikvorona authored and sonartech committed Feb 1, 2024
1 parent d72acd5 commit cab06a5
Show file tree
Hide file tree
Showing 12 changed files with 411 additions and 286 deletions.
39 changes: 34 additions & 5 deletions server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
SettingValue,
SettingsKey,
} from '../../types/settings';
import { Dict } from '../../types/types';
import {
checkSecretKey,
encryptValue,
Expand Down Expand Up @@ -159,7 +160,16 @@ export default class SettingsServiceMock {

handleGetValue = (data: { key: string; component?: string } & BranchParameters) => {
const setting = this.#settingValues.find((s) => s.key === data.key) as SettingValue;
return this.reply(setting ?? {});
const definition = this.#definitions.find(
(d) => d.key === data.key,
) as ExtendedSettingDefinition;
if (!setting && definition?.defaultValue !== undefined) {
const fields = definition.multiValues
? { values: definition.defaultValue?.split(',') }
: { value: definition.defaultValue };
return this.reply({ key: data.key, ...fields });
}
return this.reply(setting ?? undefined);
};

handleGetValues = (data: { keys: string[]; component?: string } & BranchParameters) => {
Expand Down Expand Up @@ -215,11 +225,26 @@ export default class SettingsServiceMock {
(s) => s.key !== 'sonar.auth.github.userConsentForPermissionProvisioningRequired',
);
} else if (definition.type === SettingType.PROPERTY_SET) {
setting.fieldValues = [];
const fieldValues: Dict<string>[] = [];
if (setting) {
setting.fieldValues = fieldValues;
} else {
this.#settingValues.push({ key: data.keys, fieldValues });
}
} else if (definition.multiValues === true) {
setting.values = definition.defaultValue?.split(',') ?? [];
} else if (setting) {
setting.value = definition.defaultValue ?? '';
const values = definition.defaultValue?.split(',') ?? [];
if (setting) {
setting.values = values;
} else {
this.#settingValues.push({ key: data.keys, values });
}
} else {
const value = definition.defaultValue ?? '';
if (setting) {
setting.value = value;
} else {
this.#settingValues.push({ key: data.keys, value });
}
}

return this.reply(undefined);
Expand All @@ -246,6 +271,10 @@ export default class SettingsServiceMock {
this.#definitions.push(definition);
};

setDefinitions = (definitions: ExtendedSettingDefinition[]) => {
this.#definitions = definitions;
};

handleCheckSecretKey = () => {
return this.reply({ secretKeyAvailable: this.#secretKeyAvailable });
};
Expand Down
Loading

0 comments on commit cab06a5

Please sign in to comment.