-
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.
- Loading branch information
Showing
4 changed files
with
59 additions
and
8 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
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 |
---|---|---|
|
@@ -78,6 +78,9 @@ public static void setup() { | |
|
||
PreparedStatement dataset_event_released = connection.prepareStatement(prepareInsertQueryDatasetEvent("EGAD00010000919", "released", "release")); | ||
dataset_event_released.executeUpdate(); | ||
|
||
PreparedStatement datasetReferenceInsert = connection.prepareStatement("INSERT INTO sda.dataset_references(dataset_id, reference_id, reference_scheme) values('1', 'GDI-NO-10001','GDI');"); | ||
datasetReferenceInsert.executeUpdate(); | ||
connection.close(); | ||
|
||
JSONArray tokens = Unirest.get("http://localhost:8000/tokens").asJson().getBody().getArray(); | ||
|
@@ -272,6 +275,38 @@ void testS3ExportRequestDatasetValidToken() { | |
} | ||
} | ||
|
||
@SneakyThrows | ||
@Test | ||
void testS3ExportRequestReferenceValidToken() { | ||
if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { | ||
Assertions.assertTrue(true); | ||
return; | ||
} | ||
export("GDI-NO-10001", true); | ||
PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); | ||
try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("[email protected]/body.enc").build()); | ||
Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { | ||
byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); | ||
Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); | ||
} | ||
} | ||
|
||
@SneakyThrows | ||
@Test | ||
void testPOSIXExportRequestReferenceValidToken() { | ||
if (System.getenv("OUTBOX_TYPE").equals("S3")) { | ||
Assertions.assertTrue(true); | ||
return; | ||
} | ||
export("GDI-NO-10001", true); | ||
PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); | ||
try (InputStream byteArrayInputStream = new FileInputStream("[email protected]/files/body.enc"); | ||
Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { | ||
byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); | ||
Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); | ||
} | ||
} | ||
|
||
@SneakyThrows | ||
void export(String id, boolean dataset) { | ||
String mqConnectionString = "amqps://admin:guest@localhost:5671/sda"; | ||
|
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 |
---|---|---|
|
@@ -102,6 +102,20 @@ def generate_token(): | |
"exp": 99999999999, | ||
"jti": "9fa600d6-4148-47c1-b708-36c4ba2e980e" | ||
} | ||
passport_dataset_gdi = { | ||
"iss": "http://129.177.177.134:8000/", | ||
"sub": "[email protected]", | ||
"ga4gh_visa_v1": { | ||
"type": "ControlledAccessGrants", | ||
"value": "https://www.ebi.ac.uk/ega/GDI-NO-10001", | ||
"source": "https://ga4gh.org/duri/no_org", | ||
"by": "dac", | ||
"asserted": 1568699331 | ||
}, | ||
"iat": 1571144438, | ||
"exp": 99999999999, | ||
"jti": "2b322848-506b-492c-914f-47f9da967cdd" | ||
} | ||
public_jwk = jwk.dumps(public_key, kty='RSA') | ||
private_jwk = jwk.dumps(pem, kty='RSA') | ||
dataset_encoded = jwt.encode(header, dataset_payload, private_jwk).decode('utf-8') | ||
|
@@ -110,8 +124,9 @@ def generate_token(): | |
passport_status_encoded = jwt.encode(header, passport_status, private_jwk).decode('utf-8') | ||
passport_dataset1_encoded = jwt.encode(header, passport_dataset1, private_jwk).decode('utf-8') | ||
passport_dataset2_encoded = jwt.encode(header, passport_dataset2, private_jwk).decode('utf-8') | ||
passport_dataset_gdi_encoded = jwt.encode(header, passport_dataset_gdi, private_jwk).decode('utf-8') | ||
return (public_jwk, dataset_encoded, empty_encoded, passport_terms_encoded, passport_status_encoded, | ||
passport_dataset1_encoded, passport_dataset2_encoded) | ||
passport_dataset1_encoded, passport_dataset2_encoded, passport_dataset_gdi_encoded) | ||
|
||
|
||
DATA = generate_token() | ||
|
@@ -143,7 +158,8 @@ async def userinfo(request): | |
DATA[3], | ||
DATA[4], | ||
DATA[5], | ||
DATA[6] | ||
DATA[6], | ||
DATA[7] | ||
] | ||
} | ||
return web.json_response(data) | ||
|