Skip to content

Commit

Permalink
Merge pull request #54 from Sam-Martin/development
Browse files Browse the repository at this point in the history
v1.2.2 - Bug fix for Update-ServiceNowNumber
  • Loading branch information
Rick-2CA authored Oct 5, 2018
2 parents 72227e0 + 3886b20 commit 9089f21
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ServiceNow

[![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)
[![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)

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.

Expand Down
6 changes: 3 additions & 3 deletions ServiceNow/Public/Update-ServiceNowNumber.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ Function Update-ServiceNowNumber {
# Process credential steps based on parameter set name
Switch ($PSCmdlet.ParameterSetName) {
'SpecifyConnectionFields' {
$getServiceNowTableEntry.Add('ServiceNowCredential',$Credential)
$getServiceNowTableEntry.Add('ServiceNowURL',$ServiceNowURL)
$ServiceNowURL = 'https://' + $ServiceNowURL + '/api/now/v1'
$updateServiceNowTableEntrySplat.Add('ServiceNowCredential',$ServiceNowCredential)
$updateServiceNowTableEntrySplat.Add('ServiceNowURL',$ServiceNowURL)
}
'UseConnectionObject' {
$getServiceNowTableEntry.Add('Connection',$Connection)
$SecurePassword = ConvertTo-SecureString $Connection.Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($Connection.Username, $SecurePassword)
$ServiceNowURL = 'https://' + $Connection.ServiceNowUri + '/api/now/v1'
$updateServiceNowTableEntrySplat.Add('Connection',$Connection)
}
Default {
If ((Test-ServiceNowAuthIsSet)) {
Expand Down
4 changes: 3 additions & 1 deletion ServiceNow/ServiceNow.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'ServiceNow.psm1'

# Version number of this module.
ModuleVersion = '1.2.1'
ModuleVersion = '1.2.2'

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





35 changes: 35 additions & 0 deletions Tests/ServiceNow.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,41 @@ Describe "ServiceNow-Module" {
$TestTicket.description | Should -Be 'Updated by Pester test Update-ServiceNowNumber works'
}

It "Update-ServiceNowNumber with SpecifyConnectionFields works" {
$ShortDescription = 'Testing Ticket Update with Pester'
$newServiceNowIncidentSplat = @{
Caller = $Defaults.TestUser
ShortDescription = $ShortDescription
Description = 'Long description'
AssignmentGroup = $Defaults.TestUserGroup
Comment = 'Comment'
Category = $Defaults.TestCategory
SubCategory = $Defaults.TestSubcategory
ConfigurationItem = $Defaults.TestConfigurationItem
}
$TestTicket = New-ServiceNowIncident @newServiceNowIncidentSplat

$TestTicket.short_description | Should -Be $ShortDescription

$Values = @{
'short_description' = 'Ticket Updated with Pester (Update-ServiceNowNumber)'
'description' = 'Updated by Pester test Update-ServiceNowNumber with SpecifyConnectionFields works'
}

$updateServiceNowNumberSplat = @{
Number = $TestTicket.Number
Table = 'incident'
Values = $Values
Credential = $Defaults.Creds
ServiceNowURL = $Defaults.ServiceNowURL
}
Update-ServiceNowNumber @updateServiceNowNumberSplat

$TestTicket = Get-ServiceNowIncident -MatchExact @{sys_id=$TestTicket.sys_id}
$TestTicket.short_description | Should -Be 'Ticket Updated with Pester (Update-ServiceNowNumber)'
$TestTicket.description | Should -Be 'Updated by Pester test Update-ServiceNowNumber with SpecifyConnectionFields works'
}

# Remove Functions
It "Remove-ServiceNowTable works" {
$TestTicket = Get-ServiceNowIncident -Limit 1
Expand Down

0 comments on commit 9089f21

Please sign in to comment.