-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests to work with the mock AAI
- Loading branch information
Showing
9 changed files
with
67 additions
and
87 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 |
---|---|---|
|
@@ -29,19 +29,58 @@ done | |
mkdir -p /shared/keys/pub | ||
if [ ! -f "/shared/keys/jwt.key" ]; then | ||
echo "creating jwt key" | ||
openssl ecparam -genkey -name prime256v1 -noout -out /shared/keys/jwt.key | ||
openssl ec -in /shared/keys/jwt.key -outform PEM -pubout >/shared/keys/pub/jwt.pub | ||
cat << 'EOF' > /shared/keys/jwt.key | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDhuZjxPmOGUIW1 | ||
LhxzKfxkN+1aTbvI5w+AptqT33X+bWuzfjvhEodiNz0bBfQgJJpQ3TZ8J1IZpM2F | ||
Tnzox+FGxKPe5T9Mgngzd4N6eByWVPXoNMk7IdmBXMdPZBFSyjMW4ba1MELCpiKV | ||
05de4J5opRDwmHmyMqYJxBk78e3iiYYixVk+j1Ku+yFl4d2R29y2+O9PlZegJloe | ||
8FGnKIGZApS/8t9iyCkXg8WbjSPzgYCTQKxn/E4lcGdTrAt/McKrWmAuppcr+rpP | ||
+BInm3l5Zu/QiRSZcMb5O460ojP9eKnaUlDpGZv9CY5j4x4lq8vjU2kK77YXBO8I | ||
2oxse5a5AgMBAAECggEABbwSX6anHqVzECxQurhJWj51gELTT4JXSXxztygJNmKP | ||
RushGFHBMMSYf9RB5IMpjH5iQPs6wb4HHqjk0YEqfwLF6wbF+eqipSQXKghdKZCV | ||
AsY8io0MmpXB1omDSygp7h3j52yHdayE2muav+VTAPOYn5QwG0/gGgVqYrR9x7CM | ||
iTuyOIuGN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AmMdURdcGTrH | ||
b6b/6vhU90+xL14CX7Awofp/ | ||
-----END PRIVATE KEY----- | ||
EOF | ||
cat << 'EOF' > /shared/keys/pub/jwt.pub | ||
-----BEGIN PUBLIC KEY----- | ||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4bmY8T5jhlCFtS4ccyn8 | ||
ZDftWk27yOcPgKbak991/m1rs3474RKHYjc9GwX0ICSaUN02fCdSGaTNhU586Mfh | ||
RsSj3uU/TIJ4M3eDengcllT16DTJOyHZgVzHT2QRUsozFuG2tTBCwqYildOXXuCe | ||
aKUQ8Jh5sjKmCcQZO/Ht4omGIsVZPo9SrvshZeHdkdvctvjvT5WXoCZaHvBRpyiB | ||
mQKUv/LfYsgpF4PFm40j84GAk0CsZ/xOJXBnU6wLfzHCq1pgLqaXK/q6T/gSJ5t5 | ||
eWbv0IkUmXDG+TuOtKIz/Xip2lJQ6Rmb/QmOY+MeJavL41NpCu+2FwTvCNqMbHuW | ||
uQIDAQAB | ||
-----END PUBLIC KEY----- | ||
EOF | ||
chmod 644 /shared/keys/pub/jwt.pub /shared/keys/jwt.key | ||
fi | ||
|
||
echo "creating token" | ||
token="$(python /scripts/sign_jwt.py)" | ||
python /scripts/sign_jwt.py [email protected] > "/shared/token" | ||
|
||
cat >/shared/s3cfg <<EOD | ||
[default] | ||
access_key=test_dummy.org | ||
secret_key=test_dummy.org | ||
access_token=$token | ||
access_key=test@dummy.org | ||
secret_key=test@dummy.org | ||
access_token="$(python /scripts/sign_jwt.py [email protected])" | ||
check_ssl_certificate = False | ||
check_ssl_hostname = False | ||
encoding = UTF-8 | ||
|
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,26 +1,27 @@ | ||
from datetime import date, timedelta | ||
from joserfc import jwt | ||
from joserfc.jwk import ECKey | ||
from joserfc.jwk import RSAKey | ||
from pathlib import Path | ||
import sys | ||
|
||
p = Path('/shared/keys/jwt.key') | ||
raw = p.read_text() | ||
key = ECKey.import_key(raw) | ||
key = RSAKey.import_key(raw) | ||
iat = date.today() - timedelta(days=1) | ||
exp = date.today() + timedelta(days=1) | ||
|
||
header = { | ||
'alg': 'ES256', | ||
'kid': key.thumbprint(), | ||
'alg': 'RS256', | ||
'kid': 'rsa1', | ||
'typ': 'JWT' | ||
} | ||
|
||
payload = { | ||
'aud': 'XC56EL11xx', | ||
'exp': exp.strftime('%s'), | ||
'iat': iat.strftime('%s'), | ||
'iss': 'http://oidc', | ||
'sub': '[email protected]' | ||
'iss': 'http://localhost', | ||
'sub': sys.argv[1] | ||
} | ||
|
||
token = jwt.encode(header, payload, key) | ||
|
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
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
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 |
---|---|---|
|
@@ -62,7 +62,7 @@ | |
"rolebinding": "submission" | ||
}, | ||
{ | ||
"role": "[email protected]", | ||
"role": "[email protected]", | ||
"rolebinding": "admin" | ||
} | ||
] | ||
|
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
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 |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
set -e | ||
|
||
# Test the API files endpoint | ||
token="$(curl -s http://oidc:8080/tokens | jq -r '.[0]')" | ||
response="$(curl -s -k -L "http://api:8080/files" -H "Authorization: Bearer $token" | jq -r 'sort_by(.inboxPath)|.[-1].fileStatus')" | ||
token="$(cat /shared/token)" | ||
response="$(curl -s -k -L "http://api:8080/users/[email protected]/files" -H "Authorization: Bearer $token" | jq -r 'sort_by(.inboxPath)|.[-1].fileStatus')" | ||
if [ "$response" != "uploaded" ]; then | ||
echo "API returned incorrect value, expected ready got: $response" | ||
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
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
set -e | ||
cd shared || true | ||
|
||
token="$(curl http://oidc:8080/tokens | jq -r '.[0]')" | ||
token="$(cat /shared/token)" | ||
# Upload a file and make sure it's listed | ||
result="$(curl -sk -L "http://api:8080/users/[email protected]/files" -H "Authorization: Bearer $token" | jq '. | length')" | ||
if [ "$result" -ne 2 ]; then | ||
|