use of com.sun.jersey.spi.container.ContainerRequest in project simba-os by cegeka.
the class SimbaGatewayTest method login.
@Test
public void login() throws Exception {
Client authenticationServicemock = setupSimbaServiceToReturnASimbaAuthenticationService();
ContainerRequest containerRequestMock = mock(ContainerRequest.class);
SimbaCredentials simbaCredentials = mock(SimbaCredentials.class);
RequestData requestData = mock(RequestData.class);
SSOToken expectedSSOToken = new SSOToken("token");
ActionDescriptor actionDescriptor = new ActionDescriptorBuilderForTests().withActionTypes(ActionType.MAKE_COOKIE).withSsoToken(expectedSSOToken).build();
when(simbaCredentialsFactoryMock.create(containerRequestMock, false)).thenReturn(simbaCredentials);
when(simbaCredentials.asRequestData()).thenReturn(requestData);
when(authenticationServicemock.processRequest(requestData, LOGIN_AUTHENTICATE_CHAIN)).thenReturn(actionDescriptor);
Optional<String> actualSSOToken = simbaGateway.login(containerRequestMock);
assertThat(actualSSOToken.isPresent()).isTrue();
assertThat(actualSSOToken.get()).isEqualTo(expectedSSOToken.getToken());
}
use of com.sun.jersey.spi.container.ContainerRequest in project simba-os by cegeka.
the class SimbaCredentialsFactoryTest method create_SSOTokenIsMappedProperly.
@Test
public void create_SSOTokenIsMappedProperly() throws Exception {
String token = "55687";
ContainerRequest containerRequest = new ContainerRequestBuilderForTests().withRequestUri(URI.create(REQUESTURL)).addHeader(X_SSO_TOKEN, token).withHttpMethod(HttpMethods.GET).build();
Map<String, String> requestParameters = Maps.newHashMap();
SimbaCredentials expected = new SimbaCredentialsBuilderForTests().withRequestUrl(REQUESTURL).addHeader(X_SSO_TOKEN, token).withRequestParameters(requestParameters).withHostServerName(RequestUtil.HOST_SERVER_NAME).withSsotoken(token).build();
SimbaCredentials actual = factory.create(containerRequest);
assertThat(actual).isEqualTo(expected);
}
use of com.sun.jersey.spi.container.ContainerRequest in project neo4j by neo4j.
the class XForwardFilterTest method shouldSetTheRequestUriToTheSameProtocolAsTheXForwardProtoHeader.
@Test
public void shouldSetTheRequestUriToTheSameProtocolAsTheXForwardProtoHeader() throws Exception {
// given
final String theProtocol = "https";
XForwardFilter filter = new XForwardFilter();
InBoundHeaders headers = new InBoundHeaders();
headers.add(X_FORWARD_PROTO_HEADER_KEY, theProtocol);
ContainerRequest request = new ContainerRequest(WEB_APPLICATION, "GET", URI.create("http://jimwebber.org:1234"), URI.create("http://jimwebber.org:1234/foo/bar"), headers, INPUT_STREAM);
// when
ContainerRequest result = filter.filter(request);
// then
assertThat(result.getBaseUri().getScheme(), containsString(theProtocol));
}
use of com.sun.jersey.spi.container.ContainerRequest in project neo4j by neo4j.
the class XForwardFilterTest method shouldSetTheBaseUriToTheSameValueAsTheXForwardHostHeader.
@Test
public void shouldSetTheBaseUriToTheSameValueAsTheXForwardHostHeader() throws Exception {
// given
final String xForwardHostAndPort = "jimwebber.org:1234";
XForwardFilter filter = new XForwardFilter();
InBoundHeaders headers = new InBoundHeaders();
headers.add(X_FORWARD_HOST_HEADER_KEY, xForwardHostAndPort);
ContainerRequest request = new ContainerRequest(WEB_APPLICATION, "GET", URI.create("http://iansrobinson.com"), URI.create("http://iansrobinson.com/foo/bar"), headers, INPUT_STREAM);
// when
ContainerRequest result = filter.filter(request);
// then
assertThat(result.getBaseUri().toString(), containsString(xForwardHostAndPort));
}
use of com.sun.jersey.spi.container.ContainerRequest in project neo4j by neo4j.
the class XForwardFilterTest method shouldSetTheRequestUriToTheSameValueAsTheXForwardHostHeader.
@Test
public void shouldSetTheRequestUriToTheSameValueAsTheXForwardHostHeader() throws Exception {
// given
final String xForwardHostAndPort = "jimwebber.org:1234";
XForwardFilter filter = new XForwardFilter();
InBoundHeaders headers = new InBoundHeaders();
headers.add(X_FORWARD_HOST_HEADER_KEY, xForwardHostAndPort);
ContainerRequest request = new ContainerRequest(WEB_APPLICATION, "GET", URI.create("http://iansrobinson.com"), URI.create("http://iansrobinson.com/foo/bar"), headers, INPUT_STREAM);
// when
ContainerRequest result = filter.filter(request);
// then
assertTrue(result.getRequestUri().toString().startsWith("http://" + xForwardHostAndPort));
}
Aggregations