示例#1
0
 private void receiveRequest(String basicAuthHeader) throws Exception {
   request.headers().add(AUTHORIZATION, basicAuthHeader);
   env = new Env(context, request);
   env.getRequest().setPath(request.getUri());
   handler.messageReceived(context, env);
 }
示例#2
0
 @Test
 public void testThatAuthIsDeniedWithArbitraryString() throws Exception {
   receiveRequest("dafuq");
   assertThat(env.getResponse().getStatusCode(), is(403));
 }
示例#3
0
 @Test
 public void testThatAuthIsAllowedWithValidUserAndPass() throws Exception {
   receiveRequest(encodeBasicAuth("user", "pass"));
   assertThat(env.getResponse().getStatusCode(), is(200));
 }
示例#4
0
 @Test
 public void testThatAuthIsDeniedWithWrongPass() throws Exception {
   receiveRequest(encodeBasicAuth("user", "wrongpass"));
   assertThat(env.getResponse().getStatusCode(), is(403));
 }