From 4014d2e599066f5e44e0520749076f5ddc4fdfd1 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Thu, 20 Feb 2020 14:57:29 +0100 Subject: [PATCH 1/3] Add ;charset=utf-8 to POST/PUT JSON requests --- CHANGELOG.md | 6 ++++++ Source/Public/Add-VSTeam.ps1 | 2 +- Source/Public/Add-VSTeamBuild.ps1 | 2 +- Source/Public/Add-VSTeamBuildDefinition.ps1 | 2 +- Source/Public/Add-VSTeamFeed.ps1 | 2 +- Source/Public/Add-VSTeamGitRepository.ps1 | 2 +- Source/Public/Add-VSTeamPolicy.ps1 | 2 +- Source/Public/Add-VSTeamProject.ps1 | 2 +- Source/Public/Add-VSTeamRelease.ps1 | 2 +- Source/Public/Add-VSTeamReleaseDefinition.ps1 | 2 +- Source/Public/Add-VSTeamServiceEndpoint.ps1 | 2 +- Source/Public/Add-VSTeamTaskGroup.ps1 | 4 ++-- Source/Public/Add-VSTeamVariableGroup.ps1 | 2 +- Source/Public/Add-VSTeamWorkItem.ps1 | 2 +- Source/Public/Set-VSTeamApproval.ps1 | 2 +- Source/Public/Set-VSTeamEnvironmentStatus.ps1 | 2 +- Source/Public/Set-VSTeamReleaseStatus.ps1 | 2 +- Source/Public/Update-VSTeam.ps1 | 2 +- Source/Public/Update-VSTeamBuild.ps1 | 2 +- Source/Public/Update-VSTeamBuildDefinition.ps1 | 4 ++-- Source/Public/Update-VSTeamPolicy.ps1 | 2 +- Source/Public/Update-VSTeamProject.ps1 | 2 +- Source/Public/Update-VSTeamRelease.ps1 | 2 +- Source/Public/Update-VSTeamReleaseDefinition.ps1 | 4 ++-- Source/Public/Update-VSTeamServiceEndpoint.ps1 | 2 +- Source/Public/Update-VSTeamTaskGroup.ps1 | 4 ++-- Source/Public/Update-VSTeamUserEntitlement.ps1 | 2 +- Source/Public/Update-VSTeamVariableGroup.ps1 | 2 +- Source/Public/Update-VSTeamWorkItem.ps1 | 2 +- Source/VSTeam.psd1 | 2 +- 30 files changed, 39 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e88b6495..57db328bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 6.4.5 + +Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/239) from [Michel Zehnder](https://github.com/MichelZ) which included the following: + +Added ;charset=utf-8 to POST/PUT JSON requests + ## 6.4.4 Merged [Pull Request](https://github.com/DarqueWarrior/vsteam/pull/231) from [Dave Neeley](https://github.com/daveneeley) which included the following: diff --git a/Source/Public/Add-VSTeam.ps1 b/Source/Public/Add-VSTeam.ps1 index 527f3409f..da33fadf6 100644 --- a/Source/Public/Add-VSTeam.ps1 +++ b/Source/Public/Add-VSTeam.ps1 @@ -19,7 +19,7 @@ function Add-VSTeam { # Call the REST API $resp = _callAPI -Area 'projects' -Resource "$ProjectName/teams" ` - -Method Post -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Core) + -Method Post -ContentType 'application/json;charset=utf-8' -Body $body -Version $([VSTeamVersions]::Core) $team = [VSTeamTeam]::new($resp, $ProjectName) diff --git a/Source/Public/Add-VSTeamBuild.ps1 b/Source/Public/Add-VSTeamBuild.ps1 index a6e4555c1..bbc986b44 100644 --- a/Source/Public/Add-VSTeamBuild.ps1 +++ b/Source/Public/Add-VSTeamBuild.ps1 @@ -88,7 +88,7 @@ function Add-VSTeamBuild { # Call the REST API $resp = _callAPI -ProjectName $ProjectName -Area 'build' -Resource 'builds' ` - -Method Post -ContentType 'application/json' -Body ($body | ConvertTo-Json) ` + -Method Post -ContentType 'application/json;charset=utf-8' -Body ($body | ConvertTo-Json) ` -Version $([VSTeamVersions]::Build) _applyTypesToBuild -item $resp diff --git a/Source/Public/Add-VSTeamBuildDefinition.ps1 b/Source/Public/Add-VSTeamBuildDefinition.ps1 index 33b69ec82..7054b06f7 100644 --- a/Source/Public/Add-VSTeamBuildDefinition.ps1 +++ b/Source/Public/Add-VSTeamBuildDefinition.ps1 @@ -13,7 +13,7 @@ function Add-VSTeamBuildDefinition { # Bind the parameter to a friendly variable $ProjectName = $PSBoundParameters["ProjectName"] - $resp = _callAPI -Method Post -ProjectName $ProjectName -Area build -Resource definitions -Version $([VSTeamVersions]::Build) -infile $InFile -ContentType 'application/json' + $resp = _callAPI -Method Post -ProjectName $ProjectName -Area build -Resource definitions -Version $([VSTeamVersions]::Build) -infile $InFile -ContentType 'application/json;charset=utf-8' return $resp } diff --git a/Source/Public/Add-VSTeamFeed.ps1 b/Source/Public/Add-VSTeamFeed.ps1 index 7aa28f612..80f78765e 100644 --- a/Source/Public/Add-VSTeamFeed.ps1 +++ b/Source/Public/Add-VSTeamFeed.ps1 @@ -50,7 +50,7 @@ function Add-VSTeamFeed { # Call the REST API $resp = _callAPI -subDomain feeds -Area packaging -Resource feeds ` - -Method Post -ContentType 'application/json' -body $bodyAsJson -Version $([VSTeamVersions]::Packaging) + -Method Post -ContentType 'application/json;charset=utf-8' -body $bodyAsJson -Version $([VSTeamVersions]::Packaging) return [VSTeamFeed]::new($resp) } diff --git a/Source/Public/Add-VSTeamGitRepository.ps1 b/Source/Public/Add-VSTeamGitRepository.ps1 index 8fd3d721e..acfdd882f 100644 --- a/Source/Public/Add-VSTeamGitRepository.ps1 +++ b/Source/Public/Add-VSTeamGitRepository.ps1 @@ -17,7 +17,7 @@ function Add-VSTeamGitRepository { try { # Call the REST API $resp = _callAPI -ProjectName $ProjectName -Area 'git' -Resource 'repositories' ` - -Method Post -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Git) + -Method Post -ContentType 'application/json;charset=utf-8' -Body $body -Version $([VSTeamVersions]::Git) # Storing the object before you return it cleaned up the pipeline. # When I just write the object from the constructor each property diff --git a/Source/Public/Add-VSTeamPolicy.ps1 b/Source/Public/Add-VSTeamPolicy.ps1 index 330e4fd6d..cd3a18366 100644 --- a/Source/Public/Add-VSTeamPolicy.ps1 +++ b/Source/Public/Add-VSTeamPolicy.ps1 @@ -31,7 +31,7 @@ function Add-VSTeamPolicy { try { # Call the REST API $resp = _callAPI -ProjectName $ProjectName -Area 'policy' -Resource 'configurations' ` - -Method Post -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Git) + -Method Post -ContentType 'application/json;charset=utf-8' -Body $body -Version $([VSTeamVersions]::Git) Write-Output $resp } diff --git a/Source/Public/Add-VSTeamProject.ps1 b/Source/Public/Add-VSTeamProject.ps1 index 841a0e441..63b4e657e 100644 --- a/Source/Public/Add-VSTeamProject.ps1 +++ b/Source/Public/Add-VSTeamProject.ps1 @@ -41,7 +41,7 @@ function Add-VSTeamProject { try { # Call the REST API $resp = _callAPI -Area 'projects' ` - -Method Post -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::Core) + -Method Post -ContentType 'application/json;charset=utf-8' -body $body -Version $([VSTeamVersions]::Core) _trackProjectProgress -resp $resp -title 'Creating team project' -msg "Name: $($ProjectName), Template: $($processTemplate), Src: $($srcCtrl)" diff --git a/Source/Public/Add-VSTeamRelease.ps1 b/Source/Public/Add-VSTeamRelease.ps1 index 984dc8a1b..32dadbca1 100644 --- a/Source/Public/Add-VSTeamRelease.ps1 +++ b/Source/Public/Add-VSTeamRelease.ps1 @@ -91,7 +91,7 @@ function Add-VSTeamRelease { try { Write-Debug 'Add-VSTeamRelease Call the REST API' $resp = _callAPI -SubDomain 'vsrm' -ProjectName $ProjectName -Area 'release' -Resource 'releases' ` - -Method Post -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Release) + -Method Post -ContentType 'application/json;charset=utf-8' -Body $body -Version $([VSTeamVersions]::Release) _applyTypesToRelease $resp diff --git a/Source/Public/Add-VSTeamReleaseDefinition.ps1 b/Source/Public/Add-VSTeamReleaseDefinition.ps1 index c9cecfb2e..f52b82056 100644 --- a/Source/Public/Add-VSTeamReleaseDefinition.ps1 +++ b/Source/Public/Add-VSTeamReleaseDefinition.ps1 @@ -16,7 +16,7 @@ function Add-VSTeamReleaseDefinition { $ProjectName = $PSBoundParameters["ProjectName"] $resp = _callAPI -Method Post -subDomain vsrm -Area release -Resource definitions -ProjectName $ProjectName ` - -Version $([VSTeamVersions]::Release) -inFile $inFile -ContentType 'application/json' + -Version $([VSTeamVersions]::Release) -inFile $inFile -ContentType 'application/json;charset=utf-8' Write-Output $resp } diff --git a/Source/Public/Add-VSTeamServiceEndpoint.ps1 b/Source/Public/Add-VSTeamServiceEndpoint.ps1 index 3c8b78fd5..d6f1b78b2 100644 --- a/Source/Public/Add-VSTeamServiceEndpoint.ps1 +++ b/Source/Public/Add-VSTeamServiceEndpoint.ps1 @@ -26,7 +26,7 @@ function Add-VSTeamServiceEndpoint { # Call the REST API $resp = _callAPI -ProjectName $projectName -Area 'distributedtask' -Resource 'serviceendpoints' ` - -Method Post -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::DistributedTask) + -Method Post -ContentType 'application/json;charset=utf-8' -body $body -Version $([VSTeamVersions]::DistributedTask) _trackServiceEndpointProgress -projectName $projectName -resp $resp -title 'Creating Service Endpoint' -msg "Creating $endpointName" diff --git a/Source/Public/Add-VSTeamTaskGroup.ps1 b/Source/Public/Add-VSTeamTaskGroup.ps1 index 5fbc0d475..5aa99b646 100644 --- a/Source/Public/Add-VSTeamTaskGroup.ps1 +++ b/Source/Public/Add-VSTeamTaskGroup.ps1 @@ -17,10 +17,10 @@ function Add-VSTeamTaskGroup { $ProjectName = $PSBoundParameters["ProjectName"] if ($InFile) { - $resp = _callAPI -Method Post -ProjectName $ProjectName -Area distributedtask -Resource taskgroups -Version $([VSTeamVersions]::TaskGroups) -InFile $InFile -ContentType 'application/json' + $resp = _callAPI -Method Post -ProjectName $ProjectName -Area distributedtask -Resource taskgroups -Version $([VSTeamVersions]::TaskGroups) -InFile $InFile -ContentType 'application/json;charset=utf-8' } else { - $resp = _callAPI -Method Post -ProjectName $ProjectName -Area distributedtask -Resource taskgroups -Version $([VSTeamVersions]::TaskGroups) -ContentType 'application/json' -Body $Body + $resp = _callAPI -Method Post -ProjectName $ProjectName -Area distributedtask -Resource taskgroups -Version $([VSTeamVersions]::TaskGroups) -ContentType 'application/json;charset=utf-8' -Body $Body } return $resp diff --git a/Source/Public/Add-VSTeamVariableGroup.ps1 b/Source/Public/Add-VSTeamVariableGroup.ps1 index cc0c76e75..28257e1d2 100644 --- a/Source/Public/Add-VSTeamVariableGroup.ps1 +++ b/Source/Public/Add-VSTeamVariableGroup.ps1 @@ -55,7 +55,7 @@ function Add-VSTeamVariableGroup { # Call the REST API $resp = _callAPI -ProjectName $projectName -Area 'distributedtask' -Resource 'variablegroups' ` - -Method Post -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::VariableGroups) + -Method Post -ContentType 'application/json;charset=utf-8' -body $body -Version $([VSTeamVersions]::VariableGroups) return Get-VSTeamVariableGroup -ProjectName $ProjectName -id $resp.id } diff --git a/Source/Public/Add-VSTeamWorkItem.ps1 b/Source/Public/Add-VSTeamWorkItem.ps1 index 459fd93e8..1de35b928 100644 --- a/Source/Public/Add-VSTeamWorkItem.ps1 +++ b/Source/Public/Add-VSTeamWorkItem.ps1 @@ -116,7 +116,7 @@ function Add-VSTeamWorkItem { # Call the REST API $resp = _callAPI -ProjectName $ProjectName -Area 'wit' -Resource 'workitems' ` -Version $([VSTeamVersions]::Core) -id $WorkItemType -Method Post ` - -ContentType 'application/json-patch+json' -Body $json + -ContentType 'application/json-patch+json;charset=utf-8' -Body $json _applyTypesToWorkItem -item $resp diff --git a/Source/Public/Set-VSTeamApproval.ps1 b/Source/Public/Set-VSTeamApproval.ps1 index 44084e846..c1b40b0bb 100644 --- a/Source/Public/Set-VSTeamApproval.ps1 +++ b/Source/Public/Set-VSTeamApproval.ps1 @@ -36,7 +36,7 @@ function Set-VSTeamApproval { try { # Call the REST API _callAPI -Method Patch -SubDomain vsrm -ProjectName $ProjectName -Area release -Resource approvals ` - -Id $item -Version $([VSTeamVersions]::Release) -body $body -ContentType 'application/json' | Out-Null + -Id $item -Version $([VSTeamVersions]::Release) -body $body -ContentType 'application/json;charset=utf-8' | Out-Null Write-Output "Approval $item status changed to $status" } diff --git a/Source/Public/Set-VSTeamEnvironmentStatus.ps1 b/Source/Public/Set-VSTeamEnvironmentStatus.ps1 index 1efd4c20e..5986d2cdc 100644 --- a/Source/Public/Set-VSTeamEnvironmentStatus.ps1 +++ b/Source/Public/Set-VSTeamEnvironmentStatus.ps1 @@ -40,7 +40,7 @@ function Set-VSTeamEnvironmentStatus { try { # Call the REST API _callAPI -Method Patch -SubDomain vsrm -Area release -Resource "releases/$ReleaseId/environments" -projectName $ProjectName -id $item ` - -body $body -ContentType 'application/json' -Version $([VSTeamVersions]::Release) | Out-Null + -body $body -ContentType 'application/json;charset=utf-8' -Version $([VSTeamVersions]::Release) | Out-Null Write-Output "Environment $item status changed to $status" } diff --git a/Source/Public/Set-VSTeamReleaseStatus.ps1 b/Source/Public/Set-VSTeamReleaseStatus.ps1 index c4f864f70..8bca40fa2 100644 --- a/Source/Public/Set-VSTeamReleaseStatus.ps1 +++ b/Source/Public/Set-VSTeamReleaseStatus.ps1 @@ -30,7 +30,7 @@ function Set-VSTeamReleaseStatus { try { # Call the REST API _callAPI -Method Patch -SubDomain vsrm -Area release -Resource releases -projectName $ProjectName -id $item ` - -body $body -ContentType 'application/json' -Version $([VSTeamVersions]::Release) | Out-Null + -body $body -ContentType 'application/json;charset=utf-8' -Version $([VSTeamVersions]::Release) | Out-Null Write-Output "Release $item status changed to $status" } diff --git a/Source/Public/Update-VSTeam.ps1 b/Source/Public/Update-VSTeam.ps1 index 3772005bb..29360591e 100644 --- a/Source/Public/Update-VSTeam.ps1 +++ b/Source/Public/Update-VSTeam.ps1 @@ -33,7 +33,7 @@ function Update-VSTeam { # Call the REST API $resp = _callAPI -Area 'projects' -Resource "$ProjectName/teams" -Id $Name ` - -Method Patch -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Core) + -Method Patch -ContentType 'application/json;charset=utf-8' -Body $body -Version $([VSTeamVersions]::Core) # Storing the object before you return it cleaned up the pipeline. # When I just write the object from the constructor each property diff --git a/Source/Public/Update-VSTeamBuild.ps1 b/Source/Public/Update-VSTeamBuild.ps1 index 065b623cb..743e96045 100644 --- a/Source/Public/Update-VSTeamBuild.ps1 +++ b/Source/Public/Update-VSTeamBuild.ps1 @@ -43,7 +43,7 @@ function Update-VSTeamBuild { # Call the REST API _callAPI -ProjectName $ProjectName -Area 'build' -Resource 'builds' -Id $Id ` - -Method Patch -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::Build) | Out-Null + -Method Patch -ContentType 'application/json;charset=utf-8' -body $body -Version $([VSTeamVersions]::Build) | Out-Null } } } \ No newline at end of file diff --git a/Source/Public/Update-VSTeamBuildDefinition.ps1 b/Source/Public/Update-VSTeamBuildDefinition.ps1 index bb3dfba4c..12bcb6887 100644 --- a/Source/Public/Update-VSTeamBuildDefinition.ps1 +++ b/Source/Public/Update-VSTeamBuildDefinition.ps1 @@ -26,10 +26,10 @@ function Update-VSTeamBuildDefinition { # Call the REST API if ($InFile) { - _callAPI -Method Put -ProjectName $ProjectName -Area build -Resource definitions -Id $Id -Version $([VSTeamVersions]::Build) -InFile $InFile -ContentType 'application/json' | Out-Null + _callAPI -Method Put -ProjectName $ProjectName -Area build -Resource definitions -Id $Id -Version $([VSTeamVersions]::Build) -InFile $InFile -ContentType 'application/json;charset=utf-8' | Out-Null } else { - _callAPI -Method Put -ProjectName $ProjectName -Area build -Resource definitions -Id $Id -Version $([VSTeamVersions]::Build) -Body $BuildDefinition -ContentType 'application/json' | Out-Null + _callAPI -Method Put -ProjectName $ProjectName -Area build -Resource definitions -Id $Id -Version $([VSTeamVersions]::Build) -Body $BuildDefinition -ContentType 'application/json;charset=utf-8' | Out-Null } } } diff --git a/Source/Public/Update-VSTeamPolicy.ps1 b/Source/Public/Update-VSTeamPolicy.ps1 index 7f4fc8d60..57f4d2eb5 100644 --- a/Source/Public/Update-VSTeamPolicy.ps1 +++ b/Source/Public/Update-VSTeamPolicy.ps1 @@ -42,7 +42,7 @@ function Update-VSTeamPolicy { if ($Force -or $pscmdlet.ShouldProcess($id, "Update Policy")) { # Call the REST API $resp = _callAPI -ProjectName $ProjectName -Area 'policy' -id $id -Resource 'configurations' ` - -Method Put -ContentType 'application/json' -Body $body -Version $([VSTeamVersions]::Git) + -Method Put -ContentType 'application/json;charset=utf-8' -Body $body -Version $([VSTeamVersions]::Git) Write-Output $resp } diff --git a/Source/Public/Update-VSTeamProject.ps1 b/Source/Public/Update-VSTeamProject.ps1 index 1fd4c7e18..dae94219e 100644 --- a/Source/Public/Update-VSTeamProject.ps1 +++ b/Source/Public/Update-VSTeamProject.ps1 @@ -52,7 +52,7 @@ function Update-VSTeamProject { # Call the REST API $resp = _callAPI -Area 'projects' -id $id ` - -Method Patch -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::Core) + -Method Patch -ContentType 'application/json;charset=utf-8' -body $body -Version $([VSTeamVersions]::Core) _trackProjectProgress -resp $resp -title 'Updating team project' -msg $msg diff --git a/Source/Public/Update-VSTeamRelease.ps1 b/Source/Public/Update-VSTeamRelease.ps1 index e72685e15..f26517b2c 100644 --- a/Source/Public/Update-VSTeamRelease.ps1 +++ b/Source/Public/Update-VSTeamRelease.ps1 @@ -23,7 +23,7 @@ function Update-VSTeamRelease { if ($Force -or $pscmdlet.ShouldProcess($Id, "Update Release")) { # Call the REST API $resp = _callAPI -ProjectName $projectName -SubDomain vsrm -Area release -Resource releases -Id $id ` - -Method Put -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::Release) + -Method Put -ContentType 'application/json;charset=utf-8' -body $body -Version $([VSTeamVersions]::Release) Write-Output $resp } diff --git a/Source/Public/Update-VSTeamReleaseDefinition.ps1 b/Source/Public/Update-VSTeamReleaseDefinition.ps1 index 19ae7fc3a..4dd5d2694 100644 --- a/Source/Public/Update-VSTeamReleaseDefinition.ps1 +++ b/Source/Public/Update-VSTeamReleaseDefinition.ps1 @@ -23,10 +23,10 @@ function Update-VSTeamReleaseDefinition { # Call the REST API if ($InFile) { - _callAPI -Method Put -ProjectName $ProjectName -SubDomain vsrm -Area Release -Resource definitions -Version $([VSTeamVersions]::Release) -InFile $InFile -ContentType 'application/json' | Out-Null + _callAPI -Method Put -ProjectName $ProjectName -SubDomain vsrm -Area Release -Resource definitions -Version $([VSTeamVersions]::Release) -InFile $InFile -ContentType 'application/json;charset=utf-8' | Out-Null } else { - _callAPI -Method Put -ProjectName $ProjectName -SubDomain vsrm -Area Release -Resource definitions -Version $([VSTeamVersions]::Release) -Body $ReleaseDefinition -ContentType 'application/json' | Out-Null + _callAPI -Method Put -ProjectName $ProjectName -SubDomain vsrm -Area Release -Resource definitions -Version $([VSTeamVersions]::Release) -Body $ReleaseDefinition -ContentType 'application/json;charset=utf-8' | Out-Null } } } diff --git a/Source/Public/Update-VSTeamServiceEndpoint.ps1 b/Source/Public/Update-VSTeamServiceEndpoint.ps1 index ef93be04b..1dc8b9d21 100644 --- a/Source/Public/Update-VSTeamServiceEndpoint.ps1 +++ b/Source/Public/Update-VSTeamServiceEndpoint.ps1 @@ -23,7 +23,7 @@ function Update-VSTeamServiceEndpoint { if ($Force -or $pscmdlet.ShouldProcess($id, "Update Service Endpoint")) { # Call the REST API $resp = _callAPI -ProjectName $projectName -Area 'distributedtask' -Resource 'serviceendpoints' -Id $id ` - -Method Put -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::DistributedTask) + -Method Put -ContentType 'application/json;charset=utf-8' -body $body -Version $([VSTeamVersions]::DistributedTask) _trackServiceEndpointProgress -projectName $projectName -resp $resp -title 'Updating Service Endpoint' -msg "Updating $id" diff --git a/Source/Public/Update-VSTeamTaskGroup.ps1 b/Source/Public/Update-VSTeamTaskGroup.ps1 index 236105f90..53f209da6 100644 --- a/Source/Public/Update-VSTeamTaskGroup.ps1 +++ b/Source/Public/Update-VSTeamTaskGroup.ps1 @@ -23,10 +23,10 @@ function Update-VSTeamTaskGroup { if ($Force -or $pscmdlet.ShouldProcess("Update Task Group")) { if ($InFile) { - $resp = _callAPI -Method Put -ProjectName $ProjectName -Area distributedtask -Resource taskgroups -Version $([VSTeamVersions]::TaskGroups) -InFile $InFile -ContentType 'application/json' -Id $Id + $resp = _callAPI -Method Put -ProjectName $ProjectName -Area distributedtask -Resource taskgroups -Version $([VSTeamVersions]::TaskGroups) -InFile $InFile -ContentType 'application/json;charset=utf-8' -Id $Id } else { - $resp = _callAPI -Method Put -ProjectName $ProjectName -Area distributedtask -Resource taskgroups -Version $([VSTeamVersions]::TaskGroups) -Body $Body -ContentType 'application/json' -Id $Id + $resp = _callAPI -Method Put -ProjectName $ProjectName -Area distributedtask -Resource taskgroups -Version $([VSTeamVersions]::TaskGroups) -Body $Body -ContentType 'application/json;charset=utf-8' -Id $Id } } diff --git a/Source/Public/Update-VSTeamUserEntitlement.ps1 b/Source/Public/Update-VSTeamUserEntitlement.ps1 index 09521eac2..8bca27d77 100644 --- a/Source/Public/Update-VSTeamUserEntitlement.ps1 +++ b/Source/Public/Update-VSTeamUserEntitlement.ps1 @@ -55,7 +55,7 @@ function Update-VSTeamUserEntitlement if ($Force -or $PSCmdlet.ShouldProcess("$( $user.userName ) ($( $user.email ))", "Update user")) { # Call the REST API - _callAPI -Method Patch -Body $body -SubDomain 'vsaex' -Resource 'userentitlements' -Id $id -Version $([VSTeamVersions]::MemberEntitlementManagement) -ContentType 'application/json-patch+json' | Out-Null + _callAPI -Method Patch -Body $body -SubDomain 'vsaex' -Resource 'userentitlements' -Id $id -Version $([VSTeamVersions]::MemberEntitlementManagement) -ContentType 'application/json-patch+json;charset=utf-8' | Out-Null Write-Output "Updated user license for $( $user.userName ) ($( $user.email )) from ($licenseOld) to ($License)" } diff --git a/Source/Public/Update-VSTeamVariableGroup.ps1 b/Source/Public/Update-VSTeamVariableGroup.ps1 index 85d7d9561..11b1917c0 100644 --- a/Source/Public/Update-VSTeamVariableGroup.ps1 +++ b/Source/Public/Update-VSTeamVariableGroup.ps1 @@ -63,7 +63,7 @@ function Update-VSTeamVariableGroup { if ($Force -or $pscmdlet.ShouldProcess($Id, "Update Variable Group")) { # Call the REST API $resp = _callAPI -ProjectName $projectName -Area 'distributedtask' -Resource 'variablegroups' -Id $Id ` - -Method Put -ContentType 'application/json' -body $body -Version $([VSTeamVersions]::VariableGroups) + -Method Put -ContentType 'application/json;charset=utf-8' -body $body -Version $([VSTeamVersions]::VariableGroups) Write-Verbose $resp diff --git a/Source/Public/Update-VSTeamWorkItem.ps1 b/Source/Public/Update-VSTeamWorkItem.ps1 index bab1366f1..ca0c62edb 100644 --- a/Source/Public/Update-VSTeamWorkItem.ps1 +++ b/Source/Public/Update-VSTeamWorkItem.ps1 @@ -79,7 +79,7 @@ function Update-VSTeamWorkItem { if ($Force -or $pscmdlet.ShouldProcess($Id, "Update-WorkItem")) { $resp = _callAPI -Area 'wit' -Resource 'workitems' ` -Version $([VSTeamVersions]::Core) -id $Id -Method Patch ` - -ContentType 'application/json-patch+json' -Body $json + -ContentType 'application/json-patch+json;charset=utf-8' -Body $json _applyTypesToWorkItem -item $resp diff --git a/Source/VSTeam.psd1 b/Source/VSTeam.psd1 index 539e9e0d6..e490197d9 100644 --- a/Source/VSTeam.psd1 +++ b/Source/VSTeam.psd1 @@ -12,7 +12,7 @@ RootModule = 'VSTeam.psm1' # Version number of this module. - ModuleVersion = '6.4.4' + ModuleVersion = '6.4.5' # Supported PSEditions # CompatiblePSEditions = @() From f846e6c003a5ba3dea49652d2c480705a4de751a Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Thu, 20 Feb 2020 16:11:12 +0100 Subject: [PATCH 2/3] Fix unit tests --- unit/test/workitem.Tests.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/unit/test/workitem.Tests.ps1 b/unit/test/workitem.Tests.ps1 index 5e7113691..0d72aecb8 100644 --- a/unit/test/workitem.Tests.ps1 +++ b/unit/test/workitem.Tests.ps1 @@ -38,7 +38,7 @@ InModuleScope VSTeam { $Method -eq 'Post' -and $Body -like '`[*' -and # Make sure the body is an array $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$([VSTeamVersions]::Core)" } } @@ -55,7 +55,7 @@ InModuleScope VSTeam { $Body -like '*/fields/System.Title*' -and $Body -like '*/fields/System.Description*' -and $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$([VSTeamVersions]::Core)" } } @@ -75,7 +75,7 @@ InModuleScope VSTeam { $Body -like '*_apis/wit/workitems/25*' -and $Body -like '*System.LinkTypes.Hierarchy-Reverse*' -and $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$([VSTeamVersions]::Core)" } } @@ -98,7 +98,7 @@ InModuleScope VSTeam { $Body -like '*/fields/System.Tags*' -and $Body -like '*/fields/System.AreaPath*' -and $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$([VSTeamVersions]::Core)" } } @@ -117,7 +117,7 @@ InModuleScope VSTeam { $Body -like '*/fields/System.Tags*' -and $Body -like '*/fields/System.AreaPath*' -and $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/test/_apis/wit/workitems/`$Task?api-version=$([VSTeamVersions]::Core)" } } @@ -163,7 +163,7 @@ InModuleScope VSTeam { $Body -like '*/fields/System.Title*' -and $Body -like '*/fields/System.Description*' -and $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$([VSTeamVersions]::Core)" } } @@ -184,7 +184,7 @@ InModuleScope VSTeam { $Body -like '*/fields/System.Tags*' -and $Body -like '*/fields/System.AreaPath*' -and $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$([VSTeamVersions]::Core)" } } @@ -203,7 +203,7 @@ InModuleScope VSTeam { $Body -like '*/fields/System.Tags*' -and $Body -like '*/fields/System.AreaPath*' -and $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$([VSTeamVersions]::Core)" } } @@ -220,7 +220,7 @@ InModuleScope VSTeam { $Body -like '*/fields/System.Tags*' -and $Body -like '*/fields/System.AreaPath*' -and $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$([VSTeamVersions]::Core)" } } From e39777fb3ad58b1c0e113d4fdf287d2c7ec88db5 Mon Sep 17 00:00:00 2001 From: Michel Zehnder Date: Thu, 20 Feb 2020 16:24:15 +0100 Subject: [PATCH 3/3] Catch more instances to replace --- .../Public/Add-VSTeamAccessControlEntry.ps1 | 2 +- Source/Public/Add-VSTeamExtension.ps1 | 2 +- Source/Public/Add-VSTeamUserEntitlement.ps1 | 2 +- Source/Public/Disable-VSTeamAgent.ps1 | 2 +- Source/Public/Enable-VSTeamAgent.ps1 | 2 +- .../Get-VSTeamPermissionInheritance.ps1 | 2 +- Source/Public/Get-VSTeamWiql.ps1 | 2 +- .../Set-VSTeamPermissionInheritance.ps1 | 2 +- Source/Public/Update-VSTeamExtension.ps1 | 2 +- unit/test/accessControlEntry.Tests.ps1 | 6 ++--- unit/test/feeds.Tests.ps1 | 4 ++-- unit/test/gitRepositoryPermissions.Tests.ps1 | 18 +++++++------- unit/test/projectPermissions.Tests.ps1 | 6 ++--- unit/test/serviceendpoints.Tests.ps1 | 6 ++--- unit/test/wiql.Tests.ps1 | 10 ++++---- unit/test/workItemPermissions.Tests.ps1 | 24 +++++++++---------- unit/test/workitem.Tests.ps1 | 2 +- 17 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Source/Public/Add-VSTeamAccessControlEntry.ps1 b/Source/Public/Add-VSTeamAccessControlEntry.ps1 index 5a7ad37f6..9da21e005 100644 --- a/Source/Public/Add-VSTeamAccessControlEntry.ps1 +++ b/Source/Public/Add-VSTeamAccessControlEntry.ps1 @@ -58,7 +58,7 @@ $body = # Call the REST API $resp = _callAPI -Area 'accesscontrolentries' -id $SecurityNamespaceId -method POST -body $body ` -Version $([VSTeamVersions]::Core) ` - -ContentType "application/json" + -ContentType "application/json;charset=utf-8" if ($resp.count -ne 1) { diff --git a/Source/Public/Add-VSTeamExtension.ps1 b/Source/Public/Add-VSTeamExtension.ps1 index eb30b1025..5dd0eb596 100644 --- a/Source/Public/Add-VSTeamExtension.ps1 +++ b/Source/Public/Add-VSTeamExtension.ps1 @@ -16,7 +16,7 @@ function Add-VSTeamExtension { $resource += '/' + $Version } - $resp = _callAPI -Method Post -SubDomain 'extmgmt' -Resource $resource -Version $([VSTeamVersions]::ExtensionsManagement) -ContentType "application/json" + $resp = _callAPI -Method Post -SubDomain 'extmgmt' -Resource $resource -Version $([VSTeamVersions]::ExtensionsManagement) -ContentType "application/json;charset=utf-8" $item = [VSTeamExtension]::new($resp) diff --git a/Source/Public/Add-VSTeamUserEntitlement.ps1 b/Source/Public/Add-VSTeamUserEntitlement.ps1 index 648b0ed8b..0d644fd6e 100644 --- a/Source/Public/Add-VSTeamUserEntitlement.ps1 +++ b/Source/Public/Add-VSTeamUserEntitlement.ps1 @@ -42,6 +42,6 @@ function Add-VSTeamUserEntitlement { $body = $obj | ConvertTo-Json # Call the REST API - _callAPI -Method Post -Body $body -SubDomain 'vsaex' -Resource 'userentitlements' -Version $([VSTeamVersions]::MemberEntitlementManagement) -ContentType "application/json" + _callAPI -Method Post -Body $body -SubDomain 'vsaex' -Resource 'userentitlements' -Version $([VSTeamVersions]::MemberEntitlementManagement) -ContentType "application/json;charset=utf-8" } } \ No newline at end of file diff --git a/Source/Public/Disable-VSTeamAgent.ps1 b/Source/Public/Disable-VSTeamAgent.ps1 index b2e6f6c92..6a1cccddc 100644 --- a/Source/Public/Disable-VSTeamAgent.ps1 +++ b/Source/Public/Disable-VSTeamAgent.ps1 @@ -11,7 +11,7 @@ function Disable-VSTeamAgent { process { foreach ($item in $Id) { try { - _callAPI -Method Patch -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $([VSTeamVersions]::DistributedTask) -ContentType "application/json" -Body "{'enabled':false,'id':$item,'maxParallelism':1}" | Out-Null + _callAPI -Method Patch -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $([VSTeamVersions]::DistributedTask) -ContentType "application/json;charset=utf-8" -Body "{'enabled':false,'id':$item,'maxParallelism':1}" | Out-Null Write-Output "Disabled agent $item" } catch { diff --git a/Source/Public/Enable-VSTeamAgent.ps1 b/Source/Public/Enable-VSTeamAgent.ps1 index f162140bf..ed635eb72 100644 --- a/Source/Public/Enable-VSTeamAgent.ps1 +++ b/Source/Public/Enable-VSTeamAgent.ps1 @@ -11,7 +11,7 @@ function Enable-VSTeamAgent { process { foreach ($item in $Id) { try { - _callAPI -Method Patch -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $([VSTeamVersions]::DistributedTask) -ContentType "application/json" -Body "{'enabled':true,'id':$item,'maxParallelism':1}" | Out-Null + _callAPI -Method Patch -Area "distributedtask/pools/$PoolId" -Resource agents -Id $item -Version $([VSTeamVersions]::DistributedTask) -ContentType "application/json;charset=utf-8" -Body "{'enabled':true,'id':$item,'maxParallelism':1}" | Out-Null Write-Output "Enabled agent $item" } catch { diff --git a/Source/Public/Get-VSTeamPermissionInheritance.ps1 b/Source/Public/Get-VSTeamPermissionInheritance.ps1 index e9c345c12..212ac2a13 100644 --- a/Source/Public/Get-VSTeamPermissionInheritance.ps1 +++ b/Source/Public/Get-VSTeamPermissionInheritance.ps1 @@ -47,7 +47,7 @@ } "@ - $resp = _callAPI -method POST -area "Contribution" -resource "HierarchyQuery/project" -id $projectID -Version $version -ContentType "application/json" -Body $body + $resp = _callAPI -method POST -area "Contribution" -resource "HierarchyQuery/project" -id $projectID -Version $version -ContentType "application/json;charset=utf-8" -Body $body Write-Verbose $($resp | ConvertTo-Json -Depth 99) diff --git a/Source/Public/Get-VSTeamWiql.ps1 b/Source/Public/Get-VSTeamWiql.ps1 index 3603a018d..3e362ef51 100644 --- a/Source/Public/Get-VSTeamWiql.ps1 +++ b/Source/Public/Get-VSTeamWiql.ps1 @@ -39,7 +39,7 @@ function Get-VSTeamWiql { }) | ConvertTo-Json $resp = _callAPI -ProjectName $ProjectName -Team $Team -Area 'wit' -Resource 'wiql' ` - -method "POST" -ContentType "application/json" ` + -method "POST" -ContentType "application/json;charset=utf-8" ` -Version $([VSTeamVersions]::Core) ` -Querystring $QueryString ` -Body $body diff --git a/Source/Public/Set-VSTeamPermissionInheritance.ps1 b/Source/Public/Set-VSTeamPermissionInheritance.ps1 index 77b476265..b068043a7 100644 --- a/Source/Public/Set-VSTeamPermissionInheritance.ps1 +++ b/Source/Public/Set-VSTeamPermissionInheritance.ps1 @@ -53,7 +53,7 @@ } "@ # Call the REST API to change the inheritance state - $resp = _callAPI -method POST -area "Contribution" -resource "HierarchyQuery" -id $projectID -Version $version -ContentType "application/json" -Body $body + $resp = _callAPI -method POST -area "Contribution" -resource "HierarchyQuery" -id $projectID -Version $version -ContentType "application/json;charset=utf-8" -Body $body } Write-Verbose "Result: $(ConvertTo-Json -InputObject $resp -Depth 100)" diff --git a/Source/Public/Update-VSTeamExtension.ps1 b/Source/Public/Update-VSTeamExtension.ps1 index 8bbd89456..d79b8124f 100644 --- a/Source/Public/Update-VSTeamExtension.ps1 +++ b/Source/Public/Update-VSTeamExtension.ps1 @@ -25,7 +25,7 @@ function Update-VSTeamExtension { $body = $obj | ConvertTo-Json - $resp = _callAPI -Method Patch -body $body -SubDomain 'extmgmt' -Resource 'extensionmanagement/installedextensions' -Version $([VSTeamVersions]::ExtensionsManagement) -ContentType "application/json" + $resp = _callAPI -Method Patch -body $body -SubDomain 'extmgmt' -Resource 'extensionmanagement/installedextensions' -Version $([VSTeamVersions]::ExtensionsManagement) -ContentType "application/json;charset=utf-8" $item = [VSTeamExtension]::new($resp) diff --git a/unit/test/accessControlEntry.Tests.ps1 b/unit/test/accessControlEntry.Tests.ps1 index 301239e3c..8e997825c 100644 --- a/unit/test/accessControlEntry.Tests.ps1 +++ b/unit/test/accessControlEntry.Tests.ps1 @@ -102,7 +102,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"abc`",*" -and $Body -like "*`"allow`": 12,*" -and $Body -like "*`"deny`": 15,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -123,7 +123,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"abc`",*" -and $Body -like "*`"allow`": 12,*" -and $Body -like "*`"deny`": 15,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -144,7 +144,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"abc`",*" -and $Body -like "*`"allow`": 12,*" -and $Body -like "*`"deny`": 15,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } diff --git a/unit/test/feeds.Tests.ps1 b/unit/test/feeds.Tests.ps1 index cdf12abf9..a1fe4fcd5 100644 --- a/unit/test/feeds.Tests.ps1 +++ b/unit/test/feeds.Tests.ps1 @@ -64,7 +64,7 @@ InModuleScope VSTeam { Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter { $Uri -eq "https://feeds.dev.azure.com/test/_apis/packaging/feeds?api-version=$([VSTeamVersions]::packaging)" -and $Method -eq 'Post' -and - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Body -like '*"name": *"module"*' } } @@ -83,7 +83,7 @@ InModuleScope VSTeam { Assert-MockCalled Invoke-RestMethod -Exactly -Scope It -Times 1 -ParameterFilter { $Uri -eq "https://feeds.dev.azure.com/test/_apis/packaging/feeds?api-version=$([VSTeamVersions]::packaging)" -and $Method -eq 'Post' -and - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Body -like '*"upstreamEnabled":*true*' -and $Body -like '*"hideDeletedPackageVersions":*false*' } diff --git a/unit/test/gitRepositoryPermissions.Tests.ps1 b/unit/test/gitRepositoryPermissions.Tests.ps1 index 4fed0c7f0..cb7801030 100644 --- a/unit/test/gitRepositoryPermissions.Tests.ps1 +++ b/unit/test/gitRepositoryPermissions.Tests.ps1 @@ -64,7 +64,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.IdentityModel.Claims.ClaimsIdentity;788df857-dcd8-444d-885e-bff359bc1982\\test@testuser.com`",*" -and $Body -like "*`"allow`": 34048,*" -and $Body -like "*`"deny`": 2056,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -83,7 +83,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 34048,*" -and $Body -like "*`"deny`": 2056,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -102,7 +102,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 34048,*" -and $Body -like "*`"deny`": 2056,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -121,7 +121,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.IdentityModel.Claims.ClaimsIdentity;788df857-dcd8-444d-885e-bff359bc1982\\test@testuser.com`",*" -and $Body -like "*`"allow`": 34048,*" -and $Body -like "*`"deny`": 2056,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -140,7 +140,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 34048,*" -and $Body -like "*`"deny`": 2056,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -159,7 +159,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 34048,*" -and $Body -like "*`"deny`": 2056,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -178,7 +178,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.IdentityModel.Claims.ClaimsIdentity;788df857-dcd8-444d-885e-bff359bc1982\\test@testuser.com`",*" -and $Body -like "*`"allow`": 34048,*" -and $Body -like "*`"deny`": 2056,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -197,7 +197,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 34048,*" -and $Body -like "*`"deny`": 2056,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -216,7 +216,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 34048,*" -and $Body -like "*`"deny`": 2056,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } diff --git a/unit/test/projectPermissions.Tests.ps1 b/unit/test/projectPermissions.Tests.ps1 index 54ea75777..78ffdbd13 100644 --- a/unit/test/projectPermissions.Tests.ps1 +++ b/unit/test/projectPermissions.Tests.ps1 @@ -64,7 +64,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.IdentityModel.Claims.ClaimsIdentity;788df857-dcd8-444d-885e-bff359bc1982\\test@testuser.com`",*" -and $Body -like "*`"allow`": 73731,*" -and $Body -like "*`"deny`": 8389120,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -83,7 +83,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 73731,*" -and $Body -like "*`"deny`": 8389120,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -102,7 +102,7 @@ InModuleScope VSTeam { $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 73731,*" -and $Body -like "*`"deny`": 8389120,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } diff --git a/unit/test/serviceendpoints.Tests.ps1 b/unit/test/serviceendpoints.Tests.ps1 index 46560a6dc..9d850ff58 100644 --- a/unit/test/serviceendpoints.Tests.ps1 +++ b/unit/test/serviceendpoints.Tests.ps1 @@ -472,7 +472,7 @@ InModuleScope VSTeam { Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter { $Uri -eq "https://dev.azure.com/test/project/_apis/distributedtask/serviceendpoints?api-version=$([VSTeamVersions]::DistributedTask)" -and $Method -eq 'Post' -and - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Body -like '*"nugetkey": *"00000000-0000-0000-0000-000000000000"*' -and $Body -like '*"scheme": *"None"*' } @@ -511,7 +511,7 @@ InModuleScope VSTeam { Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter { $Uri -eq "https://dev.azure.com/test/project/_apis/distributedtask/serviceendpoints?api-version=$([VSTeamVersions]::DistributedTask)" -and $Method -eq 'Post' -and - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Body -like '*"username": *"testUser"*' -and $Body -like '*"password": *"00000000-0000-0000-0000-000000000000"*' -and $Body -like '*"scheme": *"UsernamePassword"*' @@ -552,7 +552,7 @@ InModuleScope VSTeam { Assert-MockCalled Invoke-RestMethod -Exactly -Scope Context -Times 1 -ParameterFilter { $Uri -eq "https://dev.azure.com/test/project/_apis/distributedtask/serviceendpoints?api-version=$([VSTeamVersions]::DistributedTask)" -and $Method -eq 'Post' -and - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Body -like '*"apitoken":*"00000000-0000-0000-0000-000000000000"*' -and $Body -like '*"scheme":*"Token"*' } diff --git a/unit/test/wiql.Tests.ps1 b/unit/test/wiql.Tests.ps1 index b19435b19..73428dcc8 100644 --- a/unit/test/wiql.Tests.ps1 +++ b/unit/test/wiql.Tests.ps1 @@ -69,7 +69,7 @@ InModuleScope VSTeam { $Body -like "*[System.Title]*" -and $Body -like "*[System.State]*" -and $Body -like '*`}' -and # Make sure the body is an object - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/test/test team/_apis/wit/wiql?api-version=$([VSTeamVersions]::Core)&`$top=100" } } @@ -86,7 +86,7 @@ InModuleScope VSTeam { $Body -like "*[System.Title]*" -and $Body -like "*[System.State]*" -and $Body -like '*`}' -and # Make sure the body is an object - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/test/test team/_apis/wit/wiql?api-version=$([VSTeamVersions]::Core)&`$top=250" } } @@ -103,7 +103,7 @@ InModuleScope VSTeam { $Body -like "*[System.Title]*" -and $Body -like "*[System.State]*" -and $Body -like '*`}' -and # Make sure the body is an object - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/test/test team/_apis/wit/wiql?api-version=$([VSTeamVersions]::Core)" } } @@ -120,7 +120,7 @@ InModuleScope VSTeam { $Body -like "*[System.Title]*" -and $Body -like "*[System.State]*" -and $Body -like '*`}' -and # Make sure the body is an object - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/test/test team/_apis/wit/wiql?api-version=$([VSTeamVersions]::Core)&`$top=100" } } @@ -137,7 +137,7 @@ InModuleScope VSTeam { $Body -like "*[System.Title]*" -and $Body -like "*[System.State]*" -and $Body -like '*`}' -and # Make sure the body is an object - $ContentType -eq 'application/json' -and + $ContentType -eq 'application/json;charset=utf-8' -and $Uri -like "*timePrecision=True*" $Uri -like "*`$top=100*" $Uri -like "https://dev.azure.com/test/test/test team/_apis/wit/wiql?api-version=$([VSTeamVersions]::Core)*" diff --git a/unit/test/workItemPermissions.Tests.ps1 b/unit/test/workItemPermissions.Tests.ps1 index 6bb649742..7278c097b 100644 --- a/unit/test/workItemPermissions.Tests.ps1 +++ b/unit/test/workItemPermissions.Tests.ps1 @@ -197,7 +197,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.IdentityModel.Claims.ClaimsIdentity;788df857-dcd8-444d-885e-bff359bc1982\\test@testuser.com`",*" -and $Body -like "*`"allow`": 65,*" -and $Body -like "*`"deny`": 10,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -220,7 +220,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 65,*" -and $Body -like "*`"deny`": 10,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -243,7 +243,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 65,*" -and $Body -like "*`"deny`": 10,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -271,7 +271,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.IdentityModel.Claims.ClaimsIdentity;788df857-dcd8-444d-885e-bff359bc1982\\test@testuser.com`",*" -and $Body -like "*`"allow`": 65,*" -and $Body -like "*`"deny`": 10,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -294,7 +294,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 65,*" -and $Body -like "*`"deny`": 10,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -317,7 +317,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 65,*" -and $Body -like "*`"deny`": 10,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -362,7 +362,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.IdentityModel.Claims.ClaimsIdentity;788df857-dcd8-444d-885e-bff359bc1982\\test@testuser.com`",*" -and $Body -like "*`"allow`": 5,*" -and $Body -like "*`"deny`": 8,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -384,7 +384,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 5,*" -and $Body -like "*`"deny`": 8,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -406,7 +406,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 5,*" -and $Body -like "*`"deny`": 8,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -434,7 +434,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.IdentityModel.Claims.ClaimsIdentity;788df857-dcd8-444d-885e-bff359bc1982\\test@testuser.com`",*" -and $Body -like "*`"allow`": 5,*" -and $Body -like "*`"deny`": 8,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -456,7 +456,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 5,*" -and $Body -like "*`"deny`": 8,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } @@ -478,7 +478,7 @@ $classificationNodeById = $Body -like "*`"descriptor`": `"Microsoft.TeamFoundation.Identity;S-1-9-1551374245-856009726-4193442117-2390756110-2740161821-0-0-0-0-1`",*" -and $Body -like "*`"allow`": 5,*" -and $Body -like "*`"deny`": 8,*" -and - $ContentType -eq "application/json" -and + $ContentType -eq "application/json;charset=utf-8" -and $Method -eq "Post" } } diff --git a/unit/test/workitem.Tests.ps1 b/unit/test/workitem.Tests.ps1 index 0d72aecb8..4550ebab0 100644 --- a/unit/test/workitem.Tests.ps1 +++ b/unit/test/workitem.Tests.ps1 @@ -146,7 +146,7 @@ InModuleScope VSTeam { $Method -eq 'Patch' -and $Body -like '`[*' -and # Make sure the body is an array $Body -like '*`]' -and # Make sure the body is an array - $ContentType -eq 'application/json-patch+json' -and + $ContentType -eq 'application/json-patch+json;charset=utf-8' -and $Uri -eq "https://dev.azure.com/test/_apis/wit/workitems/1?api-version=$([VSTeamVersions]::Core)" } }