use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class IssuePermissionTest method need_user_permission_on_project_to_see_issue_changelog.
/**
* SONAR-4839
*/
@Test
public void need_user_permission_on_project_to_see_issue_changelog() {
SonarClient client = orchestrator.getServer().adminWsClient();
Issue issue = client.issueClient().find(IssueQuery.create().componentRoots("sample")).list().get(0);
client.issueClient().assign(issue.key(), "admin");
String withBrowsePermission = "with-browse-permission";
String withoutBrowsePermission = "without-browse-permission";
try {
client.userClient().create(UserParameters.create().login(withBrowsePermission).name(withBrowsePermission).password("password").passwordConfirmation("password"));
addUserPermission(withBrowsePermission, "sample", "user");
client.userClient().create(UserParameters.create().login(withoutBrowsePermission).name(withoutBrowsePermission).password("password").passwordConfirmation("password"));
// By default, it's the group anyone that have the permission user, it would be better to remove all groups on this permission
removeGroupPermission("anyone", "sample", "user");
// Without user permission, a user cannot see issue changelog on the project
try {
changelog(issue.key(), withoutBrowsePermission, "password");
fail();
} catch (Exception e) {
assertThat(e).isInstanceOf(org.sonarqube.ws.client.HttpException.class).describedAs("403");
}
// Without user permission, a user cannot see issues on the project
assertThat(changelog(issue.key(), withBrowsePermission, "password").getChangelogList()).isNotEmpty();
} finally {
client.userClient().deactivate(withBrowsePermission);
client.userClient().deactivate(withoutBrowsePermission);
}
}
use of org.sonar.wsclient.issue.Issue in project sonarqube by SonarSource.
the class AutoAssignTest method update_author_and_assignee_when_scm_is_activated.
/**
* SONAR-7098
*
* Given two versions of same project:
* v1: issue, but no SCM data
* v2: old issue and SCM data
* Expected: all issues should be associated with authors
*/
@Test
public void update_author_and_assignee_when_scm_is_activated() {
createUser(SIMON_USER, SIMON_USER);
// Run a first analysis without SCM
projectAnalysis.withProperties("sonar.scm.disabled", "true").run();
List<Issue> issues = searchIssues();
assertThat(issues).isNotEmpty();
// No author and assignee are set
for (Issue issue : issues) {
assertThat(issue.author()).isEmpty();
}
assertThat(search(IssueQuery.create().assigned(true)).list()).isEmpty();
// Run a second analysis with SCM
projectAnalysis.run();
issues = searchIssues();
assertThat(issues).isNotEmpty();
// Authors and assignees are set
for (Issue issue : issues) {
assertThat(issue.author()).isNotEmpty();
}
assertThat(search(IssueQuery.create().assignees(SIMON_USER)).list()).hasSize(3);
}
Aggregations