Search in sources :

Example 11 with AuthorisationException

use of com.atlassian.stash.exception.AuthorisationException 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 12 with AuthorisationException

use of com.atlassian.stash.exception.AuthorisationException 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)12 KeyedMessage (com.atlassian.stash.i18n.KeyedMessage)7 Test (org.junit.Test)7 Repository (com.atlassian.stash.repository.Repository)5 ImmutableMap (com.google.common.collect.ImmutableMap)3 JenkinsServerConfiguration (com.palantir.stash.stashbot.persistence.JenkinsServerConfiguration)3 IOException (java.io.IOException)3 SQLException (java.sql.SQLException)3 ServletException (javax.servlet.ServletException)3 SoyException (com.atlassian.soy.renderer.SoyException)2 PageRequest (com.atlassian.stash.util.PageRequest)2 PageRequestImpl (com.atlassian.stash.util.PageRequestImpl)2 RepositoryConfiguration (com.palantir.stash.stashbot.persistence.RepositoryConfiguration)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 PullRequest (com.atlassian.stash.pull.PullRequest)1 PullRequestSearchRequest (com.atlassian.stash.pull.PullRequestSearchRequest)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 GlobalSettings (com.palantir.stash.codesearch.admin.GlobalSettings)1