Skip to content

Commit 7c67ba7

Browse files
authored
fix: enable integration test for devops variable group description (#400)
* enable `Sets the DevOps variable group description with the release name` test, different way of authenticating to the devops api * update api version and retrieve description from first value * remove unused var * added debug logging * added debug logging * add param for url encoded variable group name * re added $env:ArmOutputs * fixed requesturi * remove debug logging * added comment about PAT --------- Co-authored-by: Pim Simons <pim.simons@codit.eu>
1 parent 22d99ec commit 7c67ba7

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/Arcus.Scripting.Tests.Integration/Arcus.Scripting.DevOps.tests.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,25 @@ InModuleScope Arcus.Scripting.DevOps {
6666
}
6767
}
6868
}
69-
It "Sets the DevOps variable group description with the release name" -Skip {
69+
It "Sets the DevOps variable group description with the release name" {
7070
# Arrange
7171
$variableGroupName = $config.Arcus.DevOps.VariableGroup.Name
72+
$variableGroupNameUrlEncoded = $config.Arcus.DevOps.VariableGroup.NameUrlEncoded
7273
$env:ArmOutputs = "{ ""my-variable"": { ""type"": ""string"", ""value"": ""my-value"" } }"
74+
#$variableGroupAuthorization contains a PAT with read access to variable groups, create a new one when it expires
75+
$variableGroupAuthorization = $config.Arcus.DevOps.VariableGroup.Authorization
7376
$projectId = $env:SYSTEM_TEAMPROJECTID
7477
$collectionUri = $env:SYSTEM_COLLECTIONURI
75-
$requestUri = "$collectionUri" + "$projectId/_apis/distributedtask/variablegroups?groupName=/" + $variableGroupName + "?api-version=6.0"
76-
$headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }
78+
$requestUri = "$collectionUri" + "$projectId/_apis/distributedtask/variablegroups?groupName=" + $variableGroupNameUrlEncoded + "&api-version=6.1-preview.2"
79+
$headers = @{ Authorization = "Basic $variableGroupAuthorization" }
7780

7881
# Act
7982
Set-AzDevOpsArmOutputsToVariableGroup -VariableGroupName $variableGroupName
8083

8184
# Assert
8285
$getResponse = Invoke-WebRequest -Uri $requestUri -Method Get -Headers $headers
8386
$json = ConvertFrom-Json $getResponse.Content
84-
$json.description | Should -BeLike "*$env:Build_DefinitionName*$env:Build_BuildNumber*"
87+
$json.value[0].description | Should -BeLike "*$env:Build_DefinitionName*$env:Build_BuildNumber*"
8588
}
8689
}
8790
}

src/Arcus.Scripting.Tests.Integration/appsettings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
},
1010
"DevOps": {
1111
"VariableGroup": {
12-
"Name": "#{Arcus.DevOps.VariableGroup.Name}#"
12+
"Name": "#{Arcus.DevOps.VariableGroup.Name}#",
13+
"NameUrlEncoded": "#{Arcus.DevOps.VariableGroup.Name.UrlEncoded}#",
14+
"Authorization": "#{Arcus.DevOps.VariableGroup.Authorization}#"
1315
}
1416
},
1517
"KeyVault": {

0 commit comments

Comments
 (0)