}
public List<Transition> listTransitions(String issueKey) {
- return issueService.listTransitions(issueKey);
+ return issueService.listTransitions(issueKey, UserSession.get());
}
public List<Transition> listTransitions(Issue issue) {
- return issueService.listTransitions(issue);
+ return issueService.listTransitions(issue, UserSession.get());
}
public List<String> listStatus() {
* <p/>
* Never return null, but return an empty list if the issue does not exist.
*/
- public List<Transition> listTransitions(String issueKey) {
- return listTransitions(loadIssue(issueKey).first());
+ public List<Transition> listTransitions(String issueKey, UserSession userSession) {
+ return listTransitions(loadIssue(issueKey).first(), userSession);
}
/**
* Never return null, but an empty list if the issue does not exist.
*/
- public List<Transition> listTransitions(@Nullable Issue issue) {
+ public List<Transition> listTransitions(@Nullable Issue issue, UserSession userSession) {
if (issue == null) {
return Collections.emptyList();
}
+ checkAuthorization(userSession, issue, UserRole.USER);
return workflow.outTransitions(issue);
}
actionPlanService.create(actionPlan, userSession);
verify(actionPlanDao).save(any(ActionPlanDto.class));
+ verify(authorizationDao).isAuthorizedComponentId(anyLong(), anyInt(), eq(UserRole.ADMIN));
}
@Test
assertThat(result).isNotNull();
assertThat(result.status()).isEqualTo("CLOSED");
+ verify(authorizationDao).isAuthorizedComponentId(anyLong(), anyInt(), eq(UserRole.ADMIN));
}
@Test
actionPlanService.update(actionPlan, userSession);
verify(actionPlanDao).update(any(ActionPlanDto.class));
+ verify(authorizationDao).isAuthorizedComponentId(anyLong(), anyInt(), eq(UserRole.ADMIN));
}
@Test
when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey("org.sonar.Sample").setId(1l));
actionPlanService.delete("ABCD", userSession);
verify(actionPlanDao).delete("ABCD");
+ verify(authorizationDao).isAuthorizedComponentId(anyLong(), anyInt(), eq(UserRole.ADMIN));
}
@Test
ActionPlan result = actionPlanService.findByKey("ABCD", userSession);
assertThat(result).isNotNull();
assertThat(result.key()).isEqualTo("ABCD");
+ verify(authorizationDao).isAuthorizedComponentId(anyLong(), anyInt(), eq(UserRole.USER));
}
@Test
Collection<ActionPlan> results = actionPlanService.findOpenByProjectKey("org.sonar.Sample", userSession);
assertThat(results).hasSize(1);
assertThat(results.iterator().next().key()).isEqualTo("ABCD");
+ verify(authorizationDao).isAuthorizedComponentId(anyLong(), anyInt(), eq(UserRole.USER));
}
@Test
Collection<ActionPlanStats> results = actionPlanService.findActionPlanStats("org.sonar.Sample", userSession);
assertThat(results).hasSize(1);
+ verify(authorizationDao).isAuthorizedComponentId(anyLong(), anyInt(), eq(UserRole.USER));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void should_list_transitions() {
+ grantAccess();
List<Transition> transitions = newArrayList(transition);
when(workflow.outTransitions(issue)).thenReturn(transitions);
- List<Transition> result = issueService.listTransitions("ABCD");
+ List<Transition> result = issueService.listTransitions("ABCD", userSession);
assertThat(result).hasSize(1);
assertThat(result.get(0)).isEqualTo(transition);
+ verify(authorizationDao).isAuthorizedComponentId(anyLong(), anyInt(), eq(UserRole.USER));
}
@Test
public void should_return_no_transition() {
+ grantAccess();
when(issueQueryResult.first()).thenReturn(null);
when(issueQueryResult.issues()).thenReturn(newArrayList((Issue) new DefaultIssue()));
- assertThat(issueService.listTransitions("ABCD")).isEmpty();
+ assertThat(issueService.listTransitions("ABCD", userSession)).isEmpty();
verifyZeroInteractions(workflow);
}