Skip to content

Commit 778d3d6

Browse files
fix all unit tests; added mock function for Invoke-MgGraphRequest
1 parent 9569e18 commit 778d3d6

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

PowerShell/ScubaGear/Testing/Unit/PowerShell/Providers/AADProvider/AADRiskyPermissionsHelper/Format-RiskyApplications.Tests.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ InModuleScope AADRiskyPermissionsHelper {
1111
$MockServicePrincipals = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "../RiskyPermissionsSnippets/MockServicePrincipals.json") | ConvertFrom-Json
1212
$MockServicePrincipalAppRoleAssignments = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "../RiskyPermissionsSnippets/MockServicePrincipalAppRoleAssignments.json") | ConvertFrom-Json
1313

14+
function Get-MgBetaApplication { $MockApplications }
15+
function Get-MgBetaApplicationFederatedIdentityCredential { $MockFederatedCredentials }
16+
function Get-MgBetaServicePrincipal { $MockServicePrincipals }
17+
1418
Mock Get-MgBetaApplication { $MockApplications }
1519
Mock Get-MgBetaApplicationFederatedIdentityCredential { $MockFederatedCredentials }
1620
Mock Get-MgBetaServicePrincipal { $MockServicePrincipals }

PowerShell/ScubaGear/Testing/Unit/PowerShell/Providers/AADProvider/AADRiskyPermissionsHelper/Get-ApplicationsWithRiskyPermissions.Tests.ps1

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ InModuleScope AADRiskyPermissionsHelper {
66
Describe "Get-ApplicationsWithRiskyPermissions" {
77
BeforeAll {
88
# Import mock data
9-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'MockApplications')]
109
$MockApplications = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "../RiskyPermissionsSnippets/MockApplications.json") | ConvertFrom-Json
11-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'MockFederatedCredentials')]
1210
$MockFederatedCredentials = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "../RiskyPermissionsSnippets/MockFederatedCredentials.json") | ConvertFrom-Json
11+
12+
function Get-MgBetaApplication { $MockApplications }
13+
function Get-MgBetaApplicationFederatedIdentityCredential { $MockFederatedCredentials }
1314
}
1415

1516
It "returns a list of applications with valid properties" {

PowerShell/ScubaGear/Testing/Unit/PowerShell/Providers/AADProvider/AADRiskyPermissionsHelper/Get-ServicePrincipalsWithRiskyPermissions.Tests.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ InModuleScope AADRiskyPermissionsHelper {
66
Describe "Get-ServicePrincipalsWithRiskyPermissions" {
77
BeforeAll {
88
# Import mock data
9-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'MockServicePrincipals')]
109
$MockServicePrincipals = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "../RiskyPermissionsSnippets/MockServicePrincipals.json") | ConvertFrom-Json
1110
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'MockServicePrincipalAppRoleAssignments')]
1211
$MockServicePrincipalAppRoleAssignments = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "../RiskyPermissionsSnippets/MockServicePrincipalAppRoleAssignments.json") | ConvertFrom-Json
1312
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'MockSafePermissions')]
1413
$MockSafePermissions = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "../RiskyPermissionsSnippets/MockSafePermissions.json") | ConvertFrom-Json
15-
14+
15+
function Get-MgBetaServicePrincipal { $MockServicePrincipals }
1616
function New-MockMgGraphResponse {
1717
param (
1818
[int] $Size,

PowerShell/ScubaGear/Testing/Unit/PowerShell/Providers/AADProvider/AADRiskyPermissionsHelper/Get-ThirdPartyRiskyServicePrincipals.Tests.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ InModuleScope AADRiskyPermissionsHelper {
1111
$MockServicePrincipals = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "../RiskyPermissionsSnippets/MockServicePrincipals.json") | ConvertFrom-Json
1212
$MockServicePrincipalAppRoleAssignments = Get-Content (Join-Path -Path $PSScriptRoot -ChildPath "../RiskyPermissionsSnippets/MockServicePrincipalAppRoleAssignments.json") | ConvertFrom-Json
1313

14+
function Get-MgBetaApplication { $MockApplications }
15+
function Get-MgBetaApplicationFederatedIdentityCredential { $MockFederatedCredentials }
16+
function Get-MgBetaServicePrincipal { $MockServicePrincipals }
17+
1418
Mock Get-MgBetaApplication { $MockApplications }
1519
Mock Get-MgBetaApplicationFederatedIdentityCredential { $MockFederatedCredentials }
1620
Mock Get-MgBetaServicePrincipal { $MockServicePrincipals }

0 commit comments

Comments
 (0)