use of com.sun.jersey.core.header.InBoundHeaders in project ORCID-Source by ORCID.
the class ApiVersionCheckFilterTest method api2_0VersionTest.
@Test
public void api2_0VersionTest() {
MockHttpServletRequest mockReq = new MockHttpServletRequest();
mockReq.setAttribute("X-Forwarded-Proto", "https");
OrcidHttpServletRequestWrapper requestWrapper = new OrcidHttpServletRequestWrapper(mockReq);
WebApplication webApp = Mockito.mock(WebApplication.class, Mockito.RETURNS_MOCKS);
URI baseUri = URI.create("http://localhost:8443/orcid-api-web/");
URI requestUri = URI.create("http://localhost:8443/orcid-api-web/v2.0/0000-0001-7510-9252/activities");
InBoundHeaders headers = new InBoundHeaders();
ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]);
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "POST", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "PUT", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "DELETE", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "GET", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
}
use of com.sun.jersey.core.header.InBoundHeaders in project ORCID-Source by ORCID.
the class ApiVersionCheckFilterTest method api2_0_rc2VersionTest.
@Test
public void api2_0_rc2VersionTest() {
MockHttpServletRequest mockReq = new MockHttpServletRequest();
mockReq.setAttribute("X-Forwarded-Proto", "https");
OrcidHttpServletRequestWrapper requestWrapper = new OrcidHttpServletRequestWrapper(mockReq);
WebApplication webApp = Mockito.mock(WebApplication.class, Mockito.RETURNS_MOCKS);
URI baseUri = URI.create("http://localhost:8443/orcid-api-web/");
URI requestUri = URI.create("http://localhost:8443/orcid-api-web/v2.0_rc2/0000-0001-7510-9252/activities");
InBoundHeaders headers = new InBoundHeaders();
ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]);
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "POST", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "PUT", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "DELETE", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "GET", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
}
use of com.sun.jersey.core.header.InBoundHeaders in project ORCID-Source by ORCID.
the class ApiVersionCheckFilterTest method webhooksShouldWorkWithoutVersionTest.
@Test
public void webhooksShouldWorkWithoutVersionTest() {
WebApplication webApp = Mockito.mock(WebApplication.class, Mockito.RETURNS_MOCKS);
URI baseUri = URI.create("http://localhost:8443/orcid-api-web/");
URI requestUri = URI.create("http://localhost:8443/orcid-api-web/0000-0001-7510-9252/webhook/http://test.orcid.org");
InBoundHeaders headers = new InBoundHeaders();
ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]);
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "POST", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "PUT", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "DELETE", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
}
use of com.sun.jersey.core.header.InBoundHeaders in project ORCID-Source by ORCID.
the class ApiVersionCheckFilterTest method apiDefaultVersionTest.
@Test
public void apiDefaultVersionTest() {
WebApplication webApp = Mockito.mock(WebApplication.class, Mockito.RETURNS_MOCKS);
URI baseUri = URI.create("http://localhost:8443/orcid-api-web/");
URI requestUri = URI.create("http://localhost:8443/orcid-api-web/0000-0001-7510-9252/activities");
InBoundHeaders headers = new InBoundHeaders();
ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]);
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "POST", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
fail();
} catch (OrcidBadRequestException e) {
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "PUT", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
fail();
} catch (OrcidBadRequestException e) {
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "DELETE", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
fail();
} catch (OrcidBadRequestException e) {
} catch (Exception e) {
fail();
}
ContainerRequest containerRequest = new ContainerRequest(webApp, "GET", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = getApiVersionCheckFilter("http");
filter.filter(containerRequest);
}
use of com.sun.jersey.core.header.InBoundHeaders in project ORCID-Source by ORCID.
the class ApiVersionCheckFilterTest method api2_0_rc3VersionTest.
@Test
public void api2_0_rc3VersionTest() {
MockHttpServletRequest mockReq = new MockHttpServletRequest();
mockReq.setAttribute("X-Forwarded-Proto", "https");
OrcidHttpServletRequestWrapper requestWrapper = new OrcidHttpServletRequestWrapper(mockReq);
WebApplication webApp = Mockito.mock(WebApplication.class, Mockito.RETURNS_MOCKS);
URI baseUri = URI.create("http://localhost:8443/orcid-api-web/");
URI requestUri = URI.create("http://localhost:8443/orcid-api-web/v2.0_rc3/0000-0001-7510-9252/activities");
InBoundHeaders headers = new InBoundHeaders();
ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[0]);
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "POST", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "PUT", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "DELETE", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
try {
ContainerRequest containerRequest = new ContainerRequest(webApp, "GET", baseUri, requestUri, headers, inputStream);
ApiVersionCheckFilter filter = new ApiVersionCheckFilter(requestWrapper);
filter.filter(containerRequest);
} catch (Exception e) {
fail();
}
}
Aggregations