use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class SsoAuthenticatorTest method verifyUserInDb.
private void verifyUserInDb(String expectedLogin, String expectedName, @Nullable String expectedEmail, GroupDto... expectedGroups) {
UserDto userDto = db.users().selectUserByLogin(expectedLogin).get();
assertThat(userDto.isActive()).isTrue();
assertThat(userDto.getName()).isEqualTo(expectedName);
assertThat(userDto.getEmail()).isEqualTo(expectedEmail);
assertThat(userDto.getExternalIdentity()).isEqualTo(expectedLogin);
assertThat(userDto.getExternalIdentityProvider()).isEqualTo("sonarqube");
verityUserGroups(expectedLogin, expectedGroups);
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class SsoAuthenticatorTest method update_user_when_user_in_token_but_refresh_time_is_old.
@Test
public void update_user_when_user_in_token_but_refresh_time_is_old() throws Exception {
startWithSso();
UserDto user = insertUser(DEFAULT_USER, group1);
// Refresh time was updated 6 minutes ago => more than 5 minutes
setUserInToken(user, NOW - 6 * 60 * 1000L);
HttpServletRequest request = createRequest(DEFAULT_LOGIN, "new name", "new email", GROUP2);
underTest.authenticate(request, response);
// User is updated
verifyUserInDb(DEFAULT_LOGIN, "new name", "new email", group2);
verifyTokenIsUpdated(NOW);
verify(authenticationEvent).loginSuccess(request, DEFAULT_LOGIN, Source.sso());
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class IssueServiceMediumTest method assign.
@Test
public void assign() {
RuleDto rule = newRule();
ComponentDto project = newProject();
ComponentDto file = newFile(project);
userSessionRule.logIn("john").addProjectUuidPermissions(UserRole.USER, project.uuid());
IssueDto issue = saveIssue(IssueTesting.newDto(rule, file, project));
UserDto user = new UserDto().setLogin("perceval").setName("Perceval");
db.userDao().insert(session, user);
session.commit();
index();
assertThat(getIssueByKey(issue.getKey()).assignee()).isNull();
service.assign(issue.getKey(), user.getLogin());
assertThat(getIssueByKey(issue.getKey()).assignee()).isEqualTo("perceval");
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class SearchActionMediumTest method load_additional_fields.
@Test
public void load_additional_fields() throws Exception {
db.userDao().insert(session, new UserDto().setLogin("simon").setName("Simon").setEmail("simon@email.com"));
db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization2, "PROJECT_ID").setKey("PROJECT_KEY").setLanguage("java"));
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("js"));
setProjectPermission(project, USER);
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2").setAuthorLogin("John").setAssignee("simon");
db.issueDao().insert(session, issue);
session.commit();
IssueIndexer r = tester.get(IssueIndexer.class);
r.indexOnStartup(r.getIndexTypes());
WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam("additionalFields", "_all").execute();
result.assertJson(this.getClass(), "load_additional_fields.json");
}
use of org.sonar.db.user.UserDto in project sonarqube by SonarSource.
the class SearchActionMediumTest method issue_with_comment_hidden.
@Test
public void issue_with_comment_hidden() throws Exception {
db.userDao().insert(session, new UserDto().setLogin("john").setName("John").setEmail("john@email.com"));
db.userDao().insert(session, new UserDto().setLogin("fabrice").setName("Fabrice").setEmail("fabrice@email.com"));
ComponentDto project = insertComponent(ComponentTesting.newProjectDto(otherOrganization1, "PROJECT_ID").setKey("PROJECT_KEY"));
setDefaultProjectPermission(project);
ComponentDto file = insertComponent(ComponentTesting.newFileDto(project, null, "FILE_ID").setKey("FILE_KEY"));
IssueDto issue = IssueTesting.newDto(newRule(), file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2");
db.issueDao().insert(session, issue);
tester.get(IssueChangeDao.class).insert(session, new IssueChangeDto().setIssueKey(issue.getKey()).setKey("COMMENT-ABCD").setChangeData("*My comment*").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserLogin("john").setCreatedAt(DateUtils.parseDateTime("2014-09-09T12:00:00+0000").getTime()));
tester.get(IssueChangeDao.class).insert(session, new IssueChangeDto().setIssueKey(issue.getKey()).setKey("COMMENT-ABCE").setChangeData("Another comment").setChangeType(IssueChangeDto.TYPE_COMMENT).setUserLogin("fabrice").setCreatedAt(DateUtils.parseDateTime("2014-09-10T19:10:03+0000").getTime()));
session.commit();
IssueIndexer r = tester.get(IssueIndexer.class);
r.indexOnStartup(r.getIndexTypes());
userSessionRule.logIn("john");
WsTester.Result result = wsTester.newGetRequest(CONTROLLER_ISSUES, ACTION_SEARCH).setParam(PARAM_HIDE_COMMENTS, "true").execute();
result.assertJson(this.getClass(), "issue_with_comment_hidden.json");
assertThat(result.outputAsString()).doesNotContain("fabrice");
}
Aggregations