From eebf665e783218fd3f271e5d0a5ea092c01835be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Moreau?= Date: Tue, 23 Nov 2021 10:38:02 +0100 Subject: [PATCH 1/7] Add Tacacs Server configuration (Add/Get/Set/Remove) --- PowerArubaCX/Private/Confirm.ps1 | 32 +++ PowerArubaCX/Public/Tacacs.ps1 | 363 +++++++++++++++++++++++++++++ Tests/common.ps1 | 2 + Tests/integration/Tacacs.Tests.ps1 | 222 ++++++++++++++++++ 4 files changed, 619 insertions(+) create mode 100644 PowerArubaCX/Public/Tacacs.ps1 create mode 100644 Tests/integration/Tacacs.Tests.ps1 diff --git a/PowerArubaCX/Private/Confirm.ps1 b/PowerArubaCX/Private/Confirm.ps1 index a514d44..c528869 100644 --- a/PowerArubaCX/Private/Confirm.ps1 +++ b/PowerArubaCX/Private/Confirm.ps1 @@ -119,4 +119,36 @@ function Confirm-ArubaCXVrfs { throw "Element specified does not contain a ssh_enable property." } $true +} + +function Confirm-ArubaCXTacacsServer { + + Param ( + [Parameter (Mandatory = $true)] + [object]$argument + ) + #Check if it looks like a tacacs server element + + if ( -not ( $argument | get-member -name auth_type -Membertype Properties)) { + throw "Element specified does not contain an auth_type property." + } + if ( -not ( $argument | get-member -name default_group_priority -Membertype Properties)) { + throw "Element specified does not contain a default_group_priority property." + } + if ( -not ( $argument | get-member -name group -Membertype Properties)) { + throw "Element specified does not contain a group property." + } + if ( -not ( $argument | get-member -name passkey -Membertype Properties)) { + throw "Element specified does not contain a passkey property." + } + if ( -not ( $argument | get-member -name timeout -Membertype Properties)) { + throw "Element specified does not contain a timeout property." + } + if ( -not ( $argument | get-member -name tracking_enable -Membertype Properties)) { + throw "Element specified does not contain a tracking_enable property." + } + if ( -not ( $argument | get-member -name user_group_priority -Membertype Properties)) { + throw "Element specified does not contain a user_group_priority property." + } + $true } \ No newline at end of file diff --git a/PowerArubaCX/Public/Tacacs.ps1 b/PowerArubaCX/Public/Tacacs.ps1 new file mode 100644 index 0000000..ff7d5ce --- /dev/null +++ b/PowerArubaCX/Public/Tacacs.ps1 @@ -0,0 +1,363 @@ +# +# Copyright 2021, Cédric Moreau +# +# SPDX-License-Identifier: Apache-2.0 +# + +function Add-ArubaCXTacacsServer { + + <# + .SYNOPSIS + Add Aruba CX Tacacs Server + + .DESCRIPTION + Add tacacs server (ip, group, port...) + + .EXAMPLE + Add-ArubaCXTacacsServer -address 192.2.0.1 -port 49 -group Clearpass -default_group_priority 10 + + Add tacacs server with ip 192.2.0.1 and port 49 in Tacacs group Clearpass + #> + Param( + [Parameter (Mandatory = $true)] + [string]$address, + [Parameter (Mandatory = $true)] + [ValidateRange(1, 65535)] + [int]$port, + [Parameter (Mandatory = $false)] + [ValidateSet('pap')] + [string]$auth_type = "pap", + [Parameter (Mandatory = $true)] + [ValidateRange(1, 9223372036854775807)] + [int]$default_group_priority, + [Parameter (Mandatory = $true)] + [string]$group, + [Parameter (Mandatory = $false)] + [string]$passkey, + [Parameter (Mandatory = $false)] + [int]$timeout, + [Parameter (Mandatory = $false)] + [switch]$tracking_enable, + [Parameter (Mandatory = $false)] + [int]$user_group_priority, + [Parameter (Mandatory = $false)] + [string]$vrf = "default", + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [PSObject]$connection = $DefaultArubaCXConnection + ) + + Begin { + } + + Process { + + $uri = "system/vrfs/${vrf}/tacacs_servers" + + $_tacacs = new-Object -TypeName PSObject + + $_tacacs | add-member -name "address" -membertype NoteProperty -Value $address + + $_tacacs | add-member -name "tcp_port" -membertype NoteProperty -Value $port + + $_tacacs | add-member -name "vrf" -membertype NoteProperty -Value ("/rest/" + $($connection.version) + "/system/vrfs/" + $vrf) + + $_tacacs | add-member -name "default_group_priority" -membertype NoteProperty -Value $default_group_priority + + $_group = @() + + $_group += "/rest/" + $($connection.version) + "/system/aaa_server_groups/" + $group + + $_tacacs | add-member -name "group" -membertype NoteProperty -Value $_group + + $_tacacs | add-member -name "auth_type" -membertype NoteProperty -Value $auth_type + + if ( $PsBoundParameters.ContainsKey('passkey') ) { + $_tacacs | add-member -name "passkey" -membertype NoteProperty -Value $passkey + } + + if ( $PsBoundParameters.ContainsKey('timeout') ) { + $_tacacs | add-member -name "timeout" -membertype NoteProperty -Value $timeout + } + + if ( $PsBoundParameters.ContainsKey('user_group_priority') ) { + $_tacacs | add-member -name "user_group_priority" -membertype NoteProperty -Value $user_group_priority + } + + if ( $PsBoundParameters.ContainsKey('tracking_enable') ) { + if ($tracking_enable) { + $_tacacs | add-member -name "tracking_enable" -membertype NoteProperty -Value $true + } + else { + $_tacacs | add-member -name "tracking_enable" -membertype NoteProperty -Value $false + } + } + + $response = Invoke-ArubaCXRestMethod -uri $uri -method 'POST' -body $_tacacs -connection $connection + $response + + Get-ArubaCXTacacsServer -address $address -port $port -vrf $vrf + + } + + End { + } +} + +function Get-ArubaCXTacacsServer { + + <# + .SYNOPSIS + Get list of tacacs server configured + + .DESCRIPTION + Get list of tacacs server configured (ip, group, port...) + + .EXAMPLE + Get-ArubaCXTacacsServer -vrf default + + Get list of tacacs server configured (ip, group, port...) on default vrf + + .EXAMPLE + Get-ArubaCXTacacsServer -address 192.2.0.1 -port 49 + + Get tacacs server with ip 192.2.0.1 and port 49 + #> + + [CmdletBinding(DefaultParametersetname = "Default")] + Param( + [Parameter (Mandatory = $true, ParameterSetName = "address")] + [ipaddress]$address, + [Parameter (Mandatory = $true, ParameterSetName = "address")] + [int]$port, + [Parameter (Mandatory = $false)] + [string]$vrf = "default", + [Parameter(Mandatory = $false)] + [ValidateRange(1, 4)] + [Int]$depth, + [Parameter(Mandatory = $false)] + [ValidateSet("configuration", "status", "statistics", "writable")] + [String]$selector, + [Parameter(Mandatory = $false)] + [String[]]$attributes, + [Parameter(Mandatory = $false)] + [switch]$vsx_peer, + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [PSObject]$connection = $DefaultArubaCXConnection + ) + + Begin { + } + + Process { + + + $invokeParams = @{ } + if ( $PsBoundParameters.ContainsKey('depth') ) { + $invokeParams.add( 'depth', $depth ) + } + else { + #by default set depth to 2 to show items + $invokeParams.add( 'depth', 2 ) + } + if ( $PsBoundParameters.ContainsKey('selector') ) { + $invokeParams.add( 'selector', $selector ) + } + if ( $PsBoundParameters.ContainsKey('attributes') ) { + $invokeParams.add( 'attributes', $attributes ) + } + if ( $PsBoundParameters.ContainsKey('vsx_peer') ) { + $invokeParams.add( 'vsx_peer', $true ) + } + + if ($PsBoundParameters.ContainsKey('address') -and $PsBoundParameters.ContainsKey('port')) { + $uri = "system/vrfs/${vrf}/tacacs_servers/${address},${port}" + } + else { + $uri = "system/vrfs/${vrf}/tacacs_servers" + } + + $response = Invoke-ArubaCXRestMethod -uri $uri -method 'GET' -connection $connection @invokeParams + + $response + + } + + End { + } +} + +function Set-ArubaCXTacacsServer { + + <# + .SYNOPSIS + Configure Tacacs Server ArubaCX Switch + + .DESCRIPTION + Configure Tacacs Server (Timeout, port...) + + .EXAMPLE + Set-ArubaCXTacacsServer -timeout 15 -address 192.2.0.1 -tcp_port + + Configure timeout on tacacs server + + .EXAMPLE + Set-ArubaCXTacacsServer -group tacacs -address 192.2.0.1 -tcp_port + + Configure group on tacacs server + + .EXAMPLE + Set-ArubaCXTacacsServer -passkey ExampleRadius -address 192.2.0.1 -tcp_port + + Configure passkey on tacacs server + #> + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'medium')] + Param( + [Parameter (Mandatory = $true, ValueFromPipeline = $true, Position = 1, ParameterSetName = "ID")] + [ValidateScript( { Confirm-ArubaCXTacacsServer $_ })] + [psobject]$tacacs, + [Parameter (Mandatory = $true, ParameterSetName = "address")] + [string]$address, + [Parameter (Mandatory = $true, ParameterSetName = "address")] + [int]$port, + [Parameter (Mandatory = $false)] + [ValidateSet('pap')] + [string]$auth_type, + [Parameter (Mandatory = $false)] + [ValidateRange(1, 9223372036854775807)] + [int]$default_group_priority, + [Parameter (Mandatory = $false)] + [string]$group, + [Parameter (Mandatory = $false)] + [string]$passkey, + [Parameter (Mandatory = $false)] + [int]$timeout, + [Parameter (Mandatory = $false)] + [switch]$tracking_enable, + [Parameter (Mandatory = $false)] + [int]$user_group_priority, + [Parameter (Mandatory = $false)] + [string]$vrf = "default", + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [PSObject]$connection = $DefaultArubaCXConnection + ) + + + Begin { + } + + Process { + + if ($tacacs) { + $address = $tacacs.address + $port = $tacacs.tcp_port + } + + $uri = "system/vrfs/${vrf}/tacacs_servers/${address},${port}" + + if ($tacacs) { + $_tacacs = $tacacs + $_tacacs.PSObject.Properties.Remove('address') + $_tacacs.PSObject.Properties.Remove('tcp_port') + } + else { + $_tacacs = Get-ArubaCXTacacsServer -address $address -port $port -selector writable -connection $connection + } + + if ( $PsBoundParameters.ContainsKey('auth_type') ) { + $_tacacs.auth_type = $auth_type + } + if ( $PsBoundParameters.ContainsKey('default_group_priority') ) { + $_tacacs.default_group_priority = $default_group_priority + } + if ( $PsBoundParameters.ContainsKey('group') ) { + $_group = @() + + $_group += "/rest/" + $($connection.version) + "/system/aaa_server_groups/" + $group + + $_tacacs.group = $_group + } + if ( $PsBoundParameters.ContainsKey('passkey') ) { + $_tacacs.passkey = $passkey + } + if ( $PsBoundParameters.ContainsKey('timeout') ) { + $_tacacs.timeout = $timeout + } + if ( $PsBoundParameters.ContainsKey('tracking_enable') ) { + $_tacacs.tracking_enable = $true + } + else { + $_tacacs.tracking_enable = $false + } + if ( $PsBoundParameters.ContainsKey('user_group_priority') ) { + $_tacacs.user_group_priority = $user_group_priority + } + + if ($PSCmdlet.ShouldProcess($_tacacs.address, 'Configure Tacacs Server')) { + Invoke-ArubaCXRestMethod -method "PUT" -body $_tacacs -uri $uri -connection $connection + } + + Get-ArubaCXTacacsServer -address $address -port $port -connection $connection + } + + End { + } +} + +function Remove-ArubaCXTacacsServer { + + <# + .SYNOPSIS + Remove a tacacs server on Aruba CX Switch + .DESCRIPTION + Remove a tacacs server on Aruba CX Switch + .EXAMPLE + $ts = Get-ArubaCXArubaCXTacacsServer -address 192.2.0.1 -port 49 + PS C:\>$ts | Remove-ArubaCXTacacsServer + Remove tacacs server with address 192.0.2.1 and port 49 + .EXAMPLE + Remove-ArubaCXTacacsServer -address 192.2.0.1 -confirm:$false -vrf default + Remove tacacs server 192.0.2.1 on default vrf with no confirmation + #> + + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'high')] + Param( + [Parameter (Mandatory = $true, ParameterSetName = "address")] + [string]$address, + [Parameter (Mandatory = $true, ParameterSetName = "address")] + [int]$port, + [Parameter (Mandatory = $true, ValueFromPipeline = $true, Position = 1, ParameterSetName = "ID")] + [ValidateScript( { Confirm-ArubaCXTacacsServer $_ })] + [psobject]$ts, + [Parameter(Mandatory = $false, ParameterSetName = "address")] + [string]$vrf = "default", + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [PSObject]$connection = $DefaultArubaCXConnection + ) + + Begin { + } + + Process { + + #get address, port and vrf from tacacs server ts object + if ($ts) { + $address = $ts.address + $port = $ts.tcp_port + } + + $uri = "system/vrfs/${vrf}/tacacs_servers/${address},${port}" + + if ($PSCmdlet.ShouldProcess("Tacacs Server (VRF: ${vrf})", "Remove ${address},${port}")) { + Write-Progress -activity "Remove Tacacs Server" + Invoke-ArubaCXRestMethod -method "DELETE" -uri $uri -connection $connection + Write-Progress -activity "Remove Tacacs Server" -completed + } + } + + End { + } +} \ No newline at end of file diff --git a/Tests/common.ps1 b/Tests/common.ps1 index 8046ad3..a42cce8 100644 --- a/Tests/common.ps1 +++ b/Tests/common.ps1 @@ -13,6 +13,8 @@ $script:pester_interface2 = "1/1/2" #interface id for test... $script:pester_lag = "2" #lag id for test... $script:pester_loopback = "2" #loopback id for test... $script:pester_vrf = "pester_vrf" #interface id for test... +$script:pester_tacacs_address = "192.2.0.1" +$script:pester_tacacs_port = "49" . ../credential.ps1 #TODO: Add check if no ipaddress/login/password info... diff --git a/Tests/integration/Tacacs.Tests.ps1 b/Tests/integration/Tacacs.Tests.ps1 new file mode 100644 index 0000000..782fd5d --- /dev/null +++ b/Tests/integration/Tacacs.Tests.ps1 @@ -0,0 +1,222 @@ +# +# Copyright 2020, Cédric Moreau +# +# SPDX-License-Identifier: Apache-2.0 +# +. ../common.ps1 + +Describe "Get Tacacs Server" { + BeforeALL { + Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -auth_type pap -timeout 15 + } + + It "Get Tacacs Server Does not throw an error" { + { + Get-ArubaCXTacacsServer + } | Should Not Throw + } + + It "Get ALL Tacacs Server" { + $tacacs = Get-ArubaCXTacacsServer + $tacacs.count | Should -Not -Be $NULL + } + + It "Get Tacacs Server ($pester_tacacs_address)" { + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs.address | Should -Be $pester_tacacs_address + $tacacs.tcp_port | Should -Be $pester_tacacs_port + } + + It "Get Tacacs Server ($pester_tacacs_address) and confirm (via Confirm-ArubaCXVlans)" { + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + Confirm-ArubaCXTacacsServer ($tacacs) | Should -Be $true + } + + #Get with attribute, depth... + Context "Selector" { + + It "Get Tacacs Server with selector equal configuration" { + { + Get-ArubaCXTacacsServer -selector configuration + } | Should Not Throw + } + + It "Get Tacacs Server with selector equal statistics" { + { + Get-ArubaCXTacacsServer -selector statistics + } | Should Not Throw + } + + It "Get Tacacs Server with selector equal status" { + { + Get-ArubaCXTacacsServer -selector status + } | Should Not Throw + } + + It "Get Tacacs Server with selector equal writable" { + { + Get-ArubaCXTacacsServer -selector writable + } | Should Not Throw + } + } + + Context "Depth" { + + It "Get Tacacs Server with depth equal 1" { + { + Get-ArubaCXTacacsServer -depth 1 + } | Should Not Throw + } + + It "Get Tacacs Server with depth equal 2" { + { + Get-ArubaCXTacacsServer -depth 2 + } | Should Not Throw + } + + It "Get Tacacs Server with depth equal 3" { + { + Get-ArubaCXTacacsServer -depth 3 + } | Should Not Throw + } + + It "Get Tacacs Server with depth equal 4" { + { + Get-ArubaCXTacacsServer -depth 4 + } | Should Not Throw + } + } + + Context "Attribute" { + + It "Get Tacacs Server with one attribute (auth_type)" { + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -attribute auth_type + @($tacacs).count | Should -be 1 + $tacacs.address | Should -BeNullOrEmpty + $tacacs.port | Should -Not -BeNullOrEmpty + } + + It "Get Tacacs Server with two attributes (auth_type, timeout)" { + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -attribute auth_type,timeout + @($tacacs).count | Should -be 1 + $tacacs.address | Should -BeNullOrEmpty + $tacacs.port | Should -Not -BeNullOrEmpty + $tacacs.auth_type | Should -Be "pap" + $tacacs.timeour | Should -Be 15 + } + + } + + Context "Search" { + It "Search Tacacs Server by address ($pester_tacacs_address)" { + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + @($tacacs).count | Should -be 1 + $tacacs.address | Should -Be $pester_tacacs_address + $tacacs.port | Should -Be $pester_tacacs_port + } + } + + AfterAll { + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Remove-ArubaCXTacacsServer -confirm:$false + } +} + +Describe "Add Tacacs Server" { + + AfterEach { + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Remove-ArubaCXTacacsServer -confirm:$false -ErrorAction SilentlyContinue + } + + It "Add Tacacs Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group)" { + Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs.address | Should -Be $pester_tacacs_address + $tacacs.port | Should -Be $pester_tacacs_port + $tacacs.group.tacacs | Should -Be "/rest/v10.04/system/aaa_server_groups/tacacs" + $tacacs.default_group_priority | Should -Be 1 + $tacacs.timeout | Should -Be $null + $tacacs.passkey | Should -Be $null + $tacacs.tracking_enable | Should -Be $false + } + + It "Add Tacacs Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group, and a timeout)" { + Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority -timeout 10 + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs.address | Should -Be $pester_tacacs_address + $tacacs.port | Should -Be $pester_tacacs_port + $tacacs.group.tacacs | Should -Be "/rest/v10.04/system/aaa_server_groups/tacacs" + $tacacs.default_group_priority | Should -Be 1 + $tacacs.timeout | Should -Be 10 + $tacacs.passkey | Should -Be $null + $tacacs.tracking_enable | Should -Be $false + } + + It "Add Tacacs Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group, a timeout, a passkey and tracking_enable)" { + Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -timeout 10 -passkey PowerArubaCX -tracking_enable + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs.address | Should -Be $pester_tacacs_address + $tacacs.port | Should -Be $pester_tacacs_port + $tacacs.group.tacacs | Should -Be "/rest/v10.04/system/aaa_server_groups/tacacs" + $tacacs.default_group_priority | Should -Be 1 + $tacacs.timeout | Should -Be 10 + $tacacs.passkey | Should -Not -BeNullOrEmpty + $tacacs.tracking_enable | Should -Be $true + } +} + +Describe "Configure Tacacs Server" { + BeforeAll { + Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 + } + + It "Change Tacacs Server default_group_priority" { + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Set-ArubaCXTacacsServer -default_group_priority 10 + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs.default_group_priority | Should -Be 10 + } + + It "Change Tacacs Server timeout" { + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Set-ArubaCXTacacsServer -timeout 10 + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs.timeout | Should -Be 10 + } + + It "Change Tacacs Server tracking_enable (enable)" { + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Set-ArubaCXTacacsServer -tracking_enable:$true + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs.tracking_enable | Should -Be $true + } + + It "Change Tacacs Server tracking_enable (disable)" { + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Set-ArubaCXTacacsServer -tracking_enable:$false + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs.tracking_enable | Should -Be $false + } + + AfterAll { + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Remove-ArubaCXTacacsServer -confirm:$false + } +} + +Describe "Remove Tacacs Server" { + + BeforeEach { + Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 + } + + It "Remove Tacacs Server $pester_tacacs_address by address and port" { + Remove-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -confirm:$false + $tacacs = Get-ArubaCXTacacsServer + $tacacs.$pester_tacacs_address | Should -Be $NULL + } + + It "Remove Tacacs Server $pester_tacacs_address by pipeline" { + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs | Remove-ArubaCXTacacsServer -confirm:$false + $tacacs = Get-ArubaCXTacacsServer + $tacacs.$pester_tacacs_address | Should -Be $NULL + } + +} + +Disconnect-ArubaCX -confirm:$false \ No newline at end of file From 32cf0ad1fa8607a059d73470ed1559ec9907ffb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Moreau?= Date: Tue, 30 Nov 2021 09:57:29 +0100 Subject: [PATCH 2/7] Add TacacsServer cmdlets (Add/Get/Set/Remove) --- PowerArubaCX/Public/Tacacs.ps1 | 67 +++++++++++++++--------------- Tests/integration/Tacacs.Tests.ps1 | 31 +++++++------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/PowerArubaCX/Public/Tacacs.ps1 b/PowerArubaCX/Public/Tacacs.ps1 index ff7d5ce..5e36d29 100644 --- a/PowerArubaCX/Public/Tacacs.ps1 +++ b/PowerArubaCX/Public/Tacacs.ps1 @@ -135,7 +135,7 @@ function Get-ArubaCXTacacsServer { [Parameter(Mandatory = $false)] [ValidateRange(1, 4)] [Int]$depth, - [Parameter(Mandatory = $false)] + [Parameter(Mandatory = $false, ParameterSetName = "address")] [ValidateSet("configuration", "status", "statistics", "writable")] [String]$selector, [Parameter(Mandatory = $false)] @@ -198,17 +198,22 @@ function Set-ArubaCXTacacsServer { Configure Tacacs Server (Timeout, port...) .EXAMPLE - Set-ArubaCXTacacsServer -timeout 15 -address 192.2.0.1 -tcp_port + Set-ArubaCXTacacsServer -timeout 15 -address 192.2.0.1 -port 49 Configure timeout on tacacs server .EXAMPLE - Set-ArubaCXTacacsServer -group tacacs -address 192.2.0.1 -tcp_port + Set-ArubaCXTacacsServer -group tacacs -address 192.2.0.1 -port 49 Configure group on tacacs server .EXAMPLE - Set-ArubaCXTacacsServer -passkey ExampleRadius -address 192.2.0.1 -tcp_port + Set-ArubaCXTacacsServer -passkey ExampleTacacs -address 192.2.0.1 -port 49 + + Configure passkey on tacacs server + + .EXAMPLE + Get-ArubaCXTacacsServer -address 192.2.0.1 -port 49 | Set-ArubaCXTacacsServer -default_group_priority 10 -group PowerArubaCX -passkey ExampleTacacs -timeout 15 -tacking_enable -user_group_priority 1 Configure passkey on tacacs server #> @@ -228,15 +233,15 @@ function Set-ArubaCXTacacsServer { [ValidateRange(1, 9223372036854775807)] [int]$default_group_priority, [Parameter (Mandatory = $false)] - [string]$group, + [string]$group = "tacacs", [Parameter (Mandatory = $false)] [string]$passkey, [Parameter (Mandatory = $false)] - [int]$timeout, + [int]$timeout = 10, [Parameter (Mandatory = $false)] [switch]$tracking_enable, [Parameter (Mandatory = $false)] - [int]$user_group_priority, + [int]$user_group_priority = 1, [Parameter (Mandatory = $false)] [string]$vrf = "default", [Parameter (Mandatory = $False)] @@ -250,6 +255,8 @@ function Set-ArubaCXTacacsServer { Process { + $_tacacs = @{ } + if ($tacacs) { $address = $tacacs.address $port = $tacacs.tcp_port @@ -257,44 +264,38 @@ function Set-ArubaCXTacacsServer { $uri = "system/vrfs/${vrf}/tacacs_servers/${address},${port}" - if ($tacacs) { - $_tacacs = $tacacs - $_tacacs.PSObject.Properties.Remove('address') - $_tacacs.PSObject.Properties.Remove('tcp_port') - } - else { - $_tacacs = Get-ArubaCXTacacsServer -address $address -port $port -selector writable -connection $connection - } + $_tacacs = Get-ArubaCXTacacsServer -address $address -port $port -selector writable if ( $PsBoundParameters.ContainsKey('auth_type') ) { - $_tacacs.auth_type = $auth_type + $_tacacs | add-member -name "auth_type" -membertype NoteProperty -Value $auth_type -Force } if ( $PsBoundParameters.ContainsKey('default_group_priority') ) { - $_tacacs.default_group_priority = $default_group_priority + $_tacacs | add-member -name "default_group_priority" -membertype NoteProperty -Value $default_group_priority -Force } - if ( $PsBoundParameters.ContainsKey('group') ) { - $_group = @() - $_group += "/rest/" + $($connection.version) + "/system/aaa_server_groups/" + $group + $_group = @() + + $_group += "/rest/" + $($connection.version) + "/system/aaa_server_groups/" + $group + + $_tacacs | add-member -name "group" -membertype NoteProperty -Value $_group -Force - $_tacacs.group = $_group - } if ( $PsBoundParameters.ContainsKey('passkey') ) { - $_tacacs.passkey = $passkey - } - if ( $PsBoundParameters.ContainsKey('timeout') ) { - $_tacacs.timeout = $timeout + $_tacacs | add-member -name "passkey" -membertype NoteProperty -Value $passkey -Force } + + $_tacacs | add-member -name "timeout" -membertype NoteProperty -Value $timeout -Force + if ( $PsBoundParameters.ContainsKey('tracking_enable') ) { - $_tacacs.tracking_enable = $true - } - else { - $_tacacs.tracking_enable = $false - } - if ( $PsBoundParameters.ContainsKey('user_group_priority') ) { - $_tacacs.user_group_priority = $user_group_priority + if ($tracking_enable) { + $_tacacs | add-member -name "tracking_enable" -membertype NoteProperty -Value $true -Force + } + else { + $_tacacs | add-member -name "tracking_enable" -membertype NoteProperty -Value $false -Force + } } + $_tacacs | add-member -name "user_group_priority" -membertype NoteProperty -Value $user_group_priority -Force + if ($PSCmdlet.ShouldProcess($_tacacs.address, 'Configure Tacacs Server')) { Invoke-ArubaCXRestMethod -method "PUT" -body $_tacacs -uri $uri -connection $connection } diff --git a/Tests/integration/Tacacs.Tests.ps1 b/Tests/integration/Tacacs.Tests.ps1 index 782fd5d..7f95c6f 100644 --- a/Tests/integration/Tacacs.Tests.ps1 +++ b/Tests/integration/Tacacs.Tests.ps1 @@ -18,7 +18,7 @@ Describe "Get Tacacs Server" { It "Get ALL Tacacs Server" { $tacacs = Get-ArubaCXTacacsServer - $tacacs.count | Should -Not -Be $NULL + @($tacacs).count | Should -Not -Be $NULL } It "Get Tacacs Server ($pester_tacacs_address)" { @@ -37,25 +37,25 @@ Describe "Get Tacacs Server" { It "Get Tacacs Server with selector equal configuration" { { - Get-ArubaCXTacacsServer -selector configuration + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -selector configuration } | Should Not Throw } It "Get Tacacs Server with selector equal statistics" { { - Get-ArubaCXTacacsServer -selector statistics + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -selector statistics } | Should Not Throw } It "Get Tacacs Server with selector equal status" { { - Get-ArubaCXTacacsServer -selector status + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -selector status } | Should Not Throw } It "Get Tacacs Server with selector equal writable" { { - Get-ArubaCXTacacsServer -selector writable + Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -selector writable } | Should Not Throw } } @@ -93,16 +93,15 @@ Describe "Get Tacacs Server" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -attribute auth_type @($tacacs).count | Should -be 1 $tacacs.address | Should -BeNullOrEmpty - $tacacs.port | Should -Not -BeNullOrEmpty + $tacacs.auth_type | Should -Not -BeNullOrEmpty } It "Get Tacacs Server with two attributes (auth_type, timeout)" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -attribute auth_type,timeout @($tacacs).count | Should -be 1 $tacacs.address | Should -BeNullOrEmpty - $tacacs.port | Should -Not -BeNullOrEmpty $tacacs.auth_type | Should -Be "pap" - $tacacs.timeour | Should -Be 15 + $tacacs.timeout | Should -Be 15 } } @@ -112,7 +111,7 @@ Describe "Get Tacacs Server" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port @($tacacs).count | Should -be 1 $tacacs.address | Should -Be $pester_tacacs_address - $tacacs.port | Should -Be $pester_tacacs_port + $tacacs.tcp_port | Should -Be $pester_tacacs_port } } @@ -131,8 +130,8 @@ Describe "Add Tacacs Server" { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.address | Should -Be $pester_tacacs_address - $tacacs.port | Should -Be $pester_tacacs_port - $tacacs.group.tacacs | Should -Be "/rest/v10.04/system/aaa_server_groups/tacacs" + $tacacs.tcp_port | Should -Be $pester_tacacs_port + $tacacs.group.tacacs | Should -Be "@{group_name=tacacs; group_type=tacacs; origin=built-in}" $tacacs.default_group_priority | Should -Be 1 $tacacs.timeout | Should -Be $null $tacacs.passkey | Should -Be $null @@ -140,11 +139,11 @@ Describe "Add Tacacs Server" { } It "Add Tacacs Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group, and a timeout)" { - Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority -timeout 10 + Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -timeout 10 $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.address | Should -Be $pester_tacacs_address - $tacacs.port | Should -Be $pester_tacacs_port - $tacacs.group.tacacs | Should -Be "/rest/v10.04/system/aaa_server_groups/tacacs" + $tacacs.tcp_port | Should -Be $pester_tacacs_port + $tacacs.group.tacacs | Should -Be "@{group_name=tacacs; group_type=tacacs; origin=built-in}" $tacacs.default_group_priority | Should -Be 1 $tacacs.timeout | Should -Be 10 $tacacs.passkey | Should -Be $null @@ -155,8 +154,8 @@ Describe "Add Tacacs Server" { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -timeout 10 -passkey PowerArubaCX -tracking_enable $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.address | Should -Be $pester_tacacs_address - $tacacs.port | Should -Be $pester_tacacs_port - $tacacs.group.tacacs | Should -Be "/rest/v10.04/system/aaa_server_groups/tacacs" + $tacacs.tcp_port | Should -Be $pester_tacacs_port + $tacacs.group.tacacs | Should -Be "@{group_name=tacacs; group_type=tacacs; origin=built-in}" $tacacs.default_group_priority | Should -Be 1 $tacacs.timeout | Should -Be 10 $tacacs.passkey | Should -Not -BeNullOrEmpty From b9fbab2ecf514d114baad768d9496e02c8b0fe95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Moreau?= Date: Tue, 30 Nov 2021 16:19:45 +0100 Subject: [PATCH 3/7] Fix after review --- PowerArubaCX/Private/Confirm.ps1 | 16 +++---- PowerArubaCX/Public/Tacacs.ps1 | 71 ++++++++++++++++------------ Tests/integration/Tacacs.Tests.ps1 | 74 +++++++++++++++--------------- 3 files changed, 86 insertions(+), 75 deletions(-) diff --git a/PowerArubaCX/Private/Confirm.ps1 b/PowerArubaCX/Private/Confirm.ps1 index c528869..afc3e47 100644 --- a/PowerArubaCX/Private/Confirm.ps1 +++ b/PowerArubaCX/Private/Confirm.ps1 @@ -127,27 +127,27 @@ function Confirm-ArubaCXTacacsServer { [Parameter (Mandatory = $true)] [object]$argument ) - #Check if it looks like a tacacs server element + #Check if it looks like a TACACS server element - if ( -not ( $argument | get-member -name auth_type -Membertype Properties)) { + if ( -not ( $argument | Get-Member -name auth_type -Membertype Properties)) { throw "Element specified does not contain an auth_type property." } - if ( -not ( $argument | get-member -name default_group_priority -Membertype Properties)) { + if ( -not ( $argument | Get-Member -name default_group_priority -Membertype Properties)) { throw "Element specified does not contain a default_group_priority property." } - if ( -not ( $argument | get-member -name group -Membertype Properties)) { + if ( -not ( $argument | Get-Member -name group -Membertype Properties)) { throw "Element specified does not contain a group property." } - if ( -not ( $argument | get-member -name passkey -Membertype Properties)) { + if ( -not ( $argument | Get-Member -name passkey -Membertype Properties)) { throw "Element specified does not contain a passkey property." } - if ( -not ( $argument | get-member -name timeout -Membertype Properties)) { + if ( -not ( $argument | Get-Member -name timeout -Membertype Properties)) { throw "Element specified does not contain a timeout property." } - if ( -not ( $argument | get-member -name tracking_enable -Membertype Properties)) { + if ( -not ( $argument | Get-Member -name tracking_enable -Membertype Properties)) { throw "Element specified does not contain a tracking_enable property." } - if ( -not ( $argument | get-member -name user_group_priority -Membertype Properties)) { + if ( -not ( $argument | Get-Member -name user_group_priority -Membertype Properties)) { throw "Element specified does not contain a user_group_priority property." } $true diff --git a/PowerArubaCX/Public/Tacacs.ps1 b/PowerArubaCX/Public/Tacacs.ps1 index 5e36d29..ff4b0a3 100644 --- a/PowerArubaCX/Public/Tacacs.ps1 +++ b/PowerArubaCX/Public/Tacacs.ps1 @@ -8,28 +8,33 @@ function Add-ArubaCXTacacsServer { <# .SYNOPSIS - Add Aruba CX Tacacs Server + Add Aruba CX TACACS Server .DESCRIPTION - Add tacacs server (ip, group, port...) + Add TACACS server (ip, group, port...) .EXAMPLE Add-ArubaCXTacacsServer -address 192.2.0.1 -port 49 -group Clearpass -default_group_priority 10 - Add tacacs server with ip 192.2.0.1 and port 49 in Tacacs group Clearpass + Add TACACS server with ip 192.2.0.1 and port 49 in TACACS group Clearpass + + .EXAMPLE + Add-ArubaCXTacacsServer -address 192.2.0.1 -port 49 -group Clearpass -default_group_priority 10 -timeout 10 -passkey ExampleTACACS + + Add TACACS server with ip 192.2.0.1 and port 49 in TACACS group Clearpass with timeout set to 10 and passkey as ExampleTACACS #> Param( [Parameter (Mandatory = $true)] [string]$address, [Parameter (Mandatory = $true)] [ValidateRange(1, 65535)] - [int]$port, + [int]$port = 49, [Parameter (Mandatory = $false)] [ValidateSet('pap')] [string]$auth_type = "pap", [Parameter (Mandatory = $true)] [ValidateRange(1, 9223372036854775807)] - [int]$default_group_priority, + [int64]$default_group_priority = 10, [Parameter (Mandatory = $true)] [string]$group, [Parameter (Mandatory = $false)] @@ -108,20 +113,20 @@ function Get-ArubaCXTacacsServer { <# .SYNOPSIS - Get list of tacacs server configured + Get list of TACACS server configured .DESCRIPTION - Get list of tacacs server configured (ip, group, port...) + Get list of TACACS server configured (ip, group, port...) .EXAMPLE Get-ArubaCXTacacsServer -vrf default - Get list of tacacs server configured (ip, group, port...) on default vrf + Get list of TACACS server configured (ip, group, port...) on default vrf .EXAMPLE Get-ArubaCXTacacsServer -address 192.2.0.1 -port 49 - Get tacacs server with ip 192.2.0.1 and port 49 + Get TACACS server with ip 192.2.0.1 and port 49 #> [CmdletBinding(DefaultParametersetname = "Default")] @@ -129,7 +134,7 @@ function Get-ArubaCXTacacsServer { [Parameter (Mandatory = $true, ParameterSetName = "address")] [ipaddress]$address, [Parameter (Mandatory = $true, ParameterSetName = "address")] - [int]$port, + [int]$port = 49, [Parameter (Mandatory = $false)] [string]$vrf = "default", [Parameter(Mandatory = $false)] @@ -192,30 +197,30 @@ function Set-ArubaCXTacacsServer { <# .SYNOPSIS - Configure Tacacs Server ArubaCX Switch + Configure TACACS Server ArubaCX Switch .DESCRIPTION - Configure Tacacs Server (Timeout, port...) + Configure TACACS Server (Timeout, port...) .EXAMPLE Set-ArubaCXTacacsServer -timeout 15 -address 192.2.0.1 -port 49 - Configure timeout on tacacs server + Configure timeout on TACACS server .EXAMPLE Set-ArubaCXTacacsServer -group tacacs -address 192.2.0.1 -port 49 - Configure group on tacacs server + Configure group on TACACS server .EXAMPLE Set-ArubaCXTacacsServer -passkey ExampleTacacs -address 192.2.0.1 -port 49 - Configure passkey on tacacs server + Configure passkey on TACACS server .EXAMPLE Get-ArubaCXTacacsServer -address 192.2.0.1 -port 49 | Set-ArubaCXTacacsServer -default_group_priority 10 -group PowerArubaCX -passkey ExampleTacacs -timeout 15 -tacking_enable -user_group_priority 1 - Configure passkey on tacacs server + Configure passkey, timeout, tacking enable and user group priority on TACACS server #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'medium')] Param( @@ -267,34 +272,38 @@ function Set-ArubaCXTacacsServer { $_tacacs = Get-ArubaCXTacacsServer -address $address -port $port -selector writable if ( $PsBoundParameters.ContainsKey('auth_type') ) { - $_tacacs | add-member -name "auth_type" -membertype NoteProperty -Value $auth_type -Force + $_tacacs.auth_type = $auth_type } if ( $PsBoundParameters.ContainsKey('default_group_priority') ) { - $_tacacs | add-member -name "default_group_priority" -membertype NoteProperty -Value $default_group_priority -Force + $_tacacs.default_group_priority = $default_group_priority } $_group = @() $_group += "/rest/" + $($connection.version) + "/system/aaa_server_groups/" + $group - $_tacacs | add-member -name "group" -membertype NoteProperty -Value $_group -Force + $_tacacs.group = $_group if ( $PsBoundParameters.ContainsKey('passkey') ) { - $_tacacs | add-member -name "passkey" -membertype NoteProperty -Value $passkey -Force + $_tacacs.passkey = $passkey } - $_tacacs | add-member -name "timeout" -membertype NoteProperty -Value $timeout -Force + if ( $PsBoundParameters.ContainsKey('timeout') ) { + $_tacacs.timeout = $timeout + } if ( $PsBoundParameters.ContainsKey('tracking_enable') ) { if ($tracking_enable) { - $_tacacs | add-member -name "tracking_enable" -membertype NoteProperty -Value $true -Force + $_tacacs.tracking_enable = $true } else { - $_tacacs | add-member -name "tracking_enable" -membertype NoteProperty -Value $false -Force + $_tacacs.tracking_enable = $false } } - $_tacacs | add-member -name "user_group_priority" -membertype NoteProperty -Value $user_group_priority -Force + if ( $PsBoundParameters.ContainsKey('user_group_priority') ) { + $_tacacs.user_group_priority = $user_group_priority + } if ($PSCmdlet.ShouldProcess($_tacacs.address, 'Configure Tacacs Server')) { Invoke-ArubaCXRestMethod -method "PUT" -body $_tacacs -uri $uri -connection $connection @@ -311,16 +320,19 @@ function Remove-ArubaCXTacacsServer { <# .SYNOPSIS - Remove a tacacs server on Aruba CX Switch + Remove a TACACS server on Aruba CX Switch + .DESCRIPTION - Remove a tacacs server on Aruba CX Switch + Remove a TACACS server on Aruba CX Switch + .EXAMPLE $ts = Get-ArubaCXArubaCXTacacsServer -address 192.2.0.1 -port 49 PS C:\>$ts | Remove-ArubaCXTacacsServer - Remove tacacs server with address 192.0.2.1 and port 49 + + Remove TACACS server with address 192.0.2.1 and port 49 .EXAMPLE Remove-ArubaCXTacacsServer -address 192.2.0.1 -confirm:$false -vrf default - Remove tacacs server 192.0.2.1 on default vrf with no confirmation + Remove TACACS server 192.0.2.1 on default vrf with no confirmation #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'high')] @@ -328,7 +340,7 @@ function Remove-ArubaCXTacacsServer { [Parameter (Mandatory = $true, ParameterSetName = "address")] [string]$address, [Parameter (Mandatory = $true, ParameterSetName = "address")] - [int]$port, + [int]$port = 49, [Parameter (Mandatory = $true, ValueFromPipeline = $true, Position = 1, ParameterSetName = "ID")] [ValidateScript( { Confirm-ArubaCXTacacsServer $_ })] [psobject]$ts, @@ -353,7 +365,6 @@ function Remove-ArubaCXTacacsServer { $uri = "system/vrfs/${vrf}/tacacs_servers/${address},${port}" if ($PSCmdlet.ShouldProcess("Tacacs Server (VRF: ${vrf})", "Remove ${address},${port}")) { - Write-Progress -activity "Remove Tacacs Server" Invoke-ArubaCXRestMethod -method "DELETE" -uri $uri -connection $connection Write-Progress -activity "Remove Tacacs Server" -completed } diff --git a/Tests/integration/Tacacs.Tests.ps1 b/Tests/integration/Tacacs.Tests.ps1 index 7f95c6f..0a2dc1f 100644 --- a/Tests/integration/Tacacs.Tests.ps1 +++ b/Tests/integration/Tacacs.Tests.ps1 @@ -5,29 +5,29 @@ # . ../common.ps1 -Describe "Get Tacacs Server" { +Describe "Get TACACS Server" { BeforeALL { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -auth_type pap -timeout 15 } - It "Get Tacacs Server Does not throw an error" { + It "Get TACACS Server Does not throw an error" { { Get-ArubaCXTacacsServer - } | Should Not Throw + } | Should -Not -Throw } - It "Get ALL Tacacs Server" { + It "Get ALL TACACS Server" { $tacacs = Get-ArubaCXTacacsServer @($tacacs).count | Should -Not -Be $NULL } - It "Get Tacacs Server ($pester_tacacs_address)" { + It "Get TACACS Server ($pester_tacacs_address)" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.address | Should -Be $pester_tacacs_address $tacacs.tcp_port | Should -Be $pester_tacacs_port } - It "Get Tacacs Server ($pester_tacacs_address) and confirm (via Confirm-ArubaCXVlans)" { + It "Get TACACS Server ($pester_tacacs_address) and confirm (via Confirm-ArubaCXTacacsServer)" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port Confirm-ArubaCXTacacsServer ($tacacs) | Should -Be $true } @@ -35,68 +35,68 @@ Describe "Get Tacacs Server" { #Get with attribute, depth... Context "Selector" { - It "Get Tacacs Server with selector equal configuration" { + It "Get TACACS Server with selector equal configuration" { { Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -selector configuration - } | Should Not Throw + } | Should -Not -Throw } - It "Get Tacacs Server with selector equal statistics" { + It "Get TACACS Server with selector equal statistics" { { Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -selector statistics - } | Should Not Throw + } | Should -Not -Throw } - It "Get Tacacs Server with selector equal status" { + It "Get TACACS Server with selector equal status" { { Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -selector status - } | Should Not Throw + } | Should -Not -Throw } - It "Get Tacacs Server with selector equal writable" { + It "Get TACACS Server with selector equal writable" { { Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -selector writable - } | Should Not Throw + } | Should -Not -Throw } } Context "Depth" { - It "Get Tacacs Server with depth equal 1" { + It "Get TACACS Server with depth equal 1" { { Get-ArubaCXTacacsServer -depth 1 - } | Should Not Throw + } | Should -Not -Throw } - It "Get Tacacs Server with depth equal 2" { + It "Get TACACS Server with depth equal 2" { { Get-ArubaCXTacacsServer -depth 2 - } | Should Not Throw + } | Should -Not -Throw } - It "Get Tacacs Server with depth equal 3" { + It "Get TACACS Server with depth equal 3" { { Get-ArubaCXTacacsServer -depth 3 - } | Should Not Throw + } | Should -Not -Throw } - It "Get Tacacs Server with depth equal 4" { + It "Get TACACS Server with depth equal 4" { { Get-ArubaCXTacacsServer -depth 4 - } | Should Not Throw + } | Should -Not -Throw } } Context "Attribute" { - It "Get Tacacs Server with one attribute (auth_type)" { + It "Get TACACS Server with one attribute (auth_type)" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -attribute auth_type @($tacacs).count | Should -be 1 $tacacs.address | Should -BeNullOrEmpty $tacacs.auth_type | Should -Not -BeNullOrEmpty } - It "Get Tacacs Server with two attributes (auth_type, timeout)" { + It "Get TACACS Server with two attributes (auth_type, timeout)" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -attribute auth_type,timeout @($tacacs).count | Should -be 1 $tacacs.address | Should -BeNullOrEmpty @@ -107,7 +107,7 @@ Describe "Get Tacacs Server" { } Context "Search" { - It "Search Tacacs Server by address ($pester_tacacs_address)" { + It "Search TACACS Server by address ($pester_tacacs_address)" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port @($tacacs).count | Should -be 1 $tacacs.address | Should -Be $pester_tacacs_address @@ -120,13 +120,13 @@ Describe "Get Tacacs Server" { } } -Describe "Add Tacacs Server" { +Describe "Add TACACS Server" { AfterEach { Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Remove-ArubaCXTacacsServer -confirm:$false -ErrorAction SilentlyContinue } - It "Add Tacacs Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group)" { + It "Add TACACS Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group)" { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.address | Should -Be $pester_tacacs_address @@ -138,7 +138,7 @@ Describe "Add Tacacs Server" { $tacacs.tracking_enable | Should -Be $false } - It "Add Tacacs Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group, and a timeout)" { + It "Add TACACS Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group, and a timeout)" { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -timeout 10 $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.address | Should -Be $pester_tacacs_address @@ -150,7 +150,7 @@ Describe "Add Tacacs Server" { $tacacs.tracking_enable | Should -Be $false } - It "Add Tacacs Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group, a timeout, a passkey and tracking_enable)" { + It "Add TACACS Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group, a timeout, a passkey and tracking_enable)" { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -timeout 10 -passkey PowerArubaCX -tracking_enable $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.address | Should -Be $pester_tacacs_address @@ -163,30 +163,30 @@ Describe "Add Tacacs Server" { } } -Describe "Configure Tacacs Server" { +Describe "Configure TACACS Server" { BeforeAll { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 } - It "Change Tacacs Server default_group_priority" { + It "Change TACACS Server default_group_priority" { Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Set-ArubaCXTacacsServer -default_group_priority 10 $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.default_group_priority | Should -Be 10 } - It "Change Tacacs Server timeout" { + It "Change TACACS Server timeout" { Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Set-ArubaCXTacacsServer -timeout 10 $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.timeout | Should -Be 10 } - It "Change Tacacs Server tracking_enable (enable)" { + It "Change TACACS Server tracking_enable (enable)" { Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Set-ArubaCXTacacsServer -tracking_enable:$true $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.tracking_enable | Should -Be $true } - It "Change Tacacs Server tracking_enable (disable)" { + It "Change TACACS Server tracking_enable (disable)" { Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port | Set-ArubaCXTacacsServer -tracking_enable:$false $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs.tracking_enable | Should -Be $false @@ -197,19 +197,19 @@ Describe "Configure Tacacs Server" { } } -Describe "Remove Tacacs Server" { +Describe "Remove TACACS Server" { BeforeEach { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 } - It "Remove Tacacs Server $pester_tacacs_address by address and port" { + It "Remove TACACS Server $pester_tacacs_address by address and port" { Remove-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -confirm:$false $tacacs = Get-ArubaCXTacacsServer $tacacs.$pester_tacacs_address | Should -Be $NULL } - It "Remove Tacacs Server $pester_tacacs_address by pipeline" { + It "Remove TACACS Server $pester_tacacs_address by pipeline" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port $tacacs | Remove-ArubaCXTacacsServer -confirm:$false $tacacs = Get-ArubaCXTacacsServer From 1cfe0e46a7d63de08816bb5b022cc67695cbe0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Moreau?= Date: Thu, 2 Dec 2021 09:05:54 +0100 Subject: [PATCH 4/7] Fix typos, and change depth of Get function --- PowerArubaCX/Private/Confirm.ps1 | 2 +- PowerArubaCX/Public/Tacacs.ps1 | 20 +++++------ README.md | 55 ++++++++++++++++++++++++++++++ Tests/integration/Tacacs.Tests.ps1 | 14 ++++---- 4 files changed, 71 insertions(+), 20 deletions(-) diff --git a/PowerArubaCX/Private/Confirm.ps1 b/PowerArubaCX/Private/Confirm.ps1 index afc3e47..605e84e 100644 --- a/PowerArubaCX/Private/Confirm.ps1 +++ b/PowerArubaCX/Private/Confirm.ps1 @@ -148,7 +148,7 @@ function Confirm-ArubaCXTacacsServer { throw "Element specified does not contain a tracking_enable property." } if ( -not ( $argument | Get-Member -name user_group_priority -Membertype Properties)) { - throw "Element specified does not contain a user_group_priority property." + throw "Element specified does not contain an user_group_priority property." } $true } \ No newline at end of file diff --git a/PowerArubaCX/Public/Tacacs.ps1 b/PowerArubaCX/Public/Tacacs.ps1 index ff4b0a3..15c3d97 100644 --- a/PowerArubaCX/Public/Tacacs.ps1 +++ b/PowerArubaCX/Public/Tacacs.ps1 @@ -32,11 +32,11 @@ function Add-ArubaCXTacacsServer { [Parameter (Mandatory = $false)] [ValidateSet('pap')] [string]$auth_type = "pap", - [Parameter (Mandatory = $true)] + [Parameter (Mandatory = $false)] [ValidateRange(1, 9223372036854775807)] [int64]$default_group_priority = 10, - [Parameter (Mandatory = $true)] - [string]$group, + [Parameter (Mandatory = $false)] + [string]$group = "tacacs", [Parameter (Mandatory = $false)] [string]$passkey, [Parameter (Mandatory = $false)] @@ -133,7 +133,7 @@ function Get-ArubaCXTacacsServer { Param( [Parameter (Mandatory = $true, ParameterSetName = "address")] [ipaddress]$address, - [Parameter (Mandatory = $true, ParameterSetName = "address")] + [Parameter (Mandatory = $false)] [int]$port = 49, [Parameter (Mandatory = $false)] [string]$vrf = "default", @@ -162,10 +162,6 @@ function Get-ArubaCXTacacsServer { if ( $PsBoundParameters.ContainsKey('depth') ) { $invokeParams.add( 'depth', $depth ) } - else { - #by default set depth to 2 to show items - $invokeParams.add( 'depth', 2 ) - } if ( $PsBoundParameters.ContainsKey('selector') ) { $invokeParams.add( 'selector', $selector ) } @@ -203,17 +199,17 @@ function Set-ArubaCXTacacsServer { Configure TACACS Server (Timeout, port...) .EXAMPLE - Set-ArubaCXTacacsServer -timeout 15 -address 192.2.0.1 -port 49 + Get-ArubaCXTacacsServer -address 192.2.0.1 -port 49 | Set-ArubaCXTacacsServer -timeout 15 Configure timeout on TACACS server .EXAMPLE - Set-ArubaCXTacacsServer -group tacacs -address 192.2.0.1 -port 49 + Get-ArubaCXTacacsServer -address 192.2.0.1 -port 49 | Set-ArubaCXTacacsServer -group tacacs Configure group on TACACS server .EXAMPLE - Set-ArubaCXTacacsServer -passkey ExampleTacacs -address 192.2.0.1 -port 49 + Get-ArubaCXTacacsServer -address 192.2.0.1 -port 49 | Set-ArubaCXTacacsServer -passkey ExampleTacacs Configure passkey on TACACS server @@ -330,6 +326,7 @@ function Remove-ArubaCXTacacsServer { PS C:\>$ts | Remove-ArubaCXTacacsServer Remove TACACS server with address 192.0.2.1 and port 49 + .EXAMPLE Remove-ArubaCXTacacsServer -address 192.2.0.1 -confirm:$false -vrf default Remove TACACS server 192.0.2.1 on default vrf with no confirmation @@ -366,7 +363,6 @@ function Remove-ArubaCXTacacsServer { if ($PSCmdlet.ShouldProcess("Tacacs Server (VRF: ${vrf})", "Remove ${address},${port}")) { Invoke-ArubaCXRestMethod -method "DELETE" -uri $uri -connection $connection - Write-Progress -activity "Remove Tacacs Server" -completed } } diff --git a/README.md b/README.md index 4043bf2..68c443f 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ With this module (version 0.5.0) you can manage: - [LLDP Neighbor](#lldp-neighbor) (Get) - [System](#System) (Get/Set) - [Users](#Users) (Get) +- [TACACS Server](#tacacs-server) (Add/Get/Set/Remove) - [Vlans](#Vlans-Management) (Add/Get/Set/Remove) - [VRF](#vrf) (Add/Get/Set/Remove) - [VM](#vm) (Deploy and Configure ArubaCX OVA (for initial setup)) @@ -748,6 +749,60 @@ For example to get system of 2 ArubaCX ``` +### TACACS Server + +You can create a new TACACS Server `Add-ArubaCXTacacsServer`, retrieve its information `Get-ArubaCXTacacsServer`, modify its properties `Set-ArubaCXTacacsServer`, or delete it `Remove-ArubaCXTacacsServer`. + +```powershell +# Create a TACACS Server + Add-ArubaCXTacacsServer -address 192.2.0.1 -port 49 -auth_type pap -default_group_priority 10 -group tacacs -passkey PowerArubaCX -timeout 10 -tracking_enable -user_group_priority 10 -vrf default + + address : 192.2.0.1 + [...] + auth_type : pap + default_group_priority : 10 + group : @{tacacs=} + [...] + passkey : AQBapWD/wBAlSYvjgEqjBhR33D8T+fRfVUjTQNKVtSYzl5kMDAAAAM6/W76103nUuYlUQQ== + reachability_status : + tcp_port : 49 + timeout : 10 + tracking_enable : True + [...] + user_group_priority : 10 + + +# Get information about TACACS Server + Get-ArubaCXTacacsServer -address 192.2.0.1 -port 49 -depth 2 -attributes auth_type, default_group_priority, group, passkey, tcp_port, timeout, tracking_enable, user_group_priority | Format-Table + + auth_type default_group_priority group passkey tcp_port timeout tracking_enable user_group_priority + --------- ---------------------- ----- ------- -------- ------- --------------- ------------------- + pap 10 @{tacacs=} AQBapWD/wBAlSYvjgEqjBhR33D8T+fRfVUjTQNKVtSYzl5kMDAAAAM6/W76103nUuYlUQQ== 49 10 True 10 + +# Change settings of a TACACS Server (Timeout and default group priority) + Get-ArubaCXTacacsServer -address 192.2.0.1 -port 49 | Set-ArubaCXTacacsServer -timeout 15 -default_group_priority 1 + + address : 192.2.0.1 + [...] + auth_type : pap + default_group_priority : 1 + group : @{tacacs=} + [...] + passkey : AQBapWD/wBAlSYvjgEqjBhR33D8T+fRfVUjTQNKVtSYzl5kMDAAAAM6/W76103nUuYlUQQ== + reachability_status : + tcp_port : 49 + timeout : 15 + tracking_enable : True + [...] + user_group_priority : 10 + + +# Remove a TACACS Server + Get-ArubaCXTacacsServer -address 192.2.0.1 | Remove-ArubaCXTacacsServer +``` + +For configure a vlan to an interface, need to use [Set-ArubaCXInterfaces](#Interface) + ### Disconnecting ```powershell diff --git a/Tests/integration/Tacacs.Tests.ps1 b/Tests/integration/Tacacs.Tests.ps1 index 0a2dc1f..c546d27 100644 --- a/Tests/integration/Tacacs.Tests.ps1 +++ b/Tests/integration/Tacacs.Tests.ps1 @@ -6,7 +6,7 @@ . ../common.ps1 Describe "Get TACACS Server" { - BeforeALL { + BeforeAll { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -auth_type pap -timeout 15 } @@ -91,14 +91,14 @@ Describe "Get TACACS Server" { It "Get TACACS Server with one attribute (auth_type)" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -attribute auth_type - @($tacacs).count | Should -be 1 + @($tacacs).count | Should -Be 1 $tacacs.address | Should -BeNullOrEmpty $tacacs.auth_type | Should -Not -BeNullOrEmpty } It "Get TACACS Server with two attributes (auth_type, timeout)" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -attribute auth_type,timeout - @($tacacs).count | Should -be 1 + @($tacacs).count | Should -Be 1 $tacacs.address | Should -BeNullOrEmpty $tacacs.auth_type | Should -Be "pap" $tacacs.timeout | Should -Be 15 @@ -109,7 +109,7 @@ Describe "Get TACACS Server" { Context "Search" { It "Search TACACS Server by address ($pester_tacacs_address)" { $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port - @($tacacs).count | Should -be 1 + @($tacacs).count | Should -Be 1 $tacacs.address | Should -Be $pester_tacacs_address $tacacs.tcp_port | Should -Be $pester_tacacs_port } @@ -128,7 +128,7 @@ Describe "Add TACACS Server" { It "Add TACACS Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group)" { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 - $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -depth 2 $tacacs.address | Should -Be $pester_tacacs_address $tacacs.tcp_port | Should -Be $pester_tacacs_port $tacacs.group.tacacs | Should -Be "@{group_name=tacacs; group_type=tacacs; origin=built-in}" @@ -140,7 +140,7 @@ Describe "Add TACACS Server" { It "Add TACACS Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group, and a timeout)" { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -timeout 10 - $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -depth 2 $tacacs.address | Should -Be $pester_tacacs_address $tacacs.tcp_port | Should -Be $pester_tacacs_port $tacacs.group.tacacs | Should -Be "@{group_name=tacacs; group_type=tacacs; origin=built-in}" @@ -152,7 +152,7 @@ Describe "Add TACACS Server" { It "Add TACACS Server $pester_tacacs_address (with only an address and a port, a group and a default priority for the group, a timeout, a passkey and tracking_enable)" { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -timeout 10 -passkey PowerArubaCX -tracking_enable - $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port + $tacacs = Get-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -depth 2 $tacacs.address | Should -Be $pester_tacacs_address $tacacs.tcp_port | Should -Be $pester_tacacs_port $tacacs.group.tacacs | Should -Be "@{group_name=tacacs; group_type=tacacs; origin=built-in}" From 6089826f10298bbfbecf371367eacec8e985b555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Moreau?= Date: Thu, 2 Dec 2021 09:31:24 +0100 Subject: [PATCH 5/7] Fix some mandatory parameters --- PowerArubaCX/Public/Tacacs.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerArubaCX/Public/Tacacs.ps1 b/PowerArubaCX/Public/Tacacs.ps1 index 15c3d97..c5c19c7 100644 --- a/PowerArubaCX/Public/Tacacs.ps1 +++ b/PowerArubaCX/Public/Tacacs.ps1 @@ -26,7 +26,7 @@ function Add-ArubaCXTacacsServer { Param( [Parameter (Mandatory = $true)] [string]$address, - [Parameter (Mandatory = $true)] + [Parameter (Mandatory = $false)] [ValidateRange(1, 65535)] [int]$port = 49, [Parameter (Mandatory = $false)] @@ -336,7 +336,7 @@ function Remove-ArubaCXTacacsServer { Param( [Parameter (Mandatory = $true, ParameterSetName = "address")] [string]$address, - [Parameter (Mandatory = $true, ParameterSetName = "address")] + [Parameter (Mandatory = $false, ParameterSetName = "address")] [int]$port = 49, [Parameter (Mandatory = $true, ValueFromPipeline = $true, Position = 1, ParameterSetName = "ID")] [ValidateScript( { Confirm-ArubaCXTacacsServer $_ })] From 541689d88ee44013648047f38cbe0c33fed8d3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Moreau?= Date: Thu, 2 Dec 2021 13:50:22 +0100 Subject: [PATCH 6/7] Remove whitespaces and save with utf8-bom --- PowerArubaCX/Public/Tacacs.ps1 | 6 +++--- Tests/integration/Tacacs.Tests.ps1 | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PowerArubaCX/Public/Tacacs.ps1 b/PowerArubaCX/Public/Tacacs.ps1 index c5c19c7..60d6644 100644 --- a/PowerArubaCX/Public/Tacacs.ps1 +++ b/PowerArubaCX/Public/Tacacs.ps1 @@ -1,4 +1,4 @@ -# +# # Copyright 2021, Cédric Moreau # # SPDX-License-Identifier: Apache-2.0 @@ -66,7 +66,7 @@ function Add-ArubaCXTacacsServer { $_tacacs | add-member -name "tcp_port" -membertype NoteProperty -Value $port $_tacacs | add-member -name "vrf" -membertype NoteProperty -Value ("/rest/" + $($connection.version) + "/system/vrfs/" + $vrf) - + $_tacacs | add-member -name "default_group_priority" -membertype NoteProperty -Value $default_group_priority $_group = @() @@ -368,4 +368,4 @@ function Remove-ArubaCXTacacsServer { End { } -} \ No newline at end of file +} \ No newline at end of file diff --git a/Tests/integration/Tacacs.Tests.ps1 b/Tests/integration/Tacacs.Tests.ps1 index c546d27..3c7642e 100644 --- a/Tests/integration/Tacacs.Tests.ps1 +++ b/Tests/integration/Tacacs.Tests.ps1 @@ -1,4 +1,4 @@ -# +# # Copyright 2020, Cédric Moreau # # SPDX-License-Identifier: Apache-2.0 From 1d4e24c8763543b3bd7f0673869642467004e0ee Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Mon, 27 Dec 2021 12:25:42 +0100 Subject: [PATCH 7/7] TACACS(Tests): Use BeforeALL for Pester V5 Discovery --- Tests/integration/Tacacs.Tests.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Tests/integration/Tacacs.Tests.ps1 b/Tests/integration/Tacacs.Tests.ps1 index 3c7642e..2b044d3 100644 --- a/Tests/integration/Tacacs.Tests.ps1 +++ b/Tests/integration/Tacacs.Tests.ps1 @@ -5,6 +5,10 @@ # . ../common.ps1 +BeforeAll { + Connect-ArubaCX @invokeParams +} + Describe "Get TACACS Server" { BeforeAll { Add-ArubaCXTacacsServer -address $pester_tacacs_address -port $pester_tacacs_port -group tacacs -default_group_priority 1 -auth_type pap -timeout 15 @@ -218,4 +222,6 @@ Describe "Remove TACACS Server" { } -Disconnect-ArubaCX -confirm:$false \ No newline at end of file +AfterAll { + Disconnect-ArubaCX -confirm:$false +} \ No newline at end of file