From 7ff6daf248b3979bec5df7ff7e0c7d2280ba272e Mon Sep 17 00:00:00 2001 From: Parisa Tejari Date: Tue, 26 Nov 2024 14:32:00 +0100 Subject: [PATCH 1/4] add tests for visa token --- .../doa/LocalEGADOAApplicationTests.java | 59 +++++++++++++++---- test/mock_auth.py | 2 +- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java index 8361e75..8635a2c 100644 --- a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java +++ b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java @@ -42,6 +42,7 @@ class LocalEGADOAApplicationTests { private static String validToken; private static String invalidToken; + private static String validVisaToken; @SneakyThrows @BeforeAll @@ -86,6 +87,7 @@ public static void setup() { JSONArray tokens = Unirest.get("http://localhost:8000/tokens").asJson().getBody().getArray(); validToken = tokens.getString(0); invalidToken = tokens.getString(1); + validVisaToken = tokens.getString(2); } @SneakyThrows @@ -218,7 +220,7 @@ void testPOSIXExportRequestFileValidToken() { Assertions.assertTrue(true); return; } - export("EGAF00000000014", false); + export("EGAF00000000014", false, validToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -234,7 +236,7 @@ void testPOSIXExportRequestDatasetValidToken() { Assertions.assertTrue(true); return; } - export("EGAD00010000919", true); + export("EGAD00010000919", true, validToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -250,7 +252,7 @@ void testS3ExportRequestFileValidToken() { Assertions.assertTrue(true); return; } - export("EGAF00000000014", false); + export("EGAF00000000014", false, validToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -266,7 +268,7 @@ void testS3ExportRequestDatasetValidToken() { Assertions.assertTrue(true); return; } - export("EGAD00010000919", true); + export("EGAD00010000919", true, validToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -275,16 +277,17 @@ void testS3ExportRequestDatasetValidToken() { } } + @SneakyThrows @Test - void testS3ExportRequestReferenceValidToken() { - if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { + void testPOSIXExportRequestFileValidVisaToken() { + if (System.getenv("OUTBOX_TYPE").equals("S3")) { Assertions.assertTrue(true); return; } - export("GDI-NO-10001", true); + export("EGAF00000000014", false, validVisaToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); - try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); + try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); @@ -293,12 +296,12 @@ void testS3ExportRequestReferenceValidToken() { @SneakyThrows @Test - void testPOSIXExportRequestReferenceValidToken() { + void testPOSIXExportRequestDatasetValidVisaToken() { if (System.getenv("OUTBOX_TYPE").equals("S3")) { Assertions.assertTrue(true); return; } - export("GDI-NO-10001", true); + export("EGAD00010000919", true, validVisaToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -308,7 +311,39 @@ void testPOSIXExportRequestReferenceValidToken() { } @SneakyThrows - void export(String id, boolean dataset) { + @Test + void testS3ExportRequestFileValidVisaToken() { + if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { + Assertions.assertTrue(true); + return; + } + export("EGAF00000000014", false, validVisaToken); + PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); + try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); + Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { + byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); + Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); + } + } + + @SneakyThrows + @Test + void testS3ExportRequestDatasetValidVisaToken() { + if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { + Assertions.assertTrue(true); + return; + } + export("EGAD00010000919", true, validVisaToken); + PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); + try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); + 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 token) { String mqConnectionString = "amqps://admin:guest@localhost:5671/sda"; ConnectionFactory factory = new ConnectionFactory(); factory.setUri(mqConnectionString); @@ -327,7 +362,7 @@ void export(String id, boolean dataset) { "\t\"%s\": \"%s\",\n" + "\t\"publicKey\": \"%s\"\n" + "}", - validToken, + token, dataset ? "datasetId" : "fileId", id, FileUtils.readFileToString(new File("test/my.pub.pem"), Charset.defaultCharset())); diff --git a/test/mock_auth.py b/test/mock_auth.py index 5c08b89..9e90ad1 100644 --- a/test/mock_auth.py +++ b/test/mock_auth.py @@ -144,7 +144,7 @@ async def jwk_response(request): async def tokens_response(request): """Serve generated tokens.""" - data = [DATA[1], DATA[2]] + data = [DATA[1], DATA[2], DATA[6]] return web.json_response(data) From 84b76d7840c1aec3c4d4aa45cc377b2669a6f2e3 Mon Sep 17 00:00:00 2001 From: Parisa Tejari Date: Tue, 26 Nov 2024 14:12:12 +0100 Subject: [PATCH 2/4] add tests for dataset reference --- .../doa/LocalEGADOAApplicationTests.java | 57 ++++--------------- 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java index 8635a2c..4a1d228 100644 --- a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java +++ b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java @@ -220,7 +220,7 @@ void testPOSIXExportRequestFileValidToken() { Assertions.assertTrue(true); return; } - export("EGAF00000000014", false, validToken); + export("EGAF00000000014", false); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -236,7 +236,7 @@ void testPOSIXExportRequestDatasetValidToken() { Assertions.assertTrue(true); return; } - export("EGAD00010000919", true, validToken); + export("EGAD00010000919", true); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -252,7 +252,7 @@ void testS3ExportRequestFileValidToken() { Assertions.assertTrue(true); return; } - export("EGAF00000000014", false, validToken); + export("EGAF00000000014", false); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -268,7 +268,7 @@ void testS3ExportRequestDatasetValidToken() { Assertions.assertTrue(true); return; } - export("EGAD00010000919", true, validToken); + export("EGAD00010000919", true); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -277,47 +277,14 @@ void testS3ExportRequestDatasetValidToken() { } } - @SneakyThrows @Test - void testPOSIXExportRequestFileValidVisaToken() { - if (System.getenv("OUTBOX_TYPE").equals("S3")) { - Assertions.assertTrue(true); - return; - } - export("EGAF00000000014", false, validVisaToken); - PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); - try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); - Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { - byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); - Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); - } - } - - @SneakyThrows - @Test - void testPOSIXExportRequestDatasetValidVisaToken() { - if (System.getenv("OUTBOX_TYPE").equals("S3")) { - Assertions.assertTrue(true); - return; - } - export("EGAD00010000919", true, validVisaToken); - PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); - try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); - Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { - byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); - Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); - } - } - - @SneakyThrows - @Test - void testS3ExportRequestFileValidVisaToken() { + void testS3ExportRequestReferenceValidToken() { if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { Assertions.assertTrue(true); return; } - export("EGAF00000000014", false, validVisaToken); + 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("requester@elixir-europe.org/body.enc").build()); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -328,14 +295,14 @@ void testS3ExportRequestFileValidVisaToken() { @SneakyThrows @Test - void testS3ExportRequestDatasetValidVisaToken() { - if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { + void testPOSIXExportRequestReferenceValidToken() { + if (System.getenv("OUTBOX_TYPE").equals("S3")) { Assertions.assertTrue(true); return; } - export("EGAD00010000919", true, validVisaToken); + 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("requester@elixir-europe.org/body.enc").build()); + try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); @@ -343,7 +310,7 @@ void testS3ExportRequestDatasetValidVisaToken() { } @SneakyThrows - void export(String id, boolean dataset, String token) { + void export(String id, boolean dataset) { String mqConnectionString = "amqps://admin:guest@localhost:5671/sda"; ConnectionFactory factory = new ConnectionFactory(); factory.setUri(mqConnectionString); @@ -362,7 +329,7 @@ void export(String id, boolean dataset, String token) { "\t\"%s\": \"%s\",\n" + "\t\"publicKey\": \"%s\"\n" + "}", - token, + validToken, dataset ? "datasetId" : "fileId", id, FileUtils.readFileToString(new File("test/my.pub.pem"), Charset.defaultCharset())); From 1f2f0ce0d41e3b8b8c04b42d8a148071cab6d141 Mon Sep 17 00:00:00 2001 From: Parisa Tejari Date: Tue, 26 Nov 2024 14:32:00 +0100 Subject: [PATCH 3/4] add tests for visa token --- .../doa/LocalEGADOAApplicationTests.java | 71 ++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java index 4a1d228..2ee190d 100644 --- a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java +++ b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java @@ -268,7 +268,72 @@ void testS3ExportRequestDatasetValidToken() { Assertions.assertTrue(true); return; } - export("EGAD00010000919", true); + export("EGAD00010000919", true, validToken); + PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); + try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); + Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { + byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); + Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); + } + } + + + @SneakyThrows + @Test + void testPOSIXExportRequestFileValidVisaToken() { + if (System.getenv("OUTBOX_TYPE").equals("S3")) { + Assertions.assertTrue(true); + return; + } + export("EGAF00000000014", false, validVisaToken); + PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); + try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); + Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { + byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); + Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); + } + } + + @SneakyThrows + @Test + void testPOSIXExportRequestDatasetValidVisaToken() { + if (System.getenv("OUTBOX_TYPE").equals("S3")) { + Assertions.assertTrue(true); + return; + } + export("EGAD00010000919", true, validVisaToken); + PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); + try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); + Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { + byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); + Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); + } + } + + @SneakyThrows + @Test + void testS3ExportRequestFileValidVisaToken() { + if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { + Assertions.assertTrue(true); + return; + } + export("EGAF00000000014", false, validVisaToken); + PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); + try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); + Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { + byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); + Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); + } + } + + @SneakyThrows + @Test + void testS3ExportRequestDatasetValidVisaToken() { + if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { + Assertions.assertTrue(true); + return; + } + export("EGAD00010000919", true, validVisaToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -310,7 +375,7 @@ void testPOSIXExportRequestReferenceValidToken() { } @SneakyThrows - void export(String id, boolean dataset) { + void export(String id, boolean dataset, String token) { String mqConnectionString = "amqps://admin:guest@localhost:5671/sda"; ConnectionFactory factory = new ConnectionFactory(); factory.setUri(mqConnectionString); @@ -329,7 +394,7 @@ void export(String id, boolean dataset) { "\t\"%s\": \"%s\",\n" + "\t\"publicKey\": \"%s\"\n" + "}", - validToken, + token, dataset ? "datasetId" : "fileId", id, FileUtils.readFileToString(new File("test/my.pub.pem"), Charset.defaultCharset())); From af280fef934b907d4a05713ca74a9f58cbfb8366 Mon Sep 17 00:00:00 2001 From: Parisa Tejari Date: Wed, 27 Nov 2024 13:47:01 +0100 Subject: [PATCH 4/4] add tests for visa token --- .../doa/LocalEGADOAApplicationTests.java | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java index 2ee190d..2ece458 100644 --- a/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java +++ b/src/test/java/no/uio/ifi/localega/doa/LocalEGADOAApplicationTests.java @@ -220,7 +220,7 @@ void testPOSIXExportRequestFileValidToken() { Assertions.assertTrue(true); return; } - export("EGAF00000000014", false); + export("EGAF00000000014", false, validToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -236,7 +236,7 @@ void testPOSIXExportRequestDatasetValidToken() { Assertions.assertTrue(true); return; } - export("EGAD00010000919", true); + export("EGAD00010000919", true, validToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -252,7 +252,7 @@ void testS3ExportRequestFileValidToken() { Assertions.assertTrue(true); return; } - export("EGAF00000000014", false); + export("EGAF00000000014", false, validToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { @@ -277,6 +277,37 @@ void testS3ExportRequestDatasetValidToken() { } } + @SneakyThrows + @Test + void testS3ExportRequestReferenceValidToken() { + if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { + Assertions.assertTrue(true); + return; + } + export("GDI-NO-10001", true, validToken); + PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); + try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/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, validToken); + PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); + try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); + Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { + byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); + Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); + } + } @SneakyThrows @Test @@ -344,14 +375,14 @@ void testS3ExportRequestDatasetValidVisaToken() { @SneakyThrows @Test - void testS3ExportRequestReferenceValidToken() { - if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { + void testPOSIXExportRequestReferenceValidVisaToken() { + if (System.getenv("OUTBOX_TYPE").equals("S3")) { Assertions.assertTrue(true); return; } - export("GDI-NO-10001", true); + export("GDI-NO-10001", true, validVisaToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); - try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); + try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) { byte[] bytes = IOUtils.toByteArray(crypt4GHInputStream); Assertions.assertEquals("2aef808fb42fa7b1ba76cb16644773f9902a3fdc2569e8fdc049f38280c4577e", DigestUtils.sha256Hex(bytes)); @@ -360,20 +391,19 @@ void testS3ExportRequestReferenceValidToken() { @SneakyThrows @Test - void testPOSIXExportRequestReferenceValidToken() { - if (System.getenv("OUTBOX_TYPE").equals("S3")) { + void testS3ExportRequestReferenceValidVisaToken() { + if (System.getenv("OUTBOX_TYPE").equals("POSIX")) { Assertions.assertTrue(true); return; } - export("GDI-NO-10001", true); + export("GDI-NO-10001", true, validVisaToken); PrivateKey privateKey = KeyUtils.getInstance().readPrivateKey(new File("test/my.sec.pem"), "passw0rd".toCharArray()); - try (InputStream byteArrayInputStream = new FileInputStream("requester@elixir-europe.org/files/body.enc"); + try (InputStream byteArrayInputStream = getMinioClient().getObject(GetObjectArgs.builder().bucket("lega").object("requester@elixir-europe.org/body.enc").build()); 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 token) { String mqConnectionString = "amqps://admin:guest@localhost:5671/sda";