From 7a5fdf49bace4755fa79b2b16bd222727ef138e9 Mon Sep 17 00:00:00 2001 From: Emmanuel Ng'ang'a <60355631+emmanuel-karanja@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:46:27 +0300 Subject: [PATCH 1/4] entra-beta-audit changes --- ...ApplicationSignInDetailedSummary.Tests.ps1 | 89 ----------- ...ntraBetaApplicationSignInSummary.Tests.ps1 | 97 ------------ ...tureRolloutPolicyDirectoryObject.Tests.ps1 | 84 ---------- .../Get-EntraBetaAuditDirectoryLog.Tests.ps1 | 147 ------------------ ...tureRolloutPolicyDirectoryObject.Tests.ps1 | 81 ---------- .../New-EntraBetaObjectSetting.Tests.ps1 | 3 + .../Set-EntraBetaObjectSetting.Tests.ps1 | 4 + 7 files changed, 7 insertions(+), 498 deletions(-) delete mode 100644 testVNext/EntraBeta/Applications/Get-EntraBetaApplicationSignInDetailedSummary.Tests.ps1 delete mode 100644 testVNext/EntraBeta/Applications/Get-EntraBetaApplicationSignInSummary.Tests.ps1 delete mode 100644 testVNext/EntraBeta/DirectoryManagement/Add-EntraBetaFeatureRolloutPolicyDirectoryObject.Tests.ps1 delete mode 100644 testVNext/EntraBeta/DirectoryManagement/Get-EntraBetaAuditDirectoryLog.Tests.ps1 delete mode 100644 testVNext/EntraBeta/DirectoryManagement/Remove-EntraBetaFeatureRolloutPolicyDirectoryObject.Tests.ps1 diff --git a/testVNext/EntraBeta/Applications/Get-EntraBetaApplicationSignInDetailedSummary.Tests.ps1 b/testVNext/EntraBeta/Applications/Get-EntraBetaApplicationSignInDetailedSummary.Tests.ps1 deleted file mode 100644 index 19f19dd634..0000000000 --- a/testVNext/EntraBeta/Applications/Get-EntraBetaApplicationSignInDetailedSummary.Tests.ps1 +++ /dev/null @@ -1,89 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. -# ------------------------------------------------------------------------------ -BeforeAll { - if((Get-Module -Name Microsoft.Graph.Entra.Beta.Applications) -eq $null){ - Import-Module Microsoft.Graph.Entra.Beta.Applications - } - Import-Module (Join-Path $PSScriptRoot "..\..\build\Common-Functions.ps1") -Force - - $scriptblock = { - return @( - [PSCustomObject]@{ - "Id" = "bbbbbbbb-1111-2222-3333-cccccccccccc" - "AppId" = "dddddddd-1111-2222-3333-aaaaaaaaaaaa" - "AppDisplayName" = "Mock Portal" - "AggregatedEventDateTime" = "29-05-2024 00:00:00" - "SignInCount" = "3" - "Status" = @{ - "AdditionalDetails" = $null - "ErrorCode" = "0" - "FailureReason" = $null - "AdditionalProperties" = $null - } - "AdditionalProperties" = @{} - "Parameters" = $args - } - ) - } - - Mock -CommandName Get-MgBetaReportApplicationSignInDetailedSummary -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta.Applications -} - -Describe "Get-EntraBetaApplicationSignInDetailedSummary" { - Context "Test for Get-EntraBetaApplicationSignInDetailedSummary" { - It "Should return specific application signed in detailed summary by filter" { - $result = Get-EntraBetaApplicationSignInDetailedSummary -Filter "appDisplayName eq 'Mock Portal'" - $result | Should -Not -BeNullOrEmpty - $result.AppDisplayName | Should -Be "Mock Portal" - $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" - $result.AppId | Should -Be "dddddddd-1111-2222-3333-aaaaaaaaaaaa" - - Should -Invoke -CommandName Get-MgBetaReportApplicationSignInDetailedSummary -ModuleName Microsoft.Graph.Entra.Beta.Applications -Times 1 - } - It "Should fail when filter is empty" { - { Get-EntraBetaApplicationSignInDetailedSummary -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" - } - It "Should return top 1 application signed in detailed summary" { - $result = Get-EntraBetaApplicationSignInDetailedSummary -Top 1 - $result | Should -Not -BeNullOrEmpty - $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" - - Should -Invoke -CommandName Get-MgBetaReportApplicationSignInDetailedSummary -ModuleName Microsoft.Graph.Entra.Beta.Applications -Times 1 - } - It "Should fail when Top is empty" { - { Get-EntraBetaApplicationSignInDetailedSummary -Top } | Should -Throw "Missing an argument for parameter 'Top'*" - } - It "Should fail when Top is invalid" { - { Get-EntraBetaApplicationSignInDetailedSummary -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" - } - It "Should contain 'User-Agent' header" { - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaApplicationSignInDetailedSummary" - - $result = Get-EntraBetaApplicationSignInDetailedSummary -Filter "appDisplayName eq 'Mock Portal'" - $result | Should -Not -BeNullOrEmpty - - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaApplicationSignInDetailedSummary" - - Should -Invoke -CommandName Get-MgBetaReportApplicationSignInDetailedSummary -ModuleName Microsoft.Graph.Entra.Beta.Applications -Times 1 -ParameterFilter { - $Headers.'User-Agent' | Should -Be $userAgentHeaderValue - $true - } - } - It "Should execute successfully without throwing an error" { - # Disable confirmation prompts - $originalDebugPreference = $DebugPreference - $DebugPreference = 'Continue' - - try { - # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaApplicationSignInDetailedSummary -Filter "appDisplayName eq 'Mock Portal'" -Debug } | Should -Not -Throw - } finally { - # Restore original confirmation preference - $DebugPreference = $originalDebugPreference - } - } - - } -} - diff --git a/testVNext/EntraBeta/Applications/Get-EntraBetaApplicationSignInSummary.Tests.ps1 b/testVNext/EntraBeta/Applications/Get-EntraBetaApplicationSignInSummary.Tests.ps1 deleted file mode 100644 index 45af3197d6..0000000000 --- a/testVNext/EntraBeta/Applications/Get-EntraBetaApplicationSignInSummary.Tests.ps1 +++ /dev/null @@ -1,97 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. -# ------------------------------------------------------------------------------ -BeforeAll { - if((Get-Module -Name Microsoft.Graph.Entra.Beta.Applications) -eq $null){ - Import-Module Microsoft.Graph.Entra.Beta.Applications - } - Import-Module (Join-Path $PSScriptRoot "..\..\build\Common-Functions.ps1") -Force - - -$scriptblock = { - return @{ - value = @( - @{ - "Id" = "bbbbbbbb-1111-2222-3333-cccccccccccc" - "AppId" = "dddddddd-1111-2222-3333-aaaaaaaaaaaa" - "AppDisplayName" = "Mock Portal" - "AggregatedEventDateTime" = "29-05-2024 00:00:00" - "SignInCount" = "3" - "isOrganizationDefault" = $false - "createdDateTime" = "16-08-2023 08:25:02" - "Parameters" = $args - } - - ) - - } - - } - - Mock -CommandName Invoke-GraphRequest -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta.Applications -} - -Describe "Get-EntraBetaApplicationSignInSummary" { - Context "Test for Get-EntraBetaApplicationSignInSummary" { - It "Should return application sign in summary" { - $result = Get-EntraBetaApplicationSignInSummary -Days "30" - $result | Should -Not -BeNullOrEmpty - $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" - $result.AppDisplayName | Should -Be "Mock Portal" - $result.AppId | Should -be "dddddddd-1111-2222-3333-aaaaaaaaaaaa" - - Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta.Applications -Times 1 - } - It "Should fail when Days is empty" { - { Get-EntraBetaApplicationSignInSummary -Days } | Should -Throw "Missing an argument for parameter 'Days'*" - } - It "Should return specific application signed in summary by filter" { - $result = Get-EntraBetaApplicationSignInSummary -Days "7" -Filter "AppdisplayName eq 'Mock Portal'" - $result | Should -Not -BeNullOrEmpty - $result.AppDisplayName | Should -Be "Mock Portal" - - Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta.Applications -Times 1 - } - It "Should fail when filter is empty" { - { Get-EntraBetaApplicationSignInDetailedSummary -Filter } | Should -Throw "Missing an argument for parameter 'Filter'*" - } - It "Should return top 1 application sign in summary" { - $result = Get-EntraBetaApplicationSignInSummary -Days "7" -Top 1 - $result | Should -Not -BeNullOrEmpty - $result.Id | Should -Be "bbbbbbbb-1111-2222-3333-cccccccccccc" - - Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta.Applications -Times 1 - } - It "Should fail when Top is empty" { - { Get-EntraBetaApplicationSignInSummary -Days "7" -Top } | Should -Throw "Missing an argument for parameter 'Top'*" - } - It "Should fail when Top is invalid" { - { Get-EntraBetaApplicationSignInSummary -Days "7" -Top XY } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" - } - It "Should contain 'User-Agent' header" { - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaApplicationSignInSummary" - - $result = Get-EntraBetaApplicationSignInSummary -Days "30" - $result | Should -Not -BeNullOrEmpty - Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta.Applications -Times 1 -ParameterFilter { - $Headers.'User-Agent' | Should -Be $userAgentHeaderValue - $true - } - } - It "Should execute successfully without throwing an error" { - # Disable confirmation prompts - $originalDebugPreference = $DebugPreference - $DebugPreference = 'Continue' - - try { - # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaApplicationSignInSummary -Days "30" -Debug } | Should -Not -Throw - } finally { - # Restore original confirmation preference - $DebugPreference = $originalDebugPreference - } - } - - } -} - diff --git a/testVNext/EntraBeta/DirectoryManagement/Add-EntraBetaFeatureRolloutPolicyDirectoryObject.Tests.ps1 b/testVNext/EntraBeta/DirectoryManagement/Add-EntraBetaFeatureRolloutPolicyDirectoryObject.Tests.ps1 deleted file mode 100644 index 6290e005e0..0000000000 --- a/testVNext/EntraBeta/DirectoryManagement/Add-EntraBetaFeatureRolloutPolicyDirectoryObject.Tests.ps1 +++ /dev/null @@ -1,84 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. -# ------------------------------------------------------------------------------ - -BeforeAll { - if((Get-Module -Name Microsoft.Graph.Entra.Beta.DirectoryManagement) -eq $null){ - Import-Module Microsoft.Graph.Entra.Beta.DirectoryManagement - } - Import-Module (Join-Path $PSScriptRoot "..\..\build\Common-Functions.ps1") -Force - - Mock -CommandName New-MgBetaDirectoryFeatureRolloutPolicyApplyToByRef -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -} - -Describe "Add-EntraBetaFeatureRolloutPolicyDirectoryObject" { - Context "Test for Add-EntraBetaFeatureRolloutPolicyDirectoryObject" { - It "Should adds a group to the cloud authentication roll-out policy in Azure AD." { - $result = Add-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" - $result | Should -BeNullOrEmpty - - Should -Invoke -CommandName New-MgBetaDirectoryFeatureRolloutPolicyApplyToByRef -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 - } - - It "Should fail when Id is empty" { - { Add-EntraBetaFeatureRolloutPolicyDirectoryObject -Id -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Missing an argument for parameter 'Id'.*" - } - - It "Should fail when Id is invalid" { - { Add-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." - } - - It "Should fail when RefObjectId is empty" { - { Add-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId } | Should -Throw "Missing an argument for parameter 'RefObjectId'.*" - } - - It "Should fail when RefObjectId is invalid" { - { Add-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter 'RefObjectId' because it is an empty string." - } - - It "Should contain FeatureRolloutPolicyId in parameters when passed Id to it" { - Mock -CommandName New-MgBetaDirectoryFeatureRolloutPolicyApplyToByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement - - $result = Add-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" - $params = Get-Parameters -data $result - $params.FeatureRolloutPolicyId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" - } - - It "Should contain OdataId in parameters when passed RefObjectId to it" { - Mock -CommandName New-MgBetaDirectoryFeatureRolloutPolicyApplyToByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement - - $result = Add-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" - $value = "https://graph.microsoft.com/v1.0/directoryObjects/bbbbcccc-1111-dddd-2222-eeee3333ffff" - $params= Get-Parameters -data $result - $params.OdataId | Should -Be $value - } - - It "Should contain 'User-Agent' header" { - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaFeatureRolloutPolicyDirectoryObject" - - Add-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" - - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraBetaFeatureRolloutPolicyDirectoryObject" - Should -Invoke -CommandName New-MgBetaDirectoryFeatureRolloutPolicyApplyToByRef -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 -ParameterFilter { - $Headers.'User-Agent' | Should -Be $userAgentHeaderValue - $true - } - } - - It "Should execute successfully without throwing an error " { - # Disable confirmation prompts - $originalDebugPreference = $DebugPreference - $DebugPreference = 'Continue' - - try { - # Act & Assert: Ensure the function doesn't throw an exception - { Add-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "aaaabbbb-0000-cccc-1111-dddd2222eeee" -RefObjectId "bbbbcccc-1111-dddd-2222-eeee3333ffff" -Debug} | Should -Not -Throw - } finally { - # Restore original confirmation preference - $DebugPreference = $originalDebugPreference - } - } - } -} - - diff --git a/testVNext/EntraBeta/DirectoryManagement/Get-EntraBetaAuditDirectoryLog.Tests.ps1 b/testVNext/EntraBeta/DirectoryManagement/Get-EntraBetaAuditDirectoryLog.Tests.ps1 deleted file mode 100644 index b54b5a744c..0000000000 --- a/testVNext/EntraBeta/DirectoryManagement/Get-EntraBetaAuditDirectoryLog.Tests.ps1 +++ /dev/null @@ -1,147 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. -# ------------------------------------------------------------------------------ - -BeforeAll { - if((Get-Module -Name Microsoft.Graph.Entra.Beta.DirectoryManagement) -eq $null){ - Import-Module Microsoft.Graph.Entra.Beta.DirectoryManagement - } - Import-Module (Join-Path $PSScriptRoot "..\..\build\Common-Functions.ps1") -Force - - $scriptblock = { - return @( - [PSCustomObject]@{ - "InitiatedBy" = [PSCustomObject]@{ - "App" = "" - "User" = "" - "AdditionalProperties" = @{} - } - "TargetResources" = [PSCustomObject]@{ - "DisplayName" = "test" - "GroupType" = "" - "Id" = "00000000-0000-0000-0000-000000000000" - "ModifiedProperties" = @() - "Type" = "N/A" - "UserPrincipalName" = "" - "AdditionalProperties" = @{} - } - "AdditionalDetails" = "" - "ActivityDateTime" = "28-May-24 11:49:02 AM" - "ActivityDisplayName" = "GroupsODataV4_GetgroupLifecyclePolicies" - "Category" = "GroupManagement" - "CorrelationId" = "aaaabbbb-0000-cccc-1111-dddd2222eeee" - "Id" = "bbbbcccc-1111-dddd-2222-eeee3333ffff" - "LoggedByService" = "Self-service Group Management" - "OperationType" = "Update" - "Result" = "success" - "ResultReason" = "OK" - "UserAgent" = "" - "AdditionalProperties" = @{} - "Parameters" = $args - } - ) - } - Mock -CommandName Get-MgBetaAuditLogDirectoryAudit -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -} - -Describe "Get-EntraBetaAuditDirectoryLog" { - Context "Test for Get-EntraBetaAuditDirectoryLog" { - It "Should get all logs" { - $result = Get-EntraBetaAuditDirectoryLog -All - $result | Should -Not -BeNullOrEmpty - Should -Invoke -CommandName Get-MgBetaAuditLogDirectoryAudit -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 - } - - It "Should fail when All has argument" { - { Get-EntraBetaAuditDirectoryLog -All $true } | Should -Throw "A positional parameter cannot be found that accepts argument 'True'." - } - - It "Should get first n logs" { - $result = Get-EntraBetaAuditDirectoryLog -Top 1 - $result | Should -Not -BeNullOrEmpty - $result.ActivityDateTime | Should -Be "28-May-24 11:49:02 AM" - $result.ActivityDisplayName | Should -Be "GroupsODataV4_GetgroupLifecyclePolicies" - $result.Category | Should -Be "GroupManagement" - $result.CorrelationId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" - $result.Id | Should -Be "bbbbcccc-1111-dddd-2222-eeee3333ffff" - $result.LoggedByService | Should -Be "Self-service Group Management" - - Should -Invoke -CommandName Get-MgBetaAuditLogDirectoryAudit -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 - } - - It "Should fail when top is empty" { - { Get-EntraBetaAuditDirectoryLog -Top } | Should -Throw "Missing an argument for parameter 'Top'*" - } - - It "Should fail when top is invalid" { - { Get-EntraBetaAuditDirectoryLog -Top y } | Should -Throw "Cannot process argument transformation on parameter 'Top'*" - } - - It "Should get audit logs containing a given ActivityDisplayName" { - $result = Get-EntraBetaAuditDirectoryLog -Filter "ActivityDisplayName eq 'GroupsODataV4_GetgroupLifecyclePolicies'" -Top 1 - $result | Should -Not -BeNullOrEmpty - $result.ActivityDateTime | Should -Be "28-May-24 11:49:02 AM" - $result.ActivityDisplayName | Should -Be "GroupsODataV4_GetgroupLifecyclePolicies" - $result.Category | Should -Be "GroupManagement" - $result.CorrelationId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" - $result.Id | Should -Be "bbbbcccc-1111-dddd-2222-eeee3333ffff" - $result.LoggedByService | Should -Be "Self-service Group Management" - - Should -Invoke -CommandName Get-MgBetaAuditLogDirectoryAudit -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 - } - - It "Should fail when Filter is empty" { - { Get-EntraBetaAuditDirectoryLog -Filter -Top 1} | Should -Throw "Missing an argument for parameter 'Filter'*" - } - - It "Should get all audit logs with a given result(success)" { - $result = Get-EntraBetaAuditDirectoryLog -Filter "result eq 'success'" - $result | Should -Not -BeNullOrEmpty - - Should -Invoke -CommandName Get-MgBetaAuditLogDirectoryAudit -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 - } - - It "Should get all audit logs with a given result(failure)" { - $result = Get-EntraBetaAuditDirectoryLog -Filter "result eq 'failure'" -All - $result | Should -Not -BeNullOrEmpty - - Should -Invoke -CommandName Get-MgBetaAuditLogDirectoryAudit -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 - } - - It "Property parameter should work" { - $result = Get-EntraBetaAuditDirectoryLog -Property ActivityDisplayName - $result | Should -Not -BeNullOrEmpty - $result.ActivityDisplayName | Should -Be 'GroupsODataV4_GetgroupLifecyclePolicies' - - Should -Invoke -CommandName Get-MgBetaAuditLogDirectoryAudit -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 - } - It "Should fail when Property is empty" { - { Get-EntraBetaAuditDirectoryLog -Property } | Should -Throw "Missing an argument for parameter 'Property'*" - } - - It "Should contain 'User-Agent' header" { - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaAuditDirectoryLog" - $result= Get-EntraBetaAuditDirectoryLog - $result | Should -Not -BeNullOrEmpty - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaAuditDirectoryLog" - Should -Invoke -CommandName Get-MgBetaAuditLogDirectoryAudit -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 -ParameterFilter { - $Headers.'User-Agent' | Should -Be $userAgentHeaderValue - $true - } - } - It "Should execute successfully without throwing an error " { - # Disable confirmation prompts - $originalDebugPreference = $DebugPreference - $DebugPreference = 'Continue' - - try { - # Act & Assert: Ensure the function doesn't throw an exception - { Get-EntraBetaAuditDirectoryLog -Top 1 -Debug } | Should -Not -Throw - } finally { - # Restore original confirmation preference - $DebugPreference = $originalDebugPreference - } - } - } -} - diff --git a/testVNext/EntraBeta/DirectoryManagement/Remove-EntraBetaFeatureRolloutPolicyDirectoryObject.Tests.ps1 b/testVNext/EntraBeta/DirectoryManagement/Remove-EntraBetaFeatureRolloutPolicyDirectoryObject.Tests.ps1 deleted file mode 100644 index 9db8f3a398..0000000000 --- a/testVNext/EntraBeta/DirectoryManagement/Remove-EntraBetaFeatureRolloutPolicyDirectoryObject.Tests.ps1 +++ /dev/null @@ -1,81 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. -# ------------------------------------------------------------------------------ - -BeforeAll { - if((Get-Module -Name Microsoft.Graph.Entra.Beta.DirectoryManagement) -eq $null){ - Import-Module Microsoft.Graph.Entra.Beta.DirectoryManagement - } - Import-Module (Join-Path $PSScriptRoot "..\..\build\Common-Functions.ps1") -Force - - Mock -CommandName Remove-MgBetaPolicyFeatureRolloutPolicyApplyToByRef -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -} - -Describe "Remove-EntraBetaFeatureRolloutPolicyDirectoryObject" { - Context "Test for Remove-EntraBetaFeatureRolloutPolicyDirectoryObject" { - It "Should removes a group from the cloud authentication roll-out policy from Azure AD" { - $result = Remove-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" - $result | Should -BeNullOrEmpty - - Should -Invoke -CommandName Remove-MgBetaPolicyFeatureRolloutPolicyApplyToByRef -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 - } - - It "Should fail when Id is empty" { - { Remove-EntraBetaFeatureRolloutPolicyDirectoryObject -Id -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" } | Should -Throw "Missing an argument for parameter 'Id'*" - } - - It "Should fail when Id is invalid" { - { Remove-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "" -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." - } - - It "Should fail when ObjectId is empty" { - { Remove-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" - } - - It "Should fail when ObjectId is invalid" { - { Remove-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -ObjectId ""} | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." - } - - It "Should contain DirectoryObjectId in parameters when passed ObjectId to it" { - Mock -CommandName Remove-MgBetaPolicyFeatureRolloutPolicyApplyToByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement - - $result = Remove-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" - $params = Get-Parameters -data $result - $params.DirectoryObjectId | Should -Be "aaaabbbb-0000-cccc-1111-dddd2222eeee" - } - - It "Should contain FeatureRolloutPolicyId in parameters when passed Id to it" { - Mock -CommandName Remove-MgBetaPolicyFeatureRolloutPolicyApplyToByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement - - $result = Remove-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" - $params = Get-Parameters -data $result - $params.FeatureRolloutPolicyId | Should -Be "bbbbcccc-1111-dddd-2222-eeee3333ffff" - } - - It "Should contain 'User-Agent' header" { - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaFeatureRolloutPolicyDirectoryObject" - $result = Remove-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" - $result | Should -BeNullOrEmpty - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaFeatureRolloutPolicyDirectoryObject" - Should -Invoke -CommandName Remove-MgBetaPolicyFeatureRolloutPolicyApplyToByRef -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement -Times 1 -ParameterFilter { - $Headers.'User-Agent' | Should -Be $userAgentHeaderValue - $true - } - } - - It "Should execute successfully without throwing an error " { - # Disable confirmation prompts - $originalDebugPreference = $DebugPreference - $DebugPreference = 'Continue' - - try { - # Act & Assert: Ensure the function doesn't throw an exception - { Remove-EntraBetaFeatureRolloutPolicyDirectoryObject -Id "bbbbcccc-1111-dddd-2222-eeee3333ffff" -ObjectId "aaaabbbb-0000-cccc-1111-dddd2222eeee" -Debug } | Should -Not -Throw - } finally { - # Restore original confirmation preference - $DebugPreference = $originalDebugPreference - } - } - } -} - diff --git a/testVNext/EntraBeta/Groups/New-EntraBetaObjectSetting.Tests.ps1 b/testVNext/EntraBeta/Groups/New-EntraBetaObjectSetting.Tests.ps1 index ff38f42f1b..4ec74707f7 100644 --- a/testVNext/EntraBeta/Groups/New-EntraBetaObjectSetting.Tests.ps1 +++ b/testVNext/EntraBeta/Groups/New-EntraBetaObjectSetting.Tests.ps1 @@ -5,6 +5,9 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra.Beta.Groups) -eq $null){ Import-Module Microsoft.Graph.Entra.Beta.Groups } + if((Get-Module -Name Microsoft.Graph.Entra.Beta.DirectoryManagement) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta.DirectoryManagement + } Import-Module (Join-Path $PSScriptRoot "..\..\build\Common-Functions.ps1") -Force $scriptblock = { diff --git a/testVNext/EntraBeta/Groups/Set-EntraBetaObjectSetting.Tests.ps1 b/testVNext/EntraBeta/Groups/Set-EntraBetaObjectSetting.Tests.ps1 index 15d8134a65..b272871076 100644 --- a/testVNext/EntraBeta/Groups/Set-EntraBetaObjectSetting.Tests.ps1 +++ b/testVNext/EntraBeta/Groups/Set-EntraBetaObjectSetting.Tests.ps1 @@ -5,6 +5,10 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra.Beta.Groups) -eq $null){ Import-Module Microsoft.Graph.Entra.Beta.Groups } + + if((Get-Module -Name Microsoft.Graph.Entra.Beta.DirectoryManagement) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta.DirectoryManagement + } Import-Module (Join-Path $PSScriptRoot "..\..\build\Common-Functions.ps1") -Force $TemplateScriptblock = { return @( From 1dee23ed81f5cb88c7eafc999922c39417272ea0 Mon Sep 17 00:00:00 2001 From: Emmanuel Ng'ang'a <60355631+emmanuel-karanja@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:01:10 +0300 Subject: [PATCH 2/4] entra-beta-audit changes --- testVNext/EntraBeta/Groups/New-EntraBetaObjectSetting.Tests.ps1 | 2 +- testVNext/EntraBeta/Groups/Set-EntraBetaObjectSetting.Tests.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testVNext/EntraBeta/Groups/New-EntraBetaObjectSetting.Tests.ps1 b/testVNext/EntraBeta/Groups/New-EntraBetaObjectSetting.Tests.ps1 index 4ec74707f7..9cc72a6a1a 100644 --- a/testVNext/EntraBeta/Groups/New-EntraBetaObjectSetting.Tests.ps1 +++ b/testVNext/EntraBeta/Groups/New-EntraBetaObjectSetting.Tests.ps1 @@ -43,7 +43,7 @@ BeforeAll { } ) } - Mock -CommandName Get-MgBetaDirectorySettingTemplate -MockWith $TemplateScriptblock -ModuleName Microsoft.Graph.Entra.Beta.Groups + Mock -CommandName Get-MgBetaDirectorySettingTemplate -MockWith $TemplateScriptblock -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement Mock -CommandName Invoke-GraphRequest -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta.Groups } Describe "New-EntraBetaObjectSetting" { diff --git a/testVNext/EntraBeta/Groups/Set-EntraBetaObjectSetting.Tests.ps1 b/testVNext/EntraBeta/Groups/Set-EntraBetaObjectSetting.Tests.ps1 index b272871076..12be199832 100644 --- a/testVNext/EntraBeta/Groups/Set-EntraBetaObjectSetting.Tests.ps1 +++ b/testVNext/EntraBeta/Groups/Set-EntraBetaObjectSetting.Tests.ps1 @@ -28,7 +28,7 @@ BeforeAll { } ) } - Mock -CommandName Get-MgBetaDirectorySettingTemplate -MockWith $TemplateScriptblock -ModuleName Microsoft.Graph.Entra.Beta.Groups + Mock -CommandName Get-MgBetaDirectorySettingTemplate -MockWith $TemplateScriptblock -ModuleName Microsoft.Graph.Entra.Beta.DirectoryManagement Mock -CommandName Invoke-GraphRequest -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta.Groups } Describe "Set-EntraBetaObjectSetting" { From 7630f1b753dfbca1c6b43188561d0d2007fb2d94 Mon Sep 17 00:00:00 2001 From: Emmanuel Ng'ang'a <60355631+emmanuel-karanja@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:08:48 +0300 Subject: [PATCH 3/4] entra-beta-audit changes --- build/Beta-TypeDefs.txt | 11 +++++++++++ build/V1.0-TypeDefs.txt | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/build/Beta-TypeDefs.txt b/build/Beta-TypeDefs.txt index 551e675620..deb9a97574 100644 --- a/build/Beta-TypeDefs.txt +++ b/build/Beta-TypeDefs.txt @@ -4,6 +4,17 @@ $def = @" +namespace Microsoft.Open.MSGraph.Model{ + public class MsRoleMemberInfo{ + public System.String Id; + } + + public class MsDirectoryObject{ + public System.String Id; + public System.String OdataType; + } +} + namespace Microsoft.Open.AzureAD.Graph.PowerShell.Custom { diff --git a/build/V1.0-TypeDefs.txt b/build/V1.0-TypeDefs.txt index 1465a1ad21..b5120d99f4 100644 --- a/build/V1.0-TypeDefs.txt +++ b/build/V1.0-TypeDefs.txt @@ -4,6 +4,17 @@ $def = @" +namespace Microsoft.Open.MSGraph.Model{ + public class MsRoleMemberInfo{ + public System.String Id; + } + + public class MsDirectoryObject{ + public System.String Id; + public System.String OdataType; + } +} + namespace Microsoft.Open.AzureAD.Graph.PowerShell.Custom { From 0be12b05fe43be84c83f819522f4f0644c7d9ce0 Mon Sep 17 00:00:00 2001 From: Emmanuel Ng'ang'a <60355631+emmanuel-karanja@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:13:01 +0300 Subject: [PATCH 4/4] entra-beta-audit changes --- build/Beta-TypeDefs.txt | 23 +++++++++++------------ build/V1.0-TypeDefs.txt | 25 +++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build/Beta-TypeDefs.txt b/build/Beta-TypeDefs.txt index deb9a97574..16b94375c5 100644 --- a/build/Beta-TypeDefs.txt +++ b/build/Beta-TypeDefs.txt @@ -4,17 +4,6 @@ $def = @" -namespace Microsoft.Open.MSGraph.Model{ - public class MsRoleMemberInfo{ - public System.String Id; - } - - public class MsDirectoryObject{ - public System.String Id; - public System.String OdataType; - } -} - namespace Microsoft.Open.AzureAD.Graph.PowerShell.Custom { @@ -152,8 +141,18 @@ namespace Microsoft.Open.AzureAD.Model namespace Microsoft.Open.MSGraph.Model { - + using System.Linq; + + public class MsRoleMemberInfo{ + public System.String Id; + } + + public class MsDirectoryObject{ + public System.String Id; + public System.String OdataType; + } + public class AddIn { public System.String Id; diff --git a/build/V1.0-TypeDefs.txt b/build/V1.0-TypeDefs.txt index b5120d99f4..529fc20967 100644 --- a/build/V1.0-TypeDefs.txt +++ b/build/V1.0-TypeDefs.txt @@ -4,17 +4,6 @@ $def = @" -namespace Microsoft.Open.MSGraph.Model{ - public class MsRoleMemberInfo{ - public System.String Id; - } - - public class MsDirectoryObject{ - public System.String Id; - public System.String OdataType; - } -} - namespace Microsoft.Open.AzureAD.Graph.PowerShell.Custom { @@ -147,6 +136,16 @@ namespace Microsoft.Open.MSGraph.Model { using System.Linq; + + public class MsRoleMemberInfo{ + public System.String Id; + } + + public class MsDirectoryObject{ + public System.String Id; + public System.String OdataType; + } + public class AddIn { public System.String Id; @@ -643,10 +642,12 @@ namespace Microsoft.Open.MSGraph.Model public System.String Id; public System.String OdataType; } + public class MsRoleMemberInfo { - public System.String Id; + public System.String Id; } + public class OptionalClaim { public System.String Name;