use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.
the class ListDefinitionsAction method handle.
@Override
public void handle(Request request, Response response) {
userSession.checkIsSystemAdministrator();
ListDefinitionsWsResponse wsResponse = doHandle();
writeProtobuf(wsResponse, request, response);
}
use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.
the class ListDefinitionsActionTest method list_is_ordered_by_create_date.
@Test
public void list_is_ordered_by_create_date() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
when(system2.now()).thenReturn(10_000_000_000L);
AlmSettingDto almSetting1 = db.almSettings().insertGitHubAlmSetting();
when(system2.now()).thenReturn(30_000_000_000L);
AlmSettingDto almSetting2 = db.almSettings().insertGitHubAlmSetting();
when(system2.now()).thenReturn(20_000_000_000L);
AlmSettingDto almSetting3 = db.almSettings().insertGitHubAlmSetting();
ListDefinitionsWsResponse wsResponse = ws.newRequest().executeProtobuf(ListDefinitionsWsResponse.class);
assertThat(wsResponse.getGithubList()).extracting(AlmSettingGithub::getKey).containsExactly(almSetting1.getKey(), almSetting3.getKey(), almSetting2.getKey());
}
use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.
the class ListDefinitionsActionTest method list_bitbucket_cloud_settings.
@Test
public void list_bitbucket_cloud_settings() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto almSetting1 = db.almSettings().insertBitbucketCloudAlmSetting(alm -> alm.setClientId("1").setClientSecret("2"));
AlmSettingDto almSetting2 = db.almSettings().insertBitbucketCloudAlmSetting(alm -> alm.setClientId("client_id").setClientSecret("client_secret"));
ListDefinitionsWsResponse wsResponse = ws.newRequest().executeProtobuf(ListDefinitionsWsResponse.class);
assertThat(wsResponse.getBitbucketcloudList()).extracting(AlmSettings.AlmSettingBitbucketCloud::getKey, AlmSettings.AlmSettingBitbucketCloud::getClientId).containsExactlyInAnyOrder(tuple(almSetting1.getKey(), "1"), tuple(almSetting2.getKey(), "client_id"));
}
use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.
the class ListDefinitionsActionTest method list_github_settings.
@Test
public void list_github_settings() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto almSetting1 = db.almSettings().insertGitHubAlmSetting(s -> s.setClientId(""));
AlmSettingDto almSetting2 = db.almSettings().insertGitHubAlmSetting(alm -> alm.setClientId("client_id").setClientSecret("client_secret"));
ListDefinitionsWsResponse wsResponse = ws.newRequest().executeProtobuf(ListDefinitionsWsResponse.class);
assertThat(wsResponse.getGithubList()).extracting(AlmSettingGithub::getKey, AlmSettingGithub::getUrl, AlmSettingGithub::getAppId, AlmSettingGithub::getClientId).containsExactlyInAnyOrder(tuple(almSetting1.getKey(), almSetting1.getUrl(), almSetting1.getAppId(), ""), tuple(almSetting2.getKey(), almSetting2.getUrl(), almSetting2.getAppId(), "client_id"));
}
use of org.sonarqube.ws.AlmSettings.ListDefinitionsWsResponse in project sonarqube by SonarSource.
the class ListDefinitionsActionTest method return_empty_list_when_no_settings.
@Test
public void return_empty_list_when_no_settings() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
ListDefinitionsWsResponse wsResponse = ws.newRequest().executeProtobuf(ListDefinitionsWsResponse.class);
assertThat(wsResponse.getGithubList()).isEmpty();
}
Aggregations