Permalink
Browse files

golang integration

  • Loading branch information...
Bill Burke
Bill Burke committed Mar 20, 2018
1 parent 8926837 commit 681e3d751e003b563f26b4105313eb69cdbda2ea

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
View
@@ -35,7 +35,6 @@
<module>as7-eap6</module>
<module>installed</module>
<module>kcinit</module>
<module>kcinit-dist</module>
<module>jaxrs-oauth-client</module>
<module>jetty</module>
<module>js</module>
@@ -228,18 +228,46 @@
<type>zip</type>
<outputDirectory>${containers.home}</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.keycloak</groupId>
<artifactId>kcinit-dist</artifactId>
<version>${project.version}</version>
<type>zip</type>
<outputDirectory>${containers.home}</outputDirectory>
</artifactItem>
</artifactItems>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>mvn-golang-wrapper</artifactId>
<version>2.1.6</version>
<extensions>true</extensions>
<configuration>
<goVersion>1.9.2</goVersion>
</configuration>
<executions>
<execution>
<id>a</id>
<goals>
<goal>get</goal>
</goals>
<configuration>
<packages>
<package>github.com/inconshreveable/mousetrap</package>
<package>github.com/keycloak/kcinit</package>
</packages>
</configuration>
</execution>
<execution>
<id>b</id>
<goals>
<goal>build</goal>
</goals>
<configuration>
<resultName>kcinit</resultName>
<packages>
<package>github.com/keycloak/kcinit</package>
</packages>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
@@ -10,9 +10,9 @@
*/
public class KcinitExec extends AbstractExec {
public static final String WORK_DIR = System.getProperty("user.dir") + "/target/containers/kcinit";
public static final String WORK_DIR = System.getProperty("user.dir") + "/target";
public static final String CMD = OS_ARCH.isWindows() ? "kcinit.bat" : "kcinit";
public static final String CMD = OS_ARCH.isWindows() ? "kcinit" : "kcinit";
private KcinitExec(String workDir, String argsLine, InputStream stdin) {
this(workDir, argsLine, null, stdin);
@@ -34,7 +34,7 @@
private boolean logStreams = Boolean.valueOf(System.getProperty("cli.log.output", "true"));
protected boolean dumpStreams;
protected boolean dumpStreams = true;
protected String workDir = WORK_DIR;
@@ -164,7 +164,7 @@ public void testDemo() throws Exception {
public void testBadCommand() throws Exception {
KcinitExec exe = KcinitExec.execute("covfefe");
Assert.assertEquals(1, exe.exitCode());
Assert.assertEquals("stderr first line", "Unknown command: covfefe", exe.stderrLines().get(0));
Assert.assertEquals("stderr first line", "Error: unknown command \"covfefe\" for \"kcinit\"", exe.stderrLines().get(0));
}
//@Test
@@ -175,16 +175,21 @@ public void testInstall() throws Exception {
exe = KcinitExec.newBuilder()
.argsLine("install")
.executeAsync();
exe.waitForStderr("(y/n):");
exe.sendLine("n");
//System.out.println(exe.stderrString());
//exe.waitForStderr("(y/n):");
//exe.sendLine("n");
exe.waitForStderr("Authentication server URL [http://localhost:8080/auth]:");
exe.sendLine(OAuthClient.AUTH_SERVER_ROOT);
//System.out.println(exe.stderrString());
exe.waitForStderr("Name of realm [master]:");
exe.sendLine("test");
//System.out.println(exe.stderrString());
exe.waitForStderr("client id [kcinit]:");
exe.sendLine("");
exe.waitForStderr("client secret [none]:");
//System.out.println(exe.stderrString());
exe.waitForStderr("Client secret [none]:");
exe.sendLine("password");
//System.out.println(exe.stderrString());
exe.waitCompletion();
Assert.assertEquals(0, exe.exitCode());
}
@@ -193,13 +198,17 @@ public void testInstall() throws Exception {
public void testBasic() throws Exception {
testInstall();
// login
//System.out.println("login....");
KcinitExec exe = KcinitExec.newBuilder()
.argsLine("login")
.executeAsync();
//System.out.println(exe.stderrString());
exe.waitForStderr("Username:");
exe.sendLine("wburke");
//System.out.println(exe.stderrString());
exe.waitForStderr("Password:");
exe.sendLine("password");
//System.out.println(exe.stderrString());
exe.waitForStderr("Login successful");
exe.waitCompletion();
Assert.assertEquals(0, exe.exitCode());
@@ -233,7 +242,7 @@ public void testBasic() throws Exception {
Assert.assertEquals(1, exe.exitCode());
Assert.assertEquals(0, exe.stdoutLines().size());
Assert.assertEquals(1, exe.stderrLines().size());
Assert.assertTrue(exe.stderrLines().get(0).contains("Failed to exchange token: invalid_client. Audience not found"));
Assert.assertTrue(exe.stderrLines().get(0), exe.stderrLines().get(0).contains("failed to exchange token: invalid_client Audience not found"));
exe = KcinitExec.execute("logout");
Assert.assertEquals(0, exe.exitCode());

0 comments on commit 681e3d7

Please sign in to comment.