Skip to content

Commit

Permalink
add tests for visa token
Browse files Browse the repository at this point in the history
  • Loading branch information
Parisa68 committed Nov 27, 2024
1 parent 1f2f0ce commit af280fe
Showing 1 changed file with 42 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]/files/body.enc");
Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) {
Expand All @@ -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("[email protected]/files/body.enc");
Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) {
Expand All @@ -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("[email protected]/body.enc").build());
Crypt4GHInputStream crypt4GHInputStream = new Crypt4GHInputStream(byteArrayInputStream, privateKey)) {
Expand All @@ -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("[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, validToken);
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
@Test
Expand Down Expand Up @@ -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("[email protected]/body.enc").build());
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));
Expand All @@ -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("[email protected]/files/body.enc");
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
void export(String id, boolean dataset, String token) {
String mqConnectionString = "amqps://admin:guest@localhost:5671/sda";
Expand Down

0 comments on commit af280fe

Please sign in to comment.