Skip to content

Commit

Permalink
Convert snmp params to uppercase. Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
staley1975 committed Nov 18, 2023
1 parent f71ad2b commit c268f57
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PowerArubaCP/Public/NetworkDevice.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Add-ArubaCPNetworkDevice {
throw "If snmp_version is specified, community_string is mandatory."
}
$snmp_read = @{
snmp_version = $snmp_version
snmp_version = $snmp_version.ToUpper()
community_string = $community_string
zone_name = "default"
}
Expand Down Expand Up @@ -385,7 +385,7 @@ function Set-ArubaCPNetworkDevice {
throw "If snmp_version is specified, community_string is mandatory."
}
$snmp_read = @{
snmp_version = $snmp_version
snmp_version = $snmp_version.ToUpper()
community_string = $community_string
zone_name = "default"
}
Expand Down
54 changes: 54 additions & 0 deletions Tests/integration/NetworkDevice.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,60 @@ Describe "Remove Network Device" {

}

Describe "Add Network Device" {

It "Add Network Device with snmp v2c" {
Add-ArubaCPNetworkDevice -name pester_SW6 -ip_address 192.0.2.6 -radius_secret MySecurePassword -vendor Cisco -snmp_version v2c -community_string myString
$nad = Get-ArubaCPNetworkDevice -name pester_SW6
$nad.name | Should -Be "pester_SW6"
$nad.ip_address | Should -Be "192.0.2.6"
$nad.vendor_name | Should -Be "Cisco"
$nad.snmp_read.snmp_version | Should -Be "v2c"
$nad.snmp_read.zone_name | Should -Be "default"
# community_string is always empty
}

It "Add Network Device with snmp v1" {
Add-ArubaCPNetworkDevice -name pester_SW6 -ip_address 192.0.2.6 -radius_secret MySecurePassword -vendor Cisco -snmp_version v1 -community_string myString
$nad = Get-ArubaCPNetworkDevice -name pester_SW6
$nad.name | Should -Be "pester_SW6"
$nad.ip_address | Should -Be "192.0.2.6"
$nad.vendor_name | Should -Be "Cisco"
$nad.snmp_read.snmp_version | Should -Be "v1"
$nad.snmp_read.zone_name | Should -Be "default"
# community_string is always empty
}

It "Add Network Device with snmp v2c then change it to v1" {
Add-ArubaCPNetworkDevice -name pester_SW6 -ip_address 192.0.2.6 -radius_secret MySecurePassword -vendor Cisco -snmp_version v2c -community_string myString
Get-ArubaCPNetworkDevice -name pester_SW6 | Set-ArubaCPNetworkDevice -snmp_version v1 -community_string myString
$nad = Get-ArubaCPNetworkDevice -name pester_SW6
$nad.name | Should -Be "pester_SW6"
$nad.ip_address | Should -Be "192.0.2.6"
$nad.vendor_name | Should -Be "Cisco"
$nad.snmp_read.snmp_version | Should -Be "v1"
$nad.snmp_read.zone_name | Should -Be "default"
# community_string is always empty
}

It "Add Network Device with snmp v1 then change it to v2c" {
Add-ArubaCPNetworkDevice -name pester_SW6 -ip_address 192.0.2.6 -radius_secret MySecurePassword -vendor Cisco -snmp_version v1 -community_string myString
Get-ArubaCPNetworkDevice -name pester_SW6 | Set-ArubaCPNetworkDevice -snmp_version v2c -community_string myString
$nad = Get-ArubaCPNetworkDevice -name pester_SW6
$nad.name | Should -Be "pester_SW6"
$nad.ip_address | Should -Be "192.0.2.6"
$nad.vendor_name | Should -Be "Cisco"
$nad.snmp_read.snmp_version | Should -Be "v2c"
$nad.snmp_read.zone_name | Should -Be "default"
# community_string is always empty
}

AfterEach {
Get-ArubaCPNetworkDevice -name pester_SW6 | Remove-ArubaCPNetworkDevice -confirm:$false
}

}

AfterAll {
Disconnect-ArubaCP -confirm:$false
}

0 comments on commit c268f57

Please sign in to comment.