use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldReturnCollectionWithOnlySelfLink.
@Test
@SubjectAware(username = "rr")
public void shouldReturnCollectionWithOnlySelfLink() throws URISyntaxException, IOException {
JsonNode links = invokeAndReturnLinks();
assertThat(links.has("self")).isTrue();
assertThat(links.has("create")).isFalse();
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldReturnCollectionWithCreateLink.
@Test
@SubjectAware(username = "slarti")
public void shouldReturnCollectionWithCreateLink() throws URISyntaxException, IOException {
JsonNode links = invokeAndReturnLinks();
assertThat(links.has("create")).isTrue();
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldHandleMissingBranch.
@Test
@SubjectAware(username = "slarti")
public void shouldHandleMissingBranch() throws URISyntaxException, IOException {
when(branchResolver.resolve(repository, "sourceBranch")).thenThrow(new NotFoundException("x", "y"));
byte[] pullRequestJson = loadJson("com/cloudogu/scm/review/pullRequest.json");
MockHttpRequest request = MockHttpRequest.post("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/" + REPOSITORY_NAMESPACE + "/" + REPOSITORY_NAME).content(pullRequestJson).contentType(PullRequestMediaType.PULL_REQUEST);
dispatcher.invoke(request, response);
assertThat(response.getContentAsString()).containsPattern("could not find.*");
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldReturnBranchesNotDifferResultIfSameBranches.
@Test
@SubjectAware(username = "dent")
public void shouldReturnBranchesNotDifferResultIfSameBranches() throws URISyntaxException, IOException {
mockLoggedInUser(new User("dent"));
mockLogCommandForPullRequestCheck(ImmutableList.of(new Changeset()));
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/ns/repo/check?source=master&target=master");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).contains("\"status\":\"BRANCHES_NOT_DIFFER\"");
assertThat(response.getContentAsString()).contains("\"_links\":{\"self\":{\"href\":\"/v2/pull-requests/ns/repo/check?source=master&target=master\"}}");
}
use of com.github.sdorra.shiro.SubjectAware in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldRejectInvalidPullRequest.
@Test
@SubjectAware(username = "dent")
public void shouldRejectInvalidPullRequest() throws URISyntaxException, IOException {
byte[] pullRequestJson = loadJson("com/cloudogu/scm/review/pullRequest_invalid.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_BAD_REQUEST, response.getStatus());
verify(store, never()).add(any());
}
Aggregations