public async Task GivenABatch_WhenPost_ThenAuditLogEntriesShouldBeCreated() { var batch = Samples.GetDefaultBatch().ToPoco <Bundle>(); await _client.UpdateAsync(batch.Entry[2].Resource as Patient); List <(string expectedActions, string expectedPathSegments, HttpStatusCode?expectedStatusCodes, ResourceType?resourceType)> expectedList = new List <(string, string, HttpStatusCode?, ResourceType?)> { ("batch", string.Empty, HttpStatusCode.OK, ResourceType.Bundle), ("delete", batch.Entry[5].Request.Url, HttpStatusCode.NoContent, null), ("create", batch.Entry[0].Request.Url, HttpStatusCode.Created, ResourceType.Patient), ("create", batch.Entry[1].Request.Url, HttpStatusCode.Created, ResourceType.Patient), ("update", batch.Entry[2].Request.Url, HttpStatusCode.OK, ResourceType.Patient), ("update", batch.Entry[3].Request.Url, HttpStatusCode.Created, ResourceType.Patient), ("update", batch.Entry[4].Request.Url, Constants.IfMatchFailureStatus, ResourceType.OperationOutcome), ("search-type", batch.Entry[8].Request.Url, HttpStatusCode.OK, ResourceType.Bundle), ("read", batch.Entry[9].Request.Url, HttpStatusCode.NotFound, ResourceType.OperationOutcome), }; await ExecuteAndValidateBundle( () => { return(_client.PostBundleAsync(batch)); }, expectedList, TestApplications.ServiceClient.ClientId); }
public async Task GivenABatchAndUserWithoutWrite_WhenPost_ThenAuditLogEntriesShouldBeCreated() { var batch = new Bundle { Type = Bundle.BundleType.Batch, Entry = new List <Bundle.EntryComponent> { new Bundle.EntryComponent { Resource = Samples.GetDefaultObservation().ToPoco(), Request = new Bundle.RequestComponent { Method = Bundle.HTTPVerb.POST, Url = "Observation", }, }, new Bundle.EntryComponent { Request = new Bundle.RequestComponent { Method = Bundle.HTTPVerb.GET, Url = "Patient?name=peter", }, }, }, }; List <(string expectedActions, string expectedPathSegments, HttpStatusCode?expectedStatusCodes, ResourceType?resourceType)> expectedList = new List <(string, string, HttpStatusCode?, ResourceType?)> { ("batch", string.Empty, HttpStatusCode.OK, ResourceType.Bundle), ("create", "Observation", HttpStatusCode.Forbidden, ResourceType.Observation), ("search-type", "Patient?name=peter", HttpStatusCode.OK, ResourceType.Bundle), }; FhirClient tempClient = _client.CreateClientForUser(TestUsers.ReadOnlyUser, TestApplications.NativeClient); await ExecuteAndValidateBundle( () => tempClient.PostBundleAsync(batch), expectedList, TestApplications.NativeClient.ClientId); }