use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class OrganizationCreationImplTest method createForUser_creates_guarded_organization_with_key_name_and_description_generated_from_user_login_and_name_and_associated_to_user.
@Test
public void createForUser_creates_guarded_organization_with_key_name_and_description_generated_from_user_login_and_name_and_associated_to_user() {
UserDto user = dbTester.users().insertUser(A_LOGIN);
when(organizationValidation.generateKeyFrom(A_LOGIN)).thenReturn(SLUG_OF_A_LOGIN);
mockForSuccessfulInsert(SOME_UUID, SOME_DATE);
enableCreatePersonalOrg(true);
underTest.createForUser(dbSession, user);
OrganizationDto organization = dbClient.organizationDao().selectByKey(dbSession, SLUG_OF_A_LOGIN).get();
assertThat(organization.getUuid()).isEqualTo(SOME_UUID);
assertThat(organization.getKey()).isEqualTo(SLUG_OF_A_LOGIN);
assertThat(organization.getName()).isEqualTo(user.getName());
assertThat(organization.getDescription()).isEqualTo(user.getName() + "'s personal organization");
assertThat(organization.getUrl()).isNull();
assertThat(organization.getAvatarUrl()).isNull();
assertThat(organization.isGuarded()).isTrue();
assertThat(organization.getUserId()).isEqualTo(user.getId());
assertThat(organization.getCreatedAt()).isEqualTo(SOME_DATE);
assertThat(organization.getUpdatedAt()).isEqualTo(SOME_DATE);
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class CreateActionTest method request_creates_default_template_for_owner_group_and_anyone.
@Test
public void request_creates_default_template_for_owner_group_and_anyone() {
mockForSuccessfulInsert(SOME_UUID, SOME_DATE);
UserDto user = dbTester.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
executeRequest("orgFoo");
OrganizationDto organization = dbClient.organizationDao().selectByKey(dbSession, "orgfoo").get();
GroupDto ownersGroup = dbClient.groupDao().selectByName(dbSession, organization.getUuid(), "Owners").get();
PermissionTemplateDto defaultTemplate = dbClient.permissionTemplateDao().selectByName(dbSession, organization.getUuid(), "default template");
assertThat(defaultTemplate.getName()).isEqualTo("Default template");
assertThat(defaultTemplate.getDescription()).isEqualTo("Default permission template of organization orgFoo");
DefaultTemplates defaultTemplates = dbClient.organizationDao().getDefaultTemplates(dbSession, organization.getUuid()).get();
assertThat(defaultTemplates.getProjectUuid()).isEqualTo(defaultTemplate.getUuid());
assertThat(defaultTemplates.getViewUuid()).isNull();
assertThat(dbClient.permissionTemplateDao().selectGroupPermissionsByTemplateId(dbSession, defaultTemplate.getId())).extracting(PermissionTemplateGroupDto::getGroupId, PermissionTemplateGroupDto::getPermission).containsOnly(tuple(ownersGroup.getId(), UserRole.ADMIN), tuple(ownersGroup.getId(), UserRole.ISSUE_ADMIN), tuple(ownersGroup.getId(), GlobalPermissions.SCAN_EXECUTION), tuple(0, UserRole.USER), tuple(0, UserRole.CODEVIEWER));
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class SearchMyOrganizationsActionTest method verify_response_example.
@Test
public void verify_response_example() {
OrganizationDto organization1 = dbTester.organizations().insertForKey("my-org");
OrganizationDto organization2 = dbTester.organizations().insertForKey("foo-corp");
UserDto user = dbTester.users().insertUser();
dbTester.users().insertPermissionOnUser(organization1, user, SYSTEM_ADMIN);
dbTester.users().insertPermissionOnUser(organization2, user, SYSTEM_ADMIN);
userSessionRule.logIn(user);
TestResponse response = underTest.newRequest().execute();
assertJson(response.getInput()).isSimilarTo(underTest.getDef().responseExampleAsString());
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class EnableSupportActionTest method enabling_support_saves_internal_property_and_flags_caller_as_root.
@Test
public void enabling_support_saves_internal_property_and_flags_caller_as_root() {
UserDto user = db.users().insertUser();
UserDto otherUser = db.users().insertUser();
verifyFeatureEnabled(false);
verifyRoot(user, false);
verifyRoot(otherUser, false);
logInAsSystemAdministrator(user.getLogin());
call();
verifyFeatureEnabled(true);
verifyRoot(user, true);
verifyRoot(otherUser, false);
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class PermissionIndexerTest method initializeOnStartup_does_not_grant_access_to_anybody.
@Test
public void initializeOnStartup_does_not_grant_access_to_anybody() {
ComponentDto project = createAndIndexProject();
UserDto user = userDbTester.insertUser();
GroupDto group = userDbTester.insertGroup();
indexOnStartup();
verifyAnyoneNotAuthorized(project);
verifyNotAuthorized(project, user);
verifyNotAuthorized(project, user, group);
}
Aggregations