public async Task DeleteTest()
        {
            await(await Connection.DeleteAsync()).WaitForCompletionResponseAsync();
            PrivateEndpointConnection connection = await ConfigStore.GetPrivateEndpointConnections().GetIfExistsAsync(Connection.Data.Name);

            Assert.IsNull(connection);
        }
예제 #2
0
        public async Task DeleteTest()
        {
            await Connection.DeleteAsync(WaitUntil.Completed);

            PrivateEndpointConnection connection = await ConfigStore.GetPrivateEndpointConnections().GetIfExistsAsync(Connection.Data.Name);

            Assert.IsNull(connection);
        }
예제 #3
0
        public async Task GetTest()
        {
            List <PrivateEndpointConnectionResource> connections = await ConfigStore.GetPrivateEndpointConnections().GetAllAsync().ToEnumerableAsync();

            string privateEndpointConnectionName = connections.First().Data.Name;
            PrivateEndpointConnectionResource privateEndpointConnection = await ConfigStore.GetPrivateEndpointConnections().GetAsync(privateEndpointConnectionName);

            Assert.IsTrue(privateEndpointConnectionName.Equals(privateEndpointConnection.Data.Name));
            Assert.IsTrue(privateEndpointConnection.Data.PrivateLinkServiceConnectionState.Status == Models.ConnectionStatus.Approved);
        }
        public async Task TestSetUp()
        {
            if (Mode == RecordedTestMode.Record || Mode == RecordedTestMode.Playback)
            {
                Initialize();
                string groupName    = Recording.GenerateAssetName(ResourceGroupPrefix);
                string VnetName     = Recording.GenerateAssetName("vnetname");
                string SubnetName   = Recording.GenerateAssetName("subnetname");
                string EndpointName = Recording.GenerateAssetName("endpointxyz");
                ResGroup = await(await ArmClient.GetDefaultSubscriptionAsync().Result.GetResourceGroups().CreateOrUpdateAsync(groupName, new ResourceGroupData(Location))).WaitForCompletionAsync();
                string configurationStoreName = Recording.GenerateAssetName("testapp-");
                ConfigurationStoreData configurationStoreData = new ConfigurationStoreData(Location, new Models.Sku("Standard"))
                {
                    PublicNetworkAccess = PublicNetworkAccess.Disabled
                };
                ConfigStore = await(await ResGroup.GetConfigurationStores().CreateOrUpdateAsync(configurationStoreName, configurationStoreData)).WaitForCompletionAsync();
                // Prepare VNet and Private Endpoint
                VirtualNetworkData vnetData = new VirtualNetworkData()
                {
                    Location     = "eastus",
                    AddressSpace = new AddressSpace()
                    {
                        AddressPrefixes = { "10.0.0.0/16", }
                    },
                    DhcpOptions = new DhcpOptions()
                    {
                        DnsServers = { "10.1.1.1", "10.1.2.4" }
                    },
                    Subnets = { new SubnetData()
                                {
                                    Name = SubnetName, AddressPrefix = "10.0.0.0/24", PrivateEndpointNetworkPolicies = "Disabled"
                                } }
                };
                VirtualNetwork      vnet = await(await ResGroup.GetVirtualNetworks().CreateOrUpdateAsync(VnetName, vnetData)).WaitForCompletionAsync();
                PrivateEndpointData privateEndpointData = new PrivateEndpointData()
                {
                    Location = "eastus",
                    PrivateLinkServiceConnections = { new PrivateLinkServiceConnection()
                                                      {
                                                          Name = "myconnection",
                                                          PrivateLinkServiceId = ConfigStore.Data.Id,
                                                          GroupIds             = { "configurationStores" },
                                                          RequestMessage       = "Please approve my connection",
                                                      } },
                    Subnet = new SubnetData()
                    {
                        Id = "/subscriptions/" + TestEnvironment.SubscriptionId + "/resourceGroups/" + groupName + "/providers/Microsoft.Network/virtualNetworks/" + VnetName + "/subnets/" + SubnetName
                    }
                };
                PrivateEndpoint = await(await ResGroup.GetPrivateEndpoints().CreateOrUpdateAsync(EndpointName, privateEndpointData)).WaitForCompletionAsync();
                List <PrivateEndpointConnection> connections = await ConfigStore.GetPrivateEndpointConnections().GetAllAsync().ToEnumerableAsync();

                Connection = connections.FirstOrDefault();
            }
        }
예제 #5
0
        public async Task CreateOrUpdateTest()
        {
            // Only support update
            List <PrivateEndpointConnectionResource> connections = await ConfigStore.GetPrivateEndpointConnections().GetAllAsync().ToEnumerableAsync();

            string privateEndpointConnectionName = connections.FirstOrDefault().Data.Name;
            PrivateEndpointConnectionData privateEndpointConnectionData = connections.FirstOrDefault().Data;

            privateEndpointConnectionData.PrivateLinkServiceConnectionState.Description = "Update descriptions";
            PrivateEndpointConnectionResource privateEndpointConnection = (await ConfigStore.GetPrivateEndpointConnections().CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, privateEndpointConnectionData)).Value;

            Assert.IsTrue(privateEndpointConnectionName.Equals(privateEndpointConnection.Data.Name));
            Assert.IsTrue(PrivateEndpointResource.Data.Id.Equals(privateEndpointConnection.Data.PrivateEndpoint.Id));
            Assert.IsTrue(privateEndpointConnection.Data.PrivateLinkServiceConnectionState.Description.Equals("Update descriptions"));
        }
        public async Task DeleteTest()
        {
            await Connection.DeleteAsync(WaitUntil.Completed);

            var exception = Assert.ThrowsAsync <RequestFailedException>(async() => { PrivateEndpointConnectionResource connection = await ConfigStore.GetPrivateEndpointConnections().GetAsync(Connection.Data.Name); });

            Assert.AreEqual(404, exception.Status);
        }