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(); } }
public async Task ContainerListClusterAdminCredentialsTest() { using (MockContext context = MockContext.Start(this.GetType())) { InitializeClients(context); string location = ContainerServiceTestUtilities.GetLocationFromProvider(resourceManagementClient); var resourceGroup = resourceManagementClient.TryGetResourceGroup(location); if (string.IsNullOrWhiteSpace(resourceGroup)) { resourceGroup = TestUtilities.GenerateName(ContainerServiceTestUtilities.ResourceGroupPrefix); resourceManagementClient.TryRegisterResourceGroup(location, resourceGroup); } string clusterName = TestUtilities.GenerateName(); // Create a managed AKS cluster ManagedCluster managedClusterResult = ContainerServiceTestUtilities.CreateManagedCluster( context, ResourceManagementClient, ContainerServiceClient, location, clusterName, resourceGroup).Result; // Wait for 10 seconds a sanity check TestUtilities.Wait(10000); CredentialResults adminCredentials = await containerServiceClient.ManagedClusters.ListClusterAdminCredentialsAsync(resourceGroup, clusterName); Assert.True(adminCredentials.Kubeconfigs.Count > 0); Assert.True(!string.IsNullOrWhiteSpace(adminCredentials.Kubeconfigs[0].Name)); // Clean up our Azure resources ResourceManagementClient.ResourceGroups.DeleteAsync(resourceGroup).Wait(); } }