Skip to content

Commit

Permalink
Added disconnect and tested for connection
Browse files Browse the repository at this point in the history
  • Loading branch information
merill committed Dec 10, 2024
1 parent b8703b4 commit 2edf7fb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
3 changes: 1 addition & 2 deletions powershell/public/Disconnect-Maester.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ function Disconnect-Maester {
Write-Verbose -Message "Disconnecting from Microsoft Exchange Online."
Disconnect-ExchangeOnline
}
if($__MtSession.Connections -contains "Teams"){ #ToValidate: Preview
#if($__MtSession.Connections -contains "Teams" -or $__MtSession.Connections -contains "All"){
if($__MtSession.Connections -contains "Teams" -or $__MtSession.Connections -contains "All"){
Write-Verbose -Message "Disconnecting from Microsoft Teams."
Disconnect-MicrosoftTeams
}
Expand Down
75 changes: 38 additions & 37 deletions tests/Maester/Teams/Test-TeamsMeeting.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
BeforeDiscovery {
try {

$TeamsMeetingPolicy = Get-CsTeamsMeetingPolicy
Write-Verbose "Found $($TeamsMeetingPolicy.Count) Teams Meeting policies"
$TeamsMeetingPolicyGlobal = $TeamsMeetingPolicy | Where-Object {$_.Identity -eq "Global"}
$TeamsMeetingPolicyGlobal = $TeamsMeetingPolicy | Where-Object { $_.Identity -eq "Global" }
Write-Verbose "Filtered $( $TeamsMeetingPolicyGlobal.Count) Global Teams Meeting policy"

} catch {
Expand All @@ -15,6 +16,11 @@ Describe "Teams Meeting policies" -Tag "Maester", "Teams", "MeetingPolicy" {

It "Configure which users are allowed to present in Teams meetings" -Tag "AllowParticipantGiveRequestControl" {

if (!(Test-MtConnection Teams)) {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
return $null
}

$result = $TeamsMeetingPolicyGlobal.AllowParticipantGiveRequestControl

if ($result -eq $false) {
Expand All @@ -25,17 +31,17 @@ Describe "Teams Meeting policies" -Tag "Maester", "Teams", "MeetingPolicy" {
$testDetailsMarkdown = "Only allow users with presenter rights to share content during meetings. Restricting who can present limits meeting disruptions and reduces the risk of unwanted or inappropriate content being shared."
Add-MtTestResultDetail -Description $testDetailsMarkdown -Result $testResultMarkdown

# Actual test
if ($null -ne $result) {
$result | Should -Be $false -Because "AllowParticipantGiveRequestControl should be False"
} else {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
}
$result | Should -Be $false -Because "AllowParticipantGiveRequestControl should be False"
}

It "Only invited users should be automatically admitted to Teams meetings" -Tag "AutoAdmittedUsers" {
#($TeamsMeetingPolicyGlobal.AutoAdmittedUsers -eq "InvitedUsers")

if (!(Test-MtConnection Teams)) {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
return $null
}

$result = $TeamsMeetingPolicyGlobal.AutoAdmittedUsers

if ($result -eq "InvitedUsers") {
Expand All @@ -46,16 +52,16 @@ Describe "Teams Meeting policies" -Tag "Maester", "Teams", "MeetingPolicy" {
$testDetailsMarkdown = "Users who aren’t invited to a meeting shouldn’t be let in automatically, because it increases the risk of data leaks, inappropriate content being shared, or malicious actors joining. If only invited users are automatically admitted, then users who weren’t invited will be sent to a meeting lobby. The host can then decide whether or not to let them in."
Add-MtTestResultDetail -Description $testDetailsMarkdown -Result $testResultMarkdown

# Actual test
if ($null -ne $result) {
$result | Should -Be "InvitedUsers" -Because "AutoAdmittedUsers should be InvitedUsers"
} else {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
}
$result | Should -Be "InvitedUsers" -Because "AutoAdmittedUsers should be InvitedUsers"
}

It "Restrict anonymous users from joining meetings" -Tag "AllowAnonymousUsersToJoinMeeting" {

if (!(Test-MtConnection Teams)) {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
return $null
}

$result = $TeamsMeetingPolicyGlobal.AllowAnonymousUsersToJoinMeeting

if ($result -eq $false) {
Expand All @@ -66,16 +72,16 @@ Describe "Teams Meeting policies" -Tag "Maester", "Teams", "MeetingPolicy" {
$testDetailsMarkdown = "By restricting anonymous users from joining Microsoft Teams meetings, you have full control over meeting access. Anonymous users may not be from your organization and could have joined for malicious purposes, such as gaining information about your organization through conversations."
Add-MtTestResultDetail -Description $testDetailsMarkdown -Result $testResultMarkdown

# Actual test
if ($null -ne $result) {
$result | Should -Be $false -Because "AllowAnonymousUsersToJoinMeeting should be False"
} else {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
}
$result | Should -Be $false -Because "AllowAnonymousUsersToJoinMeeting should be False"
}

It "Restrict anonymous users from starting Teams meetings" -Tag "AllowAnonymousUsersToStartMeeting" {

if (!(Test-MtConnection Teams)) {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
return $null
}

$result = $TeamsMeetingPolicyGlobal.AllowAnonymousUsersToStartMeeting

if ($result -eq $false) {
Expand All @@ -86,16 +92,16 @@ Describe "Teams Meeting policies" -Tag "Maester", "Teams", "MeetingPolicy" {
$testDetailsMarkdown = "If anonymous users are allowed to start meetings, they can admit any users from the lobbies, authenticated or otherwise. Anonymous users haven’t been authenticated, which can increase the risk of data leakage."
Add-MtTestResultDetail -Description $testDetailsMarkdown -Result $testResultMarkdown

# Actual test
if ($null -ne $result) {
$result | Should -Be $false -Because "AllowAnonymousUsersToStartMeeting should be False"
} else {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
}
$result | Should -Be $false -Because "AllowAnonymousUsersToStartMeeting should be False"
}

It "Limit external participants from having control in a Teams meeting" -Tag "AllowExternalParticipantGiveRequestControl" {

if (!(Test-MtConnection Teams)) {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
return $null
}

$result = $TeamsMeetingPolicyGlobal.AllowExternalParticipantGiveRequestControl

if ($result -eq $false) {
Expand All @@ -106,16 +112,16 @@ Describe "Teams Meeting policies" -Tag "Maester", "Teams", "MeetingPolicy" {
$testDetailsMarkdown = "External participants are users that are outside your organization. Limiting their permission to share content, add new users, and more protects your organization’s information from data leaks, inappropriate content being shared, or malicious actors joining the meeting."
Add-MtTestResultDetail -Description $testDetailsMarkdown -Result $testResultMarkdown

# Actual test
if ($null -ne $result) {
$result | Should -Be $false -Because "AllowExternalParticipantGiveRequestControl should be False"
} else {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
}
$result | Should -Be $false -Because "AllowExternalParticipantGiveRequestControl should be False"
}

It "Restrict dial-in users from bypassing a meeting lobby " -Tag "AllowPSTNUsersToBypassLobby" {

if (!(Test-MtConnection Teams)) {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
return $null
}

$result = $TeamsMeetingPolicyGlobal.AllowPSTNUsersToBypassLobby

if ($result -eq $false) {
Expand All @@ -126,11 +132,6 @@ Describe "Teams Meeting policies" -Tag "Maester", "Teams", "MeetingPolicy" {
$testDetailsMarkdown = "Dial-in users aren’t authenticated though the Teams app. Increase the security of your meetings by preventing these unknown users from bypassing the lobby and immediately joining the meeting."
Add-MtTestResultDetail -Description $testDetailsMarkdown -Result $testResultMarkdown

# Actual test
if ($null -ne $result) {
$result | Should -Be $false -Because "AllowPSTNUsersToBypassLobby should be False"
} else {
Add-MtTestResultDetail -SkippedBecause NotConnectedTeams
}
$result | Should -Be $false -Because "AllowPSTNUsersToBypassLobby should be False"
}
}

0 comments on commit 2edf7fb

Please sign in to comment.