public async Task ListClusterUserCredentialCSPAADTest()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                InitializeClients(context);

                string location = KubernetesServiceTestUtilities.GetLocationFromProvider(resourceManagementClient);
                ListClusterUserCredentialProperties listClusterUserCredentialProperties = new ListClusterUserCredentialProperties("AAD", true);
                var resourceGroup = resourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(KubernetesServiceTestUtilities.ResourceGroupPrefix);
                    resourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                string clusterName = TestUtilities.GenerateName();

                // Create a connected cluster
                ConnectedCluster connectedClusterResult = await KubernetesServiceTestUtilities.CreateConnectedCluster(
                    context,
                    ResourceManagementClient,
                    ConnectedKubernetesClient,
                    location,
                    clusterName,
                    resourceGroup);

                Assert.NotNull(connectedClusterResult);
                Assert.Equal(clusterName, connectedClusterResult.Name);
                Assert.Equal(connectedClusterResult.ProvisioningState, ProvisioningState.Succeeded);

                CredentialResults credentialResults = await kubernetesServiceClient.ConnectedCluster.ListClusterUserCredentialAsync(resourceGroup, clusterName, listClusterUserCredentialProperties);

                Assert.NotNull(credentialResults);
                Assert.NotNull(credentialResults.HybridConnectionConfig);
                Assert.NotNull(credentialResults.Kubeconfigs);

                // Clean up our Azure resources
                ResourceManagementClient.ResourceGroups.DeleteAsync(resourceGroup).Wait();
            }
        }
예제 #2
0
 /// <summary>
 /// Gets cluster user credentials of a connected cluster
 /// </summary>
 /// <remarks>
 /// Gets cluster user credentials of the connected cluster with a specified
 /// resource group and name.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='clusterName'>
 /// The name of the Kubernetes cluster on which get is called.
 /// </param>
 /// <param name='properties'>
 /// ListClusterUserCredential properties
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <CredentialResults> ListClusterUserCredentialAsync(this IConnectedClusterOperations operations, string resourceGroupName, string clusterName, ListClusterUserCredentialProperties properties, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ListClusterUserCredentialWithHttpMessagesAsync(resourceGroupName, clusterName, properties, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
예제 #3
0
 /// <summary>
 /// Gets cluster user credentials of a connected cluster
 /// </summary>
 /// <remarks>
 /// Gets cluster user credentials of the connected cluster with a specified
 /// resource group and name.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='clusterName'>
 /// The name of the Kubernetes cluster on which get is called.
 /// </param>
 /// <param name='properties'>
 /// ListClusterUserCredential properties
 /// </param>
 public static CredentialResults ListClusterUserCredential(this IConnectedClusterOperations operations, string resourceGroupName, string clusterName, ListClusterUserCredentialProperties properties)
 {
     return(operations.ListClusterUserCredentialAsync(resourceGroupName, clusterName, properties).GetAwaiter().GetResult());
 }