@Test(expected = IllegalArgumentException.class) public void testMissingConfigurationThrowsException() throws Exception { Configuration conf = new Configuration(); conf.setInt(HttpServer.HTTP_MAX_THREADS, TestHttpServer.MAX_THREADS); // Enable Kerberos (pre-req) conf.set("hbase.security.authentication", "kerberos"); // Intentionally skip keytab and principal HttpServer customServer = createTestServerWithSecurity(conf); customServer.addServlet("echo", "/echo", EchoServlet.class); customServer.addJerseyResourcePackage(JerseyResource.class.getPackage().getName(), "/jersey/*"); customServer.start(); } }
@BeforeClass public static void setup() throws Exception { Configuration conf = new Configuration(); conf.setInt(HttpServer.HTTP_MAX_THREADS, MAX_THREADS); server = createTestServer(conf); server.addServlet("echo", "/echo", EchoServlet.class); server.addServlet("echomap", "/echomap", EchoMapServlet.class); server.addServlet("htmlcontent", "/htmlcontent", HtmlContentServlet.class); server.addServlet("longheader", "/longheader", LongHeaderServlet.class); server.addJerseyResourcePackage( JerseyResource.class.getPackage().getName(), "/jersey/*"); server.start(); baseUrl = getServerURL(server); LOG.info("HTTP server started: "+ baseUrl); }
@BeforeClass public static void setupServer() throws Exception { final String serverPrincipal = "HTTP/" + KDC_SERVER_HOST; final File target = new File(System.getProperty("user.dir"), "target"); assertTrue(target.exists()); kdc = buildMiniKdc(); kdc.start(); File keytabDir = new File(target, TestSpnegoHttpServer.class.getSimpleName() + "_keytabs"); if (keytabDir.exists()) { deleteRecursively(keytabDir); } keytabDir.mkdirs(); infoServerKeytab = new File(keytabDir, serverPrincipal.replace('/', '_') + ".keytab"); clientKeytab = new File(keytabDir, CLIENT_PRINCIPAL + ".keytab"); setupUser(kdc, clientKeytab, CLIENT_PRINCIPAL); setupUser(kdc, infoServerKeytab, serverPrincipal); Configuration conf = buildSpnegoConfiguration(serverPrincipal, infoServerKeytab); server = createTestServerWithSecurity(conf); server.addServlet("echo", "/echo", EchoServlet.class); server.addJerseyResourcePackage(JerseyResource.class.getPackage().getName(), "/jersey/*"); server.start(); baseUrl = getServerURL(server); LOG.info("HTTP server started: "+ baseUrl); }