Skip to content

Commit 7521719

Browse files
authored
Merge pull request #11 from BiobankLab/sync_fork_6
Sync fork 6
2 parents 4501faa + 2cbc60b commit 7521719

154 files changed

Lines changed: 6475 additions & 3801 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/integration/scripts/charts/dependencies.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ random-string() {
99
}
1010

1111
if [ "$1" == "local" ]; then
12-
if [ ! "$(command crypt4gh)" ]; then
12+
if [ ! "$(command crypt4gh --version)" ]; then
1313
echo "crypt4gh not installed, get it from here: https://github.com/neicnordic/crypt4gh/releases/latest"
1414
exit 1
1515
elif [ "$(crypt4gh --version | cut -d ' ' -f1)" == "GA4GH" ]; then
@@ -18,10 +18,20 @@ if [ "$1" == "local" ]; then
1818
exit 1
1919
fi
2020

21-
if [ ! "$(command yq)" ]; then
21+
if [ ! "$(command yq --version)" ]; then
2222
echo "yq not installed, get it from here: https://github.com/mikefarah/yq/releases/latest"
2323
exit 1
2424
fi
25+
26+
if [ ! "$(command jq --version)" ]; then
27+
echo "jq not installed"
28+
exit 1
29+
fi
30+
31+
if [ ! "$(command xxd --version 2>&1)" ]; then
32+
echo "xxd not installed"
33+
exit 1
34+
fi
2535
else
2636
sudo curl --retry 100 -sL "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" -o /usr/bin/yq &&
2737
sudo chmod +x /usr/bin/yq
@@ -104,4 +114,4 @@ yq -i '
104114
.releasetest.secrets.accessToken = strenv(TEST_TOKEN)
105115
' "$values_file"
106116

107-
kubectl create secret generic api-rbac --from-file=".github/integration/sda/rbac.json"
117+
kubectl create secret generic api-rbac --from-file=".github/integration/sda/rbac.json"

.github/integration/scripts/charts/deploy_charts.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ if [ "$1" == "sda-mq" ]; then
3636
--set image.pullPolicy=IfNotPresent \
3737
--set global.adminPassword="$ADMINPASS" \
3838
--set global.adminUser=admin \
39+
--set global.ingress.hostName=broker.127.0.0.1.nip.io \
3940
--set global.tls.enabled="$3" \
4041
--set global.tls.clusterIssuer=cert-issuer \
4142
--set persistence.enabled=false \

.github/integration/scripts/charts/values.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
global:
22
schemaType: "isolated"
33
ingress:
4-
deploy: false
4+
deploy: true
55
hostName:
6-
api: pipeline-sda-svc-api
7-
auth: pipeline-sda-svc-auth
8-
download: pipeline-sda-svc-download
9-
s3Inbox: pipeline-sda-svc-inbox
6+
api: api.127.0.0.1.nip.io
7+
auth: auth.127.0.0.1.nip.io
8+
download: download.127.0.0.1.nip.io
9+
s3Inbox: inbox.127.0.0.1.nip.io
10+
syncapi: sync-api.127.0.0.1.nip.io
1011
log:
1112
level: "debug"
1213
tls:

.github/integration/scripts/make_certs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ openssl x509 -req -in "$out_dir/mq.csr" -days 1200 -CA "$out_dir/ca.crt" -CAkey
3434

3535
# Create client certificate
3636
openssl req -config "$script_dir/ssl.cnf" -new -nodes -newkey rsa:4096 -keyout "$out_dir/client.key" -out "$out_dir/client.csr" -extensions client_cert -subj "/CN=admin"
37+
openssl pkcs8 -topk8 -inform PEM -outform DER -in "$out_dir/client.key" -out "$out_dir/client.der" -nocrypt
3738
openssl x509 -req -in "$out_dir/client.csr" -days 1200 -CA "$out_dir/ca.crt" -CAkey "$out_dir/ca-key.pem" -set_serial 01 -out "$out_dir/client.crt" -extensions client_cert -extfile "$script_dir/ssl.cnf"
3839

3940
if [ -n "$KEYSTORE_PASSWORD" ]; then
@@ -68,7 +69,9 @@ chmod 600 /certs/*.key
6869
cp -p "$out_dir/ca.crt" /client_certs/ca.crt
6970
cp -p "$out_dir/client.crt" /client_certs/
7071
cp -p "$out_dir/client.key" /client_certs/
72+
cp -p "$out_dir/client.der" /client_certs/
7173
chmod 600 /client_certs/*.key
74+
chmod 644 /client_certs/*.der
7275

7376
# needed if testing locally
7477
mkdir -p /temp/certs

.github/integration/scripts/make_sda_credentials.sh

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,58 @@ done
2929
mkdir -p /shared/keys/pub
3030
if [ ! -f "/shared/keys/jwt.key" ]; then
3131
echo "creating jwt key"
32-
openssl ecparam -genkey -name prime256v1 -noout -out /shared/keys/jwt.key
33-
openssl ec -in /shared/keys/jwt.key -outform PEM -pubout >/shared/keys/pub/jwt.pub
32+
cat << 'EOF' > /shared/keys/jwt.key
33+
-----BEGIN PRIVATE KEY-----
34+
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDhuZjxPmOGUIW1
35+
LhxzKfxkN+1aTbvI5w+AptqT33X+bWuzfjvhEodiNz0bBfQgJJpQ3TZ8J1IZpM2F
36+
Tnzox+FGxKPe5T9Mgngzd4N6eByWVPXoNMk7IdmBXMdPZBFSyjMW4ba1MELCpiKV
37+
05de4J5opRDwmHmyMqYJxBk78e3iiYYixVk+j1Ku+yFl4d2R29y2+O9PlZegJloe
38+
8FGnKIGZApS/8t9iyCkXg8WbjSPzgYCTQKxn/E4lcGdTrAt/McKrWmAuppcr+rpP
39+
+BInm3l5Zu/QiRSZcMb5O460ojP9eKnaUlDpGZv9CY5j4x4lq8vjU2kK77YXBO8I
40+
2oxse5a5AgMBAAECggEABbwSX6anHqVzECxQurhJWj51gELTT4JXSXxztygJNmKP
41+
RushGFHBMMSYf9RB5IMpjH5iQPs6wb4HHqjk0YEqfwLF6wbF+eqipSQXKghdKZCV
42+
AsY8io0MmpXB1omDSygp7h3j52yHdayE2muav+VTAPOYn5QwG0/gGgVqYrR9x7CM
43+
iTuyOIuGNO4Wlly4/5RhLtSo0pal9AgBvX4crtVEwN8tPgqPVo9w71bSROt9EVNI
44+
3cZiFFrrapY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<< 'EOF' > /shared/keys/pub/jwt.pub
63+
-----BEGIN PUBLIC KEY-----
64+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4bmY8T5jhlCFtS4ccyn8
65+
ZDftWk27yOcPgKbak991/m1rs3474RKHYjc9GwX0ICSaUN02fCdSGaTNhU586Mfh
66+
RsSj3uU/TIJ4M3eDengcllT16DTJOyHZgVzHT2QRUsozFuG2tTBCwqYildOXXuCe
67+
aKUQ8Jh5sjKmCcQZO/Ht4omGIsVZPo9SrvshZeHdkdvctvjvT5WXoCZaHvBRpyiB
68+
mQKUv/LfYsgpF4PFm40j84GAk0CsZ/xOJXBnU6wLfzHCq1pgLqaXK/q6T/gSJ5t5
69+
eWbv0IkUmXDG+TuOtKIz/Xip2lJQ6Rmb/QmOY+MeJavL41NpCu+2FwTvCNqMbHuW
70+
uQIDAQAB
71+
-----END PUBLIC KEY-----
72+
EOF
3473
chmod 644 /shared/keys/pub/jwt.pub /shared/keys/jwt.key
3574
fi
3675

3776
echo "creating token"
38-
token="$(python /scripts/sign_jwt.py)"
77+
python /scripts/sign_jwt.py testu@lifescience-ri.eu > "/shared/token"
3978

4079
cat >/shared/s3cfg <<EOD
4180
[default]
42-
access_key=test_dummy.org
43-
secret_key=test_dummy.org
44-
access_token=$token
81+
access_key=test@dummy.org
82+
secret_key=test@dummy.org
83+
access_token="$(python /scripts/sign_jwt.py test@dummy.org)"
4584
check_ssl_certificate = False
4685
check_ssl_hostname = False
4786
encoding = UTF-8

.github/integration/scripts/sign_jwt.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
from datetime import date, timedelta
22
from joserfc import jwt
3-
from joserfc.jwk import ECKey
3+
from joserfc.jwk import RSAKey
44
from pathlib import Path
5+
import sys
56

67
p = Path('/shared/keys/jwt.key')
78
raw = p.read_text()
8-
key = ECKey.import_key(raw)
9+
key = RSAKey.import_key(raw)
910
iat = date.today() - timedelta(days=1)
1011
exp = date.today() + timedelta(days=1)
1112

1213
header = {
13-
'alg': 'ES256',
14-
'kid': key.thumbprint(),
14+
'alg': 'RS256',
15+
'kid': 'rsa1',
1516
'typ': 'JWT'
1617
}
1718

1819
payload = {
1920
'aud': 'XC56EL11xx',
2021
'exp': exp.strftime('%s'),
2122
'iat': iat.strftime('%s'),
22-
'iss': 'http://oidc',
23-
'sub': 'test@dummy.org'
23+
'iss': 'http://localhost',
24+
'sub': sys.argv[1]
2425
}
2526

2627
token = jwt.encode(header, payload, key)
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
services:
2+
certfixer:
3+
command:
4+
- /bin/sh
5+
- /scripts/make_certs.sh
6+
container_name: certfixer
7+
image: alpine:latest
8+
volumes:
9+
- ./scripts:/scripts
10+
- certs:/certs
11+
- client_certs:/client_certs
12+
- /tmp:/temp
13+
14+
postgres:
15+
build:
16+
context: ../../postgresql
17+
container_name: postgres
18+
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}-postgres
19+
depends_on:
20+
certfixer:
21+
condition: service_completed_successfully
22+
ports:
23+
- 5432:5432
24+
environment:
25+
- LEGA_IN_PASSWORD=password
26+
- LEGA_OUT_PASSWORD=password
27+
- POSTGRES_PASSWORD=rootpasswd
28+
- POSTGRES_SERVER_CACERT=/certs/ca.crt
29+
- POSTGRES_SERVER_CERT=/certs/db.crt
30+
- POSTGRES_SERVER_KEY=/certs/db.key
31+
32+
healthcheck:
33+
test: [ "CMD", "pg_isready", "-h", "localhost", "-U", "lega_out" ]
34+
interval: 5s
35+
timeout: 20s
36+
retries: 3
37+
volumes:
38+
- certs:/certs
39+
40+
mockauth:
41+
container_name: mockauth
42+
image: python:3.11-slim
43+
ports:
44+
- 8000:8000
45+
environment:
46+
- ISSUER_URL=http://mockauth:8000
47+
volumes:
48+
- ../../sda-doa/test/mock_auth.py:/mock_auth.py
49+
- client_certs:/client_certs
50+
command: >
51+
sh -c "pip install --upgrade pip && pip install aiohttp Authlib && python -u /mock_auth.py 0.0.0.0 8000"
52+
53+
rabbitmq:
54+
build:
55+
context: ../../rabbitmq
56+
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}-rabbitmq
57+
container_name: rabbitmq
58+
depends_on:
59+
certfixer:
60+
condition: service_completed_successfully
61+
environment:
62+
- RABBITMQ_SERVER_CACERT=/etc/rabbitmq/ssl/ca.crt
63+
- RABBITMQ_SERVER_CERT=/etc/rabbitmq/ssl/mq.crt
64+
- RABBITMQ_SERVER_KEY=/etc/rabbitmq/ssl/mq.key
65+
- RABBITMQ_SERVER_VERIFY=verify_none
66+
healthcheck:
67+
test:
68+
[
69+
"CMD",
70+
"bash",
71+
"-c",
72+
"rabbitmq-diagnostics -q check_running && rabbitmq-diagnostics -q check_local_alarms",
73+
]
74+
interval: 5s
75+
timeout: 20s
76+
retries: 3
77+
restart: always
78+
volumes:
79+
- certs:/etc/rabbitmq/ssl/
80+
- rabbitmq_data:/var/lib/rabbitmq
81+
ports:
82+
- 5671:5671
83+
- 25671:15671
84+
85+
doa:
86+
container_name: doa
87+
build:
88+
context: ../../sda-doa
89+
image: ghcr.io/neicnordic/sensitive-data-archive:PR${PR_NUMBER}-doa
90+
depends_on:
91+
postgres:
92+
condition: service_healthy
93+
rabbitmq:
94+
condition: service_healthy
95+
certfixer:
96+
condition: service_completed_successfully
97+
ports:
98+
- "8080:8080"
99+
environment:
100+
- SSL_MODE=verify-ca
101+
- POSTGRES_USER=postgres
102+
- POSTGRES_DB=sda
103+
- POSTGRES_PASSWORD=rootpasswd
104+
- DB_INSTANCE=postgres
105+
- SSL_ENABLED=false
106+
- BROKER_HOST=rabbitmq
107+
- BROKER_VALIDATE=false
108+
- OPENID_CONFIGURATION_URL=http://mockauth:8000/openid-configuration
109+
- USERINFO_ENDPOINT_URL=http://mockauth:8000/userinfo
110+
- CRYPT4GH_PRIVATE_KEY_PATH=test/crypt4gh.sec.pem
111+
- CRYPT4GH_PRIVATE_KEY_PASSWORD_PATH=test/crypt4gh.pass
112+
- OUTBOX_TYPE=POSIX
113+
- OUTBOX_LOCATION=/outbox/%s/files/
114+
- SSL_ENABLED=false
115+
- ROOT_CERT_PATH=/certs/ca.crt
116+
- CERT_PATH=/certs/client.crt
117+
- CERT_KEY=/certs/client.der
118+
- BROKER_USERNAME=guest
119+
120+
volumes:
121+
- client_certs:/certs
122+
- ../../sda-doa/test/body.enc:/test/body.enc
123+
- test_file:/outbox
124+
- encryption_files:/test
125+
126+
integration_test:
127+
container_name: integration_test
128+
image: maven:3.9.9-eclipse-temurin-21
129+
profiles: [test]
130+
volumes:
131+
- ../../sda-doa/src:/sda-doa/src
132+
- ../../sda-doa/pom.xml:/sda-doa/pom.xml
133+
- ../../sda-doa/settings.xml:/root/.m2/settings.xml
134+
- test_file:/sda-doa/outbox
135+
- ./tests:/tests
136+
- encryption_files:/test
137+
- client_certs:/certs
138+
139+
depends_on:
140+
- doa
141+
- mockauth
142+
environment:
143+
- OUTBOX_TYPE=POSIX
144+
- DOA_URL=http://doa:8080
145+
- MOCKAUTH_URL=http://mockauth:8000
146+
- MINIO_HOST=outbox
147+
148+
command:
149+
- "/bin/sh"
150+
- "/tests/run_scripts.sh"
151+
- "/tests/doa"
152+
153+
volumes:
154+
certs:
155+
client_certs:
156+
rabbitmq_data:
157+
test_file:
158+
encryption_files:

0 commit comments

Comments
 (0)