示例#1
0
        public async Task OptionsSetStableVersionQueryParameter()
        {
            var response = new MockResponse(200);

            response.SetContent(managedPrivateEndpointJson);

            var mockTransport = new MockTransport(response);

            ManagedPrivateEndpointsClient previewClient = CreateTestClient(ManagedPrivateEndpointsClientOptions.ServiceVersion.V2020_12_01, mockTransport);

            Response <ManagedPrivateEndpoint> endpoint = await previewClient.GetAsync("TestEndpoint");

            MockRequest request = mockTransport.SingleRequest;

            Assert.AreEqual(RequestMethod.Get, request.Method);
            Assert.IsTrue(request.Uri.ToString().Contains(ManagedPrivateEndpointsClientOptions.ServiceVersion.V2020_12_01.ToVersionString()));
        }
示例#2
0
        public async Task TestManagedPrivateEndpoints()
        {
            ManagedPrivateEndpointsClient client = CreateClient();

            // Create a managed private endpoint
            string managedVnetName            = "default";
            string managedPrivateEndpointName = Recording.GenerateId("myPrivateEndpoint", 21);
            string fakedStorageAccountName    = Recording.GenerateId("myStorageAccount", 21);
            string privateLinkResourceId      = $"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/myResourceGroup/providers/Microsoft.Storage/accounts/{fakedStorageAccountName}";
            string groupId = "blob";
            ManagedPrivateEndpoint managedPrivateEndpoint = await client.CreateAsync(managedVnetName, new ManagedPrivateEndpoint
            {
                Properties = new ManagedPrivateEndpointProperties
                {
                    PrivateLinkResourceId = privateLinkResourceId,
                    GroupId = groupId
                }
            });

            Assert.NotNull(managedPrivateEndpoint);
            Assert.AreEqual(managedPrivateEndpointName, managedPrivateEndpoint.Name);
            Assert.AreEqual(privateLinkResourceId, managedPrivateEndpoint.Properties.PrivateLinkResourceId);
            Assert.AreEqual(groupId, managedPrivateEndpoint.Properties.GroupId);

            // List managed private endpoints
            List <ManagedPrivateEndpoint> privateEndpoints = await client.ListAsync(managedVnetName).ToEnumerableAsync();

            Assert.NotNull(privateEndpoints);
            CollectionAssert.IsNotEmpty(privateEndpoints);
            Assert.IsTrue(privateEndpoints.Any(pe => pe.Name == managedPrivateEndpointName));

            // Get managed private endpoint
            ManagedPrivateEndpoint privateEndpoint = await client.GetAsync(managedVnetName, managedPrivateEndpointName);

            Assert.AreEqual(managedPrivateEndpointName, privateEndpoint.Name);

            // Delete managed private endpoint
            await client.DeleteAsync(managedVnetName, managedPrivateEndpointName);

            privateEndpoints = await client.ListAsync(managedVnetName).ToEnumerableAsync();

            Assert.IsFalse(privateEndpoints.Any(pe => pe.Name == managedPrivateEndpointName));
        }