public void ListWhenNoConfigurationExists() { using (NetworkTestClient testClient = new NetworkTestClient()) { testClient.EnsureNoNetworkConfigurationExists(); NetworkListResponse listResponse = testClient.ListNetworkConfigurations(); Assert.NotNull(listResponse); Assert.False(listResponse.Any(), "List() should have returned an empty list if no configurations exist."); } }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteCmdlet() { try { NetworkListResponse networkListResponse = RecoveryServicesClient.GetAzureSiteRecoveryNetworks(this.Server.ID); this.WriteNetworks(networkListResponse.Networks); } catch (Exception exception) { this.HandleException(exception); } }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteCmdlet() { try { this.WriteWarningWithTimestamp( string.Format( Properties.Resources.CmdletWillBeDeprecatedSoon, this.MyInvocation.MyCommand.Name)); NetworkListResponse networkListResponse = RecoveryServicesClient.GetAzureSiteRecoveryNetworks(this.Server.ID); this.WriteNetworks(networkListResponse.Networks); } catch (Exception exception) { this.HandleException(exception); } }
public void AbortSimpleVNetConfiguration() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { OperationStatusResponse osResp = networkTestClient.SetNetworkConfiguration(NetworkTestConstants.SimpleMigrationNetworkConfigurationParameters); Assert.Equal(OperationStatus.Succeeded, osResp.Status); osResp = networkTestClient.PrepareVnetMigration(NetworkTestConstants.VirtualNetworkSiteName); Assert.Equal(OperationStatus.Succeeded, osResp.Status); NetworkListResponse response = networkTestClient.ListNetworkConfigurations(); // BUG: Return "2" instead of "Prepared" // Re-record after the bug is fixed in Server. Assert.NotNull(response.VirtualNetworkSites.First().MigrationState); //Assert.Equal(IaasClassicToArmMigrationState.Prepared, response.VirtualNetworkSites.First().MigrationState); osResp = networkTestClient.AbortVnetMigration(NetworkTestConstants.VirtualNetworkSiteName); Assert.Equal(OperationStatus.Succeeded, osResp.Status); } }
private NetworkListResponse.VirtualNetworkSite GetAzureVNet(string name) { NetworkManagementClient networkClient = new NetworkManagementClient(this.Client.Credentials, this.Client.BaseUri); Task <NetworkListResponse> listNetworkTask = networkClient.Networks.ListAsync(); listNetworkTask.Wait(); if (listNetworkTask.Status == TaskStatus.RanToCompletion) { NetworkListResponse networkList = listNetworkTask.Result; foreach (NetworkListResponse.VirtualNetworkSite network in networkList.VirtualNetworkSites) { if (network.Name == name) { return(network); } } } return(null); }
/// <summary> /// The List Virtual network sites operation retrieves the virtual /// networks configured for the subscription. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj157185.aspx /// for more information) /// </summary> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// The response structure for the Server List operation. /// </returns> public async Task <NetworkListResponse> ListAsync(CancellationToken cancellationToken) { // Validate // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); Tracing.Enter(invocationId, this, "ListAsync", tracingParameters); } // Construct URL string url = new Uri(this.Client.BaseUri, "/").ToString() + this.Client.Credentials.SubscriptionId + "/services/networking/virtualnetwork"; // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("x-ms-version", "2013-11-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false), CloudExceptionType.Xml); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result NetworkListResponse result = null; // Deserialize Response cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new NetworkListResponse(); XDocument responseDoc = XDocument.Parse(responseContent); XElement virtualNetworkSitesSequenceElement = responseDoc.Element(XName.Get("VirtualNetworkSites", "http://schemas.microsoft.com/windowsazure")); if (virtualNetworkSitesSequenceElement != null) { foreach (XElement virtualNetworkSitesElement in virtualNetworkSitesSequenceElement.Elements(XName.Get("VirtualNetworkSite", "http://schemas.microsoft.com/windowsazure"))) { NetworkListResponse.VirtualNetworkSite virtualNetworkSiteInstance = new NetworkListResponse.VirtualNetworkSite(); result.VirtualNetworkSites.Add(virtualNetworkSiteInstance); XElement nameElement = virtualNetworkSitesElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement != null) { string nameInstance = nameElement.Value; virtualNetworkSiteInstance.Name = nameInstance; } XElement labelElement = virtualNetworkSitesElement.Element(XName.Get("Label", "http://schemas.microsoft.com/windowsazure")); if (labelElement != null) { string labelInstance = labelElement.Value; virtualNetworkSiteInstance.Label = labelInstance; } XElement idElement = virtualNetworkSitesElement.Element(XName.Get("Id", "http://schemas.microsoft.com/windowsazure")); if (idElement != null) { string idInstance = idElement.Value; virtualNetworkSiteInstance.Id = idInstance; } XElement affinityGroupElement = virtualNetworkSitesElement.Element(XName.Get("AffinityGroup", "http://schemas.microsoft.com/windowsazure")); if (affinityGroupElement != null) { string affinityGroupInstance = affinityGroupElement.Value; virtualNetworkSiteInstance.AffinityGroup = affinityGroupInstance; } XElement stateElement = virtualNetworkSitesElement.Element(XName.Get("State", "http://schemas.microsoft.com/windowsazure")); if (stateElement != null) { string stateInstance = stateElement.Value; virtualNetworkSiteInstance.State = stateInstance; } XElement addressSpaceElement = virtualNetworkSitesElement.Element(XName.Get("AddressSpace", "http://schemas.microsoft.com/windowsazure")); if (addressSpaceElement != null) { NetworkListResponse.AddressSpace addressSpaceInstance = new NetworkListResponse.AddressSpace(); virtualNetworkSiteInstance.AddressSpace = addressSpaceInstance; XElement addressPrefixesSequenceElement = addressSpaceElement.Element(XName.Get("AddressPrefixes", "http://schemas.microsoft.com/windowsazure")); if (addressPrefixesSequenceElement != null) { foreach (XElement addressPrefixesElement in addressPrefixesSequenceElement.Elements(XName.Get("AddressPrefix", "http://schemas.microsoft.com/windowsazure"))) { addressSpaceInstance.AddressPrefixes.Add(addressPrefixesElement.Value); } } } XElement subnetsSequenceElement = virtualNetworkSitesElement.Element(XName.Get("Subnets", "http://schemas.microsoft.com/windowsazure")); if (subnetsSequenceElement != null) { foreach (XElement subnetsElement in subnetsSequenceElement.Elements(XName.Get("Subnet", "http://schemas.microsoft.com/windowsazure"))) { NetworkListResponse.Subnet subnetInstance = new NetworkListResponse.Subnet(); virtualNetworkSiteInstance.Subnets.Add(subnetInstance); XElement nameElement2 = subnetsElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement2 != null) { string nameInstance2 = nameElement2.Value; subnetInstance.Name = nameInstance2; } XElement addressPrefixElement = subnetsElement.Element(XName.Get("AddressPrefix", "http://schemas.microsoft.com/windowsazure")); if (addressPrefixElement != null) { string addressPrefixInstance = addressPrefixElement.Value; subnetInstance.AddressPrefix = addressPrefixInstance; } } } XElement dnsElement = virtualNetworkSitesElement.Element(XName.Get("Dns", "http://schemas.microsoft.com/windowsazure")); if (dnsElement != null) { XElement dnsServersSequenceElement = dnsElement.Element(XName.Get("DnsServers", "http://schemas.microsoft.com/windowsazure")); if (dnsServersSequenceElement != null) { foreach (XElement dnsServersElement in dnsServersSequenceElement.Elements(XName.Get("DnsServer", "http://schemas.microsoft.com/windowsazure"))) { NetworkListResponse.DnsServer dnsServerInstance = new NetworkListResponse.DnsServer(); virtualNetworkSiteInstance.DnsServers.Add(dnsServerInstance); XElement nameElement3 = dnsServersElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement3 != null) { string nameInstance3 = nameElement3.Value; dnsServerInstance.Name = nameInstance3; } XElement addressElement = dnsServersElement.Element(XName.Get("Address", "http://schemas.microsoft.com/windowsazure")); if (addressElement != null) { string addressInstance = addressElement.Value; dnsServerInstance.Address = addressInstance; } } } } XElement gatewayElement = virtualNetworkSitesElement.Element(XName.Get("Gateway", "http://schemas.microsoft.com/windowsazure")); if (gatewayElement != null) { NetworkListResponse.Gateway gatewayInstance = new NetworkListResponse.Gateway(); virtualNetworkSiteInstance.Gateway = gatewayInstance; XElement profileElement = gatewayElement.Element(XName.Get("Profile", "http://schemas.microsoft.com/windowsazure")); if (profileElement != null) { GatewayProfile profileInstance = (GatewayProfile)Enum.Parse(typeof(GatewayProfile), profileElement.Value, false); gatewayInstance.Profile = profileInstance; } XElement sitesSequenceElement = gatewayElement.Element(XName.Get("Sites", "http://schemas.microsoft.com/windowsazure")); if (sitesSequenceElement != null) { foreach (XElement sitesElement in sitesSequenceElement.Elements(XName.Get("LocalNetworkSite", "http://schemas.microsoft.com/windowsazure"))) { NetworkListResponse.LocalNetworkSite localNetworkSiteInstance = new NetworkListResponse.LocalNetworkSite(); gatewayInstance.Sites.Add(localNetworkSiteInstance); XElement nameElement4 = sitesElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement4 != null) { string nameInstance4 = nameElement4.Value; localNetworkSiteInstance.Name = nameInstance4; } XElement vpnGatewayAddressElement = sitesElement.Element(XName.Get("VpnGatewayAddress", "http://schemas.microsoft.com/windowsazure")); if (vpnGatewayAddressElement != null) { string vpnGatewayAddressInstance = vpnGatewayAddressElement.Value; localNetworkSiteInstance.VpnGatewayAddress = vpnGatewayAddressInstance; } XElement addressSpaceElement2 = sitesElement.Element(XName.Get("AddressSpace", "http://schemas.microsoft.com/windowsazure")); if (addressSpaceElement2 != null) { NetworkListResponse.AddressSpace addressSpaceInstance2 = new NetworkListResponse.AddressSpace(); localNetworkSiteInstance.AddressSpace = addressSpaceInstance2; XElement addressPrefixesSequenceElement2 = addressSpaceElement2.Element(XName.Get("AddressPrefixes", "http://schemas.microsoft.com/windowsazure")); if (addressPrefixesSequenceElement2 != null) { foreach (XElement addressPrefixesElement2 in addressPrefixesSequenceElement2.Elements(XName.Get("AddressPrefix", "http://schemas.microsoft.com/windowsazure"))) { addressSpaceInstance2.AddressPrefixes.Add(addressPrefixesElement2.Value); } } } XElement connectionsSequenceElement = sitesElement.Element(XName.Get("Connections", "http://schemas.microsoft.com/windowsazure")); if (connectionsSequenceElement != null) { foreach (XElement connectionsElement in connectionsSequenceElement.Elements(XName.Get("Connection", "http://schemas.microsoft.com/windowsazure"))) { NetworkListResponse.Connection connectionInstance = new NetworkListResponse.Connection(); localNetworkSiteInstance.Connections.Add(connectionInstance); XElement typeElement = connectionsElement.Element(XName.Get("Type", "http://schemas.microsoft.com/windowsazure")); if (typeElement != null) { LocalNetworkConnectionType typeInstance = VirtualNetworkManagementClient.ParseLocalNetworkConnectionType(typeElement.Value); connectionInstance.Type = typeInstance; } } } } } XElement vPNClientAddressPoolElement = gatewayElement.Element(XName.Get("VPNClientAddressPool", "http://schemas.microsoft.com/windowsazure")); if (vPNClientAddressPoolElement != null) { NetworkListResponse.VPNClientAddressPool vPNClientAddressPoolInstance = new NetworkListResponse.VPNClientAddressPool(); gatewayInstance.VPNClientAddressPool = vPNClientAddressPoolInstance; XElement addressPrefixesSequenceElement3 = vPNClientAddressPoolElement.Element(XName.Get("AddressPrefixes", "http://schemas.microsoft.com/windowsazure")); if (addressPrefixesSequenceElement3 != null) { foreach (XElement addressPrefixesElement3 in addressPrefixesSequenceElement3.Elements(XName.Get("AddressPrefix", "http://schemas.microsoft.com/windowsazure"))) { vPNClientAddressPoolInstance.AddressPrefixes.Add(addressPrefixesElement3.Value); } } } } } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
/// <summary> /// Get the list of all networks under the vault. /// </summary> /// <param name='serverId'> /// Required. Network query parameter. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// The response model for the list networks operation. /// </returns> public async Task <NetworkListResponse> ListAsync(string serverId, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) { // Validate if (serverId == null) { throw new ArgumentNullException("serverId"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("serverId", serverId); tracingParameters.Add("customRequestHeaders", customRequestHeaders); TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); } // Construct URL string url = ""; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/cloudservices/"; url = url + Uri.EscapeDataString(this.Client.CloudServiceName); url = url + "/resources/"; url = url + "WAHyperVRecoveryManager"; url = url + "/~/"; url = url + "HyperVRecoveryManagerVault"; url = url + "/"; url = url + Uri.EscapeDataString(this.Client.ResourceName); url = url + "/Networks"; List <string> queryParameters = new List <string>(); queryParameters.Add("api-version=2015-04-10"); queryParameters.Add("ServerId=" + Uri.EscapeDataString(serverId)); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("Accept", "application/xml"); httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); httpRequest.Headers.Add("x-ms-version", "2013-03-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { TracingAdapter.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } // Create Result NetworkListResponse result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new NetworkListResponse(); XDocument responseDoc = XDocument.Parse(responseContent); XElement arrayOfNetworkSequenceElement = responseDoc.Element(XName.Get("ArrayOfNetwork", "http://schemas.microsoft.com/windowsazure")); if (arrayOfNetworkSequenceElement != null) { foreach (XElement arrayOfNetworkElement in arrayOfNetworkSequenceElement.Elements(XName.Get("Network", "http://schemas.microsoft.com/windowsazure"))) { Network networkInstance = new Network(); result.Networks.Add(networkInstance); XElement typeElement = arrayOfNetworkElement.Element(XName.Get("Type", "http://schemas.microsoft.com/windowsazure")); if (typeElement != null) { string typeInstance = typeElement.Value; networkInstance.Type = typeInstance; } XElement fabricObjectIDElement = arrayOfNetworkElement.Element(XName.Get("FabricObjectID", "http://schemas.microsoft.com/windowsazure")); if (fabricObjectIDElement != null) { string fabricObjectIDInstance = fabricObjectIDElement.Value; networkInstance.FabricObjectID = fabricObjectIDInstance; } XElement vmNetworkSubnetListSequenceElement = arrayOfNetworkElement.Element(XName.Get("VmNetworkSubnetList", "http://schemas.microsoft.com/windowsazure")); if (vmNetworkSubnetListSequenceElement != null) { foreach (XElement vmNetworkSubnetListElement in vmNetworkSubnetListSequenceElement.Elements(XName.Get("VmNetworkSubnetDetails", "http://schemas.microsoft.com/windowsazure"))) { VmNetworkSubnetDetails vmNetworkSubnetDetailsInstance = new VmNetworkSubnetDetails(); networkInstance.VmNetworkSubnetList.Add(vmNetworkSubnetDetailsInstance); XElement idElement = vmNetworkSubnetListElement.Element(XName.Get("Id", "http://schemas.microsoft.com/windowsazure")); if (idElement != null) { string idInstance = idElement.Value; vmNetworkSubnetDetailsInstance.Id = idInstance; } XElement nameElement = vmNetworkSubnetListElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement != null) { string nameInstance = nameElement.Value; vmNetworkSubnetDetailsInstance.Name = nameInstance; } XElement addressListSequenceElement = vmNetworkSubnetListElement.Element(XName.Get("AddressList", "http://schemas.microsoft.com/windowsazure")); if (addressListSequenceElement != null) { foreach (XElement addressListElement in addressListSequenceElement.Elements(XName.Get("string", "http://schemas.microsoft.com/2003/10/Serialization/Arrays"))) { vmNetworkSubnetDetailsInstance.AddressList.Add(addressListElement.Value); } } } } XElement fabricTypeElement = arrayOfNetworkElement.Element(XName.Get("FabricType", "http://schemas.microsoft.com/windowsazure")); if (fabricTypeElement != null) { string fabricTypeInstance = fabricTypeElement.Value; networkInstance.FabricType = fabricTypeInstance; } XElement serverIDElement = arrayOfNetworkElement.Element(XName.Get("ServerID", "http://schemas.microsoft.com/windowsazure")); if (serverIDElement != null) { string serverIDInstance = serverIDElement.Value; networkInstance.ServerID = serverIDInstance; } XElement nameElement2 = arrayOfNetworkElement.Element(XName.Get("Name", "http://schemas.microsoft.com/windowsazure")); if (nameElement2 != null) { string nameInstance2 = nameElement2.Value; networkInstance.Name = nameInstance2; } XElement idElement2 = arrayOfNetworkElement.Element(XName.Get("ID", "http://schemas.microsoft.com/windowsazure")); if (idElement2 != null) { string idInstance2 = idElement2.Value; networkInstance.ID = idInstance2; } } } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
public void VirtualNetworkGatewayConnectionAPIsTests() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { // 1.CreateGatewayConnection API :- // a.CreateVirtualnetworkGateway API string virtualNetworkSiteName = "coexistenceVirtualNetworkSiteName"; string vnetGatewayName = "coexistenceVnetGateway"; networkTestClient.EnsureNoNetworkConfigurationExists(virtualNetworkSiteName); networkTestClient.SetNetworkConfiguration(NetworkTestConstants.CoexistenceFeatureNetworkConfigurationParameters); NetworkListResponse listResponse = networkTestClient.ListNetworkConfigurations(); Assert.NotNull(listResponse); Assert.True(listResponse.VirtualNetworkSites.Any(vnet => vnet.Name.Equals(virtualNetworkSiteName)), "Virtual network:" + virtualNetworkSiteName + " is not found!"); string vnetId = listResponse.First(vnet => vnet.Name.Equals(virtualNetworkSiteName)).Id; GatewayGetOperationStatusResponse response = networkTestClient.Gateways.CreateVirtualNetworkGateway( virtualNetworkSiteName, new VirtualNetworkGatewayCreateParameters() { GatewayName = vnetGatewayName, GatewayType = GatewayType.DynamicRouting }); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); ListVirtualNetworkGatewaysResponse listVirtualNetworkGatewaysResponse = networkTestClient.Gateways.ListVirtualNetworkGateways(); Assert.True(listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.Count >= 1); Guid vnetGatewayId = listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.First(vnetGateway => vnetGateway.GatewayName.Equals(vnetGatewayName)).GatewayId; // b.CreateLocalNetworkGateway API string localnetGatewayName = "coexistenceLocalnetGateway"; var param = new LocalNetworkGatewayCreateParameters() { AddressSpace = new LazyList <string>() { addressSpace }, GatewayName = localnetGatewayName, IpAddress = localNetworkGatewayIpAddress, }; LocalNetworkGatewayCreateResponse localNetworkGatewayCreateResponse = networkTestClient.Gateways.CreateLocalNetworkGateway(param); Assert.NotNull(localNetworkGatewayCreateResponse); Assert.Equal(HttpStatusCode.OK, localNetworkGatewayCreateResponse.StatusCode); Assert.NotNull(localNetworkGatewayCreateResponse.LocalNetworkGatewayId); ListLocalNetworkGatewaysResponse listLocalNetworkGatewaysResponse = networkTestClient.Gateways.ListLocalNetworkGateways(); Assert.NotNull(listLocalNetworkGatewaysResponse); Assert.Equal(HttpStatusCode.OK, listLocalNetworkGatewaysResponse.StatusCode); Assert.Equal(1, listLocalNetworkGatewaysResponse.LocalNetworkGateways.Count); string localNetworkGatewayId = listLocalNetworkGatewaysResponse.LocalNetworkGateways.First(localnetGateway => localnetGateway.GatewayName.Equals(localnetGatewayName)).Id.ToString(); // c.CreateGatewayConnection API string gatewayConnectionName = "coexistenceGatewayConnection"; GatewayGetOperationStatusResponse gatewayGetOperationStatusResponse = networkTestClient.Gateways.CreateGatewayConnection( new GatewayConnectionCreateParameters() { ConnectedEntityId = localNetworkGatewayId, GatewayConnectionName = gatewayConnectionName, GatewayConnectionType = GatewayConnectionType.IPsec, VirtualNetworkGatewayId = vnetGatewayId, RoutingWeight = 3, SharedKey = "abc" } ); Assert.NotNull(gatewayGetOperationStatusResponse); Assert.Equal(HttpStatusCode.OK, gatewayGetOperationStatusResponse.HttpStatusCode); // 2.GetGatewayConnection API GatewayConnectionGetResponse gatewayConnectionGetResponse = networkTestClient.Gateways.GetGatewayConnection(vnetGatewayId.ToString(), localNetworkGatewayId); Assert.NotNull(gatewayConnectionGetResponse); Assert.Equal(HttpStatusCode.OK, gatewayConnectionGetResponse.StatusCode); Assert.Equal(vnetGatewayId, gatewayConnectionGetResponse.VirtualNetworkGatewayId); Assert.Equal(localNetworkGatewayId, gatewayConnectionGetResponse.ConnectedEntityId); Assert.Equal(gatewayConnectionName, gatewayConnectionGetResponse.GatewayConnectionName); Assert.Equal(GatewayConnectionType.IPsec, gatewayConnectionGetResponse.GatewayConnectionType); Assert.Equal(3, gatewayConnectionGetResponse.RoutingWeight); Assert.Equal("abc", gatewayConnectionGetResponse.SharedKey); // 3.UpdateGatewayConnection API gatewayGetOperationStatusResponse = networkTestClient.Gateways.UpdateGatewayConnection( vnetGatewayId.ToString(), localNetworkGatewayId, new UpdateGatewayConnectionParameters() { RoutingWeight = 4, SharedKey = "xyz" }); Assert.NotNull(gatewayGetOperationStatusResponse); Assert.Equal(HttpStatusCode.OK, gatewayGetOperationStatusResponse.HttpStatusCode); // GetGatewayConnection API after UpdateGatewayConnection API gatewayConnectionGetResponse = networkTestClient.Gateways.GetGatewayConnection(vnetGatewayId.ToString(), localNetworkGatewayId); Assert.NotNull(gatewayConnectionGetResponse); Assert.Equal(HttpStatusCode.OK, gatewayConnectionGetResponse.StatusCode); Assert.Equal(4, gatewayConnectionGetResponse.RoutingWeight); Assert.Equal("xyz", gatewayConnectionGetResponse.SharedKey); // 4.ListGatewayConnections API GatewayListGatewayConnectionsResponse gatewayListGatewayConnectionsResponse = networkTestClient.Gateways.ListGatewayConnections(); Assert.NotNull(gatewayListGatewayConnectionsResponse); Assert.Equal(HttpStatusCode.OK, gatewayListGatewayConnectionsResponse.StatusCode); Assert.Equal(1, gatewayListGatewayConnectionsResponse.VirtualNetworkGatewayConnections.Count); Assert.True(gatewayListGatewayConnectionsResponse.VirtualNetworkGatewayConnections.Any(vnetGatewayConnection => vnetGatewayConnection.GatewayConnectionName.Equals(gatewayConnectionName)), "Gateway connection " + gatewayConnectionName + " not found!"); // 5.DeleteGatewayConnection API gatewayGetOperationStatusResponse = networkTestClient.Gateways.DeleteGatewayConnection(vnetGatewayId.ToString(), localNetworkGatewayId); Assert.NotNull(gatewayGetOperationStatusResponse); Assert.Equal(HttpStatusCode.OK, gatewayGetOperationStatusResponse.HttpStatusCode); gatewayListGatewayConnectionsResponse = networkTestClient.Gateways.ListGatewayConnections(); Assert.False(gatewayListGatewayConnectionsResponse.VirtualNetworkGatewayConnections.Any(vnetGatewayConnection => vnetGatewayConnection.GatewayConnectionName.Equals(gatewayConnectionName)), "Virtual network gateway connection: " + gatewayConnectionName + " is not deleted even after DeleteGatewayConnection API call!"); // Cleanup test setup at end response = networkTestClient.Gateways.DeleteVirtualNetworkGateway(vnetGatewayId.ToString()); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); AzureOperationResponse deleteLocalNetworkGatewayResponse = networkTestClient.Gateways.DeleteLocalNetworkGateway(localNetworkGatewayId); Assert.NotNull(deleteLocalNetworkGatewayResponse); Assert.Equal(HttpStatusCode.OK, deleteLocalNetworkGatewayResponse.StatusCode); } }
public void VirtualNetworkGatewayAPIsTests() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { string virtualNetworkSiteName = "coexistenceVirtualNetworkSiteName"; string vnetGatewayName = "coexistenceVnetGateway"; networkTestClient.EnsureNoNetworkConfigurationExists(virtualNetworkSiteName); // 1.CreateVirtualnetworkGateway API networkTestClient.SetNetworkConfiguration(NetworkTestConstants.CoexistenceFeatureNetworkConfigurationParameters); NetworkListResponse listResponse = networkTestClient.ListNetworkConfigurations(); Assert.NotNull(listResponse); Assert.True(listResponse.VirtualNetworkSites.Any(vnet => vnet.Name.Equals(virtualNetworkSiteName)), "Virtual network:" + virtualNetworkSiteName + " is not found!"); string vnetId = listResponse.First(vnet => vnet.Name.Equals(virtualNetworkSiteName)).Id; GatewayGetOperationStatusResponse response = networkTestClient.Gateways.CreateVirtualNetworkGateway( virtualNetworkSiteName, new VirtualNetworkGatewayCreateParameters() { GatewayName = vnetGatewayName, GatewayType = GatewayType.DynamicRouting }); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); // 2.Listvirtualnetworkgateways API ListVirtualNetworkGatewaysResponse listVirtualNetworkGatewaysResponse = networkTestClient.Gateways.ListVirtualNetworkGateways(); Assert.True(listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.Count >= 1); string vnetGatewayId = listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.First(vnetGateway => vnetGateway.GatewayName.Equals(vnetGatewayName)).GatewayId.ToString(); // 3.Getvirtualnetworkgateway API VirtualNetworkGatewayGetResponse virtualNetworkGatewayGetResponse = networkTestClient.Gateways.GetVirtualNetworkGateway(vnetGatewayId); Assert.NotNull(virtualNetworkGatewayGetResponse); Assert.Equal(HttpStatusCode.OK, virtualNetworkGatewayGetResponse.StatusCode); Assert.Equal(vnetGatewayName, virtualNetworkGatewayGetResponse.GatewayName); Assert.Equal(GatewaySKU.Default, virtualNetworkGatewayGetResponse.GatewaySKU); Assert.Equal(GatewayType.DynamicRouting, virtualNetworkGatewayGetResponse.GatewayType); // 4.ResizeVirtualnetworkGateway API ResizeGatewayParameters parameters = new ResizeGatewayParameters() { GatewaySKU = GatewaySKU.HighPerformance }; response = networkTestClient.Gateways.ResizeVirtualNetworkGateway(vnetGatewayId, parameters); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); virtualNetworkGatewayGetResponse = networkTestClient.Gateways.GetVirtualNetworkGateway(vnetGatewayId); Assert.NotNull(virtualNetworkGatewayGetResponse); Assert.Equal(HttpStatusCode.OK, virtualNetworkGatewayGetResponse.StatusCode); Assert.Equal(vnetGatewayName, virtualNetworkGatewayGetResponse.GatewayName); Assert.Equal(GatewaySKU.HighPerformance, virtualNetworkGatewayGetResponse.GatewaySKU); // 5.ResetVirtualnetworkGateway API ResetGatewayParameters resetGatewayParameters = new ResetGatewayParameters(); response = networkTestClient.Gateways.ResetVirtualNetworkGateway(vnetGatewayId, resetGatewayParameters); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); // 6.DeleteVirtualNetworkGateway API response = networkTestClient.Gateways.DeleteVirtualNetworkGateway(vnetGatewayId); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); listVirtualNetworkGatewaysResponse = networkTestClient.Gateways.ListVirtualNetworkGateways(); Assert.False(listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.Any(vnetGateway => vnetGateway.GatewayName.Equals(vnetGatewayName)), "Virtual network: " + virtualNetworkSiteName + " gateway: " + vnetGatewayName + " is not deleted even after DeleteVirtualNetworkGateway API call!"); } }
public void DiagnosticsV2APIsTests() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { // 1.StartDiagnosticsV2 API // a.CreateVirtualnetworkGateway API string virtualNetworkSiteName = "coexistenceVirtualNetworkSiteName"; string vnetGatewayName = "coexistenceVnetGateway"; networkTestClient.EnsureNoNetworkConfigurationExists(virtualNetworkSiteName); networkTestClient.SetNetworkConfiguration(NetworkTestConstants.CoexistenceFeatureNetworkConfigurationParameters); NetworkListResponse listResponse = networkTestClient.ListNetworkConfigurations(); Assert.NotNull(listResponse); Assert.True(listResponse.VirtualNetworkSites.Any(vnet => vnet.Name.Equals(virtualNetworkSiteName)), "Virtual network:" + virtualNetworkSiteName + " is not found!"); string vnetId = listResponse.First(vnet => vnet.Name.Equals(virtualNetworkSiteName)).Id; GatewayGetOperationStatusResponse response = networkTestClient.Gateways.CreateVirtualNetworkGateway( virtualNetworkSiteName, new VirtualNetworkGatewayCreateParameters() { GatewayName = vnetGatewayName, GatewayType = GatewayType.DynamicRouting }); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); // Listvirtualnetworkgateways API ListVirtualNetworkGatewaysResponse listVirtualNetworkGatewaysResponse = networkTestClient.Gateways.ListVirtualNetworkGateways(); Assert.True(listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.Count >= 1); Guid vnetGatewayId = listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.First(vnetGateway => vnetGateway.GatewayName.Equals(vnetGatewayName)).GatewayId; // b.StartDiagnosticsV2 API StartGatewayPublicDiagnosticsParameters startParameters = new StartGatewayPublicDiagnosticsParameters() { Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics, CustomerStorageName = "daschult20140611a", // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")] CustomerStorageKey = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==", ContainerName = "hydra-test-diagnostics", CaptureDurationInSeconds = "60", }; GatewayGetOperationStatusResponse startResponse = networkTestClient.Gateways.StartDiagnosticsV2(vnetGatewayId.ToString(), startParameters); Assert.NotNull(startResponse); Assert.Equal(HttpStatusCode.OK, startResponse.HttpStatusCode); // 2.GetDiagnosticsV2 API GatewayDiagnosticsStatus startStatus = networkTestClient.Gateways.GetDiagnosticsV2(vnetGatewayId.ToString()); Assert.NotNull(startStatus); Assert.Equal(HttpStatusCode.OK, startStatus.StatusCode); Assert.True(startStatus.DiagnosticsUrl != null, "The diagnostics url was null."); Assert.Equal(GatewayDiagnosticsState.InProgress, startStatus.State); // StopDiagnosticsV2 API StopGatewayPublicDiagnosticsParameters stopParameters = new StopGatewayPublicDiagnosticsParameters(); GatewayOperationResponse gatewayOperationResponse = networkTestClient.Gateways.StopDiagnosticsV2(vnetGatewayId.ToString(), stopParameters); Assert.NotNull(gatewayOperationResponse); Assert.Equal(HttpStatusCode.Accepted, gatewayOperationResponse.StatusCode); GatewayDiagnosticsStatus stopStatus; do { stopStatus = networkTestClient.Gateways.GetDiagnosticsV2(vnetGatewayId.ToString()); Assert.NotNull(stopStatus); } while (stopStatus.State != GatewayDiagnosticsState.Ready); Assert.Equal(GatewayDiagnosticsState.Ready, stopStatus.State); Assert.True(stopStatus.DiagnosticsUrl != null, "The diagnostics url was null."); Assert.True(1 <= stopStatus.DiagnosticsUrl.Length, "The diagnostics url was empty."); // Cleanup test setup at end response = networkTestClient.Gateways.DeleteVirtualNetworkGateway(vnetGatewayId.ToString()); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); } }
public void SharedKeyV2APIsTests() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { // 1.ResetSharedKeyV2 API:- // a.CreateVirtualnetworkGateway API string virtualNetworkSiteName = "coexistenceVirtualNetworkSiteName"; string vnetGatewayName = "coexistenceVnetGateway"; networkTestClient.EnsureNoNetworkConfigurationExists(virtualNetworkSiteName); networkTestClient.SetNetworkConfiguration(NetworkTestConstants.CoexistenceFeatureNetworkConfigurationParameters); NetworkListResponse listResponse = networkTestClient.ListNetworkConfigurations(); Assert.NotNull(listResponse); Assert.True(listResponse.VirtualNetworkSites.Any(vnet => vnet.Name.Equals(virtualNetworkSiteName)), "Virtual network:" + virtualNetworkSiteName + " is not found!"); string vnetId = listResponse.First(vnet => vnet.Name.Equals(virtualNetworkSiteName)).Id; GatewayGetOperationStatusResponse response = networkTestClient.Gateways.CreateVirtualNetworkGateway( virtualNetworkSiteName, new VirtualNetworkGatewayCreateParameters() { GatewayName = vnetGatewayName, GatewayType = GatewayType.DynamicRouting }); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); ListVirtualNetworkGatewaysResponse listVirtualNetworkGatewaysResponse = networkTestClient.Gateways.ListVirtualNetworkGateways(); Assert.True(listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.Count >= 1); Guid vnetGatewayId = listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.First(vnetGateway => vnetGateway.GatewayName.Equals(vnetGatewayName)).GatewayId; // b.CreateLocalNetworkGateway API string localnetGatewayName = "coexistenceLocalnetGateway"; string addressSpace = "200.168.0.0/16"; var param = new LocalNetworkGatewayCreateParameters() { AddressSpace = new LazyList <string>() { addressSpace }, GatewayName = localnetGatewayName, IpAddress = "204.95.99.237", }; LocalNetworkGatewayCreateResponse localNetworkGatewayCreateResponse = networkTestClient.Gateways.CreateLocalNetworkGateway(param); Assert.NotNull(localNetworkGatewayCreateResponse); Assert.Equal(HttpStatusCode.OK, localNetworkGatewayCreateResponse.StatusCode); Assert.NotNull(localNetworkGatewayCreateResponse.LocalNetworkGatewayId); ListLocalNetworkGatewaysResponse listLocalNetworkGatewaysResponse = networkTestClient.Gateways.ListLocalNetworkGateways(); Assert.NotNull(listLocalNetworkGatewaysResponse); Assert.Equal(HttpStatusCode.OK, listLocalNetworkGatewaysResponse.StatusCode); Assert.Equal(1, listLocalNetworkGatewaysResponse.LocalNetworkGateways.Count); string localNetworkGatewayId = listLocalNetworkGatewaysResponse.LocalNetworkGateways.First(localnetGateway => localnetGateway.GatewayName.Equals(localnetGatewayName)).Id.ToString(); // c.CreateGatewayConnection API string gatewayConnectionName = "coexistenceGatewayConnection"; GatewayGetOperationStatusResponse gatewayGetOperationStatusResponse = networkTestClient.Gateways.CreateGatewayConnection( new GatewayConnectionCreateParameters() { ConnectedEntityId = localNetworkGatewayId, GatewayConnectionName = gatewayConnectionName, GatewayConnectionType = GatewayConnectionType.IPsec, VirtualNetworkGatewayId = vnetGatewayId, RoutingWeight = 3, SharedKey = "abc" } ); Assert.NotNull(gatewayGetOperationStatusResponse); Assert.Equal(HttpStatusCode.OK, gatewayGetOperationStatusResponse.HttpStatusCode); // d.ResetSharedKeyV2 API GatewayResetSharedKeyParameters resetParameters = new GatewayResetSharedKeyParameters() { KeyLength = 128, }; GatewayGetOperationStatusResponse resetResponse = networkTestClient.Gateways.ResetSharedKeyV2(vnetGatewayId.ToString(), localNetworkGatewayId, resetParameters); Assert.NotNull(resetResponse); Assert.Equal(HttpStatusCode.OK, resetResponse.HttpStatusCode); // 2.GetSharedKeyV2 API const string sharedKeyToSet = "MNO"; GatewayGetSharedKeyResponse firstGetResponse = networkTestClient.Gateways.GetSharedKeyV2(vnetGatewayId.ToString(), localNetworkGatewayId); Assert.NotNull(firstGetResponse); Assert.Equal(HttpStatusCode.OK, firstGetResponse.StatusCode); Assert.NotEqual(sharedKeyToSet, firstGetResponse.SharedKey); // 3. SetSharedKeyV2 API GatewaySetSharedKeyParameters setParameters = new GatewaySetSharedKeyParameters() { Value = sharedKeyToSet }; GatewayGetOperationStatusResponse setResponse = networkTestClient.Gateways.SetSharedKeyV2(vnetGatewayId.ToString(), localNetworkGatewayId, setParameters); Assert.NotNull(setResponse); Assert.Equal(HttpStatusCode.OK, setResponse.HttpStatusCode); // GetSharedKeyV2 API after SetSharedKeyV2 API GatewayGetSharedKeyResponse secondGetResponse = networkTestClient.Gateways.GetSharedKeyV2(vnetGatewayId.ToString(), localNetworkGatewayId); Assert.NotNull(secondGetResponse); Assert.Equal(HttpStatusCode.OK, secondGetResponse.StatusCode); Assert.Equal(sharedKeyToSet, secondGetResponse.SharedKey); // Cleanup test setup at end gatewayGetOperationStatusResponse = networkTestClient.Gateways.DeleteGatewayConnection(vnetGatewayId.ToString(), localNetworkGatewayId); Assert.NotNull(gatewayGetOperationStatusResponse); Assert.Equal(HttpStatusCode.OK, gatewayGetOperationStatusResponse.HttpStatusCode); response = networkTestClient.Gateways.DeleteVirtualNetworkGateway(vnetGatewayId.ToString()); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); AzureOperationResponse deleteLocalNetworkGatewayResponse = networkTestClient.Gateways.DeleteLocalNetworkGateway(localNetworkGatewayId); Assert.NotNull(deleteLocalNetworkGatewayResponse); Assert.Equal(HttpStatusCode.OK, deleteLocalNetworkGatewayResponse.StatusCode); } }
public void IPsecParametersV2APIsTests() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { // 1.SetIPsecParametersV2 API:- // a.CreateVirtualnetworkGateway API string virtualNetworkSiteName = "coexistenceVirtualNetworkSiteName"; string vnetGatewayName = "coexistenceVnetGateway"; networkTestClient.EnsureNoNetworkConfigurationExists(virtualNetworkSiteName); networkTestClient.SetNetworkConfiguration(NetworkTestConstants.CoexistenceFeatureNetworkConfigurationParameters); NetworkListResponse listResponse = networkTestClient.ListNetworkConfigurations(); Assert.NotNull(listResponse); Assert.True(listResponse.VirtualNetworkSites.Any(vnet => vnet.Name.Equals(virtualNetworkSiteName)), "Virtual network:" + virtualNetworkSiteName + " is not found!"); string vnetId = listResponse.First(vnet => vnet.Name.Equals(virtualNetworkSiteName)).Id; GatewayGetOperationStatusResponse response = networkTestClient.Gateways.CreateVirtualNetworkGateway( virtualNetworkSiteName, new VirtualNetworkGatewayCreateParameters() { GatewayName = vnetGatewayName, GatewayType = GatewayType.DynamicRouting }); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); ListVirtualNetworkGatewaysResponse listVirtualNetworkGatewaysResponse = networkTestClient.Gateways.ListVirtualNetworkGateways(); Assert.True(listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.Count >= 1); Guid vnetGatewayId = listVirtualNetworkGatewaysResponse.VirtualNetworkGateways.First(vnetGateway => vnetGateway.GatewayName.Equals(vnetGatewayName)).GatewayId; // b.CreateLocalNetworkGateway API string localnetGatewayName = "coexistenceLocalnetGateway"; string addressSpace = "200.168.0.0/16"; var param = new LocalNetworkGatewayCreateParameters() { AddressSpace = new LazyList <string>() { addressSpace }, GatewayName = localnetGatewayName, IpAddress = "204.95.99.237", }; LocalNetworkGatewayCreateResponse localNetworkGatewayCreateResponse = networkTestClient.Gateways.CreateLocalNetworkGateway(param); Assert.NotNull(localNetworkGatewayCreateResponse); Assert.Equal(HttpStatusCode.OK, localNetworkGatewayCreateResponse.StatusCode); Assert.NotNull(localNetworkGatewayCreateResponse.LocalNetworkGatewayId); ListLocalNetworkGatewaysResponse listLocalNetworkGatewaysResponse = networkTestClient.Gateways.ListLocalNetworkGateways(); Assert.NotNull(listLocalNetworkGatewaysResponse); Assert.Equal(HttpStatusCode.OK, listLocalNetworkGatewaysResponse.StatusCode); Assert.Equal(1, listLocalNetworkGatewaysResponse.LocalNetworkGateways.Count); string localNetworkGatewayId = listLocalNetworkGatewaysResponse.LocalNetworkGateways.First(localnetGateway => localnetGateway.GatewayName.Equals(localnetGatewayName)).Id.ToString(); // c.CreateGatewayConnection API string gatewayConnectionName = "coexistenceGatewayConnection"; GatewayGetOperationStatusResponse gatewayGetOperationStatusResponse = networkTestClient.Gateways.CreateGatewayConnection( new GatewayConnectionCreateParameters() { ConnectedEntityId = localNetworkGatewayId, GatewayConnectionName = gatewayConnectionName, GatewayConnectionType = GatewayConnectionType.IPsec, VirtualNetworkGatewayId = vnetGatewayId, RoutingWeight = 3, SharedKey = "abc" } ); Assert.NotNull(gatewayGetOperationStatusResponse); Assert.Equal(HttpStatusCode.OK, gatewayGetOperationStatusResponse.HttpStatusCode); //d. SetIPsecParametersV2 API GatewaySetIPsecParametersParameters setParameters = CreateIPSecParameters(); response = networkTestClient.Gateways.SetIPsecParametersV2(vnetGatewayId.ToString(), localNetworkGatewayId, setParameters); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); Assert.NotNull(response.Id); // 2.GetIPsecParametersV2 API GatewayGetIPsecParametersResponse paramResponse = networkTestClient.Gateways.GetIPsecParametersV2(vnetGatewayId.ToString(), localNetworkGatewayId); Assert.NotNull(paramResponse); Assert.Equal(HttpStatusCode.OK, paramResponse.StatusCode); Assert.NotNull(paramResponse.IPsecParameters); Assert.Equal(EncryptionType.NoEncryption, paramResponse.IPsecParameters.EncryptionType); Assert.Equal(PfsGroup.PFS1, paramResponse.IPsecParameters.PfsGroup); Assert.Equal(102400000, paramResponse.IPsecParameters.SADataSizeKilobytes); //Check for default value Assert.Equal(3600, paramResponse.IPsecParameters.SALifeTimeSeconds); //Check for default value Assert.Equal("SHA1", paramResponse.IPsecParameters.HashAlgorithm); //Check for default value // Cleanup test setup at end gatewayGetOperationStatusResponse = networkTestClient.Gateways.DeleteGatewayConnection(vnetGatewayId.ToString(), localNetworkGatewayId); Assert.NotNull(gatewayGetOperationStatusResponse); Assert.Equal(HttpStatusCode.OK, gatewayGetOperationStatusResponse.HttpStatusCode); response = networkTestClient.Gateways.DeleteVirtualNetworkGateway(vnetGatewayId.ToString()); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode); AzureOperationResponse deleteLocalNetworkGatewayResponse = networkTestClient.Gateways.DeleteLocalNetworkGateway(localNetworkGatewayId); Assert.NotNull(deleteLocalNetworkGatewayResponse); Assert.Equal(HttpStatusCode.OK, deleteLocalNetworkGatewayResponse.StatusCode); } }