Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a local copy of the npm packages for the validator #3241

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Microsoft.Health.Fhir.Api</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>R4</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Content Remove="C:\Users\jaerwin\.nuget\packages\hl7.fhir.specification.r4\4.3.0\contentFiles\any\any\specification.zip" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Microsoft.Health.Fhir.Shared.Api\Modules\AnonymizationModule.cs" Link="Modules\AnonymizationModule.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
<PropertyGroup>
<DefineConstants>R4;R4B</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Content Remove="C:\Users\jaerwin\.nuget\packages\hl7.fhir.specification.r4b\4.3.0\contentFiles\any\any\specification.zip" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ensure.That" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
<PropertyGroup>
<DefineConstants>R5</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Content Remove="C:\Users\jaerwin\.nuget\packages\hl7.fhir.specification.r5\4.3.0\contentFiles\any\any\specification.zip" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ensure.That" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ private IResourceResolver Initialize()
packagesToInclude.Add(packageVariables.CorePackageName);
packagesToInclude.Add(packageVariables.ExpansionsPackageName);

#if !R5
// elements package name is not included in the reflection metadata, but we should try and include it
var extensionsPackageName = packageVariables.ExpansionsPackageName.Replace("expansions", "elements", StringComparison.OrdinalIgnoreCase);
LTA-Thinking marked this conversation as resolved.
Show resolved Hide resolved
packagesToInclude.Add(extensionsPackageName);
#endif
}

foreach (var package in _coreConfig.PackageConfiguration.PackageNames)
Expand All @@ -80,9 +82,20 @@ private IResourceResolver Initialize()
{
// Allow local packages
var resolvedPath = Path.GetFullPath(_coreConfig.PackageConfiguration.PackageSource, Environment.CurrentDirectory);
validationSource = new FhirPackageSource(Directory.GetFiles(resolvedPath)

var packageFileList = Directory.GetFiles(resolvedPath)
.Where(f => packagesToInclude.Any(p => f.Contains(p, StringComparison.OrdinalIgnoreCase)
&& f.EndsWith("tgz", StringComparison.OrdinalIgnoreCase))).ToArray());
&& f.EndsWith("tgz", StringComparison.OrdinalIgnoreCase))).ToArray();

if (packageFileList.Length != packagesToInclude.Count)
{
_logger.LogWarning(
"Attempted to load {DesiredPackageList} packages, but found {ActualPackageList} in file system.",
string.Join(',', packagesToInclude),
string.Join(',', packageFileList));
}

validationSource = new FhirPackageSource(packageFileList);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Health.Fhir.Shared.Web/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FhirServer": {
"Security": {
"Enabled": true,
"Enabled": false,
LTA-Thinking marked this conversation as resolved.
Show resolved Hide resolved
"EnableAadSmartOnFhirProxy": true,
"Authentication": {
"Audience": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<DefineConstants>STU3</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Content Remove="C:\Users\jaerwin\.nuget\packages\hl7.fhir.specification.stu3\4.3.0\contentFiles\any\any\specification.zip" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Microsoft.Health.Fhir.Shared.Api\Modules\AnonymizationModule.cs" Link="Modules\AnonymizationModule.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reflection;
using Hl7.Fhir.Model;
using Microsoft.Health.Fhir.Client;
using Microsoft.Health.Fhir.Core.Extensions;
using Microsoft.Health.Fhir.Core.Models;
using Microsoft.Health.Fhir.Tests.Common;
using Microsoft.Health.Fhir.Tests.Common.FixtureParameters;
using Microsoft.Health.Fhir.Tests.E2E.Common;
Expand All @@ -27,6 +27,7 @@ namespace Microsoft.Health.Fhir.Tests.E2E.Rest
public class BatchTests : IClassFixture<HttpIntegrationTestFixture>
{
private readonly TestFhirClient _client;
private readonly int _firelySdkVersion;
private readonly Dictionary<HttpStatusCode, string> _statusCodeMap = new Dictionary<HttpStatusCode, string>()
{
{ HttpStatusCode.NoContent, "204" },
Expand All @@ -40,6 +41,7 @@ public class BatchTests : IClassFixture<HttpIntegrationTestFixture>
public BatchTests(HttpIntegrationTestFixture fixture)
{
_client = fixture.TestFhirClient;
_firelySdkVersion = Assembly.GetAssembly(typeof(Hl7.Fhir.Model.Resource)).GetName().Version.Major;
}

[Fact]
Expand Down Expand Up @@ -178,7 +180,7 @@ private void ValidateOperationOutcome(string actualStatusCode, OperationOutcome
[InlineData(false)]
public async Task GivenABatchBundle_WithProfileValidationFlag_ReturnsABundleResponse(bool profileValidation)
{
Skip.If(ModelInfoProvider.Instance.Version == FhirSpecification.R5, "Validation not currently working correctly for R5");
Skip.If(_firelySdkVersion < 5, "Validation not currently working correctly for R5 previous to firely version 5");

var bundle = new Hl7.Fhir.Model.Bundle
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
using System;
using System.Linq;
using System.Net;
using System.Reflection;
using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Hl7.Fhir.Serialization;
using Microsoft.Health.Fhir.Client;
using Microsoft.Health.Fhir.Core.Extensions;
using Microsoft.Health.Fhir.Core.Models;
using Microsoft.Health.Fhir.Tests.Common;
using Microsoft.Health.Fhir.Tests.Common.FixtureParameters;
using Microsoft.Health.Fhir.Tests.E2E.Common;
Expand All @@ -27,10 +27,12 @@ public class ValidateTests : IClassFixture<ValidateTestFixture>
{
private const string Success = "All OK";
private readonly TestFhirClient _client;
private readonly int _firelySdkVersion;

public ValidateTests(ValidateTestFixture fixture)
{
_client = fixture.TestFhirClient;
_firelySdkVersion = Assembly.GetAssembly(typeof(Hl7.Fhir.Model.Resource)).GetName().Version.Major;
}

[SkippableTheory]
Expand All @@ -44,7 +46,7 @@ public ValidateTests(ValidateTestFixture fixture)
[InlineData("CarePlan/$validate", "Profile-CarePlan-uscore", null)]
public async void GivenAValidateRequest_WhenTheResourceIsValid_ThenAnOkMessageIsReturned(string path, string filename, string profile)
{
Skip.If(ModelInfoProvider.Instance.Version == FhirSpecification.R5, "Validation not currently working correctly for R5");
Skip.If(_firelySdkVersion < 5, "Validation not currently working correctly for R5 previous to firely version 5");

OperationOutcome outcome = await _client.ValidateAsync(path, Samples.GetJson(filename), profile);

Expand Down Expand Up @@ -140,7 +142,7 @@ public async void GivenAValidateRequest_WhenTheResourceIsInvalid_ThenADetailedEr
[SkippableFact]
public async void GivenAValidateByIdRequest_WhenTheResourceIsValid_ThenAnOkMessageIsReturned()
{
Skip.If(ModelInfoProvider.Instance.Version == FhirSpecification.R5, "Validation not currently working correctly for R5");
Skip.If(_firelySdkVersion < 5, "Validation not currently working correctly for R5 previous to firely version 5");

var fhirSource = Samples.GetJson("Profile-Patient-uscore");
var parser = new FhirJsonParser();
Expand Down Expand Up @@ -172,7 +174,7 @@ public async void GivenAValidateByIdRequestWithStricterProfile_WhenRunningValida
[SkippableFact]
public async void GivenAValidateRequest_WhenAValidResourceIsPassedByParameter_ThenAnOkMessageIsReturned()
{
Skip.If(ModelInfoProvider.Instance.Version == FhirSpecification.R5, "Validation not currently working correctly for R5");
Skip.If(_firelySdkVersion < 5, "Validation not currently working correctly for R5 previous to firely version 5");

var payload = "{\"resourceType\": \"Parameters\", \"parameter\": [{\"name\": \"resource\", \"resource\": {\"resourceType\": \"Patient\", \"id\": \"123\"}}]}";

Expand Down