use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class SearchBitbucketServerReposActionTest method use_projectKey_to_disambiguate_when_multiple_projects_are_binded_on_one_bitbucketserver_repo.
@Test
public void use_projectKey_to_disambiguate_when_multiple_projects_are_binded_on_one_bitbucketserver_repo() {
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertBitbucketAlmSetting();
db.almPats().insert(dto -> {
dto.setAlmSettingUuid(almSetting.getUuid());
dto.setUserUuid(user.getUuid());
});
ProjectDto project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("B"));
ProjectDto project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("A"));
db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project1, s -> s.setAlmRepo("projectKey2"), s -> s.setAlmSlug("repo-slug-2"));
db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project2, s -> s.setAlmRepo("projectKey2"), s -> s.setAlmSlug("repo-slug-2"));
AlmIntegrations.SearchBitbucketserverReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(SearchBitbucketserverReposWsResponse.class);
assertThat(response.getIsLastPage()).isTrue();
assertThat(response.getRepositoriesList()).extracting(AlmIntegrations.BBSRepo::getId, AlmIntegrations.BBSRepo::getName, AlmIntegrations.BBSRepo::getSlug, AlmIntegrations.BBSRepo::getSqProjectKey, AlmIntegrations.BBSRepo::getProjectKey).containsExactlyInAnyOrder(tuple(1L, "repoName1", "repo-slug-1", "", "projectKey1"), tuple(3L, "repoName2", "repo-slug-2", "A", "projectKey2"));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ImportGithubProjectActionTest method fail_when_personal_access_token_doesnt_exist.
@Test
public void fail_when_personal_access_token_doesnt_exist() {
AlmSettingDto githubAlmSetting = setupAlm();
TestRequest request = ws.newRequest().setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()).setParam(PARAM_ORGANIZATION, "test").setParam(PARAM_REPOSITORY_KEY, "test/repo");
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("No personal access token found");
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ImportGithubProjectActionTest method fail_project_already_exist.
@Test
public void fail_project_already_exist() {
AlmSettingDto githubAlmSetting = setupAlm();
db.almPats().insert(p -> p.setAlmSettingUuid(githubAlmSetting.getUuid()).setUserUuid(userSession.getUuid()));
db.components().insertPublicProject(p -> p.setDbKey("octocat_Hello-World"));
GithubApplicationClient.Repository repository = new GithubApplicationClient.Repository(1L, "Hello-World", false, "octocat/Hello-World", "https://github.sonarsource.com/api/v3/repos/octocat/Hello-World", "main");
when(appClient.getRepository(any(), any(), any(), any())).thenReturn(Optional.of(repository));
TestRequest request = ws.newRequest().setParam(PARAM_ALM_SETTING, githubAlmSetting.getKey()).setParam(PARAM_ORGANIZATION, "octocat").setParam(PARAM_REPOSITORY_KEY, "octocat/Hello-World");
assertThatThrownBy(request::execute).isInstanceOf(BadRequestException.class).hasMessage("Could not create null, key already exists: octocat_Hello-World");
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class CreateGitlabActionTest method create_with_url.
@Test
public void create_with_url() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
ws.newRequest().setParam("key", "Gitlab - Dev Team").setParam("url", GITLAB_URL).setParam("personalAccessToken", "98765432100").execute();
assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getUrl, s -> s.getDecryptedPersonalAccessToken(encryption)).containsOnly(tuple("Gitlab - Dev Team", GITLAB_URL, "98765432100"));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class DeleteActionTest method fail_when_missing_administer_system_permission.
@Test
public void fail_when_missing_administer_system_permission() {
UserDto user = db.users().insertUser();
userSession.logIn(user);
AlmSettingDto almSettingDto = db.almSettings().insertGitHubAlmSetting();
assertThatThrownBy(() -> ws.newRequest().setParam("key", almSettingDto.getKey()).execute()).isInstanceOf(ForbiddenException.class);
}
Aggregations