public async Task InitializeAsync()
        {
            string environmentUrl = Environment.GetEnvironmentVariable($"TestEnvironmentUrl{Constants.TestEnvironmentVariableVersionSuffix}");

            // Only set up test fixture if running against remote server
            if (!string.IsNullOrWhiteSpace(environmentUrl))
            {
                var baseUrl = "https://localhost:" + Port;
                SmartLauncherUrl = baseUrl + "/index.html";

                var builder = WebHost.CreateDefaultBuilder()
                    .ConfigureAppConfiguration((hostingContext, config) =>
                    {
                        config.AddInMemoryCollection(new Dictionary<string, string>
                        {
                            { "FhirServerUrl", environmentUrl },
                            { "ClientId", TestApplications.NativeClient.ClientId },
                            { "DefaultSmartAppUrl", "/sampleapp/launch.html" },
                        });
                    })
                    .UseStartup<SmartLauncher.Startup>()
                    .UseUrls(baseUrl);

                WebServer = builder.Build();
                WebServer.Start();

                TestFhirServer testFhirServer = await _testFhirServerFactory.GetTestFhirServerAsync(DataStore.CosmosDb, null);
                TestFhirClient = testFhirServer.GetTestFhirClient(ResourceFormat.Json);
            }
        }
Exemple #2
0
 public FhirClient(
     HttpClient httpClient,
     TestFhirServer testFhirServer,
     ResourceFormat format,
     TestApplication clientApplication,
     TestUser user,
     (bool SecurityEnabled, string AuthorizeUrl, string TokenUrl) securitySettings)
 public TestFhirClient(
     HttpClient httpClient,
     TestFhirServer testFhirServer,
     ResourceFormat format,
     TestApplication clientApplication,
     TestUser user)
     : base(httpClient, format)
 {
     _testFhirServer    = testFhirServer;
     _clientApplication = clientApplication;
     _user = user;
 }
        public TestFhirClient(
            HttpClient httpClient,
            TestFhirServer testFhirServer,
            ResourceFormat format,
            TestApplication clientApplication,
            TestUser user)
            : base(httpClient, format)
        {
            _testFhirServer    = testFhirServer;
            _clientApplication = clientApplication;
            _user = user;

            ConfigureSecurityOptions().GetAwaiter().GetResult();
            SetupAuthenticationAsync(clientApplication, user).GetAwaiter().GetResult();
        }
Exemple #5
0
        public void Background()
        {
            "Given a running server".x(() => _server = new TestFhirServer(_outputHelper, "https://localhost:60001"));

            "and a FHIR client".x(
                () => _client = new FhirClient(
                    "https://localhost:60001/fhir",
                    new FhirClientSettings
            {
                CompressRequestBody       = true,
                ParserSettings            = ParserSettings.CreateDefault(),
                PreferCompressedResponses = true,
                PreferredFormat           = ResourceFormat.Json,
                UseFormatParameter        = false,
                VerifyFhirVersion         = false
            },
                    messageHandler: _server.Server.CreateHandler()));
        }