--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.almsettings;
+
+import org.sonar.api.SonarRuntime;
+import org.sonar.api.ce.ComputeEngineSide;
+import org.sonar.api.server.ServerSide;
+import org.sonar.server.feature.SonarQubeFeature;
+
+import static org.sonar.api.SonarEdition.DATACENTER;
+import static org.sonar.api.SonarEdition.ENTERPRISE;
+
+@ServerSide
+@ComputeEngineSide
+public class MultipleAlmFeature implements SonarQubeFeature {
+
+ private final SonarRuntime sonarRuntime;
+
+ public MultipleAlmFeature(SonarRuntime sonarRuntime) {
+ this.sonarRuntime = sonarRuntime;
+ }
+
+ @Override
+ public String getName() {
+ return "multiple-alm";
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return sonarRuntime.getEdition() == ENTERPRISE || sonarRuntime.getEdition() == DATACENTER;
+ }
+
+}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.almsettings;
-
-import java.util.Optional;
-import org.sonar.core.platform.EditionProvider;
-import org.sonar.core.platform.PlatformEditionProvider;
-
-public class MultipleAlmFeatureProvider {
-
- private PlatformEditionProvider editionProvider;
-
- public MultipleAlmFeatureProvider(PlatformEditionProvider editionProvider) {
- this.editionProvider = editionProvider;
- }
-
- public boolean enabled() {
- Optional<EditionProvider.Edition> edition = editionProvider.get();
- if (!edition.isPresent()) {
- return false;
- }
- switch (edition.get()) {
- case ENTERPRISE:
- case DATACENTER:
- return true;
- default:
- return false;
- }
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.almsettings;
-
-import java.util.Optional;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
-import org.sonar.core.platform.EditionProvider;
-import org.sonar.core.platform.PlatformEditionProvider;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class MultipleAlmFeatureProviderTest {
-
- private PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class);
- private final MultipleAlmFeatureProvider underTest = new MultipleAlmFeatureProvider(editionProvider);
-
- @Test
- public void is_enabled_on_CE() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
- Assertions.assertThat(underTest.enabled()).isFalse();
- }
-
- @Test
- public void is_enabled_on_DE() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.DEVELOPER));
- Assertions.assertThat(underTest.enabled()).isFalse();
- }
-
- @Test
- public void is_enabled_on_EE() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.ENTERPRISE));
- Assertions.assertThat(underTest.enabled()).isTrue();
- }
-
- @Test
- public void is_enabled_on_DCE() {
- when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.DATACENTER));
- Assertions.assertThat(underTest.enabled()).isTrue();
- }
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.almsettings;
+
+import com.tngtech.java.junit.dataprovider.DataProvider;
+import com.tngtech.java.junit.dataprovider.DataProviderRunner;
+import com.tngtech.java.junit.dataprovider.UseDataProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.sonar.api.SonarEdition;
+import org.sonar.api.SonarRuntime;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(DataProviderRunner.class)
+public class MultipleAlmFeatureTest {
+
+ private final SonarRuntime sonarRuntime = mock(SonarRuntime.class);
+ private final MultipleAlmFeature underTest = new MultipleAlmFeature(sonarRuntime);
+
+ @Test
+ public void getName_nameShouldBeCorrect() {
+ assertEquals("multiple-alm",underTest.getName());
+ }
+
+ @Test
+ @UseDataProvider("editionsAndMultipleAlmAvailability")
+ public void isEnabled_shouldOnlyBeEnabledInEnterpriseEditionPlus(SonarEdition edition, boolean shouldBeEnabled) {
+ when(sonarRuntime.getEdition()).thenReturn(edition);
+
+ boolean isEnabled = underTest.isEnabled();
+
+ assertThat(isEnabled).isEqualTo(shouldBeEnabled);
+ }
+
+ @DataProvider
+ public static Object[][] editionsAndMultipleAlmAvailability() {
+ return new Object[][] {
+ {SonarEdition.COMMUNITY, false},
+ {SonarEdition.DEVELOPER, false},
+ {SonarEdition.ENTERPRISE, true},
+ {SonarEdition.DATACENTER, true}
+ };
+ }
+}
`;
exports[`should render additional categories component correctly 4`] = `
-<withRouter(withAppStateContext(AlmIntegration))
+<withRouter(withAppStateContext(withAvailableFeaturesContext(AlmIntegration)))
categories={Array []}
component={
Object {
className="big-padded"
key="almintegration"
>
- <withRouter(withAppStateContext(AlmIntegration))
+ <withRouter(withAppStateContext(withAvailableFeaturesContext(AlmIntegration)))
categories={
Array [
"foo category",
validateAlmSettings
} from '../../../../api/alm-settings';
import withAppStateContext from '../../../../app/components/app-state/withAppStateContext';
+import withAvailableFeatures from '../../../../app/components/available-features/withAvailableFeatures';
import { Location, Router, withRouter } from '../../../../components/hoc/withRouter';
import {
AlmBindingDefinitionBase,
AlmSettingsBindingStatusType
} from '../../../../types/alm-settings';
import { AppState } from '../../../../types/appstate';
+import { Feature } from '../../../../types/features';
import { Dict } from '../../../../types/types';
import AlmIntegrationRenderer from './AlmIntegrationRenderer';
interface Props {
appState: AppState;
+ hasFeature: (feature: Feature) => boolean;
location: Location;
router: Router;
}
render() {
const {
- appState: { branchesEnabled, multipleAlmEnabled }
+ appState: { branchesEnabled },
+ hasFeature
} = this.props;
const {
currentAlmTab,
return (
<AlmIntegrationRenderer
branchesEnabled={Boolean(branchesEnabled)}
- multipleAlmEnabled={Boolean(multipleAlmEnabled)}
+ multipleAlmEnabled={hasFeature(Feature.MultipleAlm)}
onCancelDelete={this.handleCancelDelete}
onConfirmDelete={this.handleConfirmDelete}
onCheckConfiguration={this.handleCheck}
}
}
-export default withRouter(withAppStateContext(AlmIntegration));
+export default withRouter(withAppStateContext(withAvailableFeatures(AlmIntegration)));
<AlmIntegration
appState={mockAppState({ branchesEnabled: true })}
location={mockLocation()}
+ hasFeature={jest.fn()}
router={mockRouter()}
{...props}
/>
}
loadingAlmDefinitions={true}
loadingProjectCount={false}
- multipleAlmEnabled={false}
onCancelDelete={[Function]}
onCheckConfiguration={[Function]}
onConfirmDelete={[Function]}
edition?: EditionKey;
globalPages?: Extension[];
instanceUsesDefaultAdminCredentials?: boolean;
- multipleAlmEnabled?: boolean;
needIssueSync?: boolean;
productionDatabase: boolean;
qualifiers: string[];
export enum Feature {
MonoRepositoryPullRequestDecoration = 'monorepo',
RegulatoryReport = 'regulatory-reports',
- ProjectImport = 'project-import'
+ ProjectImport = 'project-import',
+ MultipleAlm = 'multiple-alm'
}
import org.sonar.db.alm.setting.ALM;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.project.ProjectDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.NotFoundException;
private final DbClient dbClient;
private final UserSession userSession;
private final ComponentFinder componentFinder;
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider;
+ private final MultipleAlmFeature multipleAlmFeature;
public AlmSettingsSupport(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder,
- MultipleAlmFeatureProvider multipleAlmFeatureProvider) {
+ MultipleAlmFeature multipleAlmFeature) {
this.dbClient = dbClient;
this.userSession = userSession;
this.componentFinder = componentFinder;
- this.multipleAlmFeatureProvider = multipleAlmFeatureProvider;
+ this.multipleAlmFeature = multipleAlmFeature;
}
- public MultipleAlmFeatureProvider getMultipleAlmFeatureProvider() {
- return multipleAlmFeatureProvider;
+ public MultipleAlmFeature getMultipleAlmFeatureProvider() {
+ return multipleAlmFeature;
}
public void checkAlmSettingDoesNotAlreadyExist(DbSession dbSession, String almSetting) {
public void checkAlmMultipleFeatureEnabled(ALM alm) {
try (DbSession dbSession = dbClient.openSession(false)) {
- if (!multipleAlmFeatureProvider.enabled() && !dbClient.almSettingDao().selectByAlm(dbSession, alm).isEmpty()) {
+ if (!multipleAlmFeature.isEnabled() && !dbClient.almSettingDao().selectByAlm(dbSession, alm).isEmpty()) {
throw BadRequestException.create("A " + alm + " setting is already defined");
}
}
*/
package org.sonar.server.ui.ws;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import javax.annotation.Nullable;
import org.sonar.api.Startable;
import org.sonar.api.config.Configuration;
import org.sonar.api.platform.Server;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.dialect.H2;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
import org.sonar.server.authentication.DefaultAdminCredentialsVerifier;
import org.sonar.server.branch.BranchFeatureProxy;
import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
import static org.sonar.core.config.WebConstants.SONAR_LF_GRAVATAR_SERVER_URL;
import static org.sonar.core.config.WebConstants.SONAR_LF_LOGO_URL;
import static org.sonar.core.config.WebConstants.SONAR_LF_LOGO_WIDTH_PX;
-import static org.sonar.core.platform.EditionProvider.Edition;
-import static org.sonar.core.platform.EditionProvider.Edition.DATACENTER;
-import static org.sonar.core.platform.EditionProvider.Edition.ENTERPRISE;
import static org.sonar.process.ProcessProperties.Property.SONAR_UPDATECENTER_ACTIVATE;
public class GlobalAction implements NavigationWsAction, Startable {
SONAR_LF_GRAVATAR_SERVER_URL,
RATING_GRID,
DEVELOPER_AGGREGATED_INFO_DISABLED);
-
+
private final Map<String, String> systemSettingValuesByKey;
private final PageRepository pageRepository;
private final BranchFeatureProxy branchFeature;
private final UserSession userSession;
private final PlatformEditionProvider editionProvider;
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider;
private final WebAnalyticsLoader webAnalyticsLoader;
private final IssueIndexSyncProgressChecker issueIndexSyncChecker;
private final DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier;
public GlobalAction(PageRepository pageRepository, Configuration config, ResourceTypes resourceTypes, Server server,
WebServer webServer, DbClient dbClient, BranchFeatureProxy branchFeature, UserSession userSession, PlatformEditionProvider editionProvider,
- MultipleAlmFeatureProvider multipleAlmFeatureProvider, WebAnalyticsLoader webAnalyticsLoader, IssueIndexSyncProgressChecker issueIndexSyncChecker,
+ WebAnalyticsLoader webAnalyticsLoader, IssueIndexSyncProgressChecker issueIndexSyncChecker,
DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier) {
this.pageRepository = pageRepository;
this.config = config;
this.branchFeature = branchFeature;
this.userSession = userSession;
this.editionProvider = editionProvider;
- this.multipleAlmFeatureProvider = multipleAlmFeatureProvider;
this.webAnalyticsLoader = webAnalyticsLoader;
this.systemSettingValuesByKey = new HashMap<>();
this.issueIndexSyncChecker = issueIndexSyncChecker;
writeDatabaseProduction(json);
writeBranchSupport(json);
writeInstanceUsesDefaultAdminCredentials(json);
- writeMultipleAlmEnabled(json);
editionProvider.get().ifPresent(e -> json.prop("edition", e.name().toLowerCase(Locale.ENGLISH)));
writeNeedIssueSync(json);
json.prop("standalone", webServer.isStandalone());
}
}
- private void writeMultipleAlmEnabled(JsonWriter json) {
- json.prop("multipleAlmEnabled", multipleAlmFeatureProvider.enabled());
- }
-
private void writeNeedIssueSync(JsonWriter json) {
try (DbSession dbSession = dbClient.openSession(false)) {
json.prop("needIssueSync", issueIndexSyncChecker.isIssueSyncInProgress(dbSession));
private void writeWebAnalytics(JsonWriter json) {
webAnalyticsLoader.getUrlPathToJs().ifPresent(p -> json.prop("webAnalyticsJsPath", p));
}
-
- private static boolean isEditionEEorDCE(@Nullable Edition edition) {
- return Arrays.asList(ENTERPRISE, DATACENTER).contains(edition);
- }
}
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.project.ProjectDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
private WsActionTester ws = new WsActionTester(new CountBindingAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
- mock(MultipleAlmFeatureProvider.class))));
+ mock(MultipleAlmFeature.class))));
@Test
public void count_github_binding() {
import org.sonar.db.DbTester;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
public DbTester db = DbTester.create();
private final Encryption encryption = mock(Encryption.class);
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+ private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
private WsActionTester ws = new WsActionTester(new CreateAzureAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
- multipleAlmFeatureProvider)));
+ multipleAlmFeature)));
@Before
public void before() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
}
@Test
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+ when(multipleAlmFeature.isEnabled()).thenReturn(true);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto azureAlmSetting = db.almSettings().insertAzureAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertAzureAlmSetting();
import org.sonar.db.DbTester;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
public DbTester db = DbTester.create();
private final Encryption encryption = mock(Encryption.class);
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+ private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
private WsActionTester ws = new WsActionTester(new CreateBitBucketAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
- multipleAlmFeatureProvider)));
+ multipleAlmFeature)));
@Before
public void before() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
}
@Test
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+ when(multipleAlmFeature.isEnabled()).thenReturn(true);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto bitbucketAlmSetting = db.almSettings().insertBitbucketAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertBitbucketAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed_and_bitbucket_cloud_exists() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertBitbucketCloudAlmSetting();
import org.sonar.db.DbTester;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
public DbTester db = DbTester.create();
private final Encryption encryption = mock(Encryption.class);
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+ private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
private WsActionTester ws = new WsActionTester(new CreateBitbucketCloudAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
- multipleAlmFeatureProvider)));
+ multipleAlmFeature)));
@Before
public void before() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
}
@Test
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+ when(multipleAlmFeature.isEnabled()).thenReturn(true);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto bitbucketAlmSetting = db.almSettings().insertBitbucketAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertBitbucketCloudAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed_and_bitbucket_server_exists() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertBitbucketAlmSetting();
@Test
public void fail_when_workspace_id_format_is_incorrect() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
String workspace = "workspace/name";
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
@Test
public void do_not_fail_when_workspace_id_format_is_correct() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
String workspace = "work-space_123";
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
import org.sonar.db.alm.setting.ALM;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
public DbTester db = DbTester.create();
private final Encryption encryption = mock(Encryption.class);
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+ private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
private final WsActionTester ws = new WsActionTester(new CreateGithubAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)),
- multipleAlmFeatureProvider)));
+ multipleAlmFeature)));
@Before
public void setUp() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
}
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+ when(multipleAlmFeature.isEnabled()).thenReturn(true);
AlmSettingDto gitHubAlmSetting = db.almSettings().insertGitHubAlmSetting();
TestRequest request = buildTestRequest().setParam("key", gitHubAlmSetting.getKey());
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
db.almSettings().insertGitHubAlmSetting();
TestRequest request = buildTestRequest();
import org.sonar.db.DbTester;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
private static String GITLAB_URL = "gitlab.com/api/v4";
private final Encryption encryption = mock(Encryption.class);
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+ private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
private WsActionTester ws = new WsActionTester(new CreateGitlabAction(db.getDbClient(), userSession,
- new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null), multipleAlmFeatureProvider)));
+ new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null), multipleAlmFeature)));
@Before
public void before() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
}
@Test
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+ when(multipleAlmFeature.isEnabled()).thenReturn(true);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto gitlabAlmSetting = db.almSettings().insertGitlabAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+ when(multipleAlmFeature.isEnabled()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertGitlabAlmSetting();
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.project.ProjectDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
private WsActionTester ws = new WsActionTester(new DeleteAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
- mock(MultipleAlmFeatureProvider.class))));
+ mock(MultipleAlmFeature.class))));
@Test
public void delete() {
import org.sonar.db.DbTester;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
private WsActionTester ws = new WsActionTester(new UpdateAzureAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
- mock(MultipleAlmFeatureProvider.class))));
+ mock(MultipleAlmFeature.class))));
@Test
public void update() {
import org.sonar.db.DbTester;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
private WsActionTester ws = new WsActionTester(new UpdateBitbucketAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
- mock(MultipleAlmFeatureProvider.class))));
+ mock(MultipleAlmFeature.class))));
@Test
public void update() {
import org.sonar.db.DbTester;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
private final WsActionTester ws = new WsActionTester(new UpdateBitbucketCloudAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)),
- mock(MultipleAlmFeatureProvider.class))));
+ mock(MultipleAlmFeature.class))));
@Test
public void update() {
import org.sonar.db.audit.model.DevOpsPlatformSettingNewValue;
import org.sonar.db.audit.model.SecretNewValue;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
private final WsActionTester ws = new WsActionTester(new UpdateGithubAction(db.getDbClient(), userSession,
new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)),
- mock(MultipleAlmFeatureProvider.class))));
+ mock(MultipleAlmFeature.class))));
private AlmSettingDto almSettingDto;
import org.sonar.db.DbTester;
import org.sonar.db.alm.setting.AlmSettingDto;
import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
private static String GITLAB_URL = "gitlab.com/api/v4";
private final Encryption encryption = mock(Encryption.class);
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+ private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
private WsActionTester ws = new WsActionTester(new UpdateGitlabAction(db.getDbClient(), userSession,
- new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null), multipleAlmFeatureProvider)));
+ new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null), multipleAlmFeature)));
@Before
public void before() {
- when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+ when(multipleAlmFeature.isEnabled()).thenReturn(true);
}
@Test
import org.sonar.alm.client.bitbucketserver.BitbucketServerSettingsValidator;
import org.sonar.alm.client.github.GithubGlobalSettingsValidator;
import org.sonar.alm.client.gitlab.GitlabGlobalSettingsValidator;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
@Rule
public DbTester db = DbTester.create();
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+ private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class));
- private final AlmSettingsSupport almSettingsSupport = new AlmSettingsSupport(db.getDbClient(), userSession, componentFinder, multipleAlmFeatureProvider);
+ private final AlmSettingsSupport almSettingsSupport = new AlmSettingsSupport(db.getDbClient(), userSession, componentFinder, multipleAlmFeature);
private final AzureDevOpsHttpClient azureDevOpsHttpClient = mock(AzureDevOpsHttpClient.class);
private final BitbucketCloudRestClient bitbucketCloudRestClient = mock(BitbucketCloudRestClient.class);
private final GitlabGlobalSettingsValidator gitlabSettingsValidator = mock(GitlabGlobalSettingsValidator.class);
import org.sonar.db.DbClient;
import org.sonar.db.dialect.H2;
import org.sonar.db.dialect.PostgreSql;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
import org.sonar.server.authentication.DefaultAdminCredentialsVerifier;
import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
import org.sonar.server.platform.WebServer;
private final IssueIndexSyncProgressChecker indexSyncProgressChecker = mock(IssueIndexSyncProgressChecker.class);
private final BranchFeatureRule branchFeature = new BranchFeatureRule();
private final PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class);
- private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
private final WebAnalyticsLoader webAnalyticsLoader = mock(WebAnalyticsLoader.class);
private final DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier = mock(DefaultAdminCredentialsVerifier.class);
assertJson(call()).isSimilarTo("{\"branchesEnabled\":false}");
}
- @Test
- public void multiple_alm_enabled() {
- init();
- when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
- assertJson(call()).isSimilarTo("{\"multipleAlmEnabled\":true}");
-
- when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
- assertJson(call()).isSimilarTo("{\"multipleAlmEnabled\":false}");
-
- }
-
@Test
public void return_need_issue_sync() {
init();
}});
pageRepository.start();
GlobalAction wsAction = new GlobalAction(pageRepository, settings.asConfig(), new ResourceTypes(resourceTypeTrees), server,
- webServer, dbClient, branchFeature, userSession, editionProvider, multipleAlmFeatureProvider, webAnalyticsLoader,
+ webServer, dbClient, branchFeature, userSession, editionProvider, webAnalyticsLoader,
indexSyncProgressChecker, defaultAdminCredentialsVerifier);
ws = new WsActionTester(wsAction);
wsAction.start();
import org.sonar.server.almintegration.ws.CredentialsEncoderHelper;
import org.sonar.server.almintegration.ws.ImportHelper;
import org.sonar.server.almintegration.ws.ProjectKeyGenerator;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
import org.sonar.server.almsettings.ws.AlmSettingsWsModule;
import org.sonar.server.authentication.AuthenticationModule;
import org.sonar.server.authentication.DefaultAdminCredentialsVerifierImpl;
CoreExtensionBootstraper.class,
CoreExtensionStopper.class,
- MultipleAlmFeatureProvider.class,
+ MultipleAlmFeature.class,
// ServerPush endpoints
new ServerPushModule(),