Skip to content

Commit 9089f21

Browse files
authored
Merge pull request #54 from Sam-Martin/development
v1.2.2 - Bug fix for Update-ServiceNowNumber
2 parents 72227e0 + 3886b20 commit 9089f21

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ServiceNow
22

3-
[![GitHub release](https://img.shields.io/github/release/Sam-Martin/servicenow-powershell.svg)](https://github.com/Sam-Martin/servicenow-powershell/releases/latest) [![GitHub license](https://img.shields.io/github/license/Sam-Martin/servicenow-powershell.svg)](LICENSE) ![Test Coverage](https://img.shields.io/badge/coverage-78%25-yellow.svg)
3+
[![GitHub release](https://img.shields.io/github/release/Sam-Martin/servicenow-powershell.svg)](https://github.com/Sam-Martin/servicenow-powershell/releases/latest) [![GitHub license](https://img.shields.io/github/license/Sam-Martin/servicenow-powershell.svg)](LICENSE) ![Test Coverage](https://img.shields.io/badge/coverage-80%25-yellow.svg)
44

55
This PowerShell module provides a series of cmdlets for interacting with the [ServiceNow REST API](http://wiki.servicenow.com/index.php?title=REST_API), performed by wrapping `Invoke-RestMethod` for the API calls.
66

ServiceNow/Public/Update-ServiceNowNumber.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ Function Update-ServiceNowNumber {
7070
# Process credential steps based on parameter set name
7171
Switch ($PSCmdlet.ParameterSetName) {
7272
'SpecifyConnectionFields' {
73+
$getServiceNowTableEntry.Add('ServiceNowCredential',$Credential)
74+
$getServiceNowTableEntry.Add('ServiceNowURL',$ServiceNowURL)
7375
$ServiceNowURL = 'https://' + $ServiceNowURL + '/api/now/v1'
74-
$updateServiceNowTableEntrySplat.Add('ServiceNowCredential',$ServiceNowCredential)
75-
$updateServiceNowTableEntrySplat.Add('ServiceNowURL',$ServiceNowURL)
7676
}
7777
'UseConnectionObject' {
78+
$getServiceNowTableEntry.Add('Connection',$Connection)
7879
$SecurePassword = ConvertTo-SecureString $Connection.Password -AsPlainText -Force
7980
$Credential = New-Object System.Management.Automation.PSCredential ($Connection.Username, $SecurePassword)
8081
$ServiceNowURL = 'https://' + $Connection.ServiceNowUri + '/api/now/v1'
81-
$updateServiceNowTableEntrySplat.Add('Connection',$Connection)
8282
}
8383
Default {
8484
If ((Test-ServiceNowAuthIsSet)) {

ServiceNow/ServiceNow.psd1

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'ServiceNow.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.2.1'
15+
ModuleVersion = '1.2.2'
1616

1717
# ID used to uniquely identify this module
1818
GUID = 'b90d67da-f8d0-4406-ad74-89d169cd0633'
@@ -103,3 +103,5 @@ PrivateData = @{
103103

104104

105105

106+
107+

Tests/ServiceNow.Tests.ps1

+35
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,41 @@ Describe "ServiceNow-Module" {
202202
$TestTicket.description | Should -Be 'Updated by Pester test Update-ServiceNowNumber works'
203203
}
204204

205+
It "Update-ServiceNowNumber with SpecifyConnectionFields works" {
206+
$ShortDescription = 'Testing Ticket Update with Pester'
207+
$newServiceNowIncidentSplat = @{
208+
Caller = $Defaults.TestUser
209+
ShortDescription = $ShortDescription
210+
Description = 'Long description'
211+
AssignmentGroup = $Defaults.TestUserGroup
212+
Comment = 'Comment'
213+
Category = $Defaults.TestCategory
214+
SubCategory = $Defaults.TestSubcategory
215+
ConfigurationItem = $Defaults.TestConfigurationItem
216+
}
217+
$TestTicket = New-ServiceNowIncident @newServiceNowIncidentSplat
218+
219+
$TestTicket.short_description | Should -Be $ShortDescription
220+
221+
$Values = @{
222+
'short_description' = 'Ticket Updated with Pester (Update-ServiceNowNumber)'
223+
'description' = 'Updated by Pester test Update-ServiceNowNumber with SpecifyConnectionFields works'
224+
}
225+
226+
$updateServiceNowNumberSplat = @{
227+
Number = $TestTicket.Number
228+
Table = 'incident'
229+
Values = $Values
230+
Credential = $Defaults.Creds
231+
ServiceNowURL = $Defaults.ServiceNowURL
232+
}
233+
Update-ServiceNowNumber @updateServiceNowNumberSplat
234+
235+
$TestTicket = Get-ServiceNowIncident -MatchExact @{sys_id=$TestTicket.sys_id}
236+
$TestTicket.short_description | Should -Be 'Ticket Updated with Pester (Update-ServiceNowNumber)'
237+
$TestTicket.description | Should -Be 'Updated by Pester test Update-ServiceNowNumber with SpecifyConnectionFields works'
238+
}
239+
205240
# Remove Functions
206241
It "Remove-ServiceNowTable works" {
207242
$TestTicket = Get-ServiceNowIncident -Limit 1

0 commit comments

Comments
 (0)