public void TestAuthenticationOnBefore() { FhirClient validationFhirClient = new FhirClient("https://sqlonfhir.azurewebsites.net/fhir"); validationFhirClient.OnBeforeRequest += (object sender, BeforeRequestEventArgs e) => { e.RawRequest.Headers.Add("Authorization", "Bearer bad-bearer"); }; try { var output = validationFhirClient.ValidateResource(new Patient()); } catch (FhirOperationException ex) { Assert.IsTrue(ex.Status == HttpStatusCode.Forbidden || ex.Status == HttpStatusCode.Unauthorized, "Excpeted a security exception"); } }
public void InvokeResourceValidation() { var client = new FhirClient(testEndpoint); var pat = client.Read <Patient>("Patient/patient-uslab-example1"); try { var vresult = client.ValidateResource(pat, null, new FhirUri("http://hl7.org/fhir/StructureDefinition/uslab-patient")); Assert.Fail("Should have resulted in 400"); } catch (FhirOperationException fe) { Assert.AreEqual(System.Net.HttpStatusCode.BadRequest, fe.Status); Assert.IsTrue(fe.Outcome.Issue.Where(i => i.Severity == OperationOutcome.IssueSeverity.Error).Any()); } }
[TestMethod,Ignore]//returns 500: validation of slices is not done yet. public void InvokeResourceValidation() { var client = new FhirClient(testEndpoint); var pat = client.Read<Patient>("Patient/patient-uslab-example1"); var vresult = client.ValidateResource(pat, null, new FhirUri("http://hl7.org/fhir/StructureDefinition/uslab-patient")); Assert.IsTrue(vresult.Success()); }
[TestMethod]//returns 500: validation of slices is not done yet. public void InvokeResourceValidation() { var client = new FhirClient(testEndpoint); var pat = client.Read<Patient>("Patient/patient-uslab-example1"); try { var vresult = client.ValidateResource(pat, null, new FhirUri("http://hl7.org/fhir/StructureDefinition/uslab-patient")); Assert.Fail("Should have resulted in 400"); } catch(FhirOperationException fe) { Assert.AreEqual(System.Net.HttpStatusCode.BadRequest, fe.Status); Assert.IsTrue(fe.Outcome.Issue.Where(i => i.Severity == OperationOutcome.IssueSeverity.Error).Any()); } }
public void InvokeResourceValidation() { var client = new FhirClient(testEndpoint); var pat = client.Read<Patient>("Patient/uslab-example1"); var vresult = client.ValidateResource(pat, null, new FhirUri("http://fhir-dev.healthintersections.com.au/open/StructureDefinition/patient-uslab-uslabpatient")); Assert.IsTrue(vresult.Success()); }