Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This PR is one fix of many for Refactor EXO Unit Tests #1111 And other problems with unit tests. One fix for all. #1162

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions Testing/AdvancedUnitTests/Connections/Connection.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Import-Module "$PSScriptRoot/../../../PowerShell/ScubaGear/Modules/Connection/Connection.psm1"
Import-Module "$PSScriptRoot/../pester-installables/Pester/src/Pester.psd1"

Describe "Connection Tests: "{
$script:test=0
$script:test++
It "$("$script:test".padleft(3, '0')): Syntax test"{
$script:syntax = Get-Content "$PSScriptRoot/MockData/SyntaxMockData/Connect-Tenant-Mock-Data.txt" |Out-String
(Get-Command -Syntax Connect-Tenant).Trim()| Should -Be $script:syntax #Can be changed if someone gives me the output of the command before the pipeline
}
$script:test++
It "$("$script:test".padleft(3, '0')): Compatibility with test objects - Success"{
try{
Connect-Teams -ProductNames "teams" -M365Environment "commercial"
$true| Should -BeTrue #Can be changed if someone gives me the output of Get-DomainComputer in xml format, after export the object via $object|Export-CliXML "<Path>"
}
catch{
Write-Host "$($_.exception.message) $($_.errordetails.message)"
$false| Should -BeTrue
}
}
$script:test++
It "$("$script:test".padleft(3, '0')): Compatibility with test objects - failure"{
try{
Connect-Teams -ProductNames "teams" -M365Environment "commercial-fail"
$false| Should -BeTrue #Can be changed if someone gives me the output of Get-DomainComputer in xml format, after export the object via $object|Export-CliXML "<Path>"
}
catch{
Write-Host "$($_.exception.message) $($_.errordetails.message)"
$true| Should -BeTrue
}
}
}

Describe "Connection Tests: Disconnect-SCuBATenant"{
$script:test=0
$script:test++
It "$("$script:test".padleft(3, '0')): Syntax test"{
$script:syntax = Get-Content "$PSScriptRoot/MockData/SyntaxMockData/Disconnect-SCuBATenant-Mock-Data.txt" |Out-String
(Get-Command -Syntax Disconnect-SCuBATenant).Trim()| Should -Be $script:syntax #Can be changed if someone gives me the output of the command before the pipeline
}
$script:test++
It "$("$script:test".padleft(3, '0')): Compatibility with test objects - Success"{
try{
Disconnect-SCuBATenant -ProductNames "teams"
$true| Should -BeTrue #Can be changed if someone gives me the output of Get-DomainComputer in xml format, after export the object via $object|Export-CliXML "<Path>"
}
catch{
Write-Host "$($_.exception.message) $($_.errordetails.message)"
$false| Should -BeTrue
}
}
$script:test++
It "$("$script:test".padleft(3, '0')): Compatibility with test objects - failure"{
try{
Disconnect-SCuBATenant -ProductNames "teams-fail"
$false| Should -BeTrue #Can be changed if someone gives me the output of Get-DomainComputer in xml format, after export the object via $object|Export-CliXML "<Path>"
}
catch{
Write-Host "$($_.exception.message) $($_.errordetails.message)"
$true| Should -BeTrue
}
}
}
66 changes: 66 additions & 0 deletions Testing/AdvancedUnitTests/Connections/ConnectionHelper.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Import-Module "$PSScriptRoot/../../../PowerShell/ScubaGear/Modules/Connection/ConnectHelpers.psm1"
Import-Module "$PSScriptRoot/../pester-installables/Pester/src/Pester.psd1"

Describe "Connection Helper Tests: Connect-EXOHelper "{
$script:test=0
$script:test++
It "$("$script:test".padleft(3, '0')): Syntax test"{
$script:syntax = Get-Content "$PSScriptRoot/MockData/SyntaxMockData/ConnectionHelper-mock-data.txt" |Out-String
(Get-Command -Syntax Connect-EXOHelper).Trim()| Should -Be $script:syntax #Can be changed if someone gives me the output of the command before the pipeline
}
$script:test++
It "$("$script:test".padleft(3, '0')): Compatibility with test objects - Success"{
try{
Connect-EXOHelper -M365Environment "commercial"
$true| Should -BeTrue #Can be changed if someone gives me the output of Get-DomainComputer in xml format, after export the object via $object|Export-CliXML "<Path>"
}
catch{
Write-Host "$($_.exception.message) $($_.errordetails.message)"
$false| Should -BeTrue
}
}
$script:test++
It "$("$script:test".padleft(3, '0')): Compatibility with test objects - failure"{
try{
Connect-EXOHelper -M365Environment "commercial-fail"
$false| Should -BeTrue #Can be changed if someone gives me the output of Get-DomainComputer in xml format, after export the object via $object|Export-CliXML "<Path>"
}
catch{
Write-Host "$($_.exception.message) $($_.errordetails.message)"
$true| Should -BeTrue
}
}
}

Describe "Connection Helper Tests: Connect-DefenderHelper"{
$script:test=0
$script:test++
It "$("$script:test".padleft(3, '0')): Syntax test"{
$script:syntax = Get-Content "$PSScriptRoot/MockData/SyntaxMockData/Connect-DefenderHelper-Mock-Data.txt" |Out-String
(Get-Command -Syntax Connect-DefenderHelper).Trim()| Should -Be $script:syntax #Can be changed if someone gives me the output of the command before the pipeline
}
$script:test++
It "$("$script:test".padleft(3, '0')): Compatibility with test objects - Success"{
try{
Connect-DefenderHelper -M365Environment "commercial"
$true| Should -BeTrue #Can be changed if someone gives me the output of Get-DomainComputer in xml format, after export the object via $object|Export-CliXML "<Path>"
}
catch{
Write-Host "$($_.exception.message) $($_.errordetails.message)"
$false| Should -BeTrue
}
}
$script:test++
It "$("$script:test".padleft(3, '0')): Compatibility with test objects - failure"{
try{
Connect-DefenderHelper -M365Environment "commercial-fail"
$false| Should -BeTrue #Can be changed if someone gives me the output of Get-DomainComputer in xml format, after export the object via $object|Export-CliXML "<Path>"
}
catch{
Write-Host "$($_.exception.message) $($_.errordetails.message)"
$true| Should -BeTrue
}
}
}

Connect-DefenderHelper
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Connect-DefenderHelper [-M365Environment] <string> [[-ServicePrincipalParams] <hashtable>] [<CommonParameters>]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Connect-Tenant [-ProductNames <string[]>] [-M365Environment <string>] [-ServicePrincipalParams <hashtable>] [<CommonParameters>]

Connect-Tenant [-ProductNames <string[]>] [-M365Environment <string>] [-ServicePrincipalParams <hashtable>] [<CommonParameters>]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Connect-EXOHelper [-M365Environment] <string> [[-ServicePrincipalParams] <hashtable>] [<CommonParameters>]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disconnect-SCuBATenant [[-ProductNames] <string[]>] [<CommonParameters>]
1 change: 1 addition & 0 deletions Testing/AdvancedUnitTests/pester-installables/Pester
Submodule Pester added at 42db19