public void ResetSharedKey() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.SetNetworkConfiguration(NetworkTestConstants.SiteToSiteNetworkConfigurationParameters); networkTestClient.Gateways.CreateGateway(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.CreateStaticRoutingGatewayParameters()); GatewayGetSharedKeyResponse firstGetResponse = networkTestClient.Gateways.GetSharedKey(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.LocalNetworkSiteName); string firstSharedKey = firstGetResponse.SharedKey; GatewayResetSharedKeyParameters parameters = new GatewayResetSharedKeyParameters() { KeyLength = 128, }; GatewayGetOperationStatusResponse resetResponse = networkTestClient.Gateways.ResetSharedKey(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.LocalNetworkSiteName, parameters); Assert.NotNull(resetResponse); Assert.Equal(HttpStatusCode.OK, resetResponse.HttpStatusCode); GatewayGetSharedKeyResponse secondGetResponse = networkTestClient.Gateways.GetSharedKey(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.LocalNetworkSiteName); string secondSharedKey = secondGetResponse.SharedKey; Assert.NotEqual(firstSharedKey, secondSharedKey); } }
public void SetSharedKey() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.Gateways.EnsureStaticRoutingGatewayExists(); GatewayResetSharedKeyParameters resetParameters = new GatewayResetSharedKeyParameters() { KeyLength = 128, }; GatewayGetOperationStatusResponse resetResponse = networkTestClient.Gateways.ResetSharedKey(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.LocalNetworkSiteName, resetParameters); Assert.NotNull(resetResponse); Assert.Equal(HttpStatusCode.OK, resetResponse.HttpStatusCode); const string sharedKeyToSet = "ABC"; GatewayGetSharedKeyResponse firstGetResponse = networkTestClient.Gateways.GetSharedKey(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.LocalNetworkSiteName); Assert.NotEqual(sharedKeyToSet, firstGetResponse.SharedKey); GatewaySetSharedKeyParameters setParameters = new GatewaySetSharedKeyParameters() { Value = sharedKeyToSet, }; GatewayGetOperationStatusResponse setResponse = networkTestClient.Gateways.SetSharedKey(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.LocalNetworkSiteName, setParameters); Assert.NotNull(setResponse); Assert.Equal(HttpStatusCode.OK, setResponse.HttpStatusCode); GatewayGetSharedKeyResponse secondGetResponse = networkTestClient.Gateways.GetSharedKey(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.LocalNetworkSiteName); Assert.Equal(sharedKeyToSet, secondGetResponse.SharedKey); } }
public ResetSharedKey(IGatewayOperations gatewayClient, string virtualNetworkSiteName, string localNetworkSiteName, GatewayResetSharedKeyParameters parameters) { this.gatewayClient = gatewayClient; this.virtualNetworkSiteName = virtualNetworkSiteName; this.localNetworkSiteName = localNetworkSiteName; this.parameters = parameters; GatewayGetSharedKeyResponse oldSharedKeyResponse = gatewayClient.GetSharedKey(virtualNetworkSiteName, localNetworkSiteName); oldSharedKey = oldSharedKeyResponse.SharedKey; }
/// <summary> /// The Begin Reset Virtual Network Gateway Shared Key operation resets /// the shared key on the virtual network gateway for the specified /// virtual network connection to the specified local network in /// Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj154114.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='networkName'> /// Required. The name of the virtual network for this gateway. /// </param> /// <param name='localNetworkName'> /// Required. The name of the local network. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Begin Virtual Network Gateway /// Reset Shared Key request. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<GatewayOperationResponse> BeginResetSharedKeyAsync(this IGatewayOperations operations, string networkName, string localNetworkName, GatewayResetSharedKeyParameters parameters) { return operations.BeginResetSharedKeyAsync(networkName, localNetworkName, parameters, CancellationToken.None); }
/// <summary> /// The Begin Reset Virtual Network Gateway Shared Key operation resets /// the shared key on the virtual network gateway for the specified /// virtual network connection to the specified local network in /// Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj154114.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='networkName'> /// Required. The name of the virtual network for this gateway. /// </param> /// <param name='localNetworkName'> /// Required. The name of the local network. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Begin Virtual Network Gateway /// Reset Shared Key request. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static GatewayOperationResponse BeginResetSharedKey(this IGatewayOperations operations, string networkName, string localNetworkName, GatewayResetSharedKeyParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IGatewayOperations)s).BeginResetSharedKeyAsync(networkName, localNetworkName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
public GatewayGetOperationStatusResponse ResetSharedKey(string virtualNetworkSiteName, string localNetworkSiteName, GatewayResetSharedKeyParameters parameters) { ResetSharedKey operation = new ResetSharedKey(gatewayClient, virtualNetworkSiteName, localNetworkSiteName, parameters); testClient.InvokeTestOperation(operation); return operation.InvokeResponse; }
public GatewayGetOperationStatusResponse ResetSharedKeyV2(string gatewayId, string connectedentityId, GatewayResetSharedKeyParameters parameters) { return gatewayClient.ResetSharedKeyV2(gatewayId, connectedentityId, parameters); }
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); } }
/// <summary> /// The Begin Reset Virtual Network Gateway Shared Key V2 operation /// resets the shared key used between the gateway and customer vpn. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='gatewayId'> /// Required. The virtual network for this gateway Id. /// </param> /// <param name='connectedentityId'> /// Required. The connected entity Id. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Begin Virtual Network Gateway /// Reset Shared Key V2 request. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<GatewayOperationResponse> BeginResetSharedKeyV2Async(this IGatewayOperations operations, string gatewayId, string connectedentityId, GatewayResetSharedKeyParameters parameters) { return operations.BeginResetSharedKeyV2Async(gatewayId, connectedentityId, parameters, CancellationToken.None); }
/// <summary> /// The Begin Reset Virtual Network Gateway Shared Key V2 operation /// resets the shared key used between the gateway and customer vpn. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='gatewayId'> /// Required. The virtual network for this gateway Id. /// </param> /// <param name='connectedentityId'> /// Required. The connected entity Id. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Begin Virtual Network Gateway /// Reset Shared Key V2 request. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static GatewayOperationResponse BeginResetSharedKeyV2(this IGatewayOperations operations, string gatewayId, string connectedentityId, GatewayResetSharedKeyParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IGatewayOperations)s).BeginResetSharedKeyV2Async(gatewayId, connectedentityId, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// The Reset Virtual network Gateway shared key operation resets the /// shared key on the virtual network gateway for the specified /// vitrual network connection to the specified local network in /// Windows Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj154114.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='virtualNetworkName'> /// The name of the virtual network for this gateway. /// </param> /// <param name='localNetworkName'> /// The name of the local network. /// </param> /// <param name='parameters'> /// The parameters to the Virtual Network Gateway Reset Shared Key /// request. /// </param> /// <returns> /// A standard storage response including an HTTP status code and /// request ID. /// </returns> public static GatewayOperationResponse BeginResetSharedKey(this IGatewayOperations operations, string virtualNetworkName, string localNetworkName, GatewayResetSharedKeyParameters parameters) { try { return operations.BeginResetSharedKeyAsync(virtualNetworkName, localNetworkName, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// The Reset Virtual network Gateway shared key operation resets the /// shared key on the virtual network gateway for the specified /// vitrual network connection to the specified local network in /// Windows Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/jj154114.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IGatewayOperations. /// </param> /// <param name='virtualNetworkName'> /// The name of the virtual network for this gateway. /// </param> /// <param name='localNetworkName'> /// The name of the local network. /// </param> /// <param name='parameters'> /// The parameters to the Virtual Network Gateway Reset Shared Key /// request. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request, and also includes error /// information regarding the failure. /// </returns> public static Task<GatewayGetOperationStatusResponse> ResetSharedKeyAsync(this IGatewayOperations operations, string virtualNetworkName, string localNetworkName, GatewayResetSharedKeyParameters parameters) { return operations.ResetSharedKeyAsync(virtualNetworkName, localNetworkName, parameters, CancellationToken.None); }