use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PermissionCheckTest method shouldAllowModificationsForAuthor.
@Test
@SubjectAware(username = "trillian", password = "secret")
public void shouldAllowModificationsForAuthor() {
BasicComment comment = createComment("trillian");
boolean modificationsAllowed = PermissionCheck.mayModifyComment(createRepository(), comment);
assertTrue(modificationsAllowed);
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PermissionCheckTest method shouldDisallowModificationsForNonAuthorWithoutPermission.
@Test
@SubjectAware(username = "trillian", password = "secret")
public void shouldDisallowModificationsForNonAuthorWithoutPermission() {
BasicComment comment = createComment("other");
boolean modificationsAllowed = PermissionCheck.mayModifyComment(createRepository(), comment);
assertFalse(modificationsAllowed);
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PermissionCheckTest method shouldFailOnModificationsForNonAuthorWithoutPermission.
@Test(expected = UnauthorizedException.class)
@SubjectAware(username = "trillian", password = "secret")
public void shouldFailOnModificationsForNonAuthorWithoutPermission() {
BasicComment comment = createComment("other");
PermissionCheck.checkModifyComment(createRepository(), comment);
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentRootResourceTest method shouldNotThrowConflictExceptionIfNoExpectationsInUrl.
@Test
@SubjectAware(username = "slarti", password = "secret")
public void shouldNotThrowConflictExceptionIfNoExpectationsInUrl() throws URISyntaxException, UnsupportedEncodingException {
when(pullRequestService.get(any(), any(), any())).thenReturn(PULL_REQUEST);
when(branchRevisionResolver.getRevisions(any(), eq(PULL_REQUEST))).thenReturn(new BranchRevisionResolver.RevisionResult("source", "target"));
byte[] commentJson = "{\"comment\" : \"this is my comment\"}".getBytes();
MockHttpRequest request = MockHttpRequest.post("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/space/name/1/comments").content(commentJson).contentType(MediaType.APPLICATION_JSON);
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_CREATED, response.getStatus());
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class CommentRootResourceTest method shouldNotThrowConflictExceptionIfOnlyOneExpectationInUrl.
@Test
@SubjectAware(username = "slarti", password = "secret")
public void shouldNotThrowConflictExceptionIfOnlyOneExpectationInUrl() throws URISyntaxException, UnsupportedEncodingException {
when(pullRequestService.get(any(), any(), any())).thenReturn(PULL_REQUEST);
when(branchRevisionResolver.getRevisions(any(), eq(PULL_REQUEST))).thenReturn(new BranchRevisionResolver.RevisionResult("source", "target"));
byte[] commentJson = "{\"comment\" : \"this is my comment\"}".getBytes();
MockHttpRequest request = MockHttpRequest.post("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/space/name/1/comments?sourceRevision=source").content(commentJson).contentType(MediaType.APPLICATION_JSON);
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_CREATED, response.getStatus());
}
Aggregations