-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Introducing HealthcareApis #6766
Changes from all commits
4dc900b
cc28213
766a18e
c6fd23c
eca6bdb
8681494
803ad7b
6f88e83
df46744
a21a2c4
60d22bc
bd30f1a
7d6ae9d
6e8a1e5
9790eb9
798155b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file--> | ||
<PropertyGroup> | ||
<AzureApiTag>HealthcareApis_2018-08-20-preview;</AzureApiTag> | ||
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags> | ||
</PropertyGroup> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" /> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<ApplicationIcon /> | ||
<OutputType>Library</OutputType> | ||
<StartupObject /> | ||
</PropertyGroup> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove line 3-8 |
||
<PropertyGroup> | ||
<PackageId>HealthcareApis.Tests</PackageId> | ||
<Description>HealthcareApis.Tests Class Library</Description> | ||
<AssemblyName>HealthcareApis.Tests</AssemblyName> | ||
<VersionPrefix>1.0.0-preview</VersionPrefix> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DefineConstants>TRACE;netcoreapp20;DebugInVS</DefineConstants> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DocumentationFile>obj\Debug\netcoreapp2.0\HealthcareApis.Tests.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove line 17-21 |
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="2.1.0-preview" /> | ||
<PackageReference Include="Microsoft.Azure.Management.ResourceManager.Fluent" Version="1.22.2" /> | ||
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework" Version="1.7.6" /> | ||
<PackageReference Include="xunit" Version="2.3.1" /> | ||
</ItemGroup> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 24,25 and 27 are unnecessary because they are included in AzSdk.test.reference.targets |
||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Management.HealthcareApis\Microsoft.Azure.Management.HealthcareApis.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="SessionRecords\HealthcareApisTests\HealthcareApisAccountUpdateWithCreateTest.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="SessionRecords\HealthcareApisTests\HealthcareApisCheckNameAvailabilityTest.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="SessionRecords\HealthcareApisTests\HealthcareApisCreateAccountErrorTest.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="SessionRecords\HealthcareApisTests\HealthcareApisCreateTest.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="SessionRecords\HealthcareApisTests\HealthcareApisCreateWithParametersTest.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="SessionRecords\HealthcareApisTests\HealthcareApisDeleteAccountErrorTest.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="SessionRecords\HealthcareApisTests\HealthcareApisDeleteTest.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="SessionRecords\HealthcareApisTests\HealthcareApisGetAccountTest.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="SessionRecords\HealthcareApisTests\HealthcareApisListAccountByResourceGroupTest.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Azure.Management.HealthcareApis; | ||
using Microsoft.Azure.Management.HealthcareApis.Models; | ||
using Microsoft.Rest; | ||
using Microsoft.Azure.Management.ResourceManager; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using Xunit; | ||
using Microsoft.Azure.Management.ResourceManager.Models; | ||
|
||
namespace HealthcareApis.Tests.Helpers | ||
{ | ||
public static class HealthcareApisManagementTestUtilities | ||
{ | ||
public static bool IsTestTenant = false; | ||
private static HttpClientHandler Handler = null; | ||
private static Uri testUri = null; | ||
|
||
// These are used to create default accounts | ||
public static string DefaultLocation = IsTestTenant ? null : "westus"; | ||
public const string DefaultKind = "Fhir"; | ||
public static Dictionary<string, string> DefaultTags = new Dictionary<string, string> | ||
{ | ||
{"key1","value1"}, | ||
{"key2","value2"} | ||
}; | ||
|
||
public static Dictionary<string, string> UpdateTags = new Dictionary<string, string> | ||
{ | ||
{"key3","value3"}, | ||
{"key4","value4"}, | ||
{"key5", "value5"} | ||
}; | ||
|
||
public static string objectId = "7df19f2f-6169-40f0-ac1e-9a9b4e65a898"; | ||
public static string authority = "https://login.microsoftonline.com/common"; | ||
public static string audience = "https://azurehealthcareapis.com"; | ||
public static bool smartOnFhirEnabled = false; | ||
public static int offerThroughput = 400; | ||
|
||
private static HttpClientHandler GetHandler() | ||
{ | ||
return Handler; | ||
} | ||
|
||
public static HealthcareApisManagementClient GetHealthcareApisManagementClient(MockContext context, RecordedDelegatingHandler handler) | ||
{ | ||
HealthcareApisManagementClient healthcareApisManagementClient; | ||
if (IsTestTenant) | ||
{ | ||
healthcareApisManagementClient = new HealthcareApisManagementClient(new TokenCredentials("xyz"), GetHandler()); | ||
healthcareApisManagementClient.SubscriptionId = "testSubscription"; | ||
healthcareApisManagementClient.BaseUri = testUri; | ||
} | ||
else | ||
{ | ||
handler.IsPassThrough = true; | ||
healthcareApisManagementClient = context.GetServiceClient<HealthcareApisManagementClient>(handlers: handler); | ||
} | ||
return healthcareApisManagementClient; | ||
} | ||
|
||
public static ServicesDescription GetServiceDescription() | ||
{ | ||
var serviceDescription = new ServicesDescription(DefaultLocation); | ||
return serviceDescription; | ||
} | ||
|
||
public static ServicesPatchDescription GetServicePatchDescription() | ||
{ | ||
var servicePatchDescription = new ServicesPatchDescription(UpdateTags); | ||
return servicePatchDescription; | ||
} | ||
|
||
public static ServicesDescription GetServiceDescriptionWithProperties() | ||
{ | ||
var serviceProperties = GetServiceProperties(); | ||
var serviceDescription = new ServicesDescription(DefaultLocation, default(string), default(string), default(string), DefaultTags, default(string), serviceProperties); | ||
return serviceDescription; | ||
} | ||
|
||
public static ServicesProperties GetServiceProperties() | ||
{ | ||
IList<ServiceAccessPolicyEntry> accessPolicies = new List<ServiceAccessPolicyEntry>(); | ||
accessPolicies.Add(new ServiceAccessPolicyEntry(objectId)); | ||
|
||
string provisioningState = "Succeeded"; | ||
|
||
ServiceCosmosDbConfigurationInfo cosmosDbConfigurationInfo = new ServiceCosmosDbConfigurationInfo(offerThroughput); | ||
ServiceAuthenticationConfigurationInfo authenticationConfigurationInfo = new ServiceAuthenticationConfigurationInfo(authority, audience, smartOnFhirEnabled); | ||
|
||
var serviceProperties = new ServicesProperties(accessPolicies, provisioningState, cosmosDbConfigurationInfo, authenticationConfigurationInfo); | ||
|
||
return serviceProperties; | ||
} | ||
|
||
public static string CreateHealthcareApisAccount(HealthcareApisManagementClient healthcareApisManagementClient, string rgname, string kind = null) | ||
{ | ||
// Generate account name | ||
string accountName = TestUtilities.GenerateName("hca"); | ||
|
||
// Create healthcareApis account | ||
var createdAccount = healthcareApisManagementClient.Services.CreateOrUpdate(rgname, accountName, GetServiceDescriptionWithProperties()); | ||
|
||
return accountName; | ||
} | ||
|
||
public static void VerifyAccountProperties(ServicesDescription account, bool useDefaults, string location = "westus") | ||
{ | ||
// verifies that the account is actually created | ||
Assert.NotNull(account); | ||
Assert.NotNull(account.Id); | ||
Assert.NotNull(account.Location); | ||
Assert.NotNull(account.Name); | ||
Assert.NotNull(account.Etag); | ||
Assert.NotNull(account.Properties); | ||
Assert.Equal(ProvisioningState.Succeeded, account.Properties.ProvisioningState); | ||
|
||
if (!useDefaults) | ||
{ | ||
Assert.NotNull(account.Properties.AuthenticationConfiguration); | ||
Assert.NotNull(account.Properties.CosmosDbConfiguration); | ||
Assert.NotNull(account.Properties.AccessPolicies); | ||
Assert.Equal("https://login.microsoftonline.com/common", account.Properties.AuthenticationConfiguration.Authority); | ||
Assert.Equal("https://azurehealthcareapis.com", account.Properties.AuthenticationConfiguration.Audience); | ||
Assert.False(account.Properties.AuthenticationConfiguration.SmartProxyEnabled); | ||
Assert.Equal(400, account.Properties.CosmosDbConfiguration.OfferThroughput); | ||
Assert.Equal(1, account.Properties.AccessPolicies.Count); | ||
Assert.Equal(ProvisioningState.Succeeded, account.Properties.ProvisioningState); | ||
} | ||
} | ||
|
||
public static void ValidateExpectedException(Action action, string expectedErrorCode) | ||
{ | ||
try | ||
{ | ||
action(); | ||
Assert.True(false, "Expected an Exception"); | ||
} | ||
catch (ErrorDetailsException e) | ||
{ | ||
Assert.Equal(expectedErrorCode, e.Response.StatusCode.ToString()); | ||
} | ||
} | ||
|
||
public static ResourceManagementClient GetResourceManagementClient(MockContext context, RecordedDelegatingHandler handler) | ||
{ | ||
if (IsTestTenant) | ||
{ | ||
return null; | ||
} | ||
else | ||
{ | ||
handler.IsPassThrough = true; | ||
ResourceManagementClient resourcesClient = context.GetServiceClient<ResourceManagementClient>(handlers: handler); | ||
return resourcesClient; | ||
} | ||
} | ||
|
||
public static string CreateResourceGroup(ResourceManagementClient resourcesClient) | ||
{ | ||
var rgname = "res7089"; | ||
|
||
if (!IsTestTenant) | ||
{ | ||
var resourceGroup = resourcesClient.ResourceGroups.CreateOrUpdateAsync( | ||
rgname, | ||
new ResourceGroup | ||
{ | ||
Location = DefaultLocation | ||
}); | ||
} | ||
return rgname; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Threading.Tasks; | ||
|
||
namespace HealthcareApis.Tests.Helpers | ||
{ | ||
public class RecordedDelegatingHandler : DelegatingHandler | ||
{ | ||
|
||
private HttpResponseMessage _response; | ||
|
||
public RecordedDelegatingHandler() | ||
{ | ||
StatusCodeToReturn = HttpStatusCode.Created; | ||
SubsequentStatusCodeToReturn = StatusCodeToReturn; | ||
} | ||
|
||
public HttpStatusCode StatusCodeToReturn { get; set; } | ||
|
||
public HttpStatusCode SubsequentStatusCodeToReturn { get; set; } | ||
|
||
public string Request { get; private set; } | ||
|
||
public HttpRequestHeaders RequestHeaders { get; private set; } | ||
|
||
public HttpContentHeaders ContentHeaders { get; private set; } | ||
|
||
public HttpMethod Method { get; private set; } | ||
|
||
public Uri Uri { get; private set; } | ||
|
||
public bool IsPassThrough { get; set; } | ||
|
||
private int counter; | ||
|
||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) | ||
{ | ||
counter++; | ||
// Save request | ||
if (request.Content == null) | ||
{ | ||
Request = string.Empty; | ||
} | ||
else | ||
{ | ||
Request = await request.Content.ReadAsStringAsync(); | ||
} | ||
RequestHeaders = request.Headers; | ||
if (request.Content != null) | ||
{ | ||
ContentHeaders = request.Content.Headers; | ||
} | ||
Method = request.Method; | ||
Uri = request.RequestUri; | ||
|
||
// Prepare response | ||
if (IsPassThrough) | ||
{ | ||
return await base.SendAsync(request, cancellationToken); | ||
} | ||
else | ||
{ | ||
if (_response != null && counter == 1) | ||
{ | ||
return _response; | ||
} | ||
else | ||
{ | ||
var statusCode = StatusCodeToReturn; | ||
if (counter > 1) | ||
statusCode = SubsequentStatusCodeToReturn; | ||
HttpResponseMessage response = new HttpResponseMessage(statusCode); | ||
response.Content = new StringContent(""); | ||
return response; | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("HealthcareApis.Tests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("HP Inc.")] | ||
[assembly: AssemblyProduct("HealthcareApis.Tests")] | ||
[assembly: AssemblyCopyright("Copyright © HP Inc. 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("060a808a-4de1-4072-9def-9dc75a353c51")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments from management plane perspective: