diff --git a/pic-sure-api-wildfly/pom.xml b/pic-sure-api-wildfly/pom.xml
deleted file mode 100644
index 6d0e0b58..00000000
--- a/pic-sure-api-wildfly/pom.xml
+++ /dev/null
@@ -1,390 +0,0 @@
-
-
- 4.0.0
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-api
- 2.0.0-SNAPSHOT
-
- pic-sure-api-wildfly
- war
- pic-sure-api-wildfly
- http://maven.apache.org
-
- UTF-8
- 17.0.0.Final
-
- ${project.build.directory}/wildfly-${wildfly.version}
-
-
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-api-data
- ${project.version}
-
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-passthrough-resource
- classes
- ${project.version}
-
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-aggregate-data-sharing-resource
- classes
- ${project.version}
-
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-resource-api
- ${project.version}
-
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-api-war
- ${project.version}
- war
-
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-util
- ${project.version}
-
-
- javax
- javaee-api
- provided
-
-
- javax.xml.bind
- jaxb-api
-
-
- com.sun.xml.bind
- jaxb-core
-
-
- com.sun.xml.bind
- jaxb-impl
-
-
- io.jsonwebtoken
- jjwt
- test
-
-
- org.hibernate.javax.persistence
- hibernate-jpa-2.1-api
-
-
- com.github.tomakehurst
- wiremock-standalone
-
-
- org.mockito
- mockito-core
- test
-
-
-
- ${project.artifactId}-${project.version}
-
-
- org.apache.maven.plugins
- maven-war-plugin
-
- false
-
-
-
- maven-clean-plugin
- 3.0.0
-
- false
-
-
-
- target/
- false
-
- **/wildfly-*/**
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- unpack-wildfly
- generate-sources
-
- unpack
-
- false
-
-
-
- org.wildfly
- wildfly-dist
- ${wildfly.version}
- zip
- false
- ${project.build.directory}
-
-
-
-
-
- retrieve-mysql-driver
- generate-sources
-
- copy
-
- false
-
-
-
- com.mysql
- mysql-connector-j
- 8.0.32
- jar
- true
- ${jboss.home}/modules/system/layers/base/com/sql/mysql/main/
-
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-hsapi-resource
- ${project.version}
- war
- true
- ${jboss.home}/standalone/deployments
-
-
-
-
-
-
-
-
-
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-passthrough-resource
- ${project.version}
- war
- true
- ${jboss.home}/standalone/deployments
-
-
- edu.harvard.hms.dbmi.avillach
- pic-sure-aggregate-data-sharing-resource
- ${project.version}
- war
- true
- ${jboss.home}/standalone/deployments
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 3.0.2
-
-
- copy-standalone-xml
- generate-sources
-
- copy-resources
-
-
- ${jboss.home}/standalone/configuration
-
-
- src/main/resources/wildflyConfiguration
-
-
-
-
-
- copy-module-xml
- generate-sources
-
- copy-resources
-
-
- ${jboss.home}/modules/
-
-
- src/main/resources/modules/
-
-
-
-
-
-
-
- org.wildfly.plugins
- wildfly-maven-plugin
- 2.0.1.Final
-
- 9990
- ${jboss.home}
-
- -Xmx1024m
- -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- wildfly-run
- pre-integration-test
-
- start
- deploy
-
-
-
-
-
-
- http://localhost:8079
- http://localhost:8079
- http://localhost:8079
- http://localhost:8079
- Patient Id
- http://localhost:8080/pic-sure-irct-resource-${project.version}/pic-sure/v1.4
- http://localhost:8080/pic-sure-aggregate-resource-${project.version}/pic-sure/group
- http://localhost:8080/pic-sure-gnome-i2b2-count-resource-${project.version}/pic-sure/gnome-i2b2-count
- http://localhost:8080/${project.artifactId}-${project.version}/pic-sure
- JSON
- foo
- email
-
-
-
-
-
- wildfly-stop
- post-integration-test
-
- undeploy
- shutdown
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-failsafe-plugin
- 2.22.0
-
-
- --illegal-access=permit
-
-
-
-
- integration-test
-
- integration-test
-
-
-
-
- foo
- email
- http://localhost:8079
- http://localhost:8079
- http://localhost:8079
- Patient Id
- http://localhost:8080/${project.artifactId}-${project.version}/pic-sure
-
-
-
- http://localhost:8080/${project.artifactId}-${project.version}/pic-sure
- http://localhost:8080/${project.artifactId}-${project.version}/
- http://localhost:8080/pic-sure-irct-resource-${project.version}/
- http://localhost:8080/pic-sure-aggregate-resource-${project.version}/pic-sure/group
- http://localhost:8080/pic-sure-hsapi-resource-${project.version}/
- eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjg3OTM1NTE5NjI0LCJzdWIiOiJpbnRlZ3JhdGlvbi50ZXN0QGhtcy5oYXJ2YXJkLmVkdSIsImVtYWlsIjoiaW50ZWdyYXRpb24udGVzdEBobXMuaGFydmFyZC5lZHUiLCJpc3MiOiJiYXIiLCJqdGkiOiJGb28iLCJpYXQiOjE1MzU2MDYwMjR9.RUKkN5_Bsd5MWHhV_YTnotoMqTtrOLszsBTN9FC4n48
-
-
-
-
- verify
-
- verify
-
-
-
-
-
- javax.xml.bind
- jaxb-api
- 2.3.0
-
-
- com.sun.xml.bind
- jaxb-core
- 2.3.0
-
-
- com.sun.xml.bind
- jaxb-impl
- 2.3.0
-
-
- javax.activation
- activation
- 1.1.1
-
-
-
-
-
-
-
diff --git a/pic-sure-api-wildfly/src/main/java/edu/harvard/dbmi/avillach/ResourceTestInitializer.java b/pic-sure-api-wildfly/src/main/java/edu/harvard/dbmi/avillach/ResourceTestInitializer.java
deleted file mode 100644
index b151daab..00000000
--- a/pic-sure-api-wildfly/src/main/java/edu/harvard/dbmi/avillach/ResourceTestInitializer.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package edu.harvard.dbmi.avillach;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Singleton;
-import javax.ejb.Startup;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-import edu.harvard.dbmi.avillach.data.entity.Resource;
-import edu.harvard.hms.dbmi.avillach.GnomeI2B2CountResourceRS;
-import edu.harvard.hms.dbmi.avillach.IRCTResourceRS;
-
-import static edu.harvard.dbmi.avillach.util.HttpClientUtil.composeURL;
-
-@Singleton
-@Startup
-public class ResourceTestInitializer
-{
- public static String TARGET_PICSURE_URL = System.getenv("TARGET_PICSURE_URL");
-// public static String TARGET_IRCT_URL = System.getenv("TARGET_IRCT_URL");
- public static String AGGREGATE_RS_URL = System.getenv("AGGREGATE_RS_URL");
- public static String IRCT_RS_URL = System.getenv("IRCT_RS_URL");
- public static String GNOME_I2B2_RS_URL = System.getenv("GNOME_I2B2_RS_URL");
- @PersistenceContext(unitName = "picsure")
- private EntityManager em;
-
- @PostConstruct
- public void insertTestResources() {
- System.out.println("ResourceTestInitializer, target picsure url is!!!: " + TARGET_PICSURE_URL);
-
- Resource fooResource = new Resource()
-// .setTargetURL(TARGET_IRCT_URL)
-// .setTargetURL("http://localhost:8080/pic-sure-api-wildfly-2.0.0-SNAPSHOT/pic-sure/v1.4")
- .setResourceRSPath(IRCT_RS_URL)
- .setDescription("HMS DBMI NHANES PIC-SURE 1.4 Supply token with key '" + IRCTResourceRS.IRCT_BEARER_TOKEN_KEY + "'")
- .setName("nhanes.hms.harvard.edu")
- .setToken("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJmb29AYmFyLmNvbSIsImlzcyI6ImJhciIsImV4cCI6ODY1NTI4Mzk4NTQzLCJpYXQiOjE1Mjg0ODQ5NDMsImp0aSI6IkZvbyIsImVtYWlsIjoiZm9vQGJhci5jb20ifQ.KE2NIfCzQnd_vhykhb0sHdPHEwvy2Wphc4UVsKAVTgM");
- em.persist(fooResource);
-
- Resource ga4ghResource = new Resource()
- .setTargetURL("http://54.174.229.198:8080/ga4gh/dos/v1/")
- .setResourceRSPath("http://54.174.229.198:8080/ga4gh/dos/v1/")
- .setDescription("GA4GH DOS Resource Server at DBMI/AvillachLab")
- .setName("ga4gh-dos-server");
- em.persist(ga4ghResource);
-
- Resource aggregateResource = new Resource()
-// .setTargetURL("http://localhost:8080/pic-sure-api-wildfly-2.0.0-SNAPSHOT/pic-sure/group")
- .setTargetURL(TARGET_PICSURE_URL)
- .setResourceRSPath(AGGREGATE_RS_URL)
- .setToken("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJmb29AYmFyLmNvbSIsImlzcyI6ImJhciIsImV4cCI6ODY1NTI4Mzk4NTQzLCJpYXQiOjE1Mjg0ODQ5NDMsImp0aSI6IkZvbyIsImVtYWlsIjoiZm9vQGJhci5jb20ifQ.KE2NIfCzQnd_vhykhb0sHdPHEwvy2Wphc4UVsKAVTgM")
- .setDescription("Aggregate Resource RS")
- .setName("Aggregate Resource RS");
- em.persist(aggregateResource);
-
- Resource hsapiResource = new Resource()
- .setTargetURL("https://beta.commonsshare.org/hsapi/")
- .setResourceRSPath(composeURL(TARGET_PICSURE_URL,"hsapi"))
- .setToken("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJmb29AYmFyLmNvbSIsImlzcyI6ImJhciIsImV4cCI6ODY1NTI4Mzk4NTQzLCJpYXQiOjE1Mjg0ODQ5NDMsImp0aSI6IkZvbyIsImVtYWlsIjoiZm9vQGJhci5jb20ifQ.KE2NIfCzQnd_vhykhb0sHdPHEwvy2Wphc4UVsKAVTgM")
- .setDescription("HSAPI Resource RS")
- .setName("HSAPI Resource RS");
- em.persist(hsapiResource);
-
- Resource gnomeI2B2Resource = new Resource()
- .setTargetURL(TARGET_PICSURE_URL)
- .setResourceRSPath(GNOME_I2B2_RS_URL)
- .setToken("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJmb29AYmFyLmNvbSIsImlzcyI6ImJhciIsImV4cCI6ODY1NTI4Mzk4NTQzLCJpYXQiOjE1Mjg0ODQ5NDMsImp0aSI6IkZvbyIsImVtYWlsIjoiZm9vQGJhci5jb20ifQ.KE2NIfCzQnd_vhykhb0sHdPHEwvy2Wphc4UVsKAVTgM")
- .setDescription("Gnome I2B2 Count Resource RS Supply tokens with keys " + GnomeI2B2CountResourceRS.I2B2_BEARER_TOKEN_KEY + " and " + GnomeI2B2CountResourceRS.GNOME_BEARER_TOKEN_KEY)
- .setName("Gnome I2B2 Count Resource RS");
- em.persist(gnomeI2B2Resource);
- }
-
-}
diff --git a/pic-sure-api-wildfly/src/main/java/edu/harvard/dbmi/avillach/UserTestInitializer.java b/pic-sure-api-wildfly/src/main/java/edu/harvard/dbmi/avillach/UserTestInitializer.java
deleted file mode 100644
index 192da95a..00000000
--- a/pic-sure-api-wildfly/src/main/java/edu/harvard/dbmi/avillach/UserTestInitializer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package edu.harvard.dbmi.avillach;
-
-import edu.harvard.dbmi.avillach.data.entity.User;
-import edu.harvard.dbmi.avillach.util.PicsureNaming;
-
-import javax.annotation.PostConstruct;
-import javax.ejb.Singleton;
-import javax.ejb.Startup;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-@Singleton
-@Startup
-public class UserTestInitializer
-{
- @PersistenceContext(unitName = "picsure")
- private EntityManager em;
-
- @PostConstruct
- public void insertTestUsers() {
- User systemUser = new User()
- .setRoles(PicsureNaming.RoleNaming.ROLE_SYSTEM)
- .setSubject("samlp|foo@bar.com")
- .setUserId("foo@bar.com");
- User nonSystemUser = new User()
- .setRoles("")
- .setSubject("samlp|foo2@bar.com")
- .setUserId("foo2@bar.com");
- User tokenInspectionSystem = new User()
- .setRoles(PicsureNaming.RoleNaming.ROLE_TOKEN_INTROSPECTION)
- .setSubject("samlp|foo3@bar.com")
- .setUserId("foo3@bar.com");
- User tokenInspectionUser = new User()
- .setRoles(PicsureNaming.RoleNaming.ROLE_INTROSPECTION_USER)
- .setSubject("samlp|foo4@bar.com")
- .setUserId("foo4@bar.com");
- em.persist(systemUser);
- em.persist(nonSystemUser);
- em.persist(tokenInspectionUser);
- em.persist(tokenInspectionSystem);
- }
-
-}
diff --git a/pic-sure-api-wildfly/src/main/resources/META-INF/persistence.xml b/pic-sure-api-wildfly/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index 84874384..00000000
--- a/pic-sure-api-wildfly/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- org.hibernate.ejb.HibernatePersistence
- java:/PicsureDS
- edu.harvard.dbmi.avillach.data.entity.AuthUser
- edu.harvard.dbmi.avillach.data.entity.Resource
- edu.harvard.dbmi.avillach.data.entity.Query
- edu.harvard.dbmi.avillach.data.entity.NamedDataset
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pic-sure-api-wildfly/src/main/resources/wildflyConfiguration/standalone.xml b/pic-sure-api-wildfly/src/main/resources/wildflyConfiguration/standalone.xml
deleted file mode 100644
index cfc15b34..00000000
--- a/pic-sure-api-wildfly/src/main/resources/wildflyConfiguration/standalone.xml
+++ /dev/null
@@ -1,533 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
- h2
-
- sa
- sa
-
-
-
- jdbc:h2:mem:picsure;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
- h2
-
- sa
- sa
-
-
-
-
- org.h2.jdbcx.JdbcDataSource
-
-
-
-
-
-
-
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${jboss.bind.address:127.0.0.1}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/AggregateResourceIT.java b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/AggregateResourceIT.java
deleted file mode 100644
index 7730c14d..00000000
--- a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/AggregateResourceIT.java
+++ /dev/null
@@ -1,372 +0,0 @@
-package edu.harvard.dbmi.avillach;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonNode;
-import edu.harvard.dbmi.avillach.domain.QueryRequest;
-import edu.harvard.dbmi.avillach.util.PicSureStatus;
-import edu.harvard.hms.dbmi.avillach.IRCTResourceRS;
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpResponse;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.*;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-
-import static edu.harvard.dbmi.avillach.util.HttpClientUtil.composeURL;
-import static edu.harvard.dbmi.avillach.util.HttpClientUtil.retrieveGetResponse;
-import static edu.harvard.dbmi.avillach.util.HttpClientUtil.retrievePostResponse;
-
-import static org.junit.Assert.*;
-
-//Need tests executed in order to fill in variables for later tests
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class AggregateResourceIT extends BaseIT {
-
- private Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private final static String token = System.getProperty("irct.token");
- private final static String queryString = "{" +
- " \"select\": [" +
- " {" +
- " \"alias\": \"gender\", \"field\": {\"pui\": \"/i2b2-nhanes/Demo/demographics/demographics/SEX/male\", \"dataType\":\"STRING\"}" +
- " }," +
- " {" +
- " \"alias\": \"gender\", \"field\": {\"pui\": \"/i2b2-nhanes/Demo/demographics/demographics/SEX/female\", \"dataType\":\"STRING\"}" +
- " }," +
- " {" +
- " \"alias\": \"age\", \"field\": {\"pui\": \"/i2b2-nhanes/Demo/demographics/demographics/AGE\", \"dataType\":\"STRING\"}" +
- " }" +
- " ]," +
- " \"where\": [" +
- " {" +
- " \"predicate\": \"CONTAINS\"," +
- " \"field\": {" +
- " \"pui\": \"/i2b2-nhanes/Demo/demographics/demographics/SEX/male/\"," +
- " \"dataType\": \"STRING\"" +
- " }," +
- " \"fields\": {" +
- " \"ENOUNTER\": \"YES\"" +
- " }" +
- " }" +
- " ]" +
- "}";
- private final static String errorQuery = "{" +
- " \"where\": [" +
- " {" +
- " \"predicate\": \"CONTAINS\"," +
- " \"field\": {" +
- " \"pui\": \"/i2b2-nhanes/Demo/demographics/demographics/nonexistentpath\"," +
- " \"dataType\": \"STRING\"" +
- " }," +
- " \"fields\": {" +
- " \"ENOUNTER\": \"YES\"" +
- " }" +
- " }" +
- " ]" +
- "}";
- private static UUID resourceUUID;
- private static UUID aggregateUUID;
- private static String queryId;
- private static String status;
-
- @BeforeClass
- public static void setUp() throws IOException{
- HttpResponse response = retrieveGetResponse(endpointUrl+"/info/resources", headers);
- assertEquals("Response status code should be 200", 200, response.getStatusLine().getStatusCode());
- List responseBody = objectMapper.readValue(response.getEntity().getContent(), new TypeReference>(){});
- assertFalse(responseBody.isEmpty());
-
- for (JsonNode node : responseBody){
- if (node.get("name").asText().equals("Aggregate Resource RS")){
- aggregateUUID = UUID.fromString(node.get("uuid").asText());
- } else if (node.get("name").asText().contains("nhanes")) {
- resourceUUID = UUID.fromString(node.get("uuid").asText());
- }
- }
- }
-
- @Test
- public void testQuery() throws IOException {
- Map resourceResponse = new HashMap<>();
- resourceResponse.put("resultId", "230958");
- resourceResponse.put("status", "AVAILABLE");
-
- wireMockRule.stubFor(any(urlPathMatching("/queryService/runQuery"))
- .withHeader("Authorization", containing("anInvalidToken"))
- .willReturn(aResponse()
- .withStatus(401)));
-
- wireMockRule.stubFor(any(urlPathMatching("/queryService/runQuery"))
- .withRequestBody(equalTo("poorlyWordedQueryString"))
- .willReturn(aResponse()
- .withStatus(500)));
-
- wireMockRule.stubFor(any(urlPathMatching("/queryService/runQuery"))
- .withRequestBody(containing("/i2b2-nhanes/Demo"))
- .withHeader("Authorization", containing(token))
- .willReturn(aResponse()
- .withStatus(200)
- .withBody(objectMapper.writeValueAsString(resourceResponse))));
-
- wireMockRule.stubFor(any(urlPathMatching("/resultService/resultStatus/.*"))
- .withHeader("Authorization", containing(token))
- .willReturn(aResponse()
- .withStatus(200)
- .withBody(objectMapper.writeValueAsString(resourceResponse))));
-
-
- //Create multiple queries and add them to a main query as a list
- QueryRequest queryRequest1 = new GeneralQueryRequest();
- QueryRequest queryRequest2 = new GeneralQueryRequest();
- Map credentials = new HashMap();
- queryRequest1.setResourceCredentials(credentials);
- queryRequest1.setQuery(queryString);
- queryRequest1.setResourceUUID(resourceUUID);
- queryRequest2.setResourceCredentials(credentials);
- queryRequest2.setQuery(queryString);
- queryRequest2.setResourceUUID(resourceUUID);
- List queryList = new ArrayList<>();
- queryList.add(queryRequest1);
- queryList.add(queryRequest2);
-
- QueryRequest topQuery = new GeneralQueryRequest();
- topQuery.setQuery(queryList);
- topQuery.setResourceUUID(aggregateUUID);
-
- String body = objectMapper.writeValueAsString(topQuery);
-
- //Should throw an error if credentials missing or wrong
- System.out.println("401 URL: " + endpointUrl+"/query" + "|headers: " + headers + "|body: " + body);
- HttpResponse response = retrievePostResponse(endpointUrl+"/query", headers, body);
-// System.out.println("Test Response: " + EntityUtils.toString(response.getEntity().getContent(), "UTF-8"));
- assertEquals("Missing credentials should return a 401", 401, response.getStatusLine().getStatusCode());
- JsonNode responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- String errorType = responseMessage.get("errorType").asText();
- assertEquals("Error type should be error", "error", errorType);
- String errorMessage = responseMessage.get("message").asText();
- assertTrue("Error message should be Unauthorized", errorMessage.contains("Unauthorized"));
-
- credentials.put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, "anInvalidToken");
- queryRequest2.setResourceCredentials(credentials);
- body = objectMapper.writeValueAsString(topQuery);
- response = retrievePostResponse(endpointUrl+"/query", headers, body);
- assertEquals("Invalid credentials should return a 401", 401, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- errorType = responseMessage.get("errorType").asText();
- assertEquals("Error type should be error", "error", errorType);
- errorMessage = responseMessage.get("message").asText();
- assertTrue("Error message should be Unauthorized", errorMessage.contains("Unauthorized"));
-
- logger.info("Aggregate token is: " + token);
- //Should throw an error if missing query string
- credentials.put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, token);
- queryRequest1.setResourceCredentials(credentials);
- queryRequest1.setQuery(null);
- queryRequest2.setResourceCredentials(credentials);
- topQuery.setResourceCredentials(credentials);
- body = objectMapper.writeValueAsString(topQuery);
- response = retrievePostResponse(endpointUrl+"/query", headers, body);
- assertEquals("Missing query should return a 500", 500, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
-
- //Try a poorly worded queryString
- queryRequest1.setQuery("poorly worded query");
- body = objectMapper.writeValueAsString(topQuery);
- response = retrievePostResponse(endpointUrl+"/query", headers, body);
- assertEquals("Incorrectly formatted query should return a 500", 500, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
-
- //Make sure all queries work
- queryRequest1.setQuery(queryString);
- body = objectMapper.writeValueAsString(topQuery);
-
- response = retrievePostResponse(endpointUrl+"/query", headers, body);
- assertEquals("Should return a 200", 200, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- assertNotNull("Status should not be null", responseMessage.get("status"));
- System.out.println("Aggregate response message from " + endpointUrl+"/query is: " + responseMessage.toString());
- queryId = responseMessage.get("picsureResultId").asText();
- System.out.println("Aggregate Resource IT, queryResultId is: " + queryId);
- assertNotNull("picsureResultId should not be null", queryId);
-
- //Want the status to be ERROR if one query errors - send query to be tested by queryStatus
- queryRequest2.setQuery(errorQuery);
- body = objectMapper.writeValueAsString(topQuery);
- response = retrievePostResponse(endpointUrl+"/query", headers, body);
- assertEquals("Should return a 200", 200, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- String errorQueryId = responseMessage.get("picsureResultId").asText();
- assertNotNull("Status should not be null", responseMessage.get("status"));
- }
-
- @Test
- public void testQueryStatus() throws IOException {
- Map resourceResponse = new HashMap<>();
- resourceResponse.put("resultId", "230958");
- resourceResponse.put("status", "AVAILABLE");
-
- Map errorResponse = new HashMap<>();
- errorResponse.put("resultId", "230999");
- errorResponse.put("status", "ERROR");
-
-
- wireMockRule.stubFor(any(urlPathMatching("/resultService/resultStatus/.*"))
- .withHeader("Authorization", containing("anInvalidToken"))
- .willReturn(aResponse()
- .withStatus(401)));
-
- wireMockRule.stubFor(any(urlPathMatching("/resultService/resultStatus/.*"))
- .withHeader("Authorization", containing(token))
- .willReturn(aResponse()
- .withStatus(200)
- .withBody(objectMapper.writeValueAsString(resourceResponse))));
-
- QueryRequest request = new GeneralQueryRequest();
- Map credentials = new HashMap();
- request.setResourceCredentials(credentials);
- String body = objectMapper.writeValueAsString(request);
-
- //Should get 401 for missing or invalid credentials
- System.out.println("401 URL: "+endpointUrl+"/query/" + queryId + "/status");
- HttpResponse response = retrievePostResponse(endpointUrl+"/query/" + queryId + "/status", headers, body);
- assertEquals("Missing credentials should return a 401", 401, response.getStatusLine().getStatusCode());
- JsonNode responseMessage = objectMapper.readTree(response.getEntity().getContent());
- System.out.println(("AggregateResourceIT - test missing or invalid credentials returns: " + responseMessage));
- assertNotNull("Response message should not be null", responseMessage);
- String errorType = responseMessage.get("errorType").asText();
- assertEquals("Error type should be error", "error", errorType);
- String errorMessage = responseMessage.get("message").asText();
- assertTrue("Error message should be Unauthorized", errorMessage.contains("Unauthorized"));
-
- request.getResourceCredentials().put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, "anInvalidToken");
- body = objectMapper.writeValueAsString(request);
-
- response = retrievePostResponse(composeURL(endpointUrl,"/query/" + queryId + "/status"), headers, body);
- assertEquals("Invalid credentials should return a 401", 401, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- errorType = responseMessage.get("errorType").asText();
- assertEquals("Error type should be error", "error", errorType);
- errorMessage = responseMessage.get("message").asText();
- assertTrue("Error message should be Unauthorized", errorMessage.contains("Unauthorized"));
-
- //This should retrieve the status of the query successfully
- request.getResourceCredentials().put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, token);
- body = objectMapper.writeValueAsString(request);
-
- response = retrievePostResponse(endpointUrl+"/query/" + queryId + "/status", headers, body);
- assertEquals("Should return a 200", 200, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- status = responseMessage.get("status").asText();
- assertNotNull("Status should not be null", status);
-
-
- //TODO What if only one query errors
- //Create an errored response
- wireMockRule.stubFor(any(urlPathMatching("/resultService/resultStatus/.*"))
- .withHeader("Authorization", containing(token))
- .willReturn(aResponse()
- .withStatus(200)
- .withBody(objectMapper.writeValueAsString(errorResponse))));
-
- response = retrievePostResponse(endpointUrl+"/query/" + queryId + "/status", headers, body);
- assertEquals("Should return a 200", 200, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- String errorStatus = responseMessage.get("status").asText();
- assertEquals("Status should be ERROR", PicSureStatus.ERROR.name(), errorStatus);
-
-
- }
-
- @Test
- public void testResult() throws IOException, InterruptedException {
- String resultResponse = "aResultOfSomeKind";
-
- wireMockRule.stubFor(any(urlPathMatching("/resultService/result/.*"))
- .withHeader("Authorization", containing("anInvalidToken"))
- .willReturn(aResponse()
- .withStatus(401)));
-
-
- wireMockRule.stubFor(any(urlPathMatching("/resultService/result/.*"))
- .withHeader("Authorization", containing(token))
- .willReturn(aResponse()
- .withStatus(200)
- .withBody(objectMapper.writeValueAsString(resultResponse))));
-
- QueryRequest resultRequest = new GeneralQueryRequest();
-
- Map credentials = new HashMap();
- credentials.put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, token);
-
- QueryRequest request = new GeneralQueryRequest();
- request.setResourceCredentials(credentials);
- String body = objectMapper.writeValueAsString(request);
-
- //Need to make sure result is ready
- while (!status.equals(PicSureStatus.AVAILABLE.name()) && !status.equals(PicSureStatus.ERROR.name())){
- Thread.sleep(2000);
- HttpResponse response = retrievePostResponse(endpointUrl+"/query/" + queryId + "/status", headers, body);
- assertEquals("Should return a 200", 200, response.getStatusLine().getStatusCode());
- JsonNode responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- status = responseMessage.get("status").asText();
- }
- if (status.equals(PicSureStatus.ERROR.name())){
- fail("Query ended with an ERROR");
- }
- request.setResourceCredentials(new HashMap<>());
- body = objectMapper.writeValueAsString(request);
-
- //Missing or invalid credentials should return 401
- HttpResponse response = retrievePostResponse(endpointUrl+"/query/" + queryId + "/result", headers, body);
- assertEquals("Missing credentials should return a 401", 401, response.getStatusLine().getStatusCode());
- JsonNode responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- String errorType = responseMessage.get("errorType").asText();
- assertEquals("Error type should be error", "error", errorType);
- String errorMessage = responseMessage.get("message").asText();
- assertTrue("Error message should be Unauthorized", errorMessage.contains("Unauthorized"));
-
- request.getResourceCredentials().put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, "anInvalidToken");
- body = objectMapper.writeValueAsString(request);
-
- response = retrievePostResponse(endpointUrl+"/query/" + queryId + "/result", headers, body);
- assertEquals("Missing credentials should return a 401", 401, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- errorType = responseMessage.get("errorType").asText();
- assertEquals("Error type should be error", "error", errorType);
- errorMessage = responseMessage.get("message").asText();
- assertTrue("Error message should be Unauthorized", errorMessage.contains("Unauthorized"));
-
- //Should return an array of results
-
- request.getResourceCredentials().put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, token);
- body = objectMapper.writeValueAsString(request);
-
- response = retrievePostResponse(endpointUrl+"/query/" + queryId + "/result", headers, body);
- assertEquals("Should return a 200", 200, response.getStatusLine().getStatusCode());
- responseMessage = objectMapper.readTree(response.getEntity().getContent());
- assertNotNull("Response message should not be null", responseMessage);
- //There were 2 queries so there should be 2 results
- assertEquals("There should be 2 results in the array", 2, responseMessage.size());
-
- }
-
-}
diff --git a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/BaseIT.java b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/BaseIT.java
deleted file mode 100644
index 1d2b3a3a..00000000
--- a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/BaseIT.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package edu.harvard.dbmi.avillach;
-
-import java.io.IOException;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.*;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.tomakehurst.wiremock.junit.WireMockClassRule;
-import edu.harvard.dbmi.avillach.data.entity.Resource;
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.message.BasicHeader;
-import org.junit.BeforeClass;
-
-import io.jsonwebtoken.Jwts;
-import io.jsonwebtoken.SignatureAlgorithm;
-import org.apache.http.client.HttpClient;
-import org.junit.Rule;
-
-import javax.ws.rs.core.HttpHeaders;
-
-import static edu.harvard.dbmi.avillach.util.HttpClientUtil.composeURL;
-import static edu.harvard.dbmi.avillach.util.HttpClientUtil.retrieveGetResponse;
-import static edu.harvard.dbmi.avillach.util.HttpClientUtil.retrievePostResponse;
-import static org.junit.Assert.*;
-
-public class BaseIT {
-
- private static final String CLIENT_SECRET = System.getenv("PIC_SURE_CLIENT_SECRET");
- private static final String USER_ID_CLAIM = System.getenv("PIC_SURE_USER_ID_CLAIM");
-
- protected static String endpointUrl;
- protected static String irctEndpointUrl;
- protected static String aggregate_url;
- protected static String hsapiEndpointUrl;
- protected static UUID resourceId;
-
- //These need to be established here to prevent multiplication of headers
- protected static String jwt = generateJwtForSystemUser();
- protected static List headers = new ArrayList<>(Arrays.asList(new BasicHeader(HttpHeaders.AUTHORIZATION, "Bearer " + jwt), new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json")));
-
- protected static HttpClient client = HttpClientBuilder.create().build();
- protected final static ObjectMapper objectMapper = new ObjectMapper();
-
- protected final static int port = 8079;
- protected final static String testURL = "http://localhost:"+port;
-
- @Rule
- public WireMockClassRule wireMockRule = new WireMockClassRule(port);
-
- @BeforeClass
- public static void beforeClass() {
- endpointUrl = System.getProperty("service.url");
- System.out.println("endpointUrl is: " + endpointUrl);
- irctEndpointUrl = System.getProperty("irct.rs.url");
- System.out.println("irctEndpointUrl is: " + irctEndpointUrl);
- aggregate_url = System.getProperty("aggregate.rs.url");
- hsapiEndpointUrl = System.getProperty("hsapi.service.url");
-
- //insert a resource for testing if necessary
- try {
- String uri = composeURL(endpointUrl, "/resource");
- HttpResponse response = retrieveGetResponse(uri, headers);
- assertEquals("Response status code should be 200", 200, response.getStatusLine().getStatusCode());
- List resources = objectMapper.readValue(response.getEntity().getContent(), new TypeReference>() {
- });
- assertFalse(resources.isEmpty());
-
- String resourceRSPath = null;
- boolean testResourceInserted = false;
- for (Resource r : resources){
- if ("Test Resource".equals(r.getName())){
- testResourceInserted = true;
- resourceId = r.getUuid();
- break;
- } else if (resourceRSPath == null){
- //We'll need a random resourceRSPath for testing
- resourceRSPath = r.getResourceRSPath();
- }
- }
-
- if (!testResourceInserted){
- List