-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* msi for native support * native powershell changes * Not printing access token in log * rename * Error messgae changed * error message changed * unused code * error message changed * build failure * url changed * native powershell * MSI * response modifieed
- Loading branch information
1 parent
c09381d
commit 4f134b9
Showing
7 changed files
with
166 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Tasks/Common/VstsAzureHelpers_/Tests/Initialize-AzureSubscription.ManagedServiceIdentity.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
[CmdletBinding()] | ||
param() | ||
|
||
# Arrange. | ||
. $PSScriptRoot\..\..\..\..\Tests\lib\Initialize-Test.ps1 | ||
Microsoft.PowerShell.Core\Import-Module Microsoft.PowerShell.Security | ||
Unregister-Mock Import-Module | ||
Register-Mock Write-VstsTaskError | ||
$module = Microsoft.PowerShell.Core\Import-Module $PSScriptRoot\.. -PassThru | ||
|
||
$endpoint = @{ | ||
Auth = @{ | ||
Parameters = @{ | ||
ServicePrincipalId = 'Some service principal ID' | ||
ServicePrincipalKey = 'Some service principal key' | ||
TenantId = 'Some tenant ID' | ||
} | ||
Scheme = 'ManagedServiceIdentity' | ||
} | ||
Data = @{ | ||
SubscriptionId = 'Some subscription ID' | ||
SubscriptionName = 'Some subscription name' | ||
} | ||
} | ||
|
||
$content = @" | ||
{"access_token" : "Dummy Token" } | ||
"@ | ||
|
||
$response = @{ | ||
Content = $content | ||
StatusCode = 200 | ||
StatusDescription = 'OK' | ||
}; | ||
|
||
$variableSets = @( | ||
@{ StorageAccount = 'Some storage account' } | ||
) | ||
foreach ($variableSet in $variableSets) { | ||
Write-Verbose ('-' * 80) | ||
Unregister-Mock Add-AzureRMAccount | ||
Unregister-Mock Set-CurrentAzureRMSubscription | ||
Unregister-Mock Invoke-WebRequest | ||
Unregister-Mock Set-UserAgent | ||
Register-Mock Add-AzureRMAccount { 'some output' } | ||
Register-Mock Set-CurrentAzureRMSubscription | ||
Register-Mock Set-UserAgent | ||
Register-Mock Invoke-WebRequest { $response } | ||
|
||
# Act. | ||
$result = & $module Initialize-AzureSubscription -Endpoint $endpoint -StorageAccount $variableSet.StorageAccount | ||
|
||
Assert-AreEqual $null $result | ||
Assert-WasCalled Set-CurrentAzureRMSubscription -- -SubscriptionId $endpoint.Data.SubscriptionId -TenantId $endpoint.Auth.Parameters.TenantId | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters