-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from alagoutte/tests
Add Connection Tests (via Pester)
- Loading branch information
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
credential.ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright 2019, Alexis La Goutte <alexis dot lagoutte at gmail dot com> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
if ("Desktop" -eq $PSVersionTable.PsEdition) { # -BeOfType is not same on PowerShell Core and Desktop (get int with Desktop and long with Core for number) | ||
$script:pester_longint = "int" | ||
} | ||
else { | ||
$script:pester_longint = "long" | ||
} | ||
|
||
. ../credential.ps1 | ||
#TODO: Add check if no ipaddress/token info... | ||
|
||
Connect-ArubaCP -Server $ipaddress -Token $token -SkipCertificateCheck | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Copyright 2019, Alexis La Goutte <alexis dot lagoutte at gmail dot com> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# Copy this file to credential.ps1 (on Tests folder) and change connection settings.. | ||
|
||
$ipaddress = "10.44.23.213" | ||
$token = "aaaaaaaaaaaaaaaaaa" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# Copyright 2019, Alexis La Goutte <alexis dot lagoutte at gmail dot com> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
. ../common.ps1 | ||
|
||
Describe "Connect to a ClearPass (using Token)" { | ||
BeforeAll { | ||
#Disconnect "default connection" | ||
Disconnect-ArubaCP -noconfirm | ||
} | ||
It "Connect to ClearPass (using Token) and check global variable" { | ||
Connect-ArubaCP $ipaddress -Token $token -SkipCertificateCheck | ||
$DefaultArubaCPConnection | Should Not BeNullOrEmpty | ||
$DefaultArubaCPConnection.server | Should be $ipaddress | ||
$DefaultArubaCPConnection.token | Should be $token | ||
} | ||
It "Disconnect to ClearPass and check global variable" { | ||
Disconnect-ArubaCP -noconfirm | ||
$DefaultArubaCPConnection | Should be $null | ||
} | ||
#TODO: Connect using wrong login/password | ||
|
||
#This test only work with PowerShell 6 / Core (-SkipCertificateCheck don't change global variable but only Invoke-WebRequest/RestMethod) | ||
#This test will be fail, if there is valid certificate... | ||
It "Throw when try to use Invoke-ArubaCPRestMethod with don't use -SkipCertifiateCheck" -Skip:("Desktop" -eq $PSEdition) { | ||
Connect-ArubaCP $ipaddress -Token $token | ||
{ Invoke-ArubaCPRestMethod -uri "rest/v4/vlans" } | Should throw "Unable to connect (certificate)" | ||
Disconnect-ArubaCP -noconfirm | ||
} | ||
It "Throw when try to use Invoke-ArubaCPRestMethod and not connected" { | ||
{ Invoke-ArubaCPRestMethod -uri "rest/v4/vlans" } | Should throw "Not Connected. Connect to the ClearPass with Connect-ArubaCP" | ||
} | ||
} |