Skip to content

Commit

Permalink
Update Smoke Test to handle CAP (#418)
Browse files Browse the repository at this point in the history
* Fix CAP table check

* Fix lint issue
  • Loading branch information
crutchfield authored and schrolla committed Nov 2, 2023
1 parent fd767b6 commit bce89ae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Testing/Functional/SmokeTest/SmokeTest001.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ Describe "Smoke Test: Generate Output" {
Context "Invoke Scuba for $Organization" {
BeforeAll {
if ($PSCmdlet.ParameterSetName -eq 'Manual'){
{ Invoke-SCuBA -ProductNames "*" -M365Environment $M365Environment } |
{ Invoke-SCuBA -ProductNames "*" -M365Environment $M365Environment -Quiet} |
Should -Not -Throw
}
else {
{ Invoke-SCuBA -CertificateThumbprint $Thumbprint -AppID $AppId -Organization $Organization -ProductNames "*" -M365Environment $M365Environment } |
{ Invoke-SCuBA -CertificateThumbprint $Thumbprint -AppID $AppId -Organization $Organization -ProductNames "*" -M365Environment $M365Environment -Quiet} |
Should -Not -Throw
}
$ReportFolders = Get-ChildItem . -directory -Filter "M365BaselineConformance*" | Sort-Object -Property LastWriteTime -Descending
Expand Down
26 changes: 24 additions & 2 deletions Testing/Functional/SmokeTest/SmokeTest002.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ param (
Import-Module Selenium

Describe -Tag "UI","Chrome" -Name "Test Report with <Browser> for $OrganizationName" -ForEach @(
@{ Browser = "Chrome"; Driver = Start-SeChrome -Headless -Arguments @('start-maximized') 2>$null }
@{ Browser = "Chrome"; Driver = Start-SeChrome -Headless -Arguments @('start-maximized', 'AcceptInsecureCertificates') 2>$null }
){
BeforeAll {
$ReportFolders = Get-ChildItem . -directory -Filter "M365BaselineConformance*" | Sort-Object -Property LastWriteTime -Descending
Expand Down Expand Up @@ -105,12 +105,34 @@ Describe -Tag "UI","Chrome" -Name "Test Report with <Browser> for $OrganizationN
$Rows = Get-SeElement -Element $Table -By TagName 'tr'
$Rows.Count | Should -BeGreaterThan 0

# First Table in report is generally tenant data
if ($Table.GetProperty("id") -eq "tenant-data"){
$Rows.Count | Should -BeExactly 2
$TenantDataColumns = Get-SeElement -Target $Rows[1] -By TagName "td"
$Tenant = $TenantDataColumns[0].Text
$Tenant | Should -Be $OrganizationName -Because "Tenant is $Tenant"
} else {
}
# AAD detailed report has a Conditional Access Policy table
elseif ($Table.GetAttribute("class") -eq "caps_table"){
ForEach ($Row in $Rows){
$RowHeaders = Get-SeElement -Element $Row -By TagName 'th'
$RowData = Get-SeElement -Element $Row -By TagName 'td'

($RowHeaders.Count -eq 0 ) -xor ($RowData.Count -eq 0) | Should -BeTrue -Because "Any given row should be homogenious"

# NOTE: Checking for 8 columns since first is 'expand' column
if ($RowHeaders.Count -gt 0){
$RowHeaders.Count | Should -BeExactly 8
$RowHeaders[1].text | Should -BeLikeExactly "Name"
}

if ($RowData.Count -gt 0){
$RowData.Count | Should -BeExactly 8
}
}
}
# Default is normal policy results table
else {
# Control report tables
ForEach ($Row in $Rows){
$RowHeaders = Get-SeElement -Element $Row -By TagName 'th'
Expand Down

0 comments on commit bce89ae

Please sign in to comment.