Search in sources :

Example 6 with PersonalAccessTokenNewValue

use of org.sonar.db.audit.model.PersonalAccessTokenNewValue in project sonarqube by SonarSource.

the class AlmPatDaoWithPersisterTest method insertAndUpdateArePersisted.

@Test
public void insertAndUpdateArePersisted() {
    when(uuidFactory.create()).thenReturn(A_UUID);
    AlmPatDto almPatDto = newAlmPatDto();
    underTest.insert(dbSession, almPatDto, "user-login", "alm-key");
    verify(auditPersister).addPersonalAccessToken(eq(dbSession), newValueCaptor.capture());
    PersonalAccessTokenNewValue newValue = newValueCaptor.getValue();
    assertThat(newValue).extracting(PersonalAccessTokenNewValue::getPatUuid, PersonalAccessTokenNewValue::getUserUuid, PersonalAccessTokenNewValue::getAlmSettingUuid, PersonalAccessTokenNewValue::getUserLogin, PersonalAccessTokenNewValue::getAlmSettingKey).containsExactly(almPatDto.getUuid(), almPatDto.getUserUuid(), almPatDto.getAlmSettingUuid(), "user-login", "alm-key");
    assertThat(newValue.toString()).contains("userLogin");
    String updated_pat = "updated pat";
    almPatDto.setPersonalAccessToken(updated_pat);
    system2.setNow(NOW + 1);
    underTest.update(dbSession, almPatDto, null, null);
    verify(auditPersister).updatePersonalAccessToken(eq(dbSession), newValueCaptor.capture());
}
Also used : PersonalAccessTokenNewValue(org.sonar.db.audit.model.PersonalAccessTokenNewValue) AlmPatsTesting.newAlmPatDto(org.sonar.db.alm.integration.pat.AlmPatsTesting.newAlmPatDto) Test(org.junit.Test)

Aggregations

PersonalAccessTokenNewValue (org.sonar.db.audit.model.PersonalAccessTokenNewValue)6 Test (org.junit.Test)4 AlmPatsTesting.newAlmPatDto (org.sonar.db.alm.integration.pat.AlmPatsTesting.newAlmPatDto)4 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)1 UserDto (org.sonar.db.user.UserDto)1