package com.perforce.workshop.tjuricek.p4oauth.test_server; import org.eclipse.jetty.server.*; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; /** */ public class TestServer { public static void main(String[] args) { if (args.length < 1) { System.err.println("Usage: java -jar test_server.jar PORT KEYSTORE"); System.exit(1); } int sslPort = Integer.valueOf(args[0], 10); String keystore = args[1]; Server server = new Server(); HttpConfiguration httpConfiguration = new HttpConfiguration(); httpConfiguration.setSecurePort(sslPort); httpConfiguration.addCustomizer(new SecureRequestCustomizer()); SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath(keystore); sslContextFactory.setKeyStorePassword("password"); sslContextFactory.setKeyManagerPassword("password"); ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpConfiguration)); https.setPort(sslPort); https.setIdleTimeout(30); server.addConnector(https); HandlerCollection handlerCollection = new HandlerCollection(); HandlebarsHelper handlebarsHelper = new HandlebarsHelper(sslPort); handlerCollection.addHandler(handlebarsHelper); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setDirectoriesListed(false); resourceHandler.setResourceBase("/META-INF/resources"); handlerCollection.addHandler(resourceHandler); handlerCollection.addHandler(new DefaultHandler()); server.setHandler(handlerCollection); try { server.start(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } System.err.println("started TestServer on port " + sslPort + " using " + "keystore at " + keystore); try { server.join(); } catch (InterruptedException e) { // ignore, we're done } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 9180 | tjuricek |
0.1.1 Adding mechanism for fetching the p4 token given the bearer token on an Authorization header. This is probably secure since we can't use these tokens except for the restricted hosts. |
||
#2 | 9157 | tjuricek | Added basic "authorization code" workflow test. | ||
#1 | 9138 | tjuricek |
Added a "test server" with startTestServer and stopTestServer gradle tasks. The test server isn't 100% complete, but the gradle tasks should be. This is to be used to drive tests forward via a web browser. |