Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Aks]Fix the issue of service principal. #13458

Merged
merged 1 commit into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/KubernetesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public void TestAzureKubernetes()
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAks");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewAzureKubernetesByServicePrincipal()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAksByServicePrincipal");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAzureKubernetesAddons()
Expand Down
31 changes: 31 additions & 0 deletions src/Aks/Aks.Test/ScenarioTests/KubernetesTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,37 @@ function Test-NewAzAks
}
}

function Test-NewAzAksByServicePrincipal
{
# Setup
$resourceGroupName = Get-RandomResourceGroupName
$kubeClusterName = Get-RandomClusterName
$location = "eastus"

$ServicePrincipalId = '618a2a3a-9d44-415a-b0ce-9729253a4ba9'
$Secret = '5E41A57vC_ODdiFb5ji-a9~C~Mp3gKt7D~'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true secret? Has the secret been revoked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service principal has been removed.

$secStringPassword = ConvertTo-SecureString $Secret -AsPlainText -Force
$credObject = New-Object System.Management.Automation.PSCredential($ServicePrincipalId,$secStringPassword)

try
{
New-AzResourceGroup -Name $resourceGroupName -Location $location


New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName `
-ServicePrincipalIdAndSecret $credObject
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Assert-AreEqual $ServicePrincipalId $cluster.ServicePrincipalProfile.ClientId

$cluster | Import-AzAksCredential -Force
$cluster | Remove-AzAksCluster -Force
}
finally
{
Remove-AzResourceGroup -Name $resourceGroupName -Force
}
}

function Test-NewAzAksAddons
{
# Setup
Expand Down
Loading