Search in sources :

Example 6 with IridaOAuthException

use of ca.corefacility.bioinformatics.irida.exceptions.IridaOAuthException in project irida by phac-nml.

the class RemoteAPIControllerTest method testConnectToAPI.

@Test(expected = IridaOAuthException.class)
public void testConnectToAPI() {
    Long apiId = 1L;
    ExtendedModelMap model = new ExtendedModelMap();
    RemoteAPI client = new RemoteAPI("name", "http://uri", "a description", "id", "secret");
    when(remoteAPIService.read(apiId)).thenReturn(client);
    when(projectRemoteService.getServiceStatus(client)).thenThrow(new IridaOAuthException("invalid token", client));
    remoteAPIController.connectToAPI(apiId, model);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) IridaOAuthException(ca.corefacility.bioinformatics.irida.exceptions.IridaOAuthException) ExtendedModelMap(org.springframework.ui.ExtendedModelMap) Test(org.junit.Test)

Example 7 with IridaOAuthException

use of ca.corefacility.bioinformatics.irida.exceptions.IridaOAuthException in project irida by phac-nml.

the class RemoteAPIControllerTest method testHandleOAuthException.

@Test
public void testHandleOAuthException() throws MalformedURLException, OAuthSystemException {
    HttpServletRequest request = mock(HttpServletRequest.class);
    String redirect = "http://request";
    when(request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).thenReturn(redirect);
    RemoteAPI client = new RemoteAPI("name", "http://uri", "a description", "id", "secret");
    IridaOAuthException ex = new IridaOAuthException("msg", client);
    remoteAPIController.handleOAuthException(request, ex);
    verify(authController).authenticate(client, redirect);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) IridaOAuthException(ca.corefacility.bioinformatics.irida.exceptions.IridaOAuthException) Test(org.junit.Test)

Aggregations

IridaOAuthException (ca.corefacility.bioinformatics.irida.exceptions.IridaOAuthException)7 RemoteAPI (ca.corefacility.bioinformatics.irida.model.RemoteAPI)4 Test (org.junit.Test)3 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)2 Project (ca.corefacility.bioinformatics.irida.model.project.Project)2 ProjectSynchronizationException (ca.corefacility.bioinformatics.irida.exceptions.ProjectSynchronizationException)1 RemoteAPIToken (ca.corefacility.bioinformatics.irida.model.RemoteAPIToken)1 User (ca.corefacility.bioinformatics.irida.model.user.User)1 DTProject (ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTProject)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpStatus (org.springframework.http.HttpStatus)1 ClientHttpRequest (org.springframework.http.client.ClientHttpRequest)1 ExtendedModelMap (org.springframework.ui.ExtendedModelMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1