use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class SearchAzureReposActionTest method search_repos_with_project_name.
@Test
public void search_repos_with_project_name() {
AlmSettingDto almSetting = insertAlmSetting();
SearchAzureReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).setParam("projectName", "project-1").executeProtobuf(SearchAzureReposWsResponse.class);
assertThat(response.getRepositoriesList()).extracting(AzureRepo::getName, AzureRepo::getProjectName).containsExactlyInAnyOrder(tuple("repoName-1", "project-1"), tuple("repoName-2", "project-2"));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class SearchBitbucketCloudReposActionTest method use_projectKey_to_disambiguate_when_multiple_projects_are_binded_on_one_bitbucket_repo.
@Test
public void use_projectKey_to_disambiguate_when_multiple_projects_are_binded_on_one_bitbucket_repo() {
when(bitbucketCloudRestClient.searchRepos(any(), any(), any(), any(), any())).thenReturn(getRepositoryList());
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertBitbucketCloudAlmSetting();
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("repo-slug-2"));
db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project2, s -> s.setAlmRepo("repo-slug-2"));
SearchBitbucketcloudReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(SearchBitbucketcloudReposWsResponse.class);
assertThat(response.getRepositoriesList()).extracting(BBCRepo::getUuid, BBCRepo::getName, BBCRepo::getSlug, BBCRepo::getProjectKey, BBCRepo::getSqProjectKey).containsExactlyInAnyOrder(tuple("REPO-UUID-ONE", "repoName1", "repo-slug-1", "projectKey1", ""), tuple("REPO-UUID-TWO", "repoName2", "repo-slug-2", "projectKey2", "A"));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class SearchBitbucketCloudReposActionTest method list_repos.
@Test
public void list_repos() {
when(bitbucketCloudRestClient.searchRepos(any(), any(), any(), any(), any())).thenReturn(getRepositoryList());
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertBitbucketCloudAlmSetting();
db.almPats().insert(dto -> {
dto.setAlmSettingUuid(almSetting.getUuid());
dto.setPersonalAccessToken("abc:xyz");
dto.setUserUuid(user.getUuid());
});
ProjectDto projectDto = db.components().insertPrivateProjectDto();
db.almSettings().insertBitbucketCloudProjectAlmSetting(almSetting, projectDto, s -> s.setAlmRepo("repo-slug-2"));
SearchBitbucketcloudReposWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).setParam("p", "1").setParam("ps", "100").executeProtobuf(SearchBitbucketcloudReposWsResponse.class);
assertThat(response.getIsLastPage()).isFalse();
assertThat(response.getPaging().getPageIndex()).isOne();
assertThat(response.getPaging().getPageSize()).isEqualTo(100);
assertThat(response.getRepositoriesList()).extracting(BBCRepo::getUuid, BBCRepo::getName, BBCRepo::getSlug, BBCRepo::getProjectKey, BBCRepo::getSqProjectKey, BBCRepo::getWorkspace).containsExactlyInAnyOrder(tuple("REPO-UUID-ONE", "repoName1", "repo-slug-1", "projectKey1", "", almSetting.getAppId()), tuple("REPO-UUID-TWO", "repoName2", "repo-slug-2", "projectKey2", projectDto.getKey(), almSetting.getAppId()));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ListBitbucketServerProjectsActionTest method list_projects.
@Test
public void list_projects() {
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertGitHubAlmSetting();
db.almPats().insert(dto -> {
dto.setAlmSettingUuid(almSetting.getUuid());
dto.setUserUuid(user.getUuid());
});
ListBitbucketserverProjectsWsResponse response = ws.newRequest().setParam("almSetting", almSetting.getKey()).executeProtobuf(ListBitbucketserverProjectsWsResponse.class);
assertThat(response.getProjectsCount()).isOne();
assertThat(response.getProjectsList()).extracting(AlmIntegrations.AlmProject::getKey, AlmIntegrations.AlmProject::getName).containsExactly(tuple("key", "name"));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class GetGithubClientIdActionTest method fail_when_client_id_does_not_exist.
@Test
public void fail_when_client_id_does_not_exist() {
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(GlobalPermission.PROVISION_PROJECTS);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting(s -> s.setClientId(null));
TestRequest request = ws.newRequest().setParam(GetGithubClientIdAction.PARAM_ALM_SETTING, githubAlmSetting.getKey());
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage("No client ID for setting with key '%s'", githubAlmSetting.getKey());
}
Aggregations