package com.perforce.workshop.tjuricek.p4oauth import org.gradle.api.tasks.TaskAction import java.lang.reflect.Field /** * This starts p4oauth up in a working directory, with a whitelist that allows * a single test application to run. */ class StartP4OAuthTask extends P4OAuthTask { @TaskAction def start() { if (!this.p4OAuthJarFile.exists()) { throw new IllegalStateException(p4OAuthJarFile.absolutePath + " does not exist. Please run './gradlew assemble' in the " + "parent project "); } if (running) { setDidWork(false) return } if (!this.initialized) { initialize() } String startCmd = "java -jar ${p4OAuthJarFile.absolutePath} P4OAuth.yml" logger.info("Executing ${startCmd}") Process process = startCmd.execute(null, p4OAuthWorkDir) Field f = process.getClass().getDeclaredField("pid"); f.setAccessible(true) int pid = f.getInt(process); getPidFile().write("${pid}"); } def initialize() { if (!p4OAuthWorkDir.exists()) { p4OAuthWorkDir.mkdirs() } // Create a very simple "whitelist" that contains the test server // implementation in it right now whitelistFile.createNewFile() whitelistFile.write(createWhitelistYaml()) configFile.createNewFile() configFile.write(createConfig()) // We may want to generate log4j configuration } File getWhitelistFile() { return new File(p4OAuthWorkDir, "whitelist") } String getHostname() { String hostname = null if (System.getProperty("COMPUTERNAME") != null) { hostname = System.getProperty("COMPUTERNAME"); // Windows } else if (System.getProperty("HOSTNAME") != null) { hostname = System.getProperty("HOSTNAME"); // Unix, sometimes } if (hostname == null) { try { hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { // Ignore, we just don't know it by default } } return hostname } String createWhitelistYaml() { return "servers:\n" + " - !com.perforce.workshop.tjuricek.p4oauth.models.WhitelistedServer\n" + " name: test_server\n" + " redirectUri: http://localhost:${project.extensions.p4oauth.testServerPort}/handled\n" + " ipAddress: 127.0.0.1" } File getConfigFile() { return new File(p4OAuthWorkDir, "P4OAuth.yml") } String createConfig() { return "!com.perforce.workshop.tjuricek.p4oauth.config.P4OAuthConfig\n" + "keyStorePath: ${project.buildDir}/keystore\n" + "keyStorePassword: password\n" + "keyManagerPassword: password\n" + "hostname: ${hostname}\n" + "rootDirectory: ${p4OAuthWorkDir.absolutePath}\n" + "\n" + "perforce: !com.perforce.workshop.tjuricek.p4oauth.config.PerforceConfig\n" + " hostname: 127.0.0.1\n" + " port: 1666" } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 9157 | tjuricek | Added basic "authorization code" workflow test. | ||
#4 | 9144 | tjuricek | Added basic webdriver config and config for P4OAuth service | ||
#3 | 9142 | tjuricek | Implemented 'startP4OAuth' and 'stopP4OAuth' tasks, fixed reference to test data, and updated plugin dependencies | ||
#2 | 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. |
||
#1 | 9105 | tjuricek |
Added the 'createKeystore' task, and framework for how the functional tests will be set up. See the functional_tests/README. The short story is that we'll execute a "test webapp" that the actual tests will interact with. |