use of org.sonar.db.permission.GlobalPermission.ADMINISTER in project sonarqube by SonarSource.
the class UserPermissionDaoTest method deleteByUserId.
@Test
public void deleteByUserId() {
UserDto user1 = insertUser();
UserDto user2 = insertUser();
ComponentDto project = db.components().insertPrivateProject();
db.users().insertPermissionOnUser(user1, SCAN);
db.users().insertPermissionOnUser(user1, ADMINISTER);
db.users().insertProjectPermissionOnUser(user1, ADMINISTER_QUALITY_GATES.getKey(), project);
db.users().insertPermissionOnUser(user2, SCAN);
db.users().insertProjectPermissionOnUser(user2, ADMINISTER_QUALITY_GATES.getKey(), project);
underTest.deleteByUserUuid(dbSession, user1);
dbSession.commit();
assertThat(db.select("select user_uuid as \"userUuid\", component_uuid as \"projectUuid\", role as \"permission\" from user_roles")).extracting((row) -> row.get("userUuid"), (row) -> row.get("projectUuid"), (row) -> row.get("permission")).containsOnly(tuple(user2.getUuid(), null, SCAN.getKey()), tuple(user2.getUuid(), project.uuid(), ADMINISTER_QUALITY_GATES.getKey()));
}
use of org.sonar.db.permission.GlobalPermission.ADMINISTER in project sonarqube by SonarSource.
the class ListActionTest method obfuscate_credentials_in_webhook_URLs.
@Test
public void obfuscate_credentials_in_webhook_URLs() {
String url = "http://foo:barouf@toto/bop";
String expectedUrl = "http://***:******@toto/bop";
WebhookDto webhook1 = webhookDbTester.insert(newGlobalWebhook("aaa", t -> t.setUrl(url)), null, null);
webhookDeliveryDbTester.insert(newDto("WH1-DELIVERY-1-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
webhookDeliveryDbTester.insert(newDto("WH1-DELIVERY-2-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
webhookDbTester.insert(newGlobalWebhook("bbb", t -> t.setUrl(url)), null, null);
userSession.logIn().addPermission(ADMINISTER);
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
List<Webhooks.ListResponseElement> elements = response.getWebhooksList();
assertThat(elements).hasSize(2).extracting(Webhooks.ListResponseElement::getUrl).containsOnly(expectedUrl);
}
Aggregations