Search in sources :

Example 6 with KeyedMessage

use of com.atlassian.stash.i18n.KeyedMessage in project stashbot by palantir.

the class RepoConfigurationServletTest method postTestWhenLockedSrc.

@Test
public void postTestWhenLockedSrc() throws Exception {
    when(jsc.getLocked()).thenReturn(true);
    when(jsc2.getLocked()).thenReturn(false);
    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());
}
Also used : AuthorisationException(com.atlassian.stash.exception.AuthorisationException) KeyedMessage(com.atlassian.stash.i18n.KeyedMessage) AuthorisationException(com.atlassian.stash.exception.AuthorisationException) Test(org.junit.Test)

Example 7 with KeyedMessage

use of com.atlassian.stash.i18n.KeyedMessage in project stash-codesearch-plugin by palantir.

the class GlobalSettingsServletTest method getTestWhenNotSysAdmin.

@Test
public void getTestWhenNotSysAdmin() throws Exception {
    Mockito.doThrow(new AuthorisationException(new KeyedMessage("testException", "testException", "testException"))).when(pvs).validateForGlobal(Permission.SYS_ADMIN);
    servlet.doGet(req, res);
    Mockito.verify(res).sendError(Mockito.eq(HttpServletResponse.SC_UNAUTHORIZED), Mockito.any(String.class));
    Mockito.verify(res, Mockito.never()).getWriter();
}
Also used : AuthorisationException(com.atlassian.stash.exception.AuthorisationException) KeyedMessage(com.atlassian.stash.i18n.KeyedMessage) Test(org.junit.Test)

Aggregations

AuthorisationException (com.atlassian.stash.exception.AuthorisationException)7 KeyedMessage (com.atlassian.stash.i18n.KeyedMessage)7 Test (org.junit.Test)7 Repository (com.atlassian.stash.repository.Repository)1