use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldGetUnauthorizedExceptionWhenMissingPermissionOnCreatePR.
@Test
@SubjectAware(username = "trillian")
public void shouldGetUnauthorizedExceptionWhenMissingPermissionOnCreatePR() throws URISyntaxException, IOException {
byte[] pullRequestJson = loadJson("com/cloudogu/scm/review/pullRequest.json");
MockHttpRequest request = MockHttpRequest.post("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/space/name").content(pullRequestJson).contentType(PullRequestMediaType.PULL_REQUEST);
dispatcher.invoke(request, response);
assertEquals(HttpServletResponse.SC_FORBIDDEN, response.getStatus());
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PermissionCheckTest method shouldNotFailOnModificationsForAuthor.
@Test
@SubjectAware(username = "trillian", password = "secret")
public void shouldNotFailOnModificationsForAuthor() {
BasicComment comment = createComment("trillian");
PermissionCheck.checkModifyComment(createRepository(), comment);
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PermissionCheckTest method shouldAllowModificationsForPushPermission.
@Test
@SubjectAware(username = "slarti", password = "secret")
public void shouldAllowModificationsForPushPermission() {
BasicComment comment = createComment("author");
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 shouldNotFailOnModificationsForPushPermission.
@Test
@SubjectAware(username = "slarti", password = "secret")
public void shouldNotFailOnModificationsForPushPermission() {
BasicComment comment = createComment("trillian");
PermissionCheck.checkModifyComment(createRepository(), comment);
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PullRequestInformationHookTest method shouldSendMessageWithoutCreateLinks.
@Test
@SubjectAware(username = "dent")
public void shouldSendMessageWithoutCreateLinks() throws Exception {
when(branchProvider.getCreatedOrModified()).thenReturn(singletonList("branch_1"));
when(service.getBranchesCommand()).thenReturn(branchesCommand);
Branches branches = new Branches(Branch.defaultBranch("main", "", 0L));
when(branchesCommand.getBranches()).thenReturn(branches);
hook.checkForInformation(event);
List<String> sentMessages = messageCaptor.getAllValues();
assertThat(sentMessages).filteredOn(s -> s.length() > 0).isEmpty();
}
Aggregations