fixing tests and added script to generate key pairs for tests
continuous-integration/drone/push Build was killed Details

drone-setup
Override-6 2 years ago
parent 023f847b06
commit d7c57f06fa

@ -3,48 +3,29 @@ type: docker
name: "Server CI" name: "Server CI"
#steps:
# - name: Unit tests
# image: override6/tbasket-backend:latest
# volumes:
# - name: build
# path: ./build
# commands:
# - ./mill tests.test
# - name: Deploy
# image: override6/tbasket-backend:latest
# depends_on:
# - 'Unit tests'
# environment:
# SSH_PRIVATE_KEY:
# from_secret: SSH_PRIVATE
# PASSWD:
# from_secret: PASSWD
# volumes:
# - name: build
# path: ./build
# commands:
# - ./mill Core.compile
# - chmod 777 drone/deliver.sh
# - drone/deliver.sh
---
kind: pipeline
type: docker
name: "Deploy committed docker images"
steps: steps:
- name: Build and push - name: Unit tests
image: override6/docker-git image: override6/tbasket-test:latest
environment: volumes:
DOCKER_USERNAME: - name: build
from_secret: DOCKER_USERNAME path: ./build
DOCKER_PASSWORD:
from_secret: DOCKER_PASSWORD
commands: commands:
- chmod +x drone/image-deploy.sh - ./mill tests.test
- drone/image-deploy.sh
- name: Deploy
image: override6/tbasket-backend:latest
depends_on:
- 'Unit tests'
environment:
SSH_PRIVATE_KEY:
from_secret: SSH_PRIVATE
PASSWD:
from_secret: PASSWD
volumes:
- name: build
path: ./build
commands:
- ./mill Core.compile
- chmod 777 drone/deliver.sh
- drone/deliver.sh

@ -1,44 +1,44 @@
{ {
"results": [ "results": [
{ {
"name" : "org.tbasket.test.pages.LoginPageHandlerTests/\/login page handler/login situation tests/login with unknown account", "name" : "Test Task name not available here/\/login page handler/login situation tests/login with unknown account",
"status" : "Success", "status" : "Success",
"durationMillis" : "3408", "durationMillis" : "3658",
"annotations" : "", "annotations" : "",
"fullyQualifiedClassName" : "org.tbasket.test.pages.LoginPageHandlerTests", "fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "login situation tests", "login with unknown account"] "labels" : ["\/login page handler", "login situation tests", "login with unknown account"]
}, },
{ {
"name" : "org.tbasket.test.pages.LoginPageHandlerTests/\/login page handler/erroned request body tests/with invalid json", "name" : "Test Task name not available here/\/login page handler/erroned request body tests/with invalid json",
"status" : "Success", "status" : "Success",
"durationMillis" : "2403", "durationMillis" : "2587",
"annotations" : "", "annotations" : "",
"fullyQualifiedClassName" : "org.tbasket.test.pages.LoginPageHandlerTests", "fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "erroned request body tests", "with invalid json"] "labels" : ["\/login page handler", "erroned request body tests", "with invalid json"]
}, },
{ {
"name" : "org.tbasket.test.pages.LoginPageHandlerTests/\/login page handler/erroned request body tests/with no password attribute", "name" : "Test Task name not available here/\/login page handler/erroned request body tests/with no mail attribute",
"status" : "Success", "status" : "Success",
"durationMillis" : "2406", "durationMillis" : "2629",
"annotations" : "", "annotations" : "",
"fullyQualifiedClassName" : "org.tbasket.test.pages.LoginPageHandlerTests", "fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "erroned request body tests", "with no password attribute"] "labels" : ["\/login page handler", "erroned request body tests", "with no mail attribute"]
}, },
{ {
"name" : "org.tbasket.test.pages.LoginPageHandlerTests/\/login page handler/erroned request body tests/with no mail attribute", "name" : "Test Task name not available here/\/login page handler/erroned request body tests/empty packet",
"status" : "Success", "status" : "Success",
"durationMillis" : "2412", "durationMillis" : "2633",
"annotations" : "", "annotations" : "",
"fullyQualifiedClassName" : "org.tbasket.test.pages.LoginPageHandlerTests", "fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "erroned request body tests", "with no mail attribute"] "labels" : ["\/login page handler", "erroned request body tests", "empty packet"]
}, },
{ {
"name" : "org.tbasket.test.pages.LoginPageHandlerTests/\/login page handler/erroned request body tests/empty packet", "name" : "Test Task name not available here/\/login page handler/erroned request body tests/with no password attribute",
"status" : "Success", "status" : "Success",
"durationMillis" : "2436", "durationMillis" : "2619",
"annotations" : "", "annotations" : "",
"fullyQualifiedClassName" : "org.tbasket.test.pages.LoginPageHandlerTests", "fullyQualifiedClassName" : "Test Task name not available here",
"labels" : ["\/login page handler", "erroned request body tests", "empty packet"] "labels" : ["\/login page handler", "erroned request body tests", "with no password attribute"]
} }
] ]

@ -0,0 +1,27 @@
#!/usr/bin/bash
echo GENERATING TEMPORARY KEY PAIRS FOR TESTS
rm -r /tmp/keys
mkdir /tmp/keys
cd /tmp/keys
keytool -genkey -noprompt \
-alias key \
-keyalg RSA \
-validity 1 \
-keystore test.keystore \
-storetype PKCS12 \
-dname "CN=mqttserver.ibm.com, OU=ID, O=IBM, L=Hursley, S=Hants, C=GB" \
-storepass 123456789 \
-keypass 123456789
keytool -noprompt -export \
-alias key \
-keystore test.keystore \
-rfc \
-file public.cert \
-keypass 123456789 \
-storepass 123456789
echo "123456789" | openssl pkcs12 -in test.keystore -nodes -nocerts -out private.pcks 2> /dev/null
echo "123456789" | openssl pkcs12 -in test.keystore -nokeys -out public.cert 2> /dev/null

@ -10,13 +10,17 @@ import java.nio.file.{Files, Path}
import java.security.cert.{Certificate, CertificateFactory} import java.security.cert.{Certificate, CertificateFactory}
object TestServerConfig extends ServerConfig { object TestServerConfig extends ServerConfig {
new ProcessBuilder("bash", "./tests/resources/generate_keys.sh")
.inheritIO()
.start()
.waitFor()
private final val CertFactory = CertificateFactory.getInstance("X509") private final val CertFactory = CertificateFactory.getInstance("X509")
override def emitterURL: URL = URL.fromString(s"http://localhost/$PORT").getOrElse(null) override def emitterURL: URL = URL.fromString(s"http://localhost/$PORT").getOrElse(null)
override def emitterCertificate: Certificate = override def emitterCertificate: Certificate =
CertFactory.generateCertificate(Files.newInputStream(Path.of("keys/public.cert"))) CertFactory.generateCertificate(Files.newInputStream(Path.of("/tmp/keys/public.cert")))
override def emitterKeyAlgorithm: JwtAsymmetricAlgorithm = JwtAlgorithm.RS256 override def emitterKeyAlgorithm: JwtAsymmetricAlgorithm = JwtAlgorithm.RS256