### Question:
ApplicationAuth implements RequestAuthorizer { protected boolean doCheckAuthorization(BasicAuthCredentials creds) { if(creds == null) { return false; } Application app = appRegistry.getApplication(creds.getUsername()); if(app == null) { return false; } return Objects.equal(app.getSecret(), creds.getPassword()); } @Inject  ApplicationAuth(AppRegistry appRegistry, BridgeMetrics metrics); @Override boolean isAuthorized(ChannelHandlerContext ctx, FullHttpRequest req); @Override boolean handleFailedAuth(ChannelHandlerContext ctx, FullHttpRequest req);  }### Answer:
@Test public void testMissingHeaderFailsAuth() { assertFalse(auth.doCheckAuthorization(null)); assertFalse(auth.doCheckAuthorization(new BasicAuthCredentials("", ""))); }
@Test public void testAppDoesntExistFailsAuth() { assertFalse(auth.doCheckAuthorization(new BasicAuthCredentials("wrong", "app1"))); }
@Test public void testWrongSecretFailsAuth() { assertFalse(auth.doCheckAuthorization(new BasicAuthCredentials("app1", "foobar"))); }
@Test public void testPassesAuth() { assertTrue(auth.doCheckAuthorization(new BasicAuthCredentials("app1", "app1"))); }