@Test public void should_remove_all_permissions() { db.prepareDbUnit(getClass(), "should_remove_all_permissions.xml"); assertThat(underTest.selectGroupPermissions(db.getSession(), "devs", 123L)).hasSize(1); assertThat(underTest.selectGroupPermissions(db.getSession(), "other", 123L)).isEmpty(); assertThat(underTest.selectUserPermissions(db.getSession(), "dave.loper", 123L)).hasSize(1); assertThat(underTest.selectUserPermissions(db.getSession(), "other.user", 123L)).isEmpty(); underTest.removeAllPermissions(db.getSession(), 123L); db.getSession().commit(); db.assertDbUnitTable( getClass(), "should_remove_all_permissions-result.xml", "group_roles", "group_id", "resource_id", "role"); db.assertDbUnitTable( getClass(), "should_remove_all_permissions-result.xml", "user_roles", "user_id", "resource_id", "role"); assertThat(underTest.selectGroupPermissions(db.getSession(), "devs", 123L)).isEmpty(); assertThat(underTest.selectUserPermissions(db.getSession(), "dave.loper", 123L)).isEmpty(); }
@Test public void retrieve_resource_group_permissions() { db.prepareDbUnit(getClass(), "resourceGroupPermissions.xml"); assertThat(underTest.selectGroupPermissions(db.getSession(), "sonar-administrators", 1L)) .containsOnly(UserRole.ADMIN, UserRole.CODEVIEWER); assertThat(underTest.selectGroupPermissions(db.getSession(), "sonar-users", 1L)) .containsOnly(UserRole.CODEVIEWER); }
@Test public void retrieve_global_group_permissions() { db.prepareDbUnit(getClass(), "globalGroupPermissions.xml"); assertThat(underTest.selectGroupPermissions(db.getSession(), "sonar-administrators", null)) .containsOnly( GlobalPermissions.SYSTEM_ADMIN, GlobalPermissions.QUALITY_PROFILE_ADMIN, GlobalPermissions.DASHBOARD_SHARING); assertThat(underTest.selectGroupPermissions(db.getSession(), "sonar-users", null)) .containsOnly(GlobalPermissions.DASHBOARD_SHARING); assertThat(underTest.selectGroupPermissions(db.getSession(), DefaultGroups.ANYONE, null)) .containsOnly(GlobalPermissions.PROVISIONING, GlobalPermissions.SCAN_EXECUTION); assertThat(underTest.selectGroupPermissions(db.getSession(), "anyone", null)) .containsOnly(GlobalPermissions.PROVISIONING, GlobalPermissions.SCAN_EXECUTION); assertThat(underTest.selectGroupPermissions(db.getSession(), "AnYoNe", null)) .containsOnly(GlobalPermissions.PROVISIONING, GlobalPermissions.SCAN_EXECUTION); }