public async Task GivenMetadata_WhenRead_ThenAuditLogEntriesShouldNotBeCreated()
        {
            // This test only works with the in-proc server with customized middleware pipeline
            Skip.If(!_fixture.IsUsingInProcTestServer);

            using FhirResponse response = await _client.ReadAsync <CapabilityStatement>("metadata");

            string correlationId = response.Headers.GetValues(RequestIdHeaderName).FirstOrDefault();

            Assert.NotNull(correlationId);

            Assert.Empty(_auditLogger.GetAuditEntriesByCorrelationId(correlationId));
        }
Exemple #2
0
        public async Task GivenAnExistingResource_WhenDeleted_ThenAuditLogEntriesShouldBeCreated()
        {
            if (!_fixture.IsUsingInProcTestServer)
            {
                // This test only works with the in-proc server with customized middleware pipeline
                return;
            }

            FhirResponse <Patient> result = await _client.CreateAsync(Samples.GetDefaultPatient());

            FhirResponse deleteResult = await _client.DeleteAsync(result.Resource);

            string correlationId = deleteResult.Headers.GetValues(RequestIdHeaderName).First();

            var expectedUri = new Uri($"http://localhost/Patient/{result.Resource.Id}");

            // TODO: The resource type being logged here is incorrect. The issue is tracked by https://github.com/Microsoft/fhir-server/issues/334.
            Assert.Collection(
                _auditLogger.GetAuditEntriesByCorrelationId(correlationId),
                ae => ValidateExecutingAuditEntry(ae, "delete", expectedUri, correlationId),
                ae => ValidateExecutedAuditEntry(ae, "delete", null, expectedUri, HttpStatusCode.NoContent, correlationId));
        }