mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-13 08:14:46 +00:00
Merge remote-tracking branch 'origin/2024-10-gg-tx-server-auth' into do-20241021-tx-auth
This commit is contained in:
commit
fa19dc44b1
@ -139,7 +139,7 @@ public class PECodeGenerator {
|
||||
w(b, "public class "+name+" extends PEGeneratedBase {");
|
||||
w(b);
|
||||
if (url != null) {
|
||||
w(b, " private static final String CANONICAL_URL = \""+url+"\";");
|
||||
w(b, " public static final String CANONICAL_URL = \""+url+"\";");
|
||||
w(b);
|
||||
}
|
||||
if (enums.length() > 0) {
|
||||
|
@ -34,6 +34,7 @@ import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.terminologies.client.ITerminologyClient;
|
||||
import org.hl7.fhir.r5.test.utils.CompareUtilities;
|
||||
import org.hl7.fhir.r5.utils.client.EFhirClientException;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.FhirPublication;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
@ -43,6 +44,8 @@ import org.hl7.fhir.utilities.json.model.JsonArray;
|
||||
import org.hl7.fhir.utilities.json.model.JsonObject;
|
||||
import org.hl7.fhir.utilities.json.parser.JsonParser;
|
||||
|
||||
import okhttp3.internal.http2.Header;
|
||||
|
||||
public class TxTester {
|
||||
|
||||
|
||||
@ -101,7 +104,7 @@ public class TxTester {
|
||||
json.add("date", new SimpleDateFormat("EEE, MMM d, yyyy HH:mmZ", new Locale("en", "US")).format(Calendar.getInstance().getTime()) + timezone());
|
||||
try {
|
||||
JsonObject tests = loadTests();
|
||||
ITerminologyClient tx = connectToServer();
|
||||
ITerminologyClient tx = connectToServer(modes);
|
||||
boolean ok = checkClient(tx);
|
||||
for (JsonObject suite : tests.getJsonObjects("suites")) {
|
||||
if ((!suite.has("mode") || modes.contains(suite.asString("mode")))) {
|
||||
@ -150,19 +153,21 @@ public class TxTester {
|
||||
return JsonParser.parseObject(loader.loadContent("test-cases.json"));
|
||||
}
|
||||
|
||||
private ITerminologyClient connectToServer() throws URISyntaxException {
|
||||
private ITerminologyClient connectToServer(List<String> modes) throws URISyntaxException {
|
||||
System.out.println("Connect to "+server);
|
||||
return new TerminologyClientFactory(FhirPublication.R4).makeClient("Test-Server", server, "Tools/Java", null);
|
||||
ITerminologyClient client = new TerminologyClientFactory(FhirPublication.R4).makeClient("Test-Server", server, "Tools/Java", null);
|
||||
return client;
|
||||
}
|
||||
|
||||
|
||||
public String executeTest(JsonObject suite, JsonObject test, List<String> modes) throws URISyntaxException, FHIRFormatError, FileNotFoundException, IOException {
|
||||
error = null;
|
||||
if (tx == null) {
|
||||
tx = connectToServer();
|
||||
tx = connectToServer(modes);
|
||||
checkClient(tx);
|
||||
}
|
||||
List<Resource> setup = loadSetupResources(suite);
|
||||
|
||||
if (runTest(test, tx, setup, modes, "*", null)) {
|
||||
return null;
|
||||
} else {
|
||||
@ -180,10 +185,12 @@ public class TxTester {
|
||||
List<Resource> setup = loadSetupResources(suite);
|
||||
boolean ok = true;
|
||||
for (JsonObject test : suite.getJsonObjects("tests")) {
|
||||
if (test.asBoolean("disabled")) {
|
||||
ok = true;
|
||||
} else {
|
||||
ok = runTest(test, tx, setup, modes, filter, outputS.forceArray("tests")) && ok;
|
||||
if ((!test.has("mode") || modes.contains(test.asString("mode")))) {
|
||||
if (test.asBoolean("disabled")) {
|
||||
ok = true;
|
||||
} else {
|
||||
ok = runTest(test, tx, setup, modes, filter, outputS.forceArray("tests")) && ok;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
@ -199,7 +206,16 @@ public class TxTester {
|
||||
outputT.add("name", test.asString("name"));
|
||||
if (Utilities.noString(filter) || filter.equals("*") || test.asString("name").contains(filter)) {
|
||||
System.out.print(" Test "+test.asString("name")+": ");
|
||||
Header header = null;
|
||||
try {
|
||||
if (test.has("header")) {
|
||||
JsonObject hdr = test.getJsonObject("header");
|
||||
if (hdr.has("mode") && modes.contains(hdr.asString("mode"))) {
|
||||
header = new Header(hdr.asString("name"), hdr.asString("value"));
|
||||
tx.getClientHeaders().addHeader(header);
|
||||
}
|
||||
}
|
||||
|
||||
Parameters req = (Parameters) loader.loadResource(chooseParam(test, "request", modes));
|
||||
|
||||
String fn = chooseParam(test, "response", modes);
|
||||
@ -236,12 +252,18 @@ public class TxTester {
|
||||
if (msg != null) {
|
||||
outputT.add("message", msg);
|
||||
}
|
||||
if (header != null) {
|
||||
tx.getClientHeaders().removeHeader(header);
|
||||
}
|
||||
return msg == null;
|
||||
} catch (Exception e) {
|
||||
System.out.println(" ... Exception: "+e.getMessage());
|
||||
System.out.print(" ");
|
||||
error = e.getMessage();
|
||||
e.printStackTrace();
|
||||
if (header != null) {
|
||||
tx.getClientHeaders().removeHeader(header);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -400,6 +422,7 @@ public class TxTester {
|
||||
} catch (EFhirClientException e) {
|
||||
code = e.getCode();
|
||||
OperationOutcome oo = e.getServerError();
|
||||
TxTesterScrubbers.scrubOO(oo, tight);
|
||||
oo.setText(null);
|
||||
pj = new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(oo);
|
||||
}
|
||||
|
@ -92,7 +92,9 @@ public class TxTesterScrubbers {
|
||||
scrubDR(po, tight);
|
||||
po.getIssue().removeIf(i -> i.hasDiagnostics() & !i.hasDetails());
|
||||
for (OperationOutcomeIssueComponent iss : po.getIssue()) {
|
||||
iss.setDiagnostics(null);
|
||||
if (iss.hasDiagnostics() && !iss.getDiagnostics().toLowerCase().contains("x-request-id")) {
|
||||
iss.setDiagnostics(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
4
pom.xml
4
pom.xml
@ -14,7 +14,7 @@
|
||||
HAPI FHIR
|
||||
-->
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.3.33-SNAPSHOT</version>
|
||||
<version>6.4.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
@ -23,7 +23,7 @@
|
||||
<commons_io_version>2.17.0</commons_io_version>
|
||||
<guava_version>32.0.1-jre</guava_version>
|
||||
<hapi_fhir_version>6.4.1</hapi_fhir_version>
|
||||
<validator_test_case_version>1.5.28-SNAPSHOT</validator_test_case_version>
|
||||
<validator_test_case_version>1.6.0-SNAPSHOT</validator_test_case_version>
|
||||
<jackson_version>2.17.0</jackson_version>
|
||||
<junit_jupiter_version>5.9.2</junit_jupiter_version>
|
||||
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
|
||||
|
Loading…
x
Reference in New Issue
Block a user