use of com.atlassian.stash.i18n.KeyedMessage in project stashbot by palantir.
the class JenkinsConfigurationServletTest method getTestWhenNotSysAdmin.
@Test
public void getTestWhenNotSysAdmin() throws Exception {
when(req.getRemoteUser()).thenReturn("nonAdminStashUser");
doThrow(new AuthorisationException(new KeyedMessage("testException", "testException", "testException"))).when(pvs).validateForGlobal(Permission.SYS_ADMIN);
jcs.doGet(req, res);
verify(res).sendError(eq(HttpServletResponse.SC_UNAUTHORIZED), any(String.class));
}
use of com.atlassian.stash.i18n.KeyedMessage in project stashbot by palantir.
the class RepoConfigurationServletTest method getTestWhenNotRepoAdmin.
@Test
public void getTestWhenNotRepoAdmin() throws Exception {
doThrow(new AuthorisationException(new KeyedMessage("testException", "testException", "testException"))).when(pvs).validateForRepository(Mockito.any(Repository.class), eq(Permission.REPO_ADMIN));
rcs.doGet(req, res);
verify(res).sendError(eq(HttpServletResponse.SC_UNAUTHORIZED), Mockito.any(String.class));
}
use of com.atlassian.stash.i18n.KeyedMessage in project stashbot by palantir.
the class RepoConfigurationServletTest method postTestWhenLockedDst.
@Test
public void postTestWhenLockedDst() throws Exception {
when(jsc.getLocked()).thenReturn(false);
when(jsc2.getLocked()).thenReturn(true);
Exception permissionException = new AuthorisationException(new KeyedMessage("permission exceptionz", null, null));
Mockito.doThrow(permissionException).when(pvs).validateForGlobal(Permission.SYS_ADMIN);
when(req.getParameter("jenkinsServerName")).thenReturn("default2");
when(cpm.getRepositoryConfigurationForRepository(mockRepo)).thenReturn(rc);
rcs.doPost(req, res);
verify(res).sendError(Mockito.anyInt(), Mockito.anyString());
}
use of com.atlassian.stash.i18n.KeyedMessage in project stash-codesearch-plugin by palantir.
the class GlobalSettingsServletTest method getTestWhenNotLoggedIn.
@Test
public void getTestWhenNotLoggedIn() throws Exception {
Mockito.doThrow(new AuthorisationException(new KeyedMessage("testException", "testException", "testException"))).when(pvs).validateAuthenticated();
servlet.doGet(req, res);
Mockito.verify(res).sendRedirect(Mockito.anyString());
Mockito.verify(res, Mockito.never()).getWriter();
}
use of com.atlassian.stash.i18n.KeyedMessage in project stashbot by palantir.
the class JenkinsConfigurationServletTest method getTestWhenNotLoggedIn.
@Test
public void getTestWhenNotLoggedIn() throws Exception {
when(req.getRemoteUser()).thenReturn(null);
doThrow(new AuthorisationException(new KeyedMessage("testException", "testException", "testException"))).when(pvs).validateAuthenticated();
jcs.doGet(req, res);
verify(res).sendRedirect(Mockito.anyString());
verify(res, Mockito.never()).getWriter();
}
Aggregations