use of org.simbasecurity.dwclient.test.dropwizard.matchers.ContainerRequestBuilderForTests in project simba-os by cegeka.
the class SimbaAuthenticatedInjectableTest method setUp.
@Before
public void setUp() {
injectable = new SimbaAuthenticatedInjectable<AuthenticatedPrincipal>(authenticatorMock, simbaCredentialsFactoryMock, domainProviderMock, false);
simbaCredentials = new SimbaCredentialsBuilderForTests().build();
ContainerRequest containerRequest = new ContainerRequestBuilderForTests().build();
when(dummyHttpContext.getRequest()).thenReturn(containerRequest);
when(simbaCredentialsFactoryMock.create(containerRequest)).thenReturn(simbaCredentials);
}
use of org.simbasecurity.dwclient.test.dropwizard.matchers.ContainerRequestBuilderForTests in project simba-os by cegeka.
the class SimbaCredentialsFactoryTest method create_NeitherSSOTokenNorBasicAuthentication_Throws401.
@Test
public void create_NeitherSSOTokenNorBasicAuthentication_Throws401() throws Exception {
ContainerRequest containerRequest = new ContainerRequestBuilderForTests().withRequestUri(URI.create("http://rest.wayneindustries.com/v1/bats?format=timeseries")).withHttpMethod(HttpMethods.GET).build();
expectedException.expect(WebApplicationExceptionMatcher.webApplicationException(UNAUTHORIZED));
factory.create(containerRequest);
}
use of org.simbasecurity.dwclient.test.dropwizard.matchers.ContainerRequestBuilderForTests in project simba-os by cegeka.
the class SimbaCredentialsFactoryTest method create_BasicAuthentication_DecodesAndCreatesCredentials.
@Test
public void create_BasicAuthentication_DecodesAndCreatesCredentials() throws Exception {
String username = "emanresu";
String password = "drowssap";
String digest = username + ":" + password;
byte[] encodedDigest = Base64.encode(digest);
String basicAuthString = "basic " + new String(encodedDigest);
ContainerRequest containerRequest = new ContainerRequestBuilderForTests().addHeader(AUTHORIZATION, basicAuthString).withRequestUri(URI.create("http://rest.wayneindustries.com/v1/bats?format=timeseries")).withHttpMethod(HttpMethods.GET).build();
SimbaCredentials expected = new SimbaCredentialsBuilderForTests().withHttpMethod(HttpMethods.GET).addHeader(AUTHORIZATION, basicAuthString).addParameter(AuthenticationConstants.USERNAME, username).addParameter(AuthenticationConstants.PASSWORD, password).addParameter("format", "timeseries").withRequestUrl("http://rest.wayneindustries.com/v1/bats/").withSimbaWebURL(SIMBA_WEB_URL).withHostServerName(RequestUtil.HOST_SERVER_NAME).withIsLoginRequest(true).build();
SimbaCredentials simbaCredentials = factory.create(containerRequest);
assertThat(simbaCredentials).isEqualTo(expected);
}
use of org.simbasecurity.dwclient.test.dropwizard.matchers.ContainerRequestBuilderForTests 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);
}
Aggregations