use of com.sun.jersey.spi.container.ContainerRequest in project ORCID-Source by ORCID.
the class APIEndpointParserTest method testAPIEndpointParserWithoutApiVersionWithOrcid.
@Test
public void testAPIEndpointParserWithoutApiVersionWithOrcid() {
ContainerRequest request = getRequest("https://localhost:8443/orcid-api-web/1234-4321-1234-4321/orcid-bio");
APIEndpointParser parser = new APIEndpointParser(request);
assertNotNull(parser.getApiVersion());
assertEquals("", parser.getApiVersion());
assertEquals("orcid-bio", parser.getCategory());
assertEquals("1234-4321-1234-4321", parser.getOrcidId());
}
use of com.sun.jersey.spi.container.ContainerRequest in project ORCID-Source by ORCID.
the class APIEndpointParserTest method testAPIEndpointParserWithoutApiVersionOrOrcid.
@Test
public void testAPIEndpointParserWithoutApiVersionOrOrcid() {
ContainerRequest request = getRequest("https://localhost:8443/orcid-api-web/oauth/token");
APIEndpointParser parser = new APIEndpointParser(request);
assertNotNull(parser.getApiVersion());
assertEquals("", parser.getApiVersion());
assertEquals("oauth", parser.getCategory());
assertNull(parser.getOrcidId());
}
use of com.sun.jersey.spi.container.ContainerRequest in project ORCID-Source by ORCID.
the class APIEndpointParserTest method testAPIEndpointParserWithApiVersionAndOrcid.
@Test
public void testAPIEndpointParserWithApiVersionAndOrcid() {
ContainerRequest request = getRequest("https://localhost:8443/orcid-api-web/v2.0/1234-4321-1234-4321/works");
APIEndpointParser parser = new APIEndpointParser(request);
assertEquals("v2.0", parser.getApiVersion());
assertEquals("works", parser.getCategory());
assertEquals("1234-4321-1234-4321", parser.getOrcidId());
}
use of com.sun.jersey.spi.container.ContainerRequest in project ORCID-Source by ORCID.
the class AnalyticsProcessTest method testAnalyticsProcessForPublicClient.
@Test
public void testAnalyticsProcessForPublicClient() throws InterruptedException {
String clientDetailsId = "some-client-details-id";
Mockito.when(clientDetailsEntityCacheManager.retrieve(Mockito.eq(clientDetailsId))).thenReturn(getPublicClient());
Mockito.when(profileEntityCacheManager.retrieve(Mockito.eq("1234-4321-1234-4321"))).thenReturn(getProfileEntity());
ContainerRequest request = getRequest();
ContainerResponse response = getResponse(request);
AnalyticsProcess process = new AnalyticsProcess();
process.setRequest(request);
process.setResponse(response);
process.setClientDetailsId(clientDetailsId);
process.setAnalyticsClient(analyticsClient);
process.setClientDetailsEntityCacheManager(clientDetailsEntityCacheManager);
process.setProfileEntityCacheManager(profileEntityCacheManager);
process.setPublicApi(true);
process.setIp("37.14.150.83");
Thread t = new Thread(process);
t.start();
t.join();
ArgumentCaptor<AnalyticsData> captor = ArgumentCaptor.forClass(AnalyticsData.class);
Mockito.verify(analyticsClient).sendAnalyticsData(captor.capture());
AnalyticsData data = captor.getValue();
assertNotNull(data);
assertEquals("POST", data.getMethod());
assertEquals("works", data.getCategory());
assertEquals("Public API v2.0", data.getApiVersion());
assertEquals(ClientType.PUBLIC_CLIENT.value() + " | a public client - some-client-details-id", data.getClientDetailsString());
assertEquals("37.14.150.0", data.getIpAddress());
assertEquals(Integer.valueOf(200), data.getResponseCode());
assertEquals("https://localhost:8443/orcid-api-web/v2.0/" + hashedOrcid + "/works", data.getUrl());
assertEquals("blah", data.getUserAgent());
assertEquals("application/xml", data.getContentType());
}
use of com.sun.jersey.spi.container.ContainerRequest in project ORCID-Source by ORCID.
the class AnalyticsProcessTest method testAnalyticsProcessForIPv6.
@Test
public void testAnalyticsProcessForIPv6() throws InterruptedException {
String clientDetailsId = "some-client-details-id";
Mockito.when(clientDetailsEntityCacheManager.retrieve(Mockito.eq(clientDetailsId))).thenReturn(getPublicClient());
Mockito.when(profileEntityCacheManager.retrieve(Mockito.eq("1234-4321-1234-4321"))).thenReturn(getProfileEntity());
ContainerRequest request = getRequest();
ContainerResponse response = getResponse(request);
AnalyticsProcess process = new AnalyticsProcess();
process.setRequest(request);
process.setResponse(response);
process.setClientDetailsId(clientDetailsId);
process.setAnalyticsClient(analyticsClient);
process.setClientDetailsEntityCacheManager(clientDetailsEntityCacheManager);
process.setProfileEntityCacheManager(profileEntityCacheManager);
process.setPublicApi(true);
process.setIp("0:0:0:0:0:0:0:1");
Thread t = new Thread(process);
t.start();
t.join();
ArgumentCaptor<AnalyticsData> captor = ArgumentCaptor.forClass(AnalyticsData.class);
Mockito.verify(analyticsClient).sendAnalyticsData(captor.capture());
AnalyticsData data = captor.getValue();
assertNotNull(data);
assertEquals("POST", data.getMethod());
assertEquals("works", data.getCategory());
assertEquals("Public API v2.0", data.getApiVersion());
assertEquals(ClientType.PUBLIC_CLIENT.value() + " | a public client - some-client-details-id", data.getClientDetailsString());
assertEquals("0:0:0:0:0:0:0:0", data.getIpAddress());
assertEquals(Integer.valueOf(200), data.getResponseCode());
assertEquals("https://localhost:8443/orcid-api-web/v2.0/" + hashedOrcid + "/works", data.getUrl());
assertEquals("blah", data.getUserAgent());
assertEquals("application/xml", data.getContentType());
}
Aggregations