-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Test): Adding SSL tests for Java
see #4
- Loading branch information
Showing
3 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ install: | |
|
||
script: | ||
- ./bin/build.sh | ||
- ./bin/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import javax.net.ssl.SSLSocket; | ||
import javax.net.ssl.SSLSocketFactory; | ||
import java.io.*; | ||
|
||
/** Establish a SSL connection to a host and port, writes a byte and | ||
* prints the response. See | ||
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services | ||
*/ | ||
public class SSLPoke { | ||
public static void main(String[] args) { | ||
if (args.length != 2) { | ||
System.out.println("Usage: "+SSLPoke.class.getName()+" <host> <port>"); | ||
System.exit(1); | ||
} | ||
try { | ||
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); | ||
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(args[0], Integer.parseInt(args[1])); | ||
|
||
InputStream in = sslsocket.getInputStream(); | ||
OutputStream out = sslsocket.getOutputStream(); | ||
|
||
// Write a test byte to get a reaction :) | ||
out.write(1); | ||
|
||
while (in.available() > 0) { | ||
System.out.print(in.read()); | ||
} | ||
System.out.println("Successfully connected"); | ||
|
||
} catch (Exception exception) { | ||
exception.printStackTrace(); | ||
System.exit(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,28 @@ | ||
#!/bin/sh | ||
|
||
# FIXME: Run tests ;) | ||
./bin/build.sh | ||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
function prepareTestImage { | ||
docker run -td --name "test-$1" "toolisticon/$1" | ||
} | ||
|
||
function removeTestImage { | ||
docker stop "test-$1" | ||
docker rm "test-$1" | ||
} | ||
|
||
function runJavaImageTests { | ||
removeTestImage $1 2>/dev/null || true | ||
prepareTestImage "$1" | ||
docker cp "$CURRENT_DIR/test-utils/SSLPoke.java" "test-$1":/tmp/ | ||
docker exec "test-$1" bash -c "cd /tmp && javac SSLPoke.java" | ||
docker exec "test-$1" bash -c "cd /tmp && java SSLPoke google.de 443" | ||
removeTestImage $1 | ||
} | ||
|
||
# TODO more test | ||
|
||
runJavaImageTests 'openjdk8-builder' | ||
runJavaImageTests 'openjdk11-builder' | ||
runJavaImageTests 'oraclejdk12-builder' | ||
runJavaImageTests 'oraclejdk13-builder' |