use of org.sonar.db.audit.model.PersonalAccessTokenNewValue in project sonarqube by SonarSource.
the class AlmPatDao method update.
public void update(DbSession dbSession, AlmPatDto almPatDto, @Nullable String userLogin, @Nullable String almSettingKey) {
long now = system2.now();
almPatDto.setUpdatedAt(now);
getMapper(dbSession).update(almPatDto);
auditPersister.updatePersonalAccessToken(dbSession, new PersonalAccessTokenNewValue(almPatDto, userLogin, almSettingKey));
}
use of org.sonar.db.audit.model.PersonalAccessTokenNewValue 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.audit.model.PersonalAccessTokenNewValue in project sonarqube by SonarSource.
the class AlmPatDaoWithPersisterTest method deleteByUserIsPersisted.
@Test
public void deleteByUserIsPersisted() {
when(uuidFactory.create()).thenReturn(A_UUID);
UserDto userDto = db.users().insertUser();
AlmPatDto almPat = newAlmPatDto();
almPat.setUserUuid(userDto.getUuid());
underTest.insert(dbSession, almPat, userDto.getLogin(), null);
verify(auditPersister).addPersonalAccessToken(eq(dbSession), newValueCaptor.capture());
underTest.deleteByUser(dbSession, userDto);
verify(auditPersister).deletePersonalAccessToken(eq(dbSession), newValueCaptor.capture());
PersonalAccessTokenNewValue newValue = newValueCaptor.getValue();
assertThat(newValue).extracting(PersonalAccessTokenNewValue::getPatUuid, PersonalAccessTokenNewValue::getUserUuid, PersonalAccessTokenNewValue::getUserLogin, PersonalAccessTokenNewValue::getAlmSettingKey).containsExactly(null, userDto.getUuid(), userDto.getLogin(), null);
assertThat(newValue.toString()).doesNotContain("patUuid");
}
use of org.sonar.db.audit.model.PersonalAccessTokenNewValue in project sonarqube by SonarSource.
the class AlmPatDao method insert.
public void insert(DbSession dbSession, AlmPatDto almPatDto, @Nullable String userLogin, @Nullable String almSettingKey) {
String uuid = uuidFactory.create();
long now = system2.now();
almPatDto.setUuid(uuid);
almPatDto.setCreatedAt(now);
almPatDto.setUpdatedAt(now);
getMapper(dbSession).insert(almPatDto);
auditPersister.addPersonalAccessToken(dbSession, new PersonalAccessTokenNewValue(almPatDto, userLogin, almSettingKey));
}
use of org.sonar.db.audit.model.PersonalAccessTokenNewValue in project sonarqube by SonarSource.
the class AlmPatDaoWithPersisterTest method deleteIsPersisted.
@Test
public void deleteIsPersisted() {
when(uuidFactory.create()).thenReturn(A_UUID);
AlmPatDto almPat = newAlmPatDto();
underTest.insert(dbSession, almPat, null, null);
verify(auditPersister).addPersonalAccessToken(eq(dbSession), newValueCaptor.capture());
underTest.delete(dbSession, almPat, null, null);
verify(auditPersister).deletePersonalAccessToken(eq(dbSession), newValueCaptor.capture());
PersonalAccessTokenNewValue newValue = newValueCaptor.getValue();
assertThat(newValue).extracting(PersonalAccessTokenNewValue::getPatUuid, PersonalAccessTokenNewValue::getUserUuid, PersonalAccessTokenNewValue::getAlmSettingUuid, PersonalAccessTokenNewValue::getUserLogin, PersonalAccessTokenNewValue::getAlmSettingKey).containsExactly(almPat.getUuid(), almPat.getUserUuid(), almPat.getAlmSettingUuid(), null, null);
assertThat(newValue.toString()).doesNotContain("userLogin");
}
Aggregations