use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class UserPermissionDaoWithPersisterTest method userProjectPermissionDeleteWithoutAffectedRowsIsNotPersisted.
@Test
public void userProjectPermissionDeleteWithoutAffectedRowsIsNotPersisted() {
UserDto user = insertUser(u -> u.setLogin("login1").setName("Marius").setEmail("email1@email.com"));
ComponentDto project = db.components().insertPrivateProject();
underTest.deleteProjectPermission(dbSession, user, SYSTEM_ADMIN, project);
verify(auditPersister).addUser(any(), any());
verify(auditPersister).addComponent(any(), any());
verifyNoMoreInteractions(auditPersister);
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class UserPermissionDaoWithPersisterTest method userGlobalPermissionInsertWithTemplateIsPersisted.
@Test
public void userGlobalPermissionInsertWithTemplateIsPersisted() {
PermissionTemplateDto templateDto = newPermissionTemplateDto();
db.getDbClient().permissionTemplateDao().insert(db.getSession(), templateDto);
UserDto user = insertUser(u -> u.setLogin("login1").setName("Marius").setEmail("email1@email.com"));
UserPermissionDto dto = new UserPermissionDto(Uuids.create(), SYSTEM_ADMIN, user.getUuid(), null);
underTest.insert(dbSession, dto, null, user, templateDto);
verify(auditPersister).addUserPermission(eq(dbSession), newValueCaptor.capture());
UserPermissionNewValue newValue = newValueCaptor.getValue();
assertThat(newValue).extracting(UserPermissionNewValue::getPermissionUuid, UserPermissionNewValue::getUserUuid, UserPermissionNewValue::getUserLogin, UserPermissionNewValue::getComponentUuid, UserPermissionNewValue::getPermission, UserPermissionNewValue::getComponentName, UserPermissionNewValue::getQualifier, UserPermissionNewValue::getPermissionTemplateId, UserPermissionNewValue::getPermissionTemplateName).containsExactly(dto.getUuid(), user.getUuid(), user.getLogin(), null, dto.getPermission(), null, null, templateDto.getUuid(), templateDto.getName());
assertThat(newValue.toString()).doesNotContain("projectUuid");
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class UserPermissionDaoWithPersisterTest method deleteUserPermissionByUserUuidIsPersisted.
@Test
public void deleteUserPermissionByUserUuidIsPersisted() {
UserDto user = insertUser(u -> u.setLogin("login1").setName("Marius").setEmail("email1@email.com"));
ComponentDto project = db.components().insertPrivateProject();
UserPermissionDto dto = new UserPermissionDto(Uuids.create(), SYSTEM_ADMIN, user.getUuid(), project.uuid());
underTest.insert(dbSession, dto, project, user, null);
underTest.deleteByUserUuid(dbSession, user);
verify(auditPersister).deleteUserPermission(eq(dbSession), newValueCaptor.capture());
UserPermissionNewValue newValue = newValueCaptor.getValue();
assertNewValue(newValue, null, user.getUuid(), user.getLogin(), null, null, null, null, null);
assertThat(newValue.toString()).contains("userUuid");
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class UserPermissionDaoWithPersisterTest method deleteUserPermissionOfAnyUserIsPersisted.
@Test
public void deleteUserPermissionOfAnyUserIsPersisted() {
UserDto user = insertUser(u -> u.setLogin("login1").setName("Marius").setEmail("email1@email.com"));
ComponentDto project = db.components().insertPrivateProject();
UserPermissionDto dto = new UserPermissionDto(Uuids.create(), SCAN_EXECUTION, user.getUuid(), project.uuid());
underTest.insert(dbSession, dto, project, user, null);
underTest.deleteProjectPermissionOfAnyUser(dbSession, SCAN_EXECUTION, project);
verify(auditPersister).deleteUserPermission(eq(dbSession), newValueCaptor.capture());
UserPermissionNewValue newValue = newValueCaptor.getValue();
assertNewValue(newValue, null, null, null, project.uuid(), dto.getPermission(), project.getKey(), project.name(), "TRK");
assertThat(newValue.toString()).doesNotContain("userUuid");
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class UserPermissionDaoWithPersisterTest method deleteUserPermissionByUserUuidWithoutAffectedRowsIsNotPersisted.
@Test
public void deleteUserPermissionByUserUuidWithoutAffectedRowsIsNotPersisted() {
UserDto user = insertUser(u -> u.setLogin("login1").setName("Marius").setEmail("email1@email.com"));
underTest.deleteByUserUuid(dbSession, user);
verify(auditPersister).addUser(any(), any());
verifyNoMoreInteractions(auditPersister);
}
Aggregations