public void ResizeStaticRoutingGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                ResizeGatewayParameters parameters = new ResizeGatewayParameters()
                {
                    GatewaySKU = GatewaySKU.HighPerformance,
                };

                try
                {
                    networkTestClient.Gateways.ResizeGateway(NetworkTestConstants.VirtualNetworkSiteName, parameters);
                    Assert.True(false, "ResizeGateway should have thrown a CloudException when it was run against a StaticRouting gateway.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.Equal("The current operation or request is invalid against Static-Routing gateway.", e.Error.Message);
                    Assert.NotNull(e.Response);
                    Assert.Equal("Bad Request", e.Response.ReasonPhrase);
                    Assert.Equal(HttpStatusCode.BadRequest, e.Response.StatusCode);
                }
            }
        }
示例#2
0
        public void StartDiagnosticsWithNoCustomerStorageKey()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();

                StartGatewayPublicDiagnosticsParameters parameters = new StartGatewayPublicDiagnosticsParameters()
                {
                    Operation                = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics,
                    CustomerStorageName      = "daschult20140611a",
                    ContainerName            = "hydra-test-diagnostics",
                    CaptureDurationInSeconds = "1",
                };

                try
                {
                    networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, parameters);
                    Assert.True(false, "UpdateDiagnostics should have thrown a CloudException.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.True(e.Error.Message.Contains("CustomerStorageKey was not valid"));
                }
            }
        }
        public void SetDefaultSitesWhenGatewayIsNotProvisioned()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();

                networkTestClient.Gateways.EnsureNoGatewayExists();

                const string virtualNetworkSiteName            = NetworkTestConstants.VirtualNetworkSiteName;
                GatewaySetDefaultSiteListParameters parameters = CreateParameters("localNetworkSiteName");

                try
                {
                    networkTestClient.Gateways.SetDefaultSites(virtualNetworkSiteName, parameters);
                    Assert.True(false, "SetDefaultSites should throw an CloudException when the gateway was not provisioned.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.NotNull(e.Response);
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.True(e.Error.Message.Contains("current provisioning status of the gateway prevents this operation"));
                    Assert.Equal(HttpStatusCode.BadRequest, e.Response.StatusCode);
                    Assert.Equal("Bad Request", e.Response.ReasonPhrase);
                }
            }
        }
        public void ListRouteTablesWhenTwoTablesExist()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Routes.EnsureNoRouteTablesExist();
                networkTestClient.Routes.EnsureRouteTableExists("MockRouteTableA");
                networkTestClient.Routes.EnsureRouteTableExists("MockRouteTableB");

                ListRouteTablesResponse listResponse = networkTestClient.Routes.ListRouteTables();
                Assert.NotNull(listResponse);
                Assert.NotNull(listResponse.RouteTables);
                Assert.Equal(2, listResponse.RouteTables.Count);

                RouteTable mockRouteTableA = listResponse.RouteTables[0];
                Assert.Equal("MockRouteTableA", mockRouteTableA.Name);
                Assert.Equal("MockLabel", mockRouteTableA.Label);
                Assert.Equal(NetworkTestConstants.WideVNetLocation, mockRouteTableA.Location);
                Assert.Equal(RouteTableState.Created, mockRouteTableA.RouteTableState);

                RouteTable mockRouteTableB = listResponse.RouteTables[1];
                Assert.Equal("MockRouteTableB", mockRouteTableB.Name);
                Assert.Equal("MockLabel", mockRouteTableB.Label);
                Assert.Equal(NetworkTestConstants.WideVNetLocation, mockRouteTableB.Location);
                Assert.Equal(RouteTableState.Created, mockRouteTableB.RouteTableState);
            }
        }
        public void CreateApplicationGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                ApplicationGatewayOperationResponse result = new ApplicationGatewayOperationResponse();

                //CREATE gateway
                var createParams = new CreateApplicationGatewayParameters
                {
                    Name = gatewayName,
                    Description = gatewayDescription,
                    VnetName = vnet,
                    Subnets = new List<string>() { subnet }
                };

                result = networkTestClient.ApplicationGateways.CreateApplicationGateway(createParams);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);

                //SET gateway config
                ApplicationGatewaySetConfiguration config = GenerateConfig();

                result = networkTestClient.ApplicationGateways.SetConfigApplicationGateway(gatewayName, config);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);

                //START gateway
                result = networkTestClient.ApplicationGateways.StartApplicationGateway(gatewayName);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
            }
        }
        public void ResizeGatewayWithNotProvisionedGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureNoGatewayExists();
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();

                ResizeGatewayParameters parameters = new ResizeGatewayParameters()
                {
                    GatewaySKU = GatewaySKU.HighPerformance,
                };

                try
                {
                    networkTestClient.Gateways.ResizeGateway(NetworkTestConstants.VirtualNetworkSiteName, parameters);
                    Assert.True(false, "ResizeGateway should have thrown a CloudException when the virtual network gateway was not provisioned.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.Equal("The current provisioning status of the gateway prevents this operation.", e.Error.Message);
                    Assert.NotNull(e.Response);
                    Assert.Equal("Bad Request", e.Response.ReasonPhrase);
                    Assert.Equal(HttpStatusCode.BadRequest, e.Response.StatusCode);
                }
            }
        }
示例#7
0
        public void AddRouteTableToSubnetWithNonExistantSubnetName()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureWideVNetNetworkConfigurationExists();
                networkTestClient.Routes.EnsureRouteTableExists("MockRouteTableName");

                AddRouteTableToSubnetParameters parameters = new AddRouteTableToSubnetParameters()
                {
                    RouteTableName = "MockRouteTableName"
                };

                try
                {
                    networkTestClient.Routes.AddRouteTableToSubnet(NetworkTestConstants.VirtualNetworkSiteName, "NonExistantSubnetName", parameters);
                    Assert.True(false, "AddRouteTableToSubnet should have thrown a CloudException when the subnetName did not exist in the current vnet.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("ResourceNotFound", e.Error.Code);
                    Assert.Equal("Subnet name NonExistantSubnetName was not found in Virtual Network virtualNetworkSiteName.", e.Error.Message);
                    Assert.Null(e.Response);
                }
            }
        }
        public void SetDefaultSitesWhenGatewayIsNotProvisioned()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();

                networkTestClient.Gateways.EnsureNoGatewayExists();

                const string virtualNetworkSiteName = NetworkTestConstants.VirtualNetworkSiteName;
                GatewaySetDefaultSiteListParameters parameters = CreateParameters("localNetworkSiteName");

                try
                {
                    networkTestClient.Gateways.SetDefaultSites(virtualNetworkSiteName, parameters);
                    Assert.True(false, "SetDefaultSites should throw an CloudException when the gateway was not provisioned.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.NotNull(e.Response);
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.True(e.Error.Message.Contains("current provisioning status of the gateway prevents this operation"));
                    Assert.Equal(HttpStatusCode.BadRequest, e.Response.StatusCode);
                    Assert.Equal("Bad Request", e.Response.ReasonPhrase);
                }
            }
        }
示例#9
0
        public void GenerateVpnClientPackageWithStaticRoutingConfiguration()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();
                networkTestClient.Gateways.EnsureNoGatewayExists();

                const string networkName = "virtualNetworkSiteName";
                GatewayGenerateVpnClientPackageParameters parameters = new GatewayGenerateVpnClientPackageParameters()
                {
                    ProcessorArchitecture = GatewayProcessorArchitecture.Amd64,
                };

                try
                {
                    networkTestClient.Gateways.GenerateVpnClientPackage(networkName, parameters);
                    Assert.True(false, "GenerateVpnClientPackage should have thrown a CloudException when the networkName was empty.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.Contains("current provisioning status of the gateway prevents this operation", e.Error.Message, StringComparison.InvariantCultureIgnoreCase);
                }
            }
        }
        public void ResizeStaticRoutingGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                ResizeGatewayParameters parameters = new ResizeGatewayParameters()
                {
                    GatewaySKU = GatewaySKU.HighPerformance,
                };

                try
                {
                    networkTestClient.Gateways.ResizeGateway(NetworkTestConstants.VirtualNetworkSiteName, parameters);
                    Assert.True(false, "ResizeGateway should have thrown a CloudException when it was run against a StaticRouting gateway.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.Equal("The current operation or request is invalid against Static-Routing gateway.", e.Error.Message);
                    Assert.NotNull(e.Response);
                    Assert.Equal("Bad Request", e.Response.ReasonPhrase);
                    Assert.Equal(HttpStatusCode.BadRequest, e.Response.StatusCode);
                }
            }
        }
        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);
            }
        }
示例#12
0
        public void StartDiagnosticsWithNotFoundVirtualNetworkName()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                StartGatewayPublicDiagnosticsParameters parameters = new StartGatewayPublicDiagnosticsParameters()
                {
                    Operation           = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics,
                    CustomerStorageName = "daschult20140611a",
                    // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
                    CustomerStorageKey       = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==",
                    ContainerName            = "hydra-test-diagnostics",
                    CaptureDurationInSeconds = "1",
                };

                const string virtualNetworkName = "NotFoundVirtualNetworkName";

                try
                {
                    networkTestClient.Gateways.StartDiagnostics(virtualNetworkName, parameters);
                    Assert.True(false, "UpdateDiagnostics should have thrown a CloudException when a virtual network name was provided that didn't exist.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.Contains(virtualNetworkName, e.Error.Message);
                    Assert.Contains("not valid or could not be found", e.Error.Message);
                }
            }
        }
        public void PrepareAndAbortMigrationRouteTable()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Routes.EnsureRouteTableDoesntExist("MockName");

                CreateRouteTableParameters parameters = CreateParameters("MockName", null, NetworkTestConstants.WideVNetLocation);

                AzureOperationResponse createResponse = networkTestClient.Routes.CreateRouteTable(parameters);
                Assert.NotNull(createResponse);
                Assert.NotNull(createResponse.RequestId);
                Assert.NotEqual(0, createResponse.RequestId.Length);
                Assert.Equal(HttpStatusCode.OK, createResponse.StatusCode);

                // Test Validate migration call
                var response = networkTestClient.ValidateRouteTableMigration("MockName");
                Assert.NotNull(response);
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);

                Assert.NotNull(response.ValidationMessages);
                Assert.Equal(0, response.ValidationMessages.Count);

                // Prepare
                OperationStatusResponse prepareVnetMigration = networkTestClient.PrepareRouteTableMigration("MockName");
                Assert.Equal(OperationStatus.Succeeded, prepareVnetMigration.Status);

                // Abort
                OperationStatusResponse abortVnetMigration = networkTestClient.AbortRouteTableMigration("MockName");
                Assert.Equal(OperationStatus.Succeeded, abortVnetMigration.Status);
            }
        }
        public void AddRouteTableToSubnetWithNonExistantVNetName()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureNoNetworkConfigurationExists();
                networkTestClient.Routes.EnsureRouteTableExists("MockRouteTableName");

                AddRouteTableToSubnetParameters parameters = new AddRouteTableToSubnetParameters()
                {
                    RouteTableName = "MockRouteTableName"
                };

                try
                {
                    networkTestClient.Routes.AddRouteTableToSubnet(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.WideVNetSubnetName, parameters);
                    Assert.True(false, "AddRouteTableToSubnet should have thrown a CloudException when the parameters object's route table name was empty.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("ResourceNotFound", e.Error.Code);
                    Assert.Equal("The virtual network virtualNetworkSiteName does not exist.", e.Error.Message);
                    Assert.Null(e.Response);
                }
            }
        }
        public void StartDiagnosticsWithNoCustomerStorageName()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();

                StartGatewayPublicDiagnosticsParameters parameters = new StartGatewayPublicDiagnosticsParameters()
                {
                    Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics,
                    CustomerStorageKey = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==",
                    ContainerName = "hydra-test-diagnostics",
                    CaptureDurationInSeconds = "1",
                };

                try
                {
                    networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, parameters);
                    Assert.True(false, "UpdateDiagnostics should have thrown a CloudException.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.True(e.Error.Message.Contains("CustomerStorageName was not valid"));
                }
            }
        }
        public void GenerateVpnClientPackageWithStaticRoutingGatewayWithNoClientRootCertificates()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                GatewayGenerateVpnClientPackageParameters parameters = new GatewayGenerateVpnClientPackageParameters()
                {
                    ProcessorArchitecture = GatewayProcessorArchitecture.Amd64,
                };

                try
                {
                    networkTestClient.Gateways.GenerateVpnClientPackage(NetworkTestConstants.VirtualNetworkSiteName, parameters);
                    Assert.True(false, "GenerateVpnClientPackage should throw a CloudException when there are no client root certificates uploaded for this virtual network.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("ResourceNotFound", e.Error.Code);
                    Assert.Equal("There must be at least one client root certificate authority installed on the Gateway", e.Error.Message);
                    Assert.NotNull(e.Response);
                    Assert.Equal("Not Found", e.Response.ReasonPhrase);
                    Assert.Equal(HttpStatusCode.NotFound, e.Response.StatusCode);
                }
            }
        }
示例#17
0
        public void CreateApplicationGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                ApplicationGatewayOperationResponse result = new ApplicationGatewayOperationResponse();

                //CREATE gateway
                var createParams = new CreateApplicationGatewayParameters
                {
                    Name        = gatewayName,
                    Description = gatewayDescription,
                    VnetName    = vnet,
                    Subnets     = new List <string>()
                    {
                        subnet
                    }
                };

                result = networkTestClient.ApplicationGateways.CreateApplicationGateway(createParams);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);

                //SET gateway config
                ApplicationGatewaySetConfiguration config = GenerateConfig();

                result = networkTestClient.ApplicationGateways.SetConfigApplicationGateway(gatewayName, config);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);

                //START gateway
                result = networkTestClient.ApplicationGateways.StartApplicationGateway(gatewayName);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);
            }
        }
示例#18
0
        public void StartDiagnosticsWithNoCustomerStorageName()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();

                StartGatewayPublicDiagnosticsParameters parameters = new StartGatewayPublicDiagnosticsParameters()
                {
                    Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics,
                    // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
                    CustomerStorageKey       = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==",
                    ContainerName            = "hydra-test-diagnostics",
                    CaptureDurationInSeconds = "1",
                };

                try
                {
                    networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, parameters);
                    Assert.True(false, "UpdateDiagnostics should have thrown a CloudException.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.True(e.Error.Message.Contains("CustomerStorageName was not valid"));
                }
            }
        }
示例#19
0
        public void GenerateVpnClientPackageWithStaticRoutingGatewayWithNoClientRootCertificates()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                GatewayGenerateVpnClientPackageParameters parameters = new GatewayGenerateVpnClientPackageParameters()
                {
                    ProcessorArchitecture = GatewayProcessorArchitecture.Amd64,
                };

                try
                {
                    networkTestClient.Gateways.GenerateVpnClientPackage(NetworkTestConstants.VirtualNetworkSiteName, parameters);
                    Assert.True(false, "GenerateVpnClientPackage should throw a CloudException when there are no client root certificates uploaded for this virtual network.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("ResourceNotFound", e.Error.Code);
                    Assert.Equal("There must be at least one client root certificate authority installed on the Gateway", e.Error.Message);
                    Assert.NotNull(e.Response);
                    Assert.Equal("Not Found", e.Response.ReasonPhrase);
                    Assert.Equal(HttpStatusCode.NotFound, e.Response.StatusCode);
                }
            }
        }
示例#20
0
        public void AddRouteTableToSubnetWithNonExistantVNetName()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureNoNetworkConfigurationExists();
                networkTestClient.Routes.EnsureRouteTableExists("MockRouteTableName");

                AddRouteTableToSubnetParameters parameters = new AddRouteTableToSubnetParameters()
                {
                    RouteTableName = "MockRouteTableName"
                };

                try
                {
                    networkTestClient.Routes.AddRouteTableToSubnet(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.WideVNetSubnetName, parameters);
                    Assert.True(false, "AddRouteTableToSubnet should have thrown a CloudException when the parameters object's route table name was empty.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("ResourceNotFound", e.Error.Code);
                    Assert.Equal("The virtual network virtualNetworkSiteName does not exist.", e.Error.Message);
                    Assert.Null(e.Response);
                }
            }
        }
示例#21
0
        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 void AddRouteTableToSubnetWithNonExistantSubnetName()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureWideVNetNetworkConfigurationExists();
                networkTestClient.Routes.EnsureRouteTableExists("MockRouteTableName");

                AddRouteTableToSubnetParameters parameters = new AddRouteTableToSubnetParameters()
                {
                    RouteTableName = "MockRouteTableName"
                };

                try
                {
                    networkTestClient.Routes.AddRouteTableToSubnet(NetworkTestConstants.VirtualNetworkSiteName, "NonExistantSubnetName", parameters);
                    Assert.True(false, "AddRouteTableToSubnet should have thrown a CloudException when the subnetName did not exist in the current vnet.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("ResourceNotFound", e.Error.Code);
                    Assert.Equal("Subnet name NonExistantSubnetName was not found in Virtual Network virtualNetworkSiteName.", e.Error.Message);
                    Assert.Null(e.Response);
                }
            }
        }
        public void PrepareAndAbortMigrationRouteTable()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Routes.EnsureRouteTableDoesntExist("MockName");

                CreateRouteTableParameters parameters = CreateParameters("MockName", null, NetworkTestConstants.WideVNetLocation);

                AzureOperationResponse createResponse = networkTestClient.Routes.CreateRouteTable(parameters);
                Assert.NotNull(createResponse);
                Assert.NotNull(createResponse.RequestId);
                Assert.NotEqual(0, createResponse.RequestId.Length);
                Assert.Equal(HttpStatusCode.OK, createResponse.StatusCode);

                // Test Validate migration call
                var response = networkTestClient.ValidateRouteTableMigration("MockName");
                Assert.NotNull(response);
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);

                Assert.NotNull(response.ValidationMessages);
                Assert.Equal(0, response.ValidationMessages.Count);

                // Prepare
                OperationStatusResponse prepareVnetMigration = networkTestClient.PrepareRouteTableMigration("MockName");
                Assert.Equal(OperationStatus.Succeeded, prepareVnetMigration.Status);

                // Abort
                OperationStatusResponse abortVnetMigration = networkTestClient.AbortRouteTableMigration("MockName");
                Assert.Equal(OperationStatus.Succeeded, abortVnetMigration.Status);
            }
        }
        public void StartDiagnosticsWithNotFoundVirtualNetworkName()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                StartGatewayPublicDiagnosticsParameters parameters = new StartGatewayPublicDiagnosticsParameters()
                {
                    Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics,
                    CustomerStorageName = "daschult20140611a",
                    CustomerStorageKey = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==",
                    ContainerName = "hydra-test-diagnostics",
                    CaptureDurationInSeconds = "1",
                };

                const string virtualNetworkName = "NotFoundVirtualNetworkName";

                try
                {
                    networkTestClient.Gateways.StartDiagnostics(virtualNetworkName, parameters);
                    Assert.True(false, "UpdateDiagnostics should have thrown a CloudException when a virtual network name was provided that didn't exist.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.Contains(virtualNetworkName, e.Error.Message);
                    Assert.Contains("not valid or could not be found", e.Error.Message);
                }
            }
        }
        public void GenerateVpnClientPackageWithStaticRoutingConfiguration()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();
                networkTestClient.Gateways.EnsureNoGatewayExists();

                const string networkName = "virtualNetworkSiteName";
                GatewayGenerateVpnClientPackageParameters parameters = new GatewayGenerateVpnClientPackageParameters()
                {
                    ProcessorArchitecture = GatewayProcessorArchitecture.Amd64,
                };

                try
                {
                    networkTestClient.Gateways.GenerateVpnClientPackage(networkName, parameters);
                    Assert.True(false, "GenerateVpnClientPackage should have thrown a CloudException when the networkName was empty.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.Contains("current provisioning status of the gateway prevents this operation", e.Error.Message, StringComparison.InvariantCultureIgnoreCase);
                }
            }
        }
        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 void ResizeGatewayWithNotProvisionedGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureNoGatewayExists();
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();

                ResizeGatewayParameters parameters = new ResizeGatewayParameters()
                {
                    GatewaySKU = GatewaySKU.HighPerformance,
                };

                try
                {
                    networkTestClient.Gateways.ResizeGateway(NetworkTestConstants.VirtualNetworkSiteName, parameters);
                    Assert.True(false, "ResizeGateway should have thrown a CloudException when the virtual network gateway was not provisioned.");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                    Assert.Equal("The current provisioning status of the gateway prevents this operation.", e.Error.Message);
                    Assert.NotNull(e.Response);
                    Assert.Equal("Bad Request", e.Response.ReasonPhrase);
                    Assert.Equal(HttpStatusCode.BadRequest, e.Response.StatusCode);
                }
            }
        }
示例#28
0
        public void StartDiagnosticsWithNoContainerName()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                StartGatewayPublicDiagnosticsParameters startParameters = new StartGatewayPublicDiagnosticsParameters()
                {
                    Operation           = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics,
                    CustomerStorageName = "daschult20140611a",
                    // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
                    CustomerStorageKey       = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==",
                    CaptureDurationInSeconds = "1",
                };

                GatewayGetOperationStatusResponse startResponse = networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, startParameters);
                Assert.NotNull(startResponse);
                Assert.Equal(HttpStatusCode.OK, startResponse.HttpStatusCode);

                GatewayDiagnosticsStatus stopStatus;
                do
                {
                    stopStatus = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName);
                    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.");
            }
        }
示例#29
0
        public void GetDiagnostics()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                GatewayDiagnosticsStatus status = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(status);
                Assert.Equal(GatewayDiagnosticsState.Ready, status.State);
            }
        }
        public void StartDiagnostics()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                StartGatewayPublicDiagnosticsParameters startParameters = new StartGatewayPublicDiagnosticsParameters()
                {
                    Operation = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics,
                    CustomerStorageName = "daschult20140611a",
                    // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
                    CustomerStorageKey = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==",
                    ContainerName = "hydra-test-diagnostics",
                    CaptureDurationInSeconds = "300",
                };

                GatewayGetOperationStatusResponse startResponse = networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, startParameters);
                Assert.NotNull(startResponse);
                Assert.Equal(HttpStatusCode.OK, startResponse.HttpStatusCode);

                GatewayDiagnosticsStatus startStatus = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(startStatus);
                Assert.True(startStatus.DiagnosticsUrl != null, "The diagnostics url was null.");
                Assert.Equal(GatewayDiagnosticsState.InProgress, startStatus.State);

                StopGatewayPublicDiagnosticsParameters stopParameters = new StopGatewayPublicDiagnosticsParameters();

                try
                {
                    networkTestClient.Gateways.StopDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, stopParameters);
                    Assert.True(false, "StopDiagnostics should throw a CloudException because the REST API is expecting a 202 (Accepted) status code, but GatewayManager is returning a 200 (OK).");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Null(e.Error.Code);
                    Assert.Null(e.Error.Message);
                    Assert.NotNull(e.Response);
                    Assert.Equal(HttpStatusCode.OK, e.Response.StatusCode);
                    Assert.Equal("OK", e.Response.ReasonPhrase);
                }

                GatewayDiagnosticsStatus stopStatus;
                do
                {
                    stopStatus = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName);
                    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.");
            }
        }
        public void GetDiagnostics()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                GatewayDiagnosticsStatus status = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(status);
                Assert.Equal(GatewayDiagnosticsState.Ready, status.State);
            }
        }
        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.");
            }
        }
示例#33
0
        public void StartDiagnostics()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                StartGatewayPublicDiagnosticsParameters startParameters = new StartGatewayPublicDiagnosticsParameters()
                {
                    Operation           = UpdateGatewayPublicDiagnosticsOperation.StartDiagnostics,
                    CustomerStorageName = "daschult20140611a",
                    // [SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
                    CustomerStorageKey       = "EyXneSsrZJJbBT4bHL6p4KdO+S5YCtM75PAA1gVWd39vwHm2CHfosBRRDkJYJWpY2mpnYlMROpgqmEci6b3u0w==",
                    ContainerName            = "hydra-test-diagnostics",
                    CaptureDurationInSeconds = "300",
                };

                GatewayGetOperationStatusResponse startResponse = networkTestClient.Gateways.StartDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, startParameters);
                Assert.NotNull(startResponse);
                Assert.Equal(HttpStatusCode.OK, startResponse.HttpStatusCode);

                GatewayDiagnosticsStatus startStatus = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(startStatus);
                Assert.True(startStatus.DiagnosticsUrl != null, "The diagnostics url was null.");
                Assert.Equal(GatewayDiagnosticsState.InProgress, startStatus.State);

                StopGatewayPublicDiagnosticsParameters stopParameters = new StopGatewayPublicDiagnosticsParameters();

                try
                {
                    networkTestClient.Gateways.StopDiagnostics(NetworkTestConstants.VirtualNetworkSiteName, stopParameters);
                    Assert.True(false, "StopDiagnostics should throw a CloudException because the REST API is expecting a 202 (Accepted) status code, but GatewayManager is returning a 200 (OK).");
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Null(e.Error.Code);
                    Assert.Null(e.Error.Message);
                    Assert.NotNull(e.Response);
                    Assert.Equal(HttpStatusCode.OK, e.Response.StatusCode);
                    Assert.Equal("OK", e.Response.ReasonPhrase);
                }

                GatewayDiagnosticsStatus stopStatus;
                do
                {
                    stopStatus = networkTestClient.Gateways.GetDiagnostics(NetworkTestConstants.VirtualNetworkSiteName);
                    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.");
            }
        }
        public void ListRouteTablesWhenNoTablesExist()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Routes.EnsureNoRouteTablesExist();

                ListRouteTablesResponse listResponse = networkTestClient.Routes.ListRouteTables();
                Assert.NotNull(listResponse);
                Assert.NotNull(listResponse.RouteTables);
                Assert.Equal(0, listResponse.RouteTables.Count);
            }
        }
示例#35
0
        public void GetGatewayWhenGatewayIsNotProvisioned()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();
                networkTestClient.Gateways.EnsureNoGatewayExists();

                GatewayGetResponse response = networkTestClient.Gateways.GetGateway(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(response);
                Assert.Equal("NotProvisioned", response.State);
                Assert.Null(response.VipAddress);
            }
        }
        public void ResetStaticRoutingGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureStaticRoutingGatewayExists();

                networkTestClient.Gateways.ResetGateway(NetworkTestConstants.VirtualNetworkSiteName, new ResetGatewayParameters());

                GatewayGetResponse response = networkTestClient.Gateways.GetGateway(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(response);
                Assert.Equal(GatewayProvisioningEventStates.Provisioned, response.State);
            }
        }
        public void DeleteRouteTable()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Routes.EnsureRouteTableExists("MockName");

                AzureOperationResponse deleteResponse = networkTestClient.Routes.DeleteRouteTable("MockName");
                Assert.NotNull(deleteResponse);
                Assert.NotNull(deleteResponse.RequestId);
                Assert.NotEqual(0, deleteResponse.RequestId.Length);
                Assert.Equal(HttpStatusCode.OK, deleteResponse.StatusCode);
            }
        }
示例#38
0
        public void RemoveDefaultSitesWithDynamicRoutingGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureDynamicRoutingGatewayExists();

                GatewayGetOperationStatusResponse response = networkTestClient.Gateways.RemoveDefaultSites(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(response);
                Assert.Equal(HttpStatusCode.OK, response.HttpStatusCode);
                Assert.NotNull(response.Id);
                Assert.Equal(GatewayOperationStatus.Successful, response.Status);
            }
        }
        public void GetGatewayWhenGatewayIsNotProvisioned()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsureSiteToSiteNetworkConfigurationExists();
                networkTestClient.Gateways.EnsureNoGatewayExists();

                GatewayGetResponse response = networkTestClient.Gateways.GetGateway(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(response);
                Assert.Equal("NotProvisioned", response.State);
                Assert.Null(response.VipAddress);
            }
        }
        public void ValidateVNetForMigration()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                string virtualNetworkName = "foo";
                var response = networkTestClient.ValidateVnetMigration(virtualNetworkName);
                Assert.NotNull(response);
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);

                Assert.NotNull(response.ValidationMessages);
                Assert.Equal(1, response.ValidationMessages.Count);
                Assert.Equal("The virtual network foo does not exist.", response.ValidationMessages[0].Message);
            }
        }
示例#41
0
        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);

                osResp = networkTestClient.AbortVnetMigration(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.Equal(OperationStatus.Succeeded, osResp.Status);
            }
        }
示例#42
0
        public void ValidateVNetForMigration()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                string virtualNetworkName = "foo";
                var    response           = networkTestClient.ValidateVnetMigration(virtualNetworkName);
                Assert.NotNull(response);
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);

                Assert.NotNull(response.ValidateVirtualNetworkMessages);
                Assert.Equal(1, response.ValidateVirtualNetworkMessages.Count);
                Assert.Equal("The virtual network foo does not exist.", response.ValidateVirtualNetworkMessages[0].Message);
            }
        }
示例#43
0
        public void GetGatewayWhenDynamicRoutingGatewayExists()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureDynamicRoutingGatewayExists();

                GatewayGetResponse response = networkTestClient.Gateways.GetGateway(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(response);
                Assert.Equal(GatewayType.DynamicRouting, response.GatewayType);
                Assert.Equal("Provisioned", response.State);
                Assert.NotNull(response.VipAddress);
                Assert.NotEqual(0, response.VipAddress.Length);
            }
        }
示例#44
0
        public void GetSharedKeyWhenGatewayIsProvisionedButNoSharedKeyHasBeenSet()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.SetNetworkConfiguration(NetworkTestConstants.SiteToSiteNetworkConfigurationParameters);

                networkTestClient.Gateways.CreateGateway(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.CreateStaticRoutingGatewayParameters());

                GatewayGetSharedKeyResponse response = networkTestClient.Gateways.GetSharedKey(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.LocalNetworkSiteName);
                Assert.NotNull(response);
                Assert.NotNull(response.SharedKey);
                Assert.NotEmpty(response.SharedKey);
            }
        }
        public void MigrateSimpleVNetConfiguration()
        {
            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);

                osResp = networkTestClient.CommitVnetMigration(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.Equal(OperationStatus.Succeeded, osResp.Status);
            }
        }
        public void GetGatewayWhenDynamicRoutingGatewayExists()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Gateways.EnsureDynamicRoutingGatewayExists();

                GatewayGetResponse response = networkTestClient.Gateways.GetGateway(NetworkTestConstants.VirtualNetworkSiteName);
                Assert.NotNull(response);
                Assert.Equal(GatewayType.DynamicRouting, response.GatewayType);
                Assert.Equal("Provisioned", response.State);
                Assert.NotNull(response.VipAddress);
                Assert.NotEqual(0, response.VipAddress.Length);
            }
        }
        public void CreateRouteTableWhenLabelIsNull()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Routes.EnsureRouteTableDoesntExist("MockName");

                CreateRouteTableParameters parameters = CreateParameters("MockName", null, NetworkTestConstants.WideVNetLocation);
                
                AzureOperationResponse createResponse = networkTestClient.Routes.CreateRouteTable(parameters);
                Assert.NotNull(createResponse);
                Assert.NotNull(createResponse.RequestId);
                Assert.NotEqual(0, createResponse.RequestId.Length);
                Assert.Equal(HttpStatusCode.OK, createResponse.StatusCode);
            }
        }
        public void CreateDynamicGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsurePointToSiteNetworkConfigurationExists();

                networkTestClient.Gateways.CreateGateway(
                    NetworkTestConstants.VirtualNetworkSiteName,
                    NetworkTestConstants.CreateDynamicRoutingGatewayParameters());

                GatewayGetResponse response = networkTestClient.Gateways.GetGateway("virtualNetworkSiteName");
                Assert.NotNull(response);
                Assert.Equal(GatewayType.DynamicRouting, response.GatewayType);
            }
        }
        public void CreateDynamicGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.EnsurePointToSiteNetworkConfigurationExists();

                networkTestClient.Gateways.CreateGateway(
                    NetworkTestConstants.VirtualNetworkSiteName,
                    NetworkTestConstants.CreateDynamicRoutingGatewayParameters());
                
                GatewayGetResponse response = networkTestClient.Gateways.GetGateway("virtualNetworkSiteName");
                Assert.NotNull(response);
                Assert.Equal(GatewayType.DynamicRouting, response.GatewayType);
            }
        }
 public void SetConfigurationThrowsArgumentNullExceptionWhenConfigurationIsNull()
 {
     using (NetworkTestClient networkTestClient = new NetworkTestClient())
     {
         NetworkSetConfigurationParameters parameters = new NetworkSetConfigurationParameters();
         try
         {
             networkTestClient.SetNetworkConfiguration(parameters);
         }
         catch (ArgumentNullException e)
         {
             Assert.Equal("parameters.Configuration", e.ParamName);
         }
     }
 }
        public void CreateRouteTableWhenLabelIsEmpty()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.Routes.EnsureRouteTableDoesntExist("MockName");

                CreateRouteTableParameters parameters = CreateParameters("MockName", "", NetworkTestConstants.WideVNetLocation);

                AzureOperationResponse createResponse = networkTestClient.Routes.CreateRouteTable(parameters);
                Assert.NotNull(createResponse);
                Assert.NotNull(createResponse.RequestId);
                Assert.NotEqual(0, createResponse.RequestId.Length);
                Assert.Equal(HttpStatusCode.OK, createResponse.StatusCode);
            }
        }
        public void GetSharedKeyWhenGatewayIsNotProvisioned()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                networkTestClient.SetNetworkConfiguration(NetworkTestConstants.SiteToSiteNetworkConfigurationParameters);

                try
                {
                    networkTestClient.Gateways.GetSharedKey(NetworkTestConstants.VirtualNetworkSiteName, NetworkTestConstants.LocalNetworkSiteName);
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("BadRequest", e.Error.Code);
                }
            }
        }
        public void GetConfigurationThrowsResourceNotFoundWhenNoConfigurationExists()
        {
            using (NetworkTestClient testClient = new NetworkTestClient())
            {
                testClient.EnsureNoNetworkConfigurationExists();

                try
                {
                    testClient.GetNetworkConfiguration();
                }
                catch (Hyak.Common.CloudException e)
                {
                    Assert.Equal("ResourceNotFound", e.Error.Code);
                }
            }
        }