use of ca.corefacility.bioinformatics.irida.model.RemoteAPIToken in project irida by phac-nml.
the class OAuthTokenRestTemplateTest method testCreateRequestExpiredToken.
@Test(expected = IridaOAuthException.class)
public void testCreateRequestExpiredToken() throws URISyntaxException, IOException {
String tokenString = "token111111";
RemoteAPIToken token = new RemoteAPIToken(tokenString, remoteAPI, new Date(System.currentTimeMillis() - 10000));
when(tokenService.getToken(remoteAPI)).thenReturn(token);
restTemplate.createRequest(serviceURI, HttpMethod.GET);
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPIToken in project irida by phac-nml.
the class OAuthTokenRestTemplateTest method testCreateRequest.
@Test
public void testCreateRequest() throws URISyntaxException, IOException {
String tokenString = "token111111";
RemoteAPIToken token = new RemoteAPIToken(tokenString, remoteAPI, new Date(System.currentTimeMillis() + 10000));
when(tokenService.getToken(remoteAPI)).thenReturn(token);
ClientHttpRequest createRequest = restTemplate.createRequest(serviceURI, HttpMethod.GET);
verify(tokenService).getToken(remoteAPI);
assertNotNull(createRequest);
assertTrue(createRequest.getHeaders().containsKey("Authorization"));
List<String> list = createRequest.getHeaders().get("Authorization");
assertTrue(list.contains("Bearer " + tokenString));
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPIToken in project irida by phac-nml.
the class RemoteAPITokenServiceImplIT method addTokenExisting.
@Test
public void addTokenExisting() {
RemoteAPI api = apiService.read(1L);
RemoteAPIToken originalToken = tokenService.getToken(api);
RemoteAPIToken token = new RemoteAPIToken("111111111", api, new Date());
tokenService.create(token);
RemoteAPIToken readToken = tokenService.getToken(api);
assertNotEquals(token, originalToken);
assertEquals(token, readToken);
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPIToken in project irida by phac-nml.
the class RemoteAPITokenServiceImplIT method testAddToken.
@Test
public void testAddToken() {
RemoteAPI api = apiService.read(2L);
RemoteAPIToken token = new RemoteAPIToken("111111111", api, new Date());
tokenService.create(token);
RemoteAPIToken readToken = tokenService.getToken(api);
assertEquals(token, readToken);
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPIToken in project irida by phac-nml.
the class RemoteAPIControllerTest method testRead.
@Test
public void testRead() {
Long apiId = 1L;
ExtendedModelMap model = new ExtendedModelMap();
RemoteAPI client = new RemoteAPI("name", "http://uri", "a description", "id", "secret");
RemoteAPIToken remoteAPIToken = new RemoteAPIToken("xyz", client, new Date());
when(remoteAPIService.read(apiId)).thenReturn(client);
when(tokenService.getToken(client)).thenReturn(remoteAPIToken);
remoteAPIController.read(apiId, model, locale);
verify(remoteAPIService).read(apiId);
verify(tokenService).getToken(client);
assertTrue(model.containsAttribute("remoteApi"));
}
Aggregations