use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class DeleteActionTest method delete_alm_setting_also_delete_pat.
@Test
public void delete_alm_setting_also_delete_pat() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto almSettingDto = db.almSettings().insertBitbucketAlmSetting();
AlmPatDto almPatDto = db.almPats().insert(p -> p.setAlmSettingUuid(almSettingDto.getUuid()), p -> p.setUserUuid(user.getUuid()));
ws.newRequest().setParam("key", almSettingDto.getKey()).execute();
assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).isEmpty();
assertThat(db.getDbClient().almPatDao().selectByUuid(db.getSession(), almPatDto.getUuid())).isNotPresent();
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ListActionTest method list.
@Test
public void list() {
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto githubAlmSetting1 = db.almSettings().insertGitHubAlmSetting();
AlmSettingDto githubAlmSetting2 = db.almSettings().insertGitHubAlmSetting();
AlmSettingDto azureAlmSetting = db.almSettings().insertAzureAlmSetting();
AlmSettingDto azureAlmSettingWithoutUrl = db.almSettings().insertAzureAlmSetting(s -> s.setUrl(null));
AlmSettingDto gitlabAlmSetting = db.almSettings().insertGitlabAlmSetting();
AlmSettingDto gitlabAlmSettingWithoutUrl = db.almSettings().insertGitlabAlmSetting(s -> s.setUrl(null));
AlmSettingDto bitbucketAlmSetting = db.almSettings().insertBitbucketAlmSetting();
AlmSettingDto bitbucketCloudAlmSetting = db.almSettings().insertBitbucketCloudAlmSetting();
ListWsResponse response = ws.newRequest().executeProtobuf(ListWsResponse.class);
assertThat(response.getAlmSettingsList()).extracting(AlmSetting::getAlm, AlmSetting::getKey, AlmSetting::hasUrl, AlmSetting::getUrl).containsExactlyInAnyOrder(tuple(AlmSettings.Alm.github, githubAlmSetting1.getKey(), true, githubAlmSetting1.getUrl()), tuple(AlmSettings.Alm.github, githubAlmSetting2.getKey(), true, githubAlmSetting2.getUrl()), tuple(AlmSettings.Alm.azure, azureAlmSetting.getKey(), true, azureAlmSetting.getUrl()), tuple(AlmSettings.Alm.azure, azureAlmSettingWithoutUrl.getKey(), false, ""), tuple(AlmSettings.Alm.gitlab, gitlabAlmSetting.getKey(), true, gitlabAlmSetting.getUrl()), tuple(AlmSettings.Alm.gitlab, gitlabAlmSettingWithoutUrl.getKey(), false, ""), tuple(AlmSettings.Alm.bitbucket, bitbucketAlmSetting.getKey(), true, bitbucketAlmSetting.getUrl()), tuple(AlmSettings.Alm.bitbucketcloud, bitbucketCloudAlmSetting.getKey(), true, "https://bitbucket.org/" + bitbucketCloudAlmSetting.getAppId() + "/"));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ListActionTest method fail_when_missing_administer_permission_on_private_project.
@Test
public void fail_when_missing_administer_permission_on_private_project() {
UserDto user = db.users().insertUser();
ProjectDto project = db.components().insertPrivateProjectDto();
userSession.logIn(user).addProjectPermission(USER, project);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting();
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, project);
TestRequest request = ws.newRequest().setParam("project", project.getKey());
assertThatThrownBy(request::execute).isInstanceOf(ForbiddenException.class).hasMessage("Insufficient privileges");
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ListActionTest method fail_when_project_does_not_exist.
@Test
public void fail_when_project_does_not_exist() {
UserDto user = db.users().insertUser();
ProjectDto project = db.components().insertPrivateProjectDto();
userSession.logIn(user).addProjectPermission(ADMIN, project);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting();
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, project);
TestRequest request = ws.newRequest().setParam("project", "unknown");
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage("Project 'unknown' not found");
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class ListActionTest method fail_when_missing_administer_permission_on_public_project.
@Test
public void fail_when_missing_administer_permission_on_public_project() {
UserDto user = db.users().insertUser();
ProjectDto project = db.components().insertPublicProjectDto();
userSession.logIn(user).addProjectPermission(SCAN, project);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting();
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, project);
TestRequest request = ws.newRequest().setParam("project", project.getKey());
assertThatThrownBy(request::execute).isInstanceOf(ForbiddenException.class).hasMessage("Insufficient privileges");
}
Aggregations