Skip to content

Commit

Permalink
Fix the issue of service principal. (Azure#13458)
Browse files Browse the repository at this point in the history
Co-authored-by: wyunchi-ms <[email protected]>
  • Loading branch information
wyunchi-ms and wyunchi-ms authored Nov 9, 2020
1 parent 4aa08c0 commit fd71499
Show file tree
Hide file tree
Showing 5 changed files with 1,982 additions and 1 deletion.
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~'
$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

0 comments on commit fd71499

Please sign in to comment.