Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Numerous changes to automated testing
Browse files Browse the repository at this point in the history
Numerous changes to automated testing and added code of conduct to
readme
  • Loading branch information
powershellshock committed Jun 13, 2016
1 parent fd5c525 commit 2485f4f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Function Test-ForErrors
Catch
{
#Write-Error "$Block encountered. The error was: $Error"
Write-Output (New-Object -TypeName PSObject -Property @{TestItem=$Block;Result=$Error})
Write-Output @{TestItem=$Block;Result=$Error}
}
If ($Error) {Write-Verbose 'ERROR'} Else {Write-Verbose 'SUCCESS'}
$Error.Clear()
Expand Down Expand Up @@ -120,15 +120,15 @@ $FailureTests += {Get-CASFile -ResultSetSize 5001}
#Get-CASAccount -ServiceNames 'Microsoft Cloud App Security' | FT


$SuccessTestResults += $SuccessTests | ForEach {Test-ForErrors $_ -Verbose}
$SuccessTestResults += $SuccessTests | ForEach {Test-ForErrors $_ }
If ($SuccessTestResults.Count -ne 0)
{
$OverallSuccess = $false
Write-Warning ("Testing found "+$SuccessTestResults.Count+" unexpected errors in success tests:")
$SuccessTestResults | FT TestItem,Result
}

$FailureTestResults += $FailureTests | ForEach {Test-ForErrors $_ -Verbose}
$FailureTestResults += $FailureTests | ForEach {Test-ForErrors $_ }
If ($FailureTestResults.Count -ne $FailureTests.Count)
{
$OverallSuccess = $false
Expand Down
45 changes: 45 additions & 0 deletions Invoke-CASModuleResultCountTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

If (Get-Module Cloud-App-Security) {Remove-Module Cloud-App-Security}
$ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
Import-Module "$ScriptPath\Cloud-App-Security.psm1"

#$CASCredential = Import-Clixml C:\Users\jpoeppel\mod102677.credential


# Initialize
$ErrorAction = 'Continue'
$CountTests = @()


$OverallSuccess = $true


#region ---------- Count Tests ----------

$CountTests += New-Object PSObject -Property @{'Test'={Get-CASAccount -ResultSetSize 1};'ExpectedCount'=1;'ResultCount'=$null}
$CountTests += New-Object PSObject -Property @{'Test'={Get-CASAccount -ResultSetSize 2};'ExpectedCount'=2;'ResultCount'=$null}

$CountTests += New-Object PSObject -Property @{'Test'={Get-CASActivity -ResultSetSize 1};'ExpectedCount'=1;'ResultCount'=$null}
$CountTests += New-Object PSObject -Property @{'Test'={Get-CASActivity -ResultSetSize 2};'ExpectedCount'=2;'ResultCount'=$null}

$CountTests += New-Object PSObject -Property @{'Test'={Get-CASAlert -ResultSetSize 1};'ExpectedCount'=1;'ResultCount'=$null}
$CountTests += New-Object PSObject -Property @{'Test'={Get-CASAlert -ResultSetSize 2};'ExpectedCount'=2;'ResultCount'=$null}

$CountTests += New-Object PSObject -Property @{'Test'={Get-CASFile -ResultSetSize 1};'ExpectedCount'=1;'ResultCount'=$null}
$CountTests += New-Object PSObject -Property @{'Test'={Get-CASFile -ResultSetSize 2};'ExpectedCount'=2;'ResultCount'=$null}

#endregion ---------- Count Tests ----------


ForEach ($t in $CountTests)
{
$t.ResultCount = ((&($t.Test) | Measure-Object).Count)

If ($t.ResultCount -ne $t.ExpectedCount)
{
$OverallSuccess = $false
Write-Warning $t
}
}

Write-Output $OverallSuccess
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Cloud-App-Security
Powershell module for Microsoft Cloud App Security

This project has adopted the [Microsoft Open Source Code of Conduct](http://microsoft.github.io/codeofconduct). For more information see the [Code of Conduct FAQ](http://microsoft.github.io/codeofconduct/faq.md) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
9 changes: 9 additions & 0 deletions Start-CASModuleAllTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$Passed = $True

#If (!(.\Invoke-CASModuleErrorTests.ps1)) {$Passed = $false}
If (!(.\Invoke-CASModuleResultCountTests.ps1)) {$Passed = $false}

If ($Passed) {Write-Host -ForegroundColor Green "All tests passed."}
Else {Write-Host -ForegroundColor Yellow "One or more tests failed!"}

Read-Host -Prompt 'Testing complete, press Enter to close'

0 comments on commit 2485f4f

Please sign in to comment.