From 805385b76169dee0f2b2bfde5afec2165442cf9f Mon Sep 17 00:00:00 2001 From: Oliver Lipkau Date: Mon, 9 Mar 2020 08:47:04 +0100 Subject: [PATCH 1/4] Hardcoded api endpoints to version 2 --- JiraPS/Public/Add-JiraGroupMember.ps1 | 2 +- JiraPS/Public/Add-JiraIssueLink.ps1 | 2 +- JiraPS/Public/Find-JiraFilter.ps1 | 2 +- JiraPS/Public/Get-JiraComponent.ps1 | 2 +- JiraPS/Public/Get-JiraField.ps1 | 2 +- JiraPS/Public/Get-JiraFilter.ps1 | 2 +- JiraPS/Public/Get-JiraGroup.ps1 | 2 +- JiraPS/Public/Get-JiraGroupMember.ps1 | 2 +- JiraPS/Public/Get-JiraIssue.ps1 | 4 ++-- JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 | 2 +- JiraPS/Public/Get-JiraIssueEditMetadata.ps1 | 2 +- JiraPS/Public/Get-JiraIssueLinkType.ps1 | 2 +- JiraPS/Public/Get-JiraIssueType.ps1 | 2 +- JiraPS/Public/Get-JiraPriority.ps1 | 2 +- JiraPS/Public/Get-JiraProject.ps1 | 2 +- JiraPS/Public/Get-JiraServerInformation.ps1 | 2 +- JiraPS/Public/Get-JiraUser.ps1 | 6 ++--- JiraPS/Public/Get-JiraVersion.ps1 | 2 +- JiraPS/Public/Move-JiraVersion.ps1 | 2 +- JiraPS/Public/New-JiraFilter.ps1 | 2 +- JiraPS/Public/New-JiraGroup.ps1 | 2 +- JiraPS/Public/New-JiraIssue.ps1 | 4 ++-- JiraPS/Public/New-JiraUser.ps1 | 2 +- JiraPS/Public/New-JiraVersion.ps1 | 2 +- JiraPS/Public/Remove-JiraGroup.ps1 | 2 +- JiraPS/Public/Remove-JiraGroupMember.ps1 | 2 +- JiraPS/Public/Remove-JiraIssue.ps1 | 2 +- JiraPS/Public/Remove-JiraIssueAttachment.ps1 | 2 +- JiraPS/Public/Remove-JiraIssueLink.ps1 | 2 +- JiraPS/Public/Remove-JiraRemoteLink.ps1 | 2 +- JiraPS/Public/Remove-JiraUser.ps1 | 2 +- JiraPS/Public/Set-JiraUser.ps1 | 2 +- .../Add-JiraFilterPermission.Unit.Tests.ps1 | 2 +- .../Add-JiraIssueAttachment.Unit.Tests.ps1 | 4 ++-- .../Add-JiraIssueComment.Unit.Tests.ps1 | 4 ++-- .../Add-JiraIssueLink.Unit.Tests.ps1 | 2 +- .../Add-JiraIssueWatcher.Unit.Tests.ps1 | 4 ++-- .../Add-JiraIssueWorklog.Unit.Tests.ps1 | 6 ++--- .../ConvertTo-JiraFilter.Unit.Tests.ps1 | 8 +++---- .../ConvertTo-JiraIssue.Unit.Tests.ps1 | 6 ++--- ...ConvertTo-JiraIssueLinkType.Unit.Tests.ps1 | 10 ++++---- .../ConvertTo-JiraIssueType.Unit.Tests.ps1 | 4 ++-- .../ConvertTo-JiraProject.Unit.Tests.ps1 | 2 +- .../Get-JiraComponent.Unit.Tests.ps1 | 2 +- Tests/Functions/Get-JiraField.Unit.Tests.ps1 | 2 +- Tests/Functions/Get-JiraFilter.Unit.Tests.ps1 | 10 ++++---- Tests/Functions/Get-JiraGroup.Unit.Tests.ps1 | 2 +- Tests/Functions/Get-JiraIssue.Unit.Tests.ps1 | 2 +- .../Get-JiraIssueAttachment.Unit.Tests.ps1 | 2 +- .../Get-JiraIssueComment.Unit.Tests.ps1 | 4 ++-- ...Get-JiraIssueCreateMetadata.Unit.Tests.ps1 | 6 ++--- .../Get-JiraIssueEditMetadata.Unit.Tests.ps1 | 6 ++--- .../Get-JiraIssueLinkType.Unit.Tests.ps1 | 4 ++-- .../Get-JiraIssueType.Unit.Tests.ps1 | 18 +++++++------- .../Get-JiraIssueWatcher.Unit.Tests.ps1 | 4 ++-- .../Functions/Get-JiraPriority.Unit.Tests.ps1 | 4 ++-- .../Get-JiraRemoteLink.Unit.Tests.ps1 | 4 ++-- .../Get-JiraServerInformation.Unit.Tests.ps1 | 2 +- .../Functions/Get-JiraVersion.Unit.Tests.ps1 | 12 +++++----- .../Invoke-JiraIssueTransition.Unit.Tests.ps1 | 14 +++++------ .../Functions/Move-JiraVersion.Unit.Tests.ps1 | 24 +++++++++---------- Tests/Functions/New-JiraFilter.Unit.Tests.ps1 | 2 +- Tests/Functions/New-JiraGroup.Unit.Tests.ps1 | 2 +- Tests/Functions/New-JiraUser.Unit.Tests.ps1 | 2 +- .../Functions/New-JiraVersion.Unit.Tests.ps1 | 6 ++--- .../Remove-JiraFilter.Unit.Tests.ps1 | 4 ++-- .../Remove-JiraIssueAttachment.Unit.Tests.ps1 | 8 +++---- .../Remove-JiraIssueWatcher.Unit.Tests.ps1 | 4 ++-- .../Remove-JiraVersion.Unit.Tests.ps1 | 22 ++++++++--------- Tests/Functions/Set-JiraFilter.Unit.Tests.ps1 | 4 ++-- Tests/Functions/Set-JiraUser.Unit.Tests.ps1 | 2 +- 71 files changed, 151 insertions(+), 151 deletions(-) diff --git a/JiraPS/Public/Add-JiraGroupMember.ps1 b/JiraPS/Public/Add-JiraGroupMember.ps1 index 1d8e6ff0..2faa2d69 100644 --- a/JiraPS/Public/Add-JiraGroupMember.ps1 +++ b/JiraPS/Public/Add-JiraGroupMember.ps1 @@ -31,7 +31,7 @@ function Add-JiraGroupMember { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/group/user?groupname={0}" + $resourceURi = "$server/rest/api/2/group/user?groupname={0}" } process { diff --git a/JiraPS/Public/Add-JiraIssueLink.ps1 b/JiraPS/Public/Add-JiraIssueLink.ps1 index 1a1dbf9a..28240b09 100644 --- a/JiraPS/Public/Add-JiraIssueLink.ps1 +++ b/JiraPS/Public/Add-JiraIssueLink.ps1 @@ -70,7 +70,7 @@ function Add-JiraIssueLink { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/issueLink" + $resourceURi = "$server/rest/api/2/issueLink" } process { diff --git a/JiraPS/Public/Find-JiraFilter.ps1 b/JiraPS/Public/Find-JiraFilter.ps1 index 775f06dc..6f18ccd1 100644 --- a/JiraPS/Public/Find-JiraFilter.ps1 +++ b/JiraPS/Public/Find-JiraFilter.ps1 @@ -78,7 +78,7 @@ function Find-JiraFilter { $server = Get-JiraConfigServer -ErrorAction Stop - $searchURi = "$server/rest/api/latest/filter/search" + $searchURi = "$server/rest/api/2/filter/search" [String]$Fields = $Fields -join ',' } diff --git a/JiraPS/Public/Get-JiraComponent.ps1 b/JiraPS/Public/Get-JiraComponent.ps1 index 57a9735d..b239bcd7 100644 --- a/JiraPS/Public/Get-JiraComponent.ps1 +++ b/JiraPS/Public/Get-JiraComponent.ps1 @@ -47,7 +47,7 @@ function Get-JiraComponent { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest{0}" + $resourceURi = "$server/rest/api/2{0}" } process { diff --git a/JiraPS/Public/Get-JiraField.ps1 b/JiraPS/Public/Get-JiraField.ps1 index fd55df9f..aee0a8ba 100644 --- a/JiraPS/Public/Get-JiraField.ps1 +++ b/JiraPS/Public/Get-JiraField.ps1 @@ -17,7 +17,7 @@ $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/field" + $resourceURi = "$server/rest/api/2/field" } process { diff --git a/JiraPS/Public/Get-JiraFilter.ps1 b/JiraPS/Public/Get-JiraFilter.ps1 index 412c161c..c5f586b5 100644 --- a/JiraPS/Public/Get-JiraFilter.ps1 +++ b/JiraPS/Public/Get-JiraFilter.ps1 @@ -53,7 +53,7 @@ $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/filter/{0}" + $resourceURi = "$server/rest/api/2/filter/{0}" } process { diff --git a/JiraPS/Public/Get-JiraGroup.ps1 b/JiraPS/Public/Get-JiraGroup.ps1 index dc4e395e..53b55084 100644 --- a/JiraPS/Public/Get-JiraGroup.ps1 +++ b/JiraPS/Public/Get-JiraGroup.ps1 @@ -19,7 +19,7 @@ function Get-JiraGroup { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/group?groupname={0}" + $resourceURi = "$server/rest/api/2/group?groupname={0}" } process { diff --git a/JiraPS/Public/Get-JiraGroupMember.ps1 b/JiraPS/Public/Get-JiraGroupMember.ps1 index 0ffe0579..9bad3418 100644 --- a/JiraPS/Public/Get-JiraGroupMember.ps1 +++ b/JiraPS/Public/Get-JiraGroupMember.ps1 @@ -50,7 +50,7 @@ function Get-JiraGroupMember { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/group/member" + $resourceURi = "$server/rest/api/2/group/member" if ($PageSize -gt 50) { Write-Warning "JIRA's API may not properly support MaxResults values higher than 50 for this method. If you receive inconsistent results, do not pass the MaxResults parameter to this function to return all results." diff --git a/JiraPS/Public/Get-JiraIssue.ps1 b/JiraPS/Public/Get-JiraIssue.ps1 index ae208d0c..1c12f4b4 100644 --- a/JiraPS/Public/Get-JiraIssue.ps1 +++ b/JiraPS/Public/Get-JiraIssue.ps1 @@ -96,8 +96,8 @@ function Get-JiraIssue { $server = Get-JiraConfigServer -ErrorAction Stop - $searchURi = "$server/rest/api/latest/search" - $resourceURi = "$server/rest/api/latest/issue/{0}" + $searchURi = "$server/rest/api/2/search" + $resourceURi = "$server/rest/api/2/issue/{0}" [String]$Fields = $Fields -join "," } diff --git a/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 b/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 index 8e1b05c8..13ef53cc 100644 --- a/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 +++ b/JiraPS/Public/Get-JiraIssueCreateMetadata.ps1 @@ -21,7 +21,7 @@ function Get-JiraIssueCreateMetadata { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/issue/createmeta?projectIds={0}&issuetypeIds={1}&expand=projects.issuetypes.fields" + $resourceURi = "$server/rest/api/2/issue/createmeta?projectIds={0}&issuetypeIds={1}&expand=projects.issuetypes.fields" } process { diff --git a/JiraPS/Public/Get-JiraIssueEditMetadata.ps1 b/JiraPS/Public/Get-JiraIssueEditMetadata.ps1 index a44655c6..e25c90f2 100644 --- a/JiraPS/Public/Get-JiraIssueEditMetadata.ps1 +++ b/JiraPS/Public/Get-JiraIssueEditMetadata.ps1 @@ -21,7 +21,7 @@ function Get-JiraIssueEditMetadata { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/issue/{0}/editmeta" + $resourceURi = "$server/rest/api/2/issue/{0}/editmeta" } process { diff --git a/JiraPS/Public/Get-JiraIssueLinkType.ps1 b/JiraPS/Public/Get-JiraIssueLinkType.ps1 index 0ca0d39a..cd45b123 100644 --- a/JiraPS/Public/Get-JiraIssueLinkType.ps1 +++ b/JiraPS/Public/Get-JiraIssueLinkType.ps1 @@ -38,7 +38,7 @@ function Get-JiraIssueLinkType { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/issueLinkType{0}" + $resourceURi = "$server/rest/api/2/issueLinkType{0}" } process { diff --git a/JiraPS/Public/Get-JiraIssueType.ps1 b/JiraPS/Public/Get-JiraIssueType.ps1 index 41df6832..f5fd9ef5 100644 --- a/JiraPS/Public/Get-JiraIssueType.ps1 +++ b/JiraPS/Public/Get-JiraIssueType.ps1 @@ -17,7 +17,7 @@ $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/issuetype" + $resourceURi = "$server/rest/api/2/issuetype" } process { diff --git a/JiraPS/Public/Get-JiraPriority.ps1 b/JiraPS/Public/Get-JiraPriority.ps1 index 441c1bf4..19f94345 100644 --- a/JiraPS/Public/Get-JiraPriority.ps1 +++ b/JiraPS/Public/Get-JiraPriority.ps1 @@ -17,7 +17,7 @@ function Get-JiraPriority { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/priority{0}" + $resourceURi = "$server/rest/api/2/priority{0}" } process { diff --git a/JiraPS/Public/Get-JiraProject.ps1 b/JiraPS/Public/Get-JiraProject.ps1 index c107663b..702eec45 100644 --- a/JiraPS/Public/Get-JiraProject.ps1 +++ b/JiraPS/Public/Get-JiraProject.ps1 @@ -17,7 +17,7 @@ function Get-JiraProject { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/project{0}?expand=description,lead,issueTypes,url,projectKeys" + $resourceURi = "$server/rest/api/2/project{0}?expand=description,lead,issueTypes,url,projectKeys" } process { diff --git a/JiraPS/Public/Get-JiraServerInformation.ps1 b/JiraPS/Public/Get-JiraServerInformation.ps1 index aee87a3a..273b4d93 100644 --- a/JiraPS/Public/Get-JiraServerInformation.ps1 +++ b/JiraPS/Public/Get-JiraServerInformation.ps1 @@ -13,7 +13,7 @@ function Get-JiraServerInformation { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/serverInfo" + $resourceURi = "$server/rest/api/2/serverInfo" } process { diff --git a/JiraPS/Public/Get-JiraUser.ps1 b/JiraPS/Public/Get-JiraUser.ps1 index bbc0deac..eb27641d 100644 --- a/JiraPS/Public/Get-JiraUser.ps1 +++ b/JiraPS/Public/Get-JiraUser.ps1 @@ -39,9 +39,9 @@ function Get-JiraUser { $server = Get-JiraConfigServer -ErrorAction Stop - $selfResourceUri = "$server/rest/api/latest/myself" - $searchResourceUri = "$server/rest/api/latest/user/search?username={0}" - $exactResourceUri = "$server/rest/api/latest/user?username={0}" + $selfResourceUri = "$server/rest/api/2/myself" + $searchResourceUri = "$server/rest/api/2/user/search?username={0}" + $exactResourceUri = "$server/rest/api/2/user?username={0}" if ($IncludeInactive) { $searchResourceUri += "&includeInactive=true" diff --git a/JiraPS/Public/Get-JiraVersion.ps1 b/JiraPS/Public/Get-JiraVersion.ps1 index b28995f3..3b95dacf 100644 --- a/JiraPS/Public/Get-JiraVersion.ps1 +++ b/JiraPS/Public/Get-JiraVersion.ps1 @@ -49,7 +49,7 @@ $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/{0}" + $resourceURi = "$server/rest/api/2/{0}" } process { diff --git a/JiraPS/Public/Move-JiraVersion.ps1 b/JiraPS/Public/Move-JiraVersion.ps1 index a3932ffb..185acc8a 100644 --- a/JiraPS/Public/Move-JiraVersion.ps1 +++ b/JiraPS/Public/Move-JiraVersion.ps1 @@ -67,7 +67,7 @@ $server = Get-JiraConfigServer -ErrorAction Stop - $versionResourceUri = "$server/rest/api/latest/version/{0}/move" + $versionResourceUri = "$server/rest/api/2/version/{0}/move" } process { diff --git a/JiraPS/Public/New-JiraFilter.ps1 b/JiraPS/Public/New-JiraFilter.ps1 index 6e7d3361..219e360a 100644 --- a/JiraPS/Public/New-JiraFilter.ps1 +++ b/JiraPS/Public/New-JiraFilter.ps1 @@ -32,7 +32,7 @@ function New-JiraFilter { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/filter" + $resourceURi = "$server/rest/api/2/filter" } process { diff --git a/JiraPS/Public/New-JiraGroup.ps1 b/JiraPS/Public/New-JiraGroup.ps1 index 956709b8..9a0a46c9 100644 --- a/JiraPS/Public/New-JiraGroup.ps1 +++ b/JiraPS/Public/New-JiraGroup.ps1 @@ -18,7 +18,7 @@ $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/group" + $resourceURi = "$server/rest/api/2/group" } process { diff --git a/JiraPS/Public/New-JiraIssue.ps1 b/JiraPS/Public/New-JiraIssue.ps1 index ee2beced..9f3eca6a 100644 --- a/JiraPS/Public/New-JiraIssue.ps1 +++ b/JiraPS/Public/New-JiraIssue.ps1 @@ -60,7 +60,7 @@ function New-JiraIssue { $createmeta = Get-JiraIssueCreateMetadata -Project $Project -IssueType $IssueType -Credential $Credential -ErrorAction Stop -Debug:$false - $resourceURi = "$server/rest/api/latest/issue" + $resourceURi = "$server/rest/api/2/issue" Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)" Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)" @@ -177,7 +177,7 @@ function New-JiraIssue { if ($PSCmdlet.ShouldProcess($Summary, "Creating new Issue on JIRA")) { if ($result = Invoke-JiraMethod @parameter) { # REST result will look something like this: - # {"id":"12345","key":"IT-3676","self":"http://jiraserver.example.com/rest/api/latest/issue/12345"} + # {"id":"12345","key":"IT-3676","self":"http://jiraserver.example.com/rest/api/2/issue/12345"} # This will fetch the created issue to return it with all it'a properties Write-Output (Get-JiraIssue -Key $result.Key -Credential $Credential) } diff --git a/JiraPS/Public/New-JiraUser.ps1 b/JiraPS/Public/New-JiraUser.ps1 index cf017bc1..ccd7dae5 100644 --- a/JiraPS/Public/New-JiraUser.ps1 +++ b/JiraPS/Public/New-JiraUser.ps1 @@ -28,7 +28,7 @@ function New-JiraUser { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/user" + $resourceURi = "$server/rest/api/2/user" } process { diff --git a/JiraPS/Public/New-JiraVersion.ps1 b/JiraPS/Public/New-JiraVersion.ps1 index 287c6125..a1edba90 100644 --- a/JiraPS/Public/New-JiraVersion.ps1 +++ b/JiraPS/Public/New-JiraVersion.ps1 @@ -90,7 +90,7 @@ $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/version" + $resourceURi = "$server/rest/api/2/version" } process { diff --git a/JiraPS/Public/Remove-JiraGroup.ps1 b/JiraPS/Public/Remove-JiraGroup.ps1 index 63aa2616..ae04ea30 100644 --- a/JiraPS/Public/Remove-JiraGroup.ps1 +++ b/JiraPS/Public/Remove-JiraGroup.ps1 @@ -42,7 +42,7 @@ $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/group?groupname={0}" + $resourceURi = "$server/rest/api/2/group?groupname={0}" if ($Force) { Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] -Force was passed. Backing up current ConfirmPreference [$ConfirmPreference] and setting to None" diff --git a/JiraPS/Public/Remove-JiraGroupMember.ps1 b/JiraPS/Public/Remove-JiraGroupMember.ps1 index 74b9b804..79a523c0 100644 --- a/JiraPS/Public/Remove-JiraGroupMember.ps1 +++ b/JiraPS/Public/Remove-JiraGroupMember.ps1 @@ -71,7 +71,7 @@ function Remove-JiraGroupMember { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/group/user?groupname={0}&username={1}" + $resourceURi = "$server/rest/api/2/group/user?groupname={0}&username={1}" if ($Force) { Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] -Force was passed. Backing up current ConfirmPreference [$ConfirmPreference] and setting to None" diff --git a/JiraPS/Public/Remove-JiraIssue.ps1 b/JiraPS/Public/Remove-JiraIssue.ps1 index 075823f9..a95ae0ba 100644 --- a/JiraPS/Public/Remove-JiraIssue.ps1 +++ b/JiraPS/Public/Remove-JiraIssue.ps1 @@ -51,7 +51,7 @@ function Remove-JiraIssue { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/issue/{0}?deleteSubtasks={1}" + $resourceURi = "$server/rest/api/2/issue/{0}?deleteSubtasks={1}" if ($Force) { Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] -Force was passed. Backing up current ConfirmPreference [$ConfirmPreference] and setting to None" diff --git a/JiraPS/Public/Remove-JiraIssueAttachment.ps1 b/JiraPS/Public/Remove-JiraIssueAttachment.ps1 index b3a270c1..8893673f 100644 --- a/JiraPS/Public/Remove-JiraIssueAttachment.ps1 +++ b/JiraPS/Public/Remove-JiraIssueAttachment.ps1 @@ -52,7 +52,7 @@ function Remove-JiraIssueAttachment { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/attachment/{0}" + $resourceURi = "$server/rest/api/2/attachment/{0}" if ($Force) { Write-DebugMessage "[Remove-JiraGroupMember] -Force was passed. Backing up current ConfirmPreference [$ConfirmPreference] and setting to None" diff --git a/JiraPS/Public/Remove-JiraIssueLink.ps1 b/JiraPS/Public/Remove-JiraIssueLink.ps1 index 33c9e133..7ba42e24 100644 --- a/JiraPS/Public/Remove-JiraIssueLink.ps1 +++ b/JiraPS/Public/Remove-JiraIssueLink.ps1 @@ -41,7 +41,7 @@ function Remove-JiraIssueLink { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/issueLink/{0}" + $resourceURi = "$server/rest/api/2/issueLink/{0}" } process { diff --git a/JiraPS/Public/Remove-JiraRemoteLink.ps1 b/JiraPS/Public/Remove-JiraRemoteLink.ps1 index 710b14db..72c8b9d7 100644 --- a/JiraPS/Public/Remove-JiraRemoteLink.ps1 +++ b/JiraPS/Public/Remove-JiraRemoteLink.ps1 @@ -46,7 +46,7 @@ function Remove-JiraRemoteLink { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/issue/{0}/remotelink/{1}" + $resourceURi = "$server/rest/api/2/issue/{0}/remotelink/{1}" if ($Force) { Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] -Force was passed. Backing up current ConfirmPreference [$ConfirmPreference] and setting to None" diff --git a/JiraPS/Public/Remove-JiraUser.ps1 b/JiraPS/Public/Remove-JiraUser.ps1 index cedd1bdb..6e9a8223 100644 --- a/JiraPS/Public/Remove-JiraUser.ps1 +++ b/JiraPS/Public/Remove-JiraUser.ps1 @@ -42,7 +42,7 @@ function Remove-JiraUser { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/user?username={0}" + $resourceURi = "$server/rest/api/2/user?username={0}" if ($Force) { Write-DebugMessage "[Remove-JiraGroup] -Force was passed. Backing up current ConfirmPreference [$ConfirmPreference] and setting to None" diff --git a/JiraPS/Public/Set-JiraUser.ps1 b/JiraPS/Public/Set-JiraUser.ps1 index 1907f4cb..a8bf8994 100644 --- a/JiraPS/Public/Set-JiraUser.ps1 +++ b/JiraPS/Public/Set-JiraUser.ps1 @@ -77,7 +77,7 @@ function Set-JiraUser { $server = Get-JiraConfigServer -ErrorAction Stop - $resourceURi = "$server/rest/api/latest/user?username={0}" + $resourceURi = "$server/rest/api/2/user?username={0}" } process { diff --git a/Tests/Functions/Add-JiraFilterPermission.Unit.Tests.ps1 b/Tests/Functions/Add-JiraFilterPermission.Unit.Tests.ps1 index 8e852d5a..dd0ebb7b 100644 --- a/Tests/Functions/Add-JiraFilterPermission.Unit.Tests.ps1 +++ b/Tests/Functions/Add-JiraFilterPermission.Unit.Tests.ps1 @@ -145,7 +145,7 @@ Describe 'Add-JiraFilterPermission' -Tag 'Unit' { foreach ($_id in $Id) { $object = New-Object -TypeName PSCustomObject -Property @{ id = $_id - RestUrl = "$jiraServer/rest/api/latest/filter/$_id" + RestUrl = "$jiraServer/rest/api/2/filter/$_id" } $object.PSObject.TypeNames.Insert(0, 'JiraPS.Filter') $object diff --git a/Tests/Functions/Add-JiraIssueAttachment.Unit.Tests.ps1 b/Tests/Functions/Add-JiraIssueAttachment.Unit.Tests.ps1 index 97656b5d..6b028af6 100644 --- a/Tests/Functions/Add-JiraIssueAttachment.Unit.Tests.ps1 +++ b/Tests/Functions/Add-JiraIssueAttachment.Unit.Tests.ps1 @@ -82,7 +82,7 @@ Describe "Add-JiraIssueAttachment" -Tag 'Unit' { Mock Get-JiraIssue -ModuleName JiraPS { $Issue = [PSCustomObject]@{ Key = $issueKey - RestURL = "$jiraServer/rest/api/latest/issue/$issueKey" + RestURL = "$jiraServer/rest/api/2/issue/$issueKey" } $Issue.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') $Issue @@ -92,7 +92,7 @@ Describe "Add-JiraIssueAttachment" -Tag 'Unit' { Get-JiraIssue -Key $Issue } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter { $Method -eq 'Post' -and $URI -eq "$jiraServer/rest/api/latest/issue/$issueKey/attachments" } { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter { $Method -eq 'Post' -and $URI -eq "$jiraServer/rest/api/2/issue/$issueKey/attachments" } { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json -InputObject $attachmentJson } diff --git a/Tests/Functions/Add-JiraIssueComment.Unit.Tests.ps1 b/Tests/Functions/Add-JiraIssueComment.Unit.Tests.ps1 index 05805148..ba511fc0 100644 --- a/Tests/Functions/Add-JiraIssueComment.Unit.Tests.ps1 +++ b/Tests/Functions/Add-JiraIssueComment.Unit.Tests.ps1 @@ -59,7 +59,7 @@ Describe "Add-JiraIssueComment" -Tag 'Unit' { $object = [PSCustomObject] @{ ID = $issueID Key = $issueKey - RestUrl = "$jiraServer/rest/api/latest/issue/$issueID" + RestUrl = "$jiraServer/rest/api/2/issue/$issueID" } $object.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') return $object @@ -69,7 +69,7 @@ Describe "Add-JiraIssueComment" -Tag 'Unit' { Get-JiraIssue -Key $Issue } - Mock Invoke-JiraMethod -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/latest/issue/$issueID/comment"} { + Mock Invoke-JiraMethod -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/2/issue/$issueID/comment"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json $restResponse } diff --git a/Tests/Functions/Add-JiraIssueLink.Unit.Tests.ps1 b/Tests/Functions/Add-JiraIssueLink.Unit.Tests.ps1 index 123bb8f4..973ceaea 100644 --- a/Tests/Functions/Add-JiraIssueLink.Unit.Tests.ps1 +++ b/Tests/Functions/Add-JiraIssueLink.Unit.Tests.ps1 @@ -67,7 +67,7 @@ Describe 'Add-JiraIssueLink' -Tag 'Unit' { throw "Unidentified call to Invoke-JiraMethod" } - Mock Invoke-JiraMethod -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/latest/issueLink"} { + Mock Invoke-JiraMethod -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/2/issueLink"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' return $true } diff --git a/Tests/Functions/Add-JiraIssueWatcher.Unit.Tests.ps1 b/Tests/Functions/Add-JiraIssueWatcher.Unit.Tests.ps1 index 1b020a93..42bd0ba8 100644 --- a/Tests/Functions/Add-JiraIssueWatcher.Unit.Tests.ps1 +++ b/Tests/Functions/Add-JiraIssueWatcher.Unit.Tests.ps1 @@ -49,7 +49,7 @@ Describe "Add-JiraIssueWatcher" -Tag 'Unit' { $object = [PSCustomObject] @{ ID = $issueID Key = $issueKey - RestUrl = "$jiraServer/rest/api/latest/issue/$issueID" + RestUrl = "$jiraServer/rest/api/2/issue/$issueID" } $object.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') return $object @@ -59,7 +59,7 @@ Describe "Add-JiraIssueWatcher" -Tag 'Unit' { Get-JiraIssue -Key $Issue } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/latest/issue/$issueID/watchers"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/2/issue/$issueID/watchers"} { ShowMockInfo 'Invoke-JiraMethod' -Params 'Uri', 'Method' } diff --git a/Tests/Functions/Add-JiraIssueWorklog.Unit.Tests.ps1 b/Tests/Functions/Add-JiraIssueWorklog.Unit.Tests.ps1 index 4e6ae499..2bcc2529 100644 --- a/Tests/Functions/Add-JiraIssueWorklog.Unit.Tests.ps1 +++ b/Tests/Functions/Add-JiraIssueWorklog.Unit.Tests.ps1 @@ -48,7 +48,7 @@ Describe "Add-JiraIssueWorklog" -Tag 'Unit' { $restResponse = @" { "id": "$worklogitemID", - "self": "$jiraServer/rest/api/latest/issue/$issueID/worklog/$worklogitemID", + "self": "$jiraServer/rest/api/2/issue/$issueID/worklog/$worklogitemID", "comment": "Test description", "created": "2015-05-01T16:24:38.000-0500", "updated": "2015-05-01T16:24:38.000-0500", @@ -92,7 +92,7 @@ Describe "Add-JiraIssueWorklog" -Tag 'Unit' { $result = [PSCustomObject] @{ ID = $issueID Key = $issueKey - RestUrl = "$jiraServer/rest/api/latest/issue/$issueID" + RestUrl = "$jiraServer/rest/api/2/issue/$issueID" } $result.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') Write-Output $result @@ -102,7 +102,7 @@ Describe "Add-JiraIssueWorklog" -Tag 'Unit' { Get-JiraIssue -Key $Issue } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/latest/issue/$issueID/worklog"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/2/issue/$issueID/worklog"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri', 'Body' ConvertFrom-Json $restResponse } diff --git a/Tests/Functions/ConvertTo-JiraFilter.Unit.Tests.ps1 b/Tests/Functions/ConvertTo-JiraFilter.Unit.Tests.ps1 index 92e5dbf8..688f73d5 100644 --- a/Tests/Functions/ConvertTo-JiraFilter.Unit.Tests.ps1 +++ b/Tests/Functions/ConvertTo-JiraFilter.Unit.Tests.ps1 @@ -40,7 +40,7 @@ Describe "ConvertTo-JiraFilter" -Tag 'Unit' { # Obtained from Atlassian's public JIRA instance $sampleJson = @' { - "self": "https://jira.atlassian.com/rest/api/latest/filter/12844", + "self": "https://jira.atlassian.com/rest/api/2/filter/12844", "id": "12844", "name": "All JIRA Bugs", "owner": { @@ -58,7 +58,7 @@ Describe "ConvertTo-JiraFilter" -Tag 'Unit' { }, "jql": "project = 10240 AND issuetype = 1 ORDER BY key DESC", "viewUrl": "https://jira.atlassian.com/secure/IssueNavigator.jspa?mode=hide&requestId=12844", - "searchUrl": "https://jira.atlassian.com/rest/api/latest/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC", + "searchUrl": "https://jira.atlassian.com/rest/api/2/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC", "favourite": false, "sharePermissions": [ { @@ -184,9 +184,9 @@ Describe "ConvertTo-JiraFilter" -Tag 'Unit' { defProp $r 'Id' 12844 defProp $r 'Name' 'All JIRA Bugs' defProp $r 'JQL' 'project = 10240 AND issuetype = 1 ORDER BY key DESC' - defProp $r 'RestUrl' 'https://jira.atlassian.com/rest/api/latest/filter/12844' + defProp $r 'RestUrl' 'https://jira.atlassian.com/rest/api/2/filter/12844' defProp $r 'ViewUrl' 'https://jira.atlassian.com/secure/IssueNavigator.jspa?mode=hide&requestId=12844' - defProp $r 'SearchUrl' 'https://jira.atlassian.com/rest/api/latest/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC' + defProp $r 'SearchUrl' 'https://jira.atlassian.com/rest/api/2/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC' defProp $r 'Favourite' $false It "Defines the 'Favorite' property as an alias of 'Favourite'" { ($r | Get-Member -Name Favorite).MemberType | Should -Be "AliasProperty" diff --git a/Tests/Functions/ConvertTo-JiraIssue.Unit.Tests.ps1 b/Tests/Functions/ConvertTo-JiraIssue.Unit.Tests.ps1 index 5c802c68..0aa0ba02 100644 --- a/Tests/Functions/ConvertTo-JiraIssue.Unit.Tests.ps1 +++ b/Tests/Functions/ConvertTo-JiraIssue.Unit.Tests.ps1 @@ -41,7 +41,7 @@ Describe "ConvertTo-JiraIssue" -Tag 'Unit' { # An example of how an issue will look when returned from JIRA's REST API. # You can obtain most of this with a one-liner: - # (Invoke-WebRequest -Method Get -Uri '$jiraServer/rest/api/latest/issue/JRA-37294?expand=transitions').Content + # (Invoke-WebRequest -Method Get -Uri '$jiraServer/rest/api/2/issue/JRA-37294?expand=transitions').Content # I have edited the result just a bit to add a fake Transitions # property that matches the expected results from JIRA. I'm not @@ -51,7 +51,7 @@ Describe "ConvertTo-JiraIssue" -Tag 'Unit' { { "expand": "renderedFields,names,schema,transitions,operations,editmeta,changelog,versionedRepresentations", "id": "320391", - "self": "$jiraServer/rest/api/latest/issue/320391", + "self": "$jiraServer/rest/api/2/issue/320391", "key": "JRA-37294", "fields": { "customfield_12130": null, @@ -911,7 +911,7 @@ Describe "ConvertTo-JiraIssue" -Tag 'Unit' { defProp $r 'Key' 'JRA-37294' defProp $r 'Id' '320391' - defProp $r 'RestUrl' "$jiraServer/rest/api/latest/issue/320391" + defProp $r 'RestUrl' "$jiraServer/rest/api/2/issue/320391" defProp $r 'HttpUrl' "$jiraServer/browse/JRA-37294" defProp $r 'Summary' 'Allow set active/inactive via REST API' It "Defines the 'Attachment' property" { diff --git a/Tests/Functions/ConvertTo-JiraIssueLinkType.Unit.Tests.ps1 b/Tests/Functions/ConvertTo-JiraIssueLinkType.Unit.Tests.ps1 index 2d2464f7..bad0e066 100644 --- a/Tests/Functions/ConvertTo-JiraIssueLinkType.Unit.Tests.ps1 +++ b/Tests/Functions/ConvertTo-JiraIssueLinkType.Unit.Tests.ps1 @@ -47,28 +47,28 @@ Describe "ConvertTo-JiraIssueLinkType" -Tag 'Unit' { "name": "Blocks", "inward": "is blocked by", "outward": "blocks", - "self": "http://jira.example.com/rest/api/latest/issueLinkType/10000" + "self": "http://jira.example.com/rest/api/2/issueLinkType/10000" }, { "id": "10001", "name": "Cloners", "inward": "is cloned by", "outward": "clones", - "self": "http://jira.example.com/rest/api/latest/issueLinkType/10001" + "self": "http://jira.example.com/rest/api/2/issueLinkType/10001" }, { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates", - "self": "http://jira.example.com/rest/api/latest/issueLinkType/10002" + "self": "http://jira.example.com/rest/api/2/issueLinkType/10002" }, { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to", - "self": "http://jira.example.com/rest/api/latest/issueLinkType/10003" + "self": "http://jira.example.com/rest/api/2/issueLinkType/10003" } ] } @@ -87,7 +87,7 @@ Describe "ConvertTo-JiraIssueLinkType" -Tag 'Unit' { defProp $r 'Name' 'Blocks' defProp $r 'InwardText' 'is blocked by' defProp $r 'OutwardText' 'blocks' - defProp $r 'RestUrl' 'http://jira.example.com/rest/api/latest/issueLinkType/10000' + defProp $r 'RestUrl' 'http://jira.example.com/rest/api/2/issueLinkType/10000' It "Provides an array of objects if an array is passed" { $r2 = ConvertTo-JiraIssueLinkType -InputObject $sampleObject diff --git a/Tests/Functions/ConvertTo-JiraIssueType.Unit.Tests.ps1 b/Tests/Functions/ConvertTo-JiraIssueType.Unit.Tests.ps1 index de7af3df..6184eedc 100644 --- a/Tests/Functions/ConvertTo-JiraIssueType.Unit.Tests.ps1 +++ b/Tests/Functions/ConvertTo-JiraIssueType.Unit.Tests.ps1 @@ -45,7 +45,7 @@ Describe "ConvertTo-JiraIssueType" -Tag 'Unit' { $sampleJson = @" { - "self": "$jiraServer/rest/api/latest/issuetype/2", + "self": "$jiraServer/rest/api/2/issuetype/2", "id": "$issueTypeId", "description": "$issueTypeDescription", "iconUrl": "$jiraServer/images/icons/issuetypes/newfeature.png", @@ -65,7 +65,7 @@ Describe "ConvertTo-JiraIssueType" -Tag 'Unit' { defProp $r 'Id' $issueTypeId defProp $r 'Name' $issueTypeName defProp $r 'Description' $issueTypeDescription - defProp $r 'RestUrl' "$jiraServer/rest/api/latest/issuetype/$issueTypeId" + defProp $r 'RestUrl' "$jiraServer/rest/api/2/issuetype/$issueTypeId" defProp $r 'IconUrl' "$jiraServer/images/icons/issuetypes/newfeature.png" defProp $r 'Subtask' $false } diff --git a/Tests/Functions/ConvertTo-JiraProject.Unit.Tests.ps1 b/Tests/Functions/ConvertTo-JiraProject.Unit.Tests.ps1 index 87abfd56..8fae8bda 100644 --- a/Tests/Functions/ConvertTo-JiraProject.Unit.Tests.ps1 +++ b/Tests/Functions/ConvertTo-JiraProject.Unit.Tests.ps1 @@ -73,7 +73,7 @@ Describe "ConvertTo-JiraProject" -Tag 'Unit' { }, "projectKeys": "HCC", "projectCategory": { - "self": "$jiraServer/rest/api/latest/projectCategory/10000", + "self": "$jiraServer/rest/api/2/projectCategory/10000", "id": "10000", "name": "Home Connect", "description": "Home Connect Projects" diff --git a/Tests/Functions/Get-JiraComponent.Unit.Tests.ps1 b/Tests/Functions/Get-JiraComponent.Unit.Tests.ps1 index fbc1c153..b540561b 100644 --- a/Tests/Functions/Get-JiraComponent.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraComponent.Unit.Tests.ps1 @@ -83,7 +83,7 @@ Describe "Get-JiraComponent" -Tag 'Unit' { Write-Output $jiraServer } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/latest/component/$componentId"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/2/component/$componentId"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json $restResultOne } diff --git a/Tests/Functions/Get-JiraField.Unit.Tests.ps1 b/Tests/Functions/Get-JiraField.Unit.Tests.ps1 index c006e6c8..506438cf 100644 --- a/Tests/Functions/Get-JiraField.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraField.Unit.Tests.ps1 @@ -170,7 +170,7 @@ Describe "Get-JiraField" -Tag 'Unit' { Write-Output $jiraServer } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $Uri -eq "$jiraServer/rest/api/latest/field"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $Uri -eq "$jiraServer/rest/api/2/field"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json $restResult } diff --git a/Tests/Functions/Get-JiraFilter.Unit.Tests.ps1 b/Tests/Functions/Get-JiraFilter.Unit.Tests.ps1 index acedcec9..cd4e3f75 100644 --- a/Tests/Functions/Get-JiraFilter.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraFilter.Unit.Tests.ps1 @@ -42,7 +42,7 @@ Describe 'Get-JiraFilter' -Tag 'Unit' { $responseFilter = @" { - "self": "$jiraServer/rest/api/latest/filter/12844", + "self": "$jiraServer/rest/api/2/filter/12844", "id": "12844", "name": "All JIRA Bugs", "owner": { @@ -60,7 +60,7 @@ Describe 'Get-JiraFilter' -Tag 'Unit' { }, "jql": "project = 10240 AND issuetype = 1 ORDER BY key DESC", "viewUrl": "$jiraServer/secure/IssueNavigator.jspa?mode=hide&requestId=12844", - "searchUrl": "$jiraServer/rest/api/latest/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC", + "searchUrl": "$jiraServer/rest/api/2/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC", "favourite": false, "sharePermissions": [ { @@ -88,21 +88,21 @@ Describe 'Get-JiraFilter' -Tag 'Unit' { $responseFilterCollection = @" [ { - "self": "$jiraServer/rest/api/latest/filter/13844", + "self": "$jiraServer/rest/api/2/filter/13844", "id": "13844", "name": "Filter 1", "jql": "project = 10240 AND issuetype = 1 ORDER BY key DESC", "favourite": true }, { - "self": "$jiraServer/rest/api/latest/filter/14844", + "self": "$jiraServer/rest/api/2/filter/14844", "id": "14844", "name": "Filter 2", "jql": "project = 10240 AND issuetype = 1 ORDER BY key DESC", "favourite": true }, { - "self": "$jiraServer/rest/api/latest/filter/15844", + "self": "$jiraServer/rest/api/2/filter/15844", "id": "15844", "name": "Filter 3", "jql": "project = 10240 AND issuetype = 1 ORDER BY key DESC", diff --git a/Tests/Functions/Get-JiraGroup.Unit.Tests.ps1 b/Tests/Functions/Get-JiraGroup.Unit.Tests.ps1 index 815b92c2..6f5a37ed 100644 --- a/Tests/Functions/Get-JiraGroup.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraGroup.Unit.Tests.ps1 @@ -63,7 +63,7 @@ Describe "Get-JiraGroup" -Tag 'Unit' { } # Searching for a group. - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/latest/group?groupname=$testGroupNameEscaped"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/2/group?groupname=$testGroupNameEscaped"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json -InputObject $restResult } diff --git a/Tests/Functions/Get-JiraIssue.Unit.Tests.ps1 b/Tests/Functions/Get-JiraIssue.Unit.Tests.ps1 index e4342e20..310ab0d9 100644 --- a/Tests/Functions/Get-JiraIssue.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraIssue.Unit.Tests.ps1 @@ -75,7 +75,7 @@ Describe "Get-JiraGroupMember" -Tag 'Unit' { [PSCustomObject]@{ PSTypeName = "JiraPS.Filter" Id = 12345 - SearchUrl = "https://jira.example.com/rest/api/latest/filter/12345" + SearchUrl = "https://jira.example.com/rest/api/2/filter/12345" } } diff --git a/Tests/Functions/Get-JiraIssueAttachment.Unit.Tests.ps1 b/Tests/Functions/Get-JiraIssueAttachment.Unit.Tests.ps1 index 8bfe542e..2a7dd72f 100644 --- a/Tests/Functions/Get-JiraIssueAttachment.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraIssueAttachment.Unit.Tests.ps1 @@ -90,7 +90,7 @@ Describe "Get-JiraIssueAttachment" -Tag 'Unit' { $IssueObj = [PSCustomObject]@{ ID = $issueID Key = $issueKey - RestUrl = "$jiraServer/rest/api/latest/issue/$issueID" + RestUrl = "$jiraServer/rest/api/2/issue/$issueID" attachment = (ConvertFrom-Json -InputObject $attachments) } $IssueObj.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') diff --git a/Tests/Functions/Get-JiraIssueComment.Unit.Tests.ps1 b/Tests/Functions/Get-JiraIssueComment.Unit.Tests.ps1 index 1ad17416..0402000c 100644 --- a/Tests/Functions/Get-JiraIssueComment.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraIssueComment.Unit.Tests.ps1 @@ -72,7 +72,7 @@ Describe "Get-JiraIssueComment" -Tag 'Unit' { $object = [PSCustomObject] @{ ID = $issueID Key = $issueKey - RestUrl = "$jiraServer/rest/api/latest/issue/$issueID" + RestUrl = "$jiraServer/rest/api/2/issue/$issueID" } $object.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') return $object @@ -83,7 +83,7 @@ Describe "Get-JiraIssueComment" -Tag 'Unit' { } # Obtaining comments from an issue...this is IT-3676 in the test environment - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/latest/issue/$issueID/comment"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/2/issue/$issueID/comment"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' (ConvertFrom-Json -InputObject $restResult).comments } diff --git a/Tests/Functions/Get-JiraIssueCreateMetadata.Unit.Tests.ps1 b/Tests/Functions/Get-JiraIssueCreateMetadata.Unit.Tests.ps1 index c8cbdc75..a2e773b2 100644 --- a/Tests/Functions/Get-JiraIssueCreateMetadata.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraIssueCreateMetadata.Unit.Tests.ps1 @@ -49,7 +49,7 @@ Describe "Get-JiraIssueCreateMetadata" -Tag 'Unit' { "key": "TEST", "name": "Test Project", "issuetypes": [{ - "self": "$jiraserver/rest/api/latest/issuetype/2", + "self": "$jiraserver/rest/api/2/issuetype/2", "id": "2", "iconUrl": "$jiraserver/images/icons/issuetypes/newfeature.png", "name": "Test Issue Type", @@ -129,7 +129,7 @@ Describe "Get-JiraIssueCreateMetadata" -Tag 'Unit' { "system": "reporter" }, "name": "Reporter", - "autoCompleteUrl": "$jiraserver/rest/api/latest/user/search?username=", + "autoCompleteUrl": "$jiraserver/rest/api/2/user/search?username=", "hasDefaultValue": false, "operations": [ "set" @@ -142,7 +142,7 @@ Describe "Get-JiraIssueCreateMetadata" -Tag 'Unit' { "system": "assignee" }, "name": "Assignee", - "autoCompleteUrl": "$jiraserver/rest/api/latest/user/assignable/search?issueKey=null&username=", + "autoCompleteUrl": "$jiraserver/rest/api/2/user/assignable/search?issueKey=null&username=", "hasDefaultValue": false, "operations": [ "set" diff --git a/Tests/Functions/Get-JiraIssueEditMetadata.Unit.Tests.ps1 b/Tests/Functions/Get-JiraIssueEditMetadata.Unit.Tests.ps1 index 999102c9..da698c2f 100644 --- a/Tests/Functions/Get-JiraIssueEditMetadata.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraIssueEditMetadata.Unit.Tests.ps1 @@ -117,7 +117,7 @@ Describe "Get-JiraIssueEditMetadata" -Tag 'Unit' { "system": "reporter" }, "name": "Reporter", - "autoCompleteUrl": "$jiraServer/rest/api/latest/user/search?username=", + "autoCompleteUrl": "$jiraServer/rest/api/2/user/search?username=", "hasDefaultValue": false, "operations": [ "set" @@ -130,7 +130,7 @@ Describe "Get-JiraIssueEditMetadata" -Tag 'Unit' { "system": "assignee" }, "name": "Assignee", - "autoCompleteUrl": "$jiraServer/rest/api/latest/user/assignable/search?issueKey=null&username=", + "autoCompleteUrl": "$jiraServer/rest/api/2/user/assignable/search?issueKey=null&username=", "hasDefaultValue": false, "operations": [ "set" @@ -207,7 +207,7 @@ Describe "Get-JiraIssueEditMetadata" -Tag 'Unit' { [PSCustomObject] @{ ID = $issueID Key = $issueKey - RestUrl = "$jiraServer/rest/api/latest/issue/$issueID" + RestUrl = "$jiraServer/rest/api/2/issue/$issueID" } } diff --git a/Tests/Functions/Get-JiraIssueLinkType.Unit.Tests.ps1 b/Tests/Functions/Get-JiraIssueLinkType.Unit.Tests.ps1 index 73b298bd..1d51d989 100644 --- a/Tests/Functions/Get-JiraIssueLinkType.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraIssueLinkType.Unit.Tests.ps1 @@ -51,8 +51,8 @@ Describe 'Get-JiraIssueLinkType' -Tag 'Unit' { defParam $command 'Credential' } - $filterAll = {$Method -eq 'Get' -and $Uri -ceq "$jiraServer/rest/api/latest/issueLinkType"} - $filterOne = {$Method -eq 'Get' -and $Uri -ceq "$jiraServer/rest/api/latest/issueLinkType/10000"} + $filterAll = {$Method -eq 'Get' -and $Uri -ceq "$jiraServer/rest/api/2/issueLinkType"} + $filterOne = {$Method -eq 'Get' -and $Uri -ceq "$jiraServer/rest/api/2/issueLinkType/10000"} Mock ConvertTo-JiraIssueLinkType { ShowMockInfo 'ConvertTo-JiraIssueLinkType' diff --git a/Tests/Functions/Get-JiraIssueType.Unit.Tests.ps1 b/Tests/Functions/Get-JiraIssueType.Unit.Tests.ps1 index f6c346d6..270a2a39 100644 --- a/Tests/Functions/Get-JiraIssueType.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraIssueType.Unit.Tests.ps1 @@ -45,7 +45,7 @@ Describe "Get-JiraIssueType" -Tag 'Unit' { $restResult = @" [ { - "self": "$jiraServer/rest/api/latest/issuetype/12", + "self": "$jiraServer/rest/api/2/issuetype/12", "id": "12", "description": "This issue type is no longer used.", "iconUrl": "$jiraServer/images/icons/issuetypes/delete.png", @@ -53,7 +53,7 @@ Describe "Get-JiraIssueType" -Tag 'Unit' { "subtask": false }, { - "self": "$jiraServer/rest/api/latest/issuetype/11", + "self": "$jiraServer/rest/api/2/issuetype/11", "id": "11", "description": "An issue related to classroom technology, moodle, library services", "iconUrl": "$jiraServer/images/icons/issuetypes/documentation.png", @@ -61,7 +61,7 @@ Describe "Get-JiraIssueType" -Tag 'Unit' { "subtask": false }, { - "self": "$jiraServer/rest/api/latest/issuetype/4", + "self": "$jiraServer/rest/api/2/issuetype/4", "id": "4", "description": "An issue related to network connectivity or infrastructure including Access Control.", "iconUrl": "$jiraServer/images/icons/issuetypes/improvement.png", @@ -69,7 +69,7 @@ Describe "Get-JiraIssueType" -Tag 'Unit' { "subtask": false }, { - "self": "$jiraServer/rest/api/latest/issuetype/6", + "self": "$jiraServer/rest/api/2/issuetype/6", "id": "6", "description": "An issue related to telephone services", "iconUrl": "$jiraServer/images/icons/issuetypes/genericissue.png", @@ -77,7 +77,7 @@ Describe "Get-JiraIssueType" -Tag 'Unit' { "subtask": false }, { - "self": "$jiraServer/rest/api/latest/issuetype/8", + "self": "$jiraServer/rest/api/2/issuetype/8", "id": "8", "description": "An issue related to A/V and media services including teacher stations", "iconUrl": "$jiraServer/images/icons/issuetypes/genericissue.png", @@ -85,7 +85,7 @@ Describe "Get-JiraIssueType" -Tag 'Unit' { "subtask": false }, { - "self": "$jiraServer/rest/api/latest/issuetype/1", + "self": "$jiraServer/rest/api/2/issuetype/1", "id": "1", "description": "An issue related to Banner, MU Online, Oracle Reports, MU Account Suite, Hobsons, or CS Gold", "iconUrl": "$jiraServer/images/icons/issuetypes/bug.png", @@ -93,7 +93,7 @@ Describe "Get-JiraIssueType" -Tag 'Unit' { "subtask": false }, { - "self": "$jiraServer/rest/api/latest/issuetype/10", + "self": "$jiraServer/rest/api/2/issuetype/10", "id": "10", "description": "The sub-task of the issue", "iconUrl": "$jiraServer/images/icons/issuetypes/subtask_alternate.png", @@ -101,7 +101,7 @@ Describe "Get-JiraIssueType" -Tag 'Unit' { "subtask": true }, { - "self": "$jiraServer/rest/api/latest/issuetype/2", + "self": "$jiraServer/rest/api/2/issuetype/2", "id": "2", "description": "An issue related to end-user workstations.", "iconUrl": "$jiraServer/images/icons/issuetypes/newfeature.png", @@ -119,7 +119,7 @@ Describe "Get-JiraIssueType" -Tag 'Unit' { $inputObject } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $Uri -eq "$jiraServer/rest/api/latest/issuetype"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $Uri -eq "$jiraServer/rest/api/2/issuetype"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json $restResult } diff --git a/Tests/Functions/Get-JiraIssueWatcher.Unit.Tests.ps1 b/Tests/Functions/Get-JiraIssueWatcher.Unit.Tests.ps1 index 29a8bfa8..1d4f073d 100644 --- a/Tests/Functions/Get-JiraIssueWatcher.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraIssueWatcher.Unit.Tests.ps1 @@ -67,7 +67,7 @@ Describe "Get-JiraIssueWatcher" -Tag 'Unit' { $object = [PSCustomObject] @{ ID = $issueID Key = $issueKey - RestUrl = "$jiraServer/rest/api/latest/issue/$issueID" + RestUrl = "$jiraServer/rest/api/2/issue/$issueID" } $object.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') return $object @@ -78,7 +78,7 @@ Describe "Get-JiraIssueWatcher" -Tag 'Unit' { } # Obtaining watchers from an issue...this is IT-3676 in the test environment - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/latest/issue/$issueID/watchers"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/2/issue/$issueID/watchers"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json -InputObject $restResult } diff --git a/Tests/Functions/Get-JiraPriority.Unit.Tests.ps1 b/Tests/Functions/Get-JiraPriority.Unit.Tests.ps1 index 7d84e0f6..d590d406 100644 --- a/Tests/Functions/Get-JiraPriority.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraPriority.Unit.Tests.ps1 @@ -97,11 +97,11 @@ Describe "Get-JiraPriority" -Tag 'Unit' { $InputObject } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/latest/priority"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/2/priority"} { ConvertFrom-Json $restResultAll } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/latest/priority/1"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/2/priority/1"} { ConvertFrom-Json $restResultOne } diff --git a/Tests/Functions/Get-JiraRemoteLink.Unit.Tests.ps1 b/Tests/Functions/Get-JiraRemoteLink.Unit.Tests.ps1 index dd0bd0c2..2248f678 100644 --- a/Tests/Functions/Get-JiraRemoteLink.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraRemoteLink.Unit.Tests.ps1 @@ -44,7 +44,7 @@ Describe "Get-JiraRemoteLink" -Tag 'Unit' { $restResult = @" { "id": 10000, - "self": "$jiraServer/rest/api/latest/issue/MKY-1/remotelink/10000", + "self": "$jiraServer/rest/api/2/issue/MKY-1/remotelink/10000", "globalId": "system=http://www.mycompany.com/support&id=1", "application": { "type": "com.acme.tracker", @@ -69,7 +69,7 @@ Describe "Get-JiraRemoteLink" -Tag 'Unit' { Mock Get-JiraIssue { $object = [PSCustomObject] @{ - 'RestURL' = "$jiraServer/rest/api/latest/issue/12345" + 'RestURL' = "$jiraServer/rest/api/2/issue/12345" 'Key' = $issueKey } $object.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') diff --git a/Tests/Functions/Get-JiraServerInformation.Unit.Tests.ps1 b/Tests/Functions/Get-JiraServerInformation.Unit.Tests.ps1 index 9869494d..2d443476 100644 --- a/Tests/Functions/Get-JiraServerInformation.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraServerInformation.Unit.Tests.ps1 @@ -56,7 +56,7 @@ Describe "Get-JiraServerInformation" -Tag 'Unit' { Write-Output $jiraServer } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/latest/serverInfo"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Get' -and $URI -eq "$jiraServer/rest/api/2/serverInfo"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json $restResult } diff --git a/Tests/Functions/Get-JiraVersion.Unit.Tests.ps1 b/Tests/Functions/Get-JiraVersion.Unit.Tests.ps1 index 76b6116c..d79b8e59 100644 --- a/Tests/Functions/Get-JiraVersion.Unit.Tests.ps1 +++ b/Tests/Functions/Get-JiraVersion.Unit.Tests.ps1 @@ -62,7 +62,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { "@ $testJson1 = @" { - "self" : "$jiraServer/rest/api/latest/version/$versionID1", + "self" : "$jiraServer/rest/api/2/version/$versionID1", "id" : $versionID1, "description" : "$versionName1", "name" : "$versionName1", @@ -73,7 +73,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { "@ $testJson2 = @" { - "self" : "$jiraServer/rest/api/latest/version/$versionID2", + "self" : "$jiraServer/rest/api/2/version/$versionID2", "id" : $versionID2, "description" : "$versionName2", "name" : "$versionName2", @@ -85,7 +85,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { $testJsonAll = @" [ { - "self" : "$jiraServer/rest/api/latest/version/$versionID1", + "self" : "$jiraServer/rest/api/2/version/$versionID1", "id" : $versionID1, "description" : "$versionName1", "name" : "$versionName1", @@ -94,7 +94,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { "projectId" : "$projectId" }, { - "self" : "$jiraServer/rest/api/latest/version/$versionID2", + "self" : "$jiraServer/rest/api/2/version/$versionID2", "id" : $versionID2, "description" : "$versionName2", "name" : "$versionName2", @@ -103,7 +103,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { "projectId" : "$projectId" }, { - "self" : "$jiraServer/rest/api/latest/version/$versionID3", + "self" : "$jiraServer/rest/api/2/version/$versionID3", "id" : $versionID3, "description" : "$versionName3", "name" : "$versionName3", @@ -137,7 +137,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { $result } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter { $Method -eq 'Get' -and $URI -like "$jiraServer/rest/api/latest/version/$versionId1" } { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter { $Method -eq 'Get' -and $URI -like "$jiraServer/rest/api/2/version/$versionId1" } { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json $testJson1 } diff --git a/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 b/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 index 5cc7c73c..543dc672 100644 --- a/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 +++ b/Tests/Functions/Invoke-JiraIssueTransition.Unit.Tests.ps1 @@ -70,7 +70,7 @@ Describe "Invoke-JiraIssueTransition" -Tag 'Unit' { $object = [PSCustomObject] @{ ID = $issueID Key = $issueKey - RestUrl = "$jiraServer/rest/api/latest/issue/$issueID" + RestUrl = "$jiraServer/rest/api/2/issue/$issueID" Transition = @($t1, $t2) } $object.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') @@ -81,7 +81,7 @@ Describe "Invoke-JiraIssueTransition" -Tag 'Unit' { Get-JiraIssue -Key $Issue } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Post' -and $URI -eq "$jiraServer/rest/api/latest/issue/$issueID/transitions"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Post' -and $URI -eq "$jiraServer/rest/api/2/issue/$issueID/transitions"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' # This should return a 204 status code, so no data should actually be returned } @@ -135,8 +135,8 @@ Describe "Invoke-JiraIssueTransition" -Tag 'Unit' { Invoke-JiraIssueTransition @parameter } | Should Not Throw - Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/latest/issue/$issueID/transitions" -and $Body -like '*customfield_12345*set*foo*' } - Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/latest/issue/$issueID/transitions" -and $Body -like '*customfield_67890*set*bar*' } + Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/2/issue/$issueID/transitions" -and $Body -like '*customfield_12345*set*foo*' } + Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/2/issue/$issueID/transitions" -and $Body -like '*customfield_67890*set*bar*' } } It "Updates assignee name if provided to the -Assignee parameter" { @@ -148,19 +148,19 @@ Describe "Invoke-JiraIssueTransition" -Tag 'Unit' { } { Invoke-JiraIssueTransition -Issue $issueKey -Transition 11 -Assignee 'powershell-user'} | Should Not Throw - Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/latest/issue/$issueID/transitions" -and $Body -like '*name*powershell-user*' } + Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/2/issue/$issueID/transitions" -and $Body -like '*name*powershell-user*' } } It "Unassigns an issue if 'Unassigned' is passed to the -Assignee parameter" { { Invoke-JiraIssueTransition -Issue $issueKey -Transition 11 -Assignee 'Unassigned'} | Should Not Throw - Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/latest/issue/$issueID/transitions" -and $Body -like '*name*""*' } + Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/2/issue/$issueID/transitions" -and $Body -like '*name*""*' } } It "Adds a comment if provide to the -Comment parameter" { { Invoke-JiraIssueTransition -Issue $issueKey -Transition 11 -Comment 'test comment'} | Should Not Throw - Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/latest/issue/$issueID/transitions" -and $Body -like '*body*test comment*' } + Assert-MockCalled -CommandName Invoke-JiraMethod -ModuleName JiraPS -Times 1 -Scope It -ParameterFilter { $Method -eq 'Post' -and $URI -like "*/rest/api/2/issue/$issueID/transitions" -and $Body -like '*body*test comment*' } } It "Returns the Issue object when -Passthru is provided" { diff --git a/Tests/Functions/Move-JiraVersion.Unit.Tests.ps1 b/Tests/Functions/Move-JiraVersion.Unit.Tests.ps1 index 8fdd98bd..07504e2a 100644 --- a/Tests/Functions/Move-JiraVersion.Unit.Tests.ps1 +++ b/Tests/Functions/Move-JiraVersion.Unit.Tests.ps1 @@ -76,7 +76,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Project = (Get-JiraProject -Project $projectKey) ReleaseDate = (Get-Date "2017-12-01") StartDate = (Get-Date "2017-01-01") - RestUrl = "$jiraServer/rest/api/latest/version/$_Id" + RestUrl = "$jiraServer/rest/api/2/version/$_Id" } $Version.PSObject.TypeNames.Insert(0, 'JiraPS.Version') $Version @@ -114,7 +114,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID1/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID1/move" -and $Body -match '"position":\s*"Last"' } } @@ -124,7 +124,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID1/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID1/move" -and $Body -match '"position":\s*"Earlier"' } } @@ -137,7 +137,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID2/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID2/move" -and $Body -match '"position":\s*"Later"' } } @@ -150,7 +150,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID2/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID2/move" -and $Body -match '"position":\s*"First"' } } @@ -163,7 +163,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID2/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID2/move" -and $Body -match '"position":\s*"First"' } } @@ -175,7 +175,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID1/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID1/move" -and $Body -match '"position":\s*"First"' } } @@ -188,7 +188,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID1/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID1/move" -and $Body -match """after"":\s*""$restUrl""" } } @@ -200,7 +200,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID1/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID1/move" -and $Body -match """after"":\s*""$restUrl""" } } @@ -211,7 +211,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID1/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID1/move" -and $Body -match """after"":\s*""$($version2.RestUrl)""" } } @@ -222,7 +222,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID1/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID1/move" -and $Body -match """after"":\s*""$($version2.RestUrl)""" } } @@ -234,7 +234,7 @@ Describe "Move-JiraVersion" -Tag 'Unit' { Assert-MockCalled 'Get-JiraConfigServer' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'POST' -and - $URI -like "$jiraServer/rest/api/latest/version/$versionID1/move" -and + $URI -like "$jiraServer/rest/api/2/version/$versionID1/move" -and $Body -match """after"":\s*""$($version2.RestUrl)""" } } diff --git a/Tests/Functions/New-JiraFilter.Unit.Tests.ps1 b/Tests/Functions/New-JiraFilter.Unit.Tests.ps1 index 85ddf1a1..b857f94c 100644 --- a/Tests/Functions/New-JiraFilter.Unit.Tests.ps1 +++ b/Tests/Functions/New-JiraFilter.Unit.Tests.ps1 @@ -42,7 +42,7 @@ Describe 'New-JiraFilter' -Tag 'Unit' { $responseFilter = @" { - "self": "$jiraServer/rest/api/latest/filter/12844", + "self": "$jiraServer/rest/api/2/filter/12844", "id": "12844", "name": "{0}", "jql": "{1}", diff --git a/Tests/Functions/New-JiraGroup.Unit.Tests.ps1 b/Tests/Functions/New-JiraGroup.Unit.Tests.ps1 index 13c408d4..3cd62859 100644 --- a/Tests/Functions/New-JiraGroup.Unit.Tests.ps1 +++ b/Tests/Functions/New-JiraGroup.Unit.Tests.ps1 @@ -60,7 +60,7 @@ Describe "New-JiraGroup" -Tag 'Unit' { Write-Output $jiraServer } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/latest/group"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/2/group"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json $testJson } diff --git a/Tests/Functions/New-JiraUser.Unit.Tests.ps1 b/Tests/Functions/New-JiraUser.Unit.Tests.ps1 index a974a0c5..b3d19d31 100644 --- a/Tests/Functions/New-JiraUser.Unit.Tests.ps1 +++ b/Tests/Functions/New-JiraUser.Unit.Tests.ps1 @@ -59,7 +59,7 @@ Describe "New-JiraUser" -Tag 'Unit' { Write-Output $jiraServer } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/latest/user"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'POST' -and $URI -eq "$jiraServer/rest/api/2/user"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json $testJson } diff --git a/Tests/Functions/New-JiraVersion.Unit.Tests.ps1 b/Tests/Functions/New-JiraVersion.Unit.Tests.ps1 index 31472951..31485d22 100644 --- a/Tests/Functions/New-JiraVersion.Unit.Tests.ps1 +++ b/Tests/Functions/New-JiraVersion.Unit.Tests.ps1 @@ -134,14 +134,14 @@ Describe "New-JiraVersion" -Tag 'Unit' { $results = $version | New-JiraVersion -ErrorAction Stop $results | Should Not BeNullOrEmpty checkType $results "JiraPS.Version" - Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Post' -and $URI -like "$jiraServer/rest/api/latest/version" } + Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Post' -and $URI -like "$jiraServer/rest/api/2/version" } Assert-MockCalled 'ConvertTo-JiraVersion' -Times 1 -Scope It -ModuleName JiraPS -Exactly } It "creates a Version using parameters" { $results = New-JiraVersion -Name $versionName -Project $projectKey -ErrorAction Stop $results | Should Not BeNullOrEmpty checkType $results "JiraPS.Version" - Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Post' -and $URI -like "$jiraServer/rest/api/latest/version" } + Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Post' -and $URI -like "$jiraServer/rest/api/2/version" } Assert-MockCalled 'ConvertTo-JiraVersion' -Times 1 -Scope It -ModuleName JiraPS -Exactly } It "creates a Version using splatting" { @@ -160,7 +160,7 @@ Describe "New-JiraVersion" -Tag 'Unit' { $results = New-JiraVersion @splat -ErrorAction Stop $results | Should Not BeNullOrEmpty checkType $results "JiraPS.Version" - Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Post' -and $URI -like "$jiraServer/rest/api/latest/version" } + Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Post' -and $URI -like "$jiraServer/rest/api/2/version" } Assert-MockCalled 'ConvertTo-JiraVersion' -Times 1 -Scope It -ModuleName JiraPS -Exactly } diff --git a/Tests/Functions/Remove-JiraFilter.Unit.Tests.ps1 b/Tests/Functions/Remove-JiraFilter.Unit.Tests.ps1 index 0a72ce25..51f4f4c2 100644 --- a/Tests/Functions/Remove-JiraFilter.Unit.Tests.ps1 +++ b/Tests/Functions/Remove-JiraFilter.Unit.Tests.ps1 @@ -42,7 +42,7 @@ Describe 'Remove-JiraFilter' -Tag 'Unit' { $responseFilter = @" { - "self": "$jiraServer/rest/api/latest/filter/12844", + "self": "$jiraServer/rest/api/2/filter/12844", "id": "12844", "name": "All JIRA Bugs", "owner": { @@ -60,7 +60,7 @@ Describe 'Remove-JiraFilter' -Tag 'Unit' { }, "jql": "project = 10240 AND issuetype = 1 ORDER BY key DESC", "viewUrl": "$jiraServer/secure/IssueNavigator.jspa?mode=hide&requestId=12844", - "searchUrl": "$jiraServer/rest/api/latest/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC", + "searchUrl": "$jiraServer/rest/api/2/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC", "favourite": false, "sharePermissions": [ { diff --git a/Tests/Functions/Remove-JiraIssueAttachment.Unit.Tests.ps1 b/Tests/Functions/Remove-JiraIssueAttachment.Unit.Tests.ps1 index 71a73bcb..0ca39fc4 100644 --- a/Tests/Functions/Remove-JiraIssueAttachment.Unit.Tests.ps1 +++ b/Tests/Functions/Remove-JiraIssueAttachment.Unit.Tests.ps1 @@ -87,10 +87,10 @@ Describe "Remove-JiraIssueAttachment" -Tag 'Unit' { Get-JiraIssue -Key $Issue } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter { $Method -eq 'Delete' -and $URI -eq "$jiraServer/rest/api/latest/attachment/$attachmentId1" } { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter { $Method -eq 'Delete' -and $URI -eq "$jiraServer/rest/api/2/attachment/$attachmentId1" } { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter { $Method -eq 'Delete' -and $URI -eq "$jiraServer/rest/api/latest/attachment/$attachmentId2" } { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter { $Method -eq 'Delete' -and $URI -eq "$jiraServer/rest/api/2/attachment/$attachmentId2" } { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' } @@ -149,8 +149,8 @@ Describe "Remove-JiraIssueAttachment" -Tag 'Unit' { Assert-MockCalled 'Invoke-JiraMethod' -ModuleName JiraPS -ParameterFilter { $Method -eq 'Post' } -Exactly -Times 0 -Scope It Assert-MockCalled 'Invoke-JiraMethod' -ModuleName JiraPS -ParameterFilter { $Method -eq 'Put' } -Exactly -Times 0 -Scope It Assert-MockCalled 'Invoke-JiraMethod' -ModuleName JiraPS -ParameterFilter { $Method -eq 'Delete' } -Exactly -Times 8 -Scope It - Assert-MockCalled 'Invoke-JiraMethod' -ModuleName JiraPS -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/latest/attachment/$attachmentId1" } -Exactly -Times 5 -Scope It - Assert-MockCalled 'Invoke-JiraMethod' -ModuleName JiraPS -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/latest/attachment/$attachmentId2" } -Exactly -Times 3 -Scope It + Assert-MockCalled 'Invoke-JiraMethod' -ModuleName JiraPS -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/2/attachment/$attachmentId1" } -Exactly -Times 5 -Scope It + Assert-MockCalled 'Invoke-JiraMethod' -ModuleName JiraPS -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/2/attachment/$attachmentId2" } -Exactly -Times 3 -Scope It } It 'accepts positional parameters' { { Remove-JiraIssueAttachment $attachmentId1 -Force } | Should Not Throw diff --git a/Tests/Functions/Remove-JiraIssueWatcher.Unit.Tests.ps1 b/Tests/Functions/Remove-JiraIssueWatcher.Unit.Tests.ps1 index ef522b06..3d17b22b 100644 --- a/Tests/Functions/Remove-JiraIssueWatcher.Unit.Tests.ps1 +++ b/Tests/Functions/Remove-JiraIssueWatcher.Unit.Tests.ps1 @@ -49,7 +49,7 @@ Describe "Remove-JiraIssueWatcher" -Tag 'Unit' { $object = [PSCustomObject] @{ ID = $issueID Key = $issueKey - RestUrl = "$jiraServer/rest/api/latest/issue/$issueID" + RestUrl = "$jiraServer/rest/api/2/issue/$issueID" } $object.PSObject.TypeNames.Insert(0, 'JiraPS.Issue') return $object @@ -59,7 +59,7 @@ Describe "Remove-JiraIssueWatcher" -Tag 'Unit' { Get-JiraIssue -Key $Issue } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'DELETE' -and $URI -eq "$jiraServer/rest/api/latest/issue/$issueID/watchers?username=fred"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'DELETE' -and $URI -eq "$jiraServer/rest/api/2/issue/$issueID/watchers?username=fred"} { ShowMockInfo 'Invoke-JiraMethod' -Params 'Uri', 'Method' } diff --git a/Tests/Functions/Remove-JiraVersion.Unit.Tests.ps1 b/Tests/Functions/Remove-JiraVersion.Unit.Tests.ps1 index 8aacda3e..58d6ac1e 100644 --- a/Tests/Functions/Remove-JiraVersion.Unit.Tests.ps1 +++ b/Tests/Functions/Remove-JiraVersion.Unit.Tests.ps1 @@ -58,7 +58,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { "@ $testJsonOne = @" { - "self" : "$jiraServer/rest/api/latest/version/$versionID1", + "self" : "$jiraServer/rest/api/2/version/$versionID1", "id" : $versionID1, "description" : "$versionName", "name" : "$versionName", @@ -70,7 +70,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { $testJsonAll = @" [ { - "self" : "$jiraServer/rest/api/latest/version/$versionID1", + "self" : "$jiraServer/rest/api/2/version/$versionID1", "id" : $versionID1, "description" : "$versionName1", "name" : "$versionName1", @@ -79,7 +79,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { "projectId" : "$projectId" }, { - "self" : "$jiraServer/rest/api/latest/version/$versionID2", + "self" : "$jiraServer/rest/api/2/version/$versionID2", "id" : $versionID2, "description" : "$versionName2", "name" : "$versionName2", @@ -88,7 +88,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { "projectId" : "$projectId" }, { - "self" : "$jiraServer/rest/api/latest/version/$versionID3", + "self" : "$jiraServer/rest/api/2/version/$versionID3", "id" : $versionID3, "description" : "$versionName2", "name" : "$versionName2", @@ -119,7 +119,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { Project = (Get-JiraProject -Project $projectKey) ReleaseDate = (Get-Date "2017-12-01") StartDate = (Get-Date "2017-01-01") - RestUrl = "$jiraServer/rest/api/latest/version/$_Id" + RestUrl = "$jiraServer/rest/api/2/version/$_Id" } $Version.PSObject.TypeNames.Insert(0, 'JiraPS.Version') $Version @@ -165,7 +165,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { { Remove-JiraVersion -Version $versionID1 -Force -ErrorAction Stop } | Should Not Throw Assert-MockCalled 'Get-JiraVersion' -Times 1 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Get-JiraProject' -Times 1 -Scope It -ModuleName JiraPS -Exactly - Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/latest/version/$versionID1" } + Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/2/version/$versionID1" } } It 'removes a Version using the Version Object' { { @@ -174,7 +174,7 @@ Describe "Get-JiraVersion" -Tag 'Unit' { } | Should Not Throw Assert-MockCalled 'Get-JiraVersion' -Times 2 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Get-JiraProject' -Times 2 -Scope It -ModuleName JiraPS -Exactly - Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/latest/version/$versionID1" } + Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/2/version/$versionID1" } } It 'removes a Version using several Version Objects' { { @@ -183,15 +183,15 @@ Describe "Get-JiraVersion" -Tag 'Unit' { } | Should Not Throw Assert-MockCalled 'Get-JiraVersion' -Times 3 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Get-JiraProject' -Times 4 -Scope It -ModuleName JiraPS -Exactly - Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/latest/version/$versionID1" } - Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/latest/version/$versionID2" } + Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/2/version/$versionID1" } + Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/2/version/$versionID2" } } It 'removes a Version using Version as input over the pipeline' { { Get-JiraVersion -Id $versionID1, $versionID2 | Remove-JiraVersion -Force -ErrorAction Stop } | Should Not Throw Assert-MockCalled 'Get-JiraVersion' -Times 3 -Scope It -ModuleName JiraPS -Exactly Assert-MockCalled 'Get-JiraProject' -Times 4 -Scope It -ModuleName JiraPS -Exactly - Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/latest/version/$versionID1" } - Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/latest/version/$versionID2" } + Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/2/version/$versionID1" } + Assert-MockCalled 'Invoke-JiraMethod' -Times 1 -Scope It -ModuleName JiraPS -Exactly -ParameterFilter { $Method -eq 'Delete' -and $URI -like "$jiraServer/rest/api/2/version/$versionID2" } } It "assert VerifiableMock" { Assert-VerifiableMock diff --git a/Tests/Functions/Set-JiraFilter.Unit.Tests.ps1 b/Tests/Functions/Set-JiraFilter.Unit.Tests.ps1 index e0230ce3..52ad68f4 100644 --- a/Tests/Functions/Set-JiraFilter.Unit.Tests.ps1 +++ b/Tests/Functions/Set-JiraFilter.Unit.Tests.ps1 @@ -42,7 +42,7 @@ Describe 'Set-JiraFilter' -Tag 'Unit' { $responseFilter = @" { - "self": "$jiraServer/rest/api/latest/filter/12844", + "self": "$jiraServer/rest/api/2/filter/12844", "id": "12844", "name": "All JIRA Bugs", "owner": { @@ -60,7 +60,7 @@ Describe 'Set-JiraFilter' -Tag 'Unit' { }, "jql": "project = 10240 AND issuetype = 1 ORDER BY key DESC", "viewUrl": "$jiraServer/secure/IssueNavigator.jspa?mode=hide&requestId=12844", - "searchUrl": "$jiraServer/rest/api/latest/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC", + "searchUrl": "$jiraServer/rest/api/2/search?jql=project+%3D+10240+AND+issuetype+%3D+1+ORDER+BY+key+DESC", "favourite": false, "sharePermissions": [ { diff --git a/Tests/Functions/Set-JiraUser.Unit.Tests.ps1 b/Tests/Functions/Set-JiraUser.Unit.Tests.ps1 index 8db76538..c0b08eb0 100644 --- a/Tests/Functions/Set-JiraUser.Unit.Tests.ps1 +++ b/Tests/Functions/Set-JiraUser.Unit.Tests.ps1 @@ -67,7 +67,7 @@ Describe "Set-JiraUser" -Tag 'Unit' { return $object } - Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Put' -and $URI -eq "$jiraServer/rest/api/latest/user?username=$testUsername"} { + Mock Invoke-JiraMethod -ModuleName JiraPS -ParameterFilter {$Method -eq 'Put' -and $URI -eq "$jiraServer/rest/api/2/user?username=$testUsername"} { ShowMockInfo 'Invoke-JiraMethod' 'Method', 'Uri' ConvertFrom-Json $restResultGet } From 58ea2b57840b28fd7c67b3db39bb41fd879b59d0 Mon Sep 17 00:00:00 2001 From: Oliver Lipkau Date: Mon, 9 Mar 2020 08:59:52 +0100 Subject: [PATCH 2/4] Fixed git script in deployment --- JiraPS.build.ps1 | 18 +++++++++++------- Tools/BuildTools.psm1 | 21 +++++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/JiraPS.build.ps1 b/JiraPS.build.ps1 index be39e00e..8e52c6bc 100644 --- a/JiraPS.build.ps1 +++ b/JiraPS.build.ps1 @@ -64,19 +64,19 @@ task GetNextVersion { #region HarmonizeVariables switch ($true) { - {$IsWindows} { + { $IsWindows } { $OS = "Windows" if (-not ($IsCoreCLR)) { $OSVersion = $PSVersionTable.BuildVersion.ToString() } } - {$IsLinux} { + { $IsLinux } { $OS = "Linux" } - {$IsMacOs} { + { $IsMacOs } { $OS = "OSX" } - {$IsCoreCLR} { + { $IsCoreCLR } { $OSVersion = $PSVersionTable.OS } } @@ -185,7 +185,7 @@ task GenerateExternalHelp Init, { task UpdateManifest GetNextVersion, { Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue Import-Module $env:BHPSModuleManifest -Force - $ModuleAlias = @(Get-Alias | Where-Object {$_.ModuleName -eq "$env:BHProjectName"}) + $ModuleAlias = @(Get-Alias | Where-Object { $_.ModuleName -eq "$env:BHProjectName" }) BuildHelpers\Update-Metadata -Path "$env:BHBuildOutput/$env:BHProjectName/$env:BHProjectName.psd1" -PropertyName ModuleVersion -Value $env:NextBuildVersion # BuildHelpers\Update-Metadata -Path "$env:BHBuildOutput/$env:BHProjectName/$env:BHProjectName.psd1" -PropertyName FileList -Value (Get-ChildItem "$env:BHBuildOutput/$env:BHProjectName" -Recurse).Name @@ -247,7 +247,7 @@ task Deploy Init, PublishToGallery, TagReplository, UpdateHomepage # Synpsis: Publish the $release to the PSGallery task PublishToGallery { Assert-True (-not [String]::IsNullOrEmpty($PSGalleryAPIKey)) "No key for the PSGallery" - Assert-True {Get-Module $env:BHProjectName -ListAvailable} "Module $env:BHProjectName is not available" + Assert-True { Get-Module $env:BHProjectName -ListAvailable } "Module $env:BHProjectName is not available" Remove-Module $env:BHProjectName -ErrorAction Ignore @@ -258,6 +258,8 @@ task PublishToGallery { task TagReplository GetNextVersion, Package, { $releaseText = "Release version $env:NextBuildVersion" + Set-GitUser + # Push a tag to the repository Write-Build Gray "git checkout $ENV:BHBranchName" cmd /c "git checkout $ENV:BHBranchName 2>&1" @@ -283,6 +285,8 @@ task TagReplository GetNextVersion, Package, { # Synopsis: Update the version of this module that the homepage uses task UpdateHomepage { try { + Set-GitUser + Write-Build Gray "git close .../AtlassianPS.github.io --recursive" $null = cmd /c "git clone https://github.com/AtlassianPS/AtlassianPS.github.io --recursive 2>&1" @@ -307,7 +311,7 @@ task UpdateHomepage { Pop-Location } - catch { Write-Warning "Failed to deploy to homepage"} + catch { Write-Warning "Failed to deploy to homepage" } } #endregion Publish diff --git a/Tools/BuildTools.psm1 b/Tools/BuildTools.psm1 index e608861a..0ca5f54c 100644 --- a/Tools/BuildTools.psm1 +++ b/Tools/BuildTools.psm1 @@ -10,13 +10,6 @@ function Invoke-Init { begin { Set-BuildEnvironment -BuildOutput '$ProjectPath/Release' -ErrorAction SilentlyContinue Add-ToModulePath -Path $env:BHBuildOutput - - # github's PAT is stored to ~\.git-credentials within the Release Pipeline - # to avoid it being passed as parameter - - git config --global user.email "support@atlassianps.net" - git config --global user.name "AtlassianPS Automated User" - git config --global credential.helper "store --file ~/.git-credentials" } } @@ -66,7 +59,8 @@ function Install-Dependency { try { Set-PSRepository PSGallery -InstallationPolicy Trusted $RequiredModules | Install-Module -Scope $Scope -Repository PSGallery -SkipPublisherCheck -AllowClobber - } finally { + } + finally { Set-PSRepository PSGallery -InstallationPolicy $Policy } $RequiredModules | Import-Module @@ -254,4 +248,15 @@ function Remove-Utf8Bom { } } +function Set-GitUser { + [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")] + param() + # github's PAT is stored to ~\.git-credentials within the Release Pipeline + # to avoid it being passed as parameter + + if (-not (git config user.email)) { git config user.email "support@atlassianps.net" } + if (-not (git config user.name)) { git config user.name "AtlassianPS Automated User" } + if (-not (git config credential.helper)) { git config credential.helper "store --file ~/.git-credentials" } +} + Export-ModuleMember -Function * -Alias * From f7e04b7b4936725c403dec1f90e0f48a9a763868 Mon Sep 17 00:00:00 2001 From: Oliver Lipkau Date: Mon, 23 Mar 2020 08:43:22 +0100 Subject: [PATCH 3/4] Fixed tests for PSv7 --- Tests/Help.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Help.Tests.ps1 b/Tests/Help.Tests.ps1 index 65375318..e66be072 100644 --- a/Tests/Help.Tests.ps1 +++ b/Tests/Help.Tests.ps1 @@ -50,7 +50,7 @@ Describe "Help tests" -Tag Documentation { ) $module = Get-Module $env:BHProjectName - $commands = Get-Command -Module $module -CommandType Cmdlet, Function, Workflow # Not alias + $commands = Get-Command -Module $env:BHProjectName -CommandType Cmdlet, Function # Not alias # $classes = Get-ChildItem "$env:BHProjectPath/docs/en-US/classes/*" # $enums = Get-ChildItem "$env:BHProjectPath/docs/en-US/enumerations/*" From 85acc262e019621bba4a10fd31e697b56c57d95a Mon Sep 17 00:00:00 2001 From: Oliver Lipkau Date: Sat, 28 Mar 2020 10:38:38 +0100 Subject: [PATCH 4/4] Bumped version to 2.14 --- .vscode/extensions.json | 3 +-- CHANGELOG.md | 9 +++++++++ JiraPS/JiraPS.psd1 | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c54ae4a6..f4b2d754 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,7 +3,6 @@ // for the documentation about the extensions.json format "recommendations": [ "ms-vscode.PowerShell", - "DavidAnson.vscode-markdownlint", - "streetsidesoftware.code-spell-checker" + "DavidAnson.vscode-markdownlint" ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index f22a6420..1a1a3fba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ ## [NEXT VERSION] - YYYY-MM-DD +## [2.14] - 2020-03-28 + +### Changed + +- Changed all commands to only use Jira's api version 2. (#409, [@lipkau]) + This is a temporary fix and should be reverted to version `latest` as soon as + a proper handling of how users work between cloud and on-premise is + implemented + ## [2.13] - 2020-02-23 ### Added diff --git a/JiraPS/JiraPS.psd1 b/JiraPS/JiraPS.psd1 index 71fca9ed..c57b900b 100644 --- a/JiraPS/JiraPS.psd1 +++ b/JiraPS/JiraPS.psd1 @@ -4,7 +4,7 @@ RootModule = 'JiraPS.psm1' # Version number of this module. - ModuleVersion = '2.13' + ModuleVersion = '2.14' # Supported PSEditions # CompatiblePSEditions = @()