-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[do not merge before 4118] Adding changes to support Private DNS Public Preview #4109
Merged
dsgouda
merged 17 commits into
Azure:psSdkJson6
from
muwaqar:muwaqar/privatedns-public-preview
Mar 14, 2018
Merged
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
bb1ef9b
Generating SDK based on 2018-03-01-preview version.
170e123
Deleting old session records.
263e2bb
Adding zone scenario tests for Private DNS.
f191ff8
Modifying RecordSet tests for Private zones.
e97cfa4
Including session records again.
959e2fc
Bumping up the version.
6cdcd44
Re-generating the SDK based from generate.cmd (fork: owolabi2/private…
ea7fb48
Bumping up the version again to 2.2.0 since 2.1.0 will be used by 201…
3678f29
Re-generating the SDK making the ZoneType optional.
afc7b3d
Including changes for 2017-10-01 API version.
95fbc7f
Re-recording all tests.
b777567
Minor refactoring.
5582818
Resolving merge conflicts.
6916503
Fixing duplicated lines.
bdac517
Generating SDK against merged Swagger.
0138f9a
capitalizing DNS in csproj
0505c17
Downgrading assemblyversion to 2.1.0.0
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>Network_2018-03-01-preview;</AzureApiTag> | ||
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,19 +2,27 @@ | |
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.Azure.Management.Dns.Models; | ||
using Microsoft.Azure.Management.Network; | ||
using Microsoft.Azure.Management.Network.Models; | ||
using Microsoft.Azure.Management.Resources; | ||
using Microsoft.Azure.Management.Resources.Models; | ||
using Microsoft.Azure.Test; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using Xunit; | ||
using Microsoft.Azure.Management.Dns.Models; | ||
using SubResource = Microsoft.Azure.Management.Dns.Models.SubResource; | ||
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. @muwaqar sort and remove unused usings (if applicable) |
||
|
||
namespace Microsoft.Azure.Management.Dns.Testing | ||
{ | ||
using Rest.ClientRuntime.Azure.TestFramework; | ||
|
||
public static class ResourceGroupHelper | ||
{ | ||
// DNS resources are in location "global" but resource groups cannot be in that same location | ||
private const string ResourceLocation = "Central US"; | ||
|
||
private static readonly Random RandomGenerator = new Random(); | ||
|
||
/// <summary> | ||
/// Default constructor for management clients, using the TestSupport Infrastructure | ||
/// </summary> | ||
|
@@ -25,8 +33,7 @@ public static ResourceManagementClient GetResourcesClient( | |
RecordedDelegatingHandler handler) | ||
{ | ||
handler.IsPassThrough = true; | ||
var client = context.GetServiceClient<ResourceManagementClient>( | ||
handlers: handler); | ||
var client = context.GetServiceClient<ResourceManagementClient>(handlers: handler); | ||
return client; | ||
} | ||
|
||
|
@@ -35,15 +42,28 @@ public static ResourceManagementClient GetResourcesClient( | |
/// using the TestSupport Infrastructure | ||
/// </summary> | ||
/// <param name="handler"></param> | ||
/// <returns>A resource management client, created from the current context | ||
/// (environment variables)</returns> | ||
/// <returns>A resource management client, created from the current context (environment variables)</returns> | ||
public static DnsManagementClient GetDnsClient( | ||
MockContext context, | ||
RecordedDelegatingHandler handler) | ||
{ | ||
handler.IsPassThrough = true; | ||
var client = context.GetServiceClient<DnsManagementClient>( | ||
handlers: handler); | ||
var client = context.GetServiceClient<DnsManagementClient>(handlers: handler); | ||
return client; | ||
} | ||
|
||
/// <summary> | ||
/// Default constructor for network clients, | ||
/// using the TestSupport Infrastructure | ||
/// </summary> | ||
/// <param name="handler"></param> | ||
/// <returns>A netowrk management client, created from the current context (environment variables)</returns> | ||
public static NetworkManagementClient GetNetworkClient( | ||
MockContext context, | ||
RecordedDelegatingHandler handler) | ||
{ | ||
handler.IsPassThrough = true; | ||
var client = context.GetServiceClient<NetworkManagementClient>(handlers: handler); | ||
return client; | ||
} | ||
|
||
|
@@ -68,8 +88,7 @@ public static string GetResourceLocation( | |
parts[1], | ||
StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
location = resource.Locations.FirstOrDefault( | ||
loca => !string.IsNullOrEmpty(loca)); | ||
location = resource.Locations.FirstOrDefault(loca => !string.IsNullOrEmpty(loca)); | ||
} | ||
} | ||
|
||
|
@@ -79,22 +98,13 @@ public static string GetResourceLocation( | |
public static ResourceGroup CreateResourceGroup( | ||
ResourceManagementClient resourcesClient) | ||
{ | ||
string resourceGroupName = | ||
TestUtilities.GenerateName("hydratestdnsrg"); | ||
|
||
// DNS resources are in location "global" but resource groups | ||
// can't be in that same location | ||
string location = "Central US"; | ||
|
||
Assert.False( | ||
string.IsNullOrEmpty(location), | ||
"CSM did not return any valid locations for DNS resources"); | ||
string resourceGroupName = TestUtilities.GenerateName("hydratestdnsrg"); | ||
|
||
var response = resourcesClient.ResourceGroups.CreateOrUpdate( | ||
resourceGroupName, | ||
new ResourceGroup | ||
{ | ||
Location = location | ||
Location = ResourceLocation | ||
}); | ||
|
||
return response; | ||
|
@@ -109,13 +119,71 @@ public static Zone CreateZone( | |
return dnsClient.Zones.CreateOrUpdate( | ||
resourceGroup.Name, | ||
zoneName, | ||
new Microsoft.Azure.Management.Dns.Models.Zone | ||
new Zone | ||
{ | ||
ZoneType = ZoneType.Public, | ||
Location = location, | ||
Etag = null | ||
}, | ||
null, | ||
null); | ||
} | ||
|
||
public static Zone CreatePrivateZone( | ||
DnsManagementClient dnsClient, | ||
string zoneName, | ||
string location, | ||
IList<SubResource> registrationVnets, | ||
IList<SubResource> resolutionVnets, | ||
ResourceGroup resourceGroup) | ||
{ | ||
return dnsClient.Zones.CreateOrUpdate( | ||
resourceGroup.Name, | ||
zoneName, | ||
new Zone | ||
{ | ||
ZoneType = ZoneType.Private, | ||
Location = location, | ||
Etag = null, | ||
RegistrationVirtualNetworks = registrationVnets, | ||
ResolutionVirtualNetworks = resolutionVnets, | ||
}, | ||
null, | ||
null); | ||
} | ||
|
||
public static VirtualNetwork CreateVirtualNetwork( | ||
string resourceGroupName, | ||
NetworkManagementClient networkClient) | ||
{ | ||
var virtualNetworkName = TestUtilities.GenerateName("hydratestdnsvn"); | ||
var subnetName = TestUtilities.GenerateName("hydratestdnssubnet"); | ||
|
||
var vnet = new VirtualNetwork | ||
{ | ||
AddressSpace = new AddressSpace | ||
{ | ||
AddressPrefixes = new List<string> | ||
{ | ||
"10.0.0.0/16" | ||
} | ||
}, | ||
Subnets = new List<Subnet> | ||
{ | ||
new Subnet | ||
{ | ||
Name = subnetName, | ||
AddressPrefix = "10.0." + RandomGenerator.Next(0, 255) + ".0/24" | ||
} | ||
}, | ||
Location = ResourceLocation | ||
}; | ||
|
||
var putVnetResponse = networkClient.VirtualNetworks.CreateOrUpdate(resourceGroupName, virtualNetworkName, vnet); | ||
Assert.Equal("Succeeded", putVnetResponse.ProvisioningState); | ||
|
||
var getVnetResponse = networkClient.VirtualNetworks.Get(resourceGroupName, virtualNetworkName); | ||
return getVnetResponse; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@muwaqar remove empty lines