use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class BitbucketCloudValidatorTest method validate_forwardsExceptionFromRestClient.
@Test
public void validate_forwardsExceptionFromRestClient() {
AlmSettingDto dto = mock(AlmSettingDto.class);
when(dto.getAppId()).thenReturn(EXAMPLE_APP_ID);
when(dto.getClientId()).thenReturn("clientId");
when(dto.getDecryptedClientSecret(any())).thenReturn("secret");
doThrow(new IllegalArgumentException("Exception from bitbucket cloud rest client")).when(bitbucketCloudRestClient).validate(any(), any(), any());
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> underTest.validate(dto)).withMessage("Exception from bitbucket cloud rest client");
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class AlmPatDaoWithPersisterTest method deleteByAlmSettingWithoutAffectedRowsIsNotPersisted.
@Test
public void deleteByAlmSettingWithoutAffectedRowsIsNotPersisted() {
AlmSettingDto almSettingDto = db.almSettings().insertBitbucketAlmSetting();
clearInvocations(auditPersister);
underTest.deleteByAlmSetting(dbSession, almSettingDto);
verifyNoInteractions(auditPersister);
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class AlmPatDaoWithPersisterTest method deleteByAlmSettingIsPersisted.
@Test
public void deleteByAlmSettingIsPersisted() {
when(uuidFactory.create()).thenReturn(A_UUID);
AlmSettingDto almSettingDto = db.almSettings().insertBitbucketAlmSetting();
AlmPatDto almPat = newAlmPatDto();
almPat.setAlmSettingUuid(almSettingDto.getUuid());
underTest.insert(dbSession, almPat, null, almSettingDto.getKey());
verify(auditPersister).addPersonalAccessToken(eq(dbSession), newValueCaptor.capture());
underTest.deleteByAlmSetting(dbSession, almSettingDto);
verify(auditPersister).deletePersonalAccessToken(eq(dbSession), newValueCaptor.capture());
PersonalAccessTokenNewValue newValue = newValueCaptor.getValue();
assertThat(newValue).extracting(PersonalAccessTokenNewValue::getPatUuid, PersonalAccessTokenNewValue::getAlmSettingUuid, PersonalAccessTokenNewValue::getAlmSettingKey).containsExactly(null, almPat.getAlmSettingUuid(), almSettingDto.getKey());
assertThat(newValue.toString()).doesNotContain("userUuid");
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class AlmPatDaoTest method deleteByAlmSetting.
@Test
public void deleteByAlmSetting() {
when(uuidFactory.create()).thenReturn(A_UUID);
AlmSettingDto almSettingDto = db.almSettings().insertBitbucketAlmSetting();
AlmPatDto almPat = newAlmPatDto();
almPat.setAlmSettingUuid(almSettingDto.getUuid());
underTest.insert(dbSession, almPat, null, null);
underTest.deleteByAlmSetting(dbSession, almSettingDto);
assertThat(underTest.selectByUuid(dbSession, almPat.getUuid())).isNotPresent();
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class AlmPatDaoTest method selectByAlmSetting.
@Test
public void selectByAlmSetting() {
when(uuidFactory.create()).thenReturn(A_UUID);
AlmSettingDto almSetting = newGithubAlmSettingDto();
almSettingDao.insert(dbSession, almSetting);
AlmPatDto almPatDto = newAlmPatDto();
almPatDto.setAlmSettingUuid(almSetting.getUuid());
String userUuid = randomAlphanumeric(40);
almPatDto.setUserUuid(userUuid);
underTest.insert(dbSession, almPatDto, null, null);
assertThat(underTest.selectByUserAndAlmSetting(dbSession, userUuid, almSetting).get()).extracting(AlmPatDto::getUuid, AlmPatDto::getPersonalAccessToken, AlmPatDto::getUserUuid, AlmPatDto::getAlmSettingUuid, AlmPatDto::getCreatedAt, AlmPatDto::getUpdatedAt).containsExactly(A_UUID, almPatDto.getPersonalAccessToken(), userUuid, almSetting.getUuid(), NOW, NOW);
assertThat(underTest.selectByUserAndAlmSetting(dbSession, randomAlphanumeric(40), newGithubAlmSettingDto())).isNotPresent();
}
Aggregations