use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class CreateAzureActionTest method create.
@Test
public void create() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
ws.newRequest().setParam("key", "Azure Server - Dev Team").setParam("personalAccessToken", "98765432100").setParam("url", "https://ado.sonarqube.com/").execute();
assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, s -> s.getDecryptedPersonalAccessToken(encryption), AlmSettingDto::getUrl).containsOnly(tuple("Azure Server - Dev Team", "98765432100", "https://ado.sonarqube.com/"));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class CreateAzureActionTest method fail_when_key_is_already_used.
@Test
public void fail_when_key_is_already_used() {
when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto azureAlmSetting = db.almSettings().insertAzureAlmSetting();
assertThatThrownBy(() -> ws.newRequest().setParam("key", azureAlmSetting.getKey()).setParam("personalAccessToken", "98765432100").setParam("url", "https://ado.sonarqube.com/").execute()).isInstanceOf(IllegalArgumentException.class).hasMessageContaining(String.format("An ALM setting with key '%s' already exist", azureAlmSetting.getKey()));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class CreateBitbucketCloudActionTest method create.
@Test
public void create() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
ws.newRequest().setParam("key", "Bitbucket Server - Dev Team").setParam("clientId", "id").setParam("clientSecret", "secret").setParam("workspace", "workspace1").execute();
assertThat(db.getDbClient().almSettingDao().selectAll(db.getSession())).extracting(AlmSettingDto::getKey, AlmSettingDto::getClientId, s -> s.getDecryptedClientSecret(encryption), AlmSettingDto::getAppId).containsOnly(tuple("Bitbucket Server - Dev Team", "id", "secret", "workspace1"));
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class CheckPatActionTest method fail_when_personal_access_token_is_invalid_for_bitbucket.
@Test
public void fail_when_personal_access_token_is_invalid_for_bitbucket() {
when(bitbucketServerRestClient.getRecentRepo(any(), any())).thenThrow(new IllegalArgumentException("Invalid personal access token"));
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());
});
TestRequest request = ws.newRequest().setParam("almSetting", almSetting.getKey());
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("Invalid personal access token");
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class CheckPatActionTest method check_pat_for_azure_devops.
@Test
public void check_pat_for_azure_devops() {
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(PROVISION_PROJECTS);
AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
db.almPats().insert(dto -> {
dto.setAlmSettingUuid(almSetting.getUuid());
dto.setUserUuid(user.getUuid());
dto.setPersonalAccessToken(PAT_SECRET);
});
ws.newRequest().setParam("almSetting", almSetting.getKey()).execute();
assertThat(almSetting.getUrl()).isNotNull();
verify(azureDevOpsPrHttpClient).checkPAT(almSetting.getUrl(), PAT_SECRET);
}
Aggregations