Skip to content

Commit d7b521b

Browse files
updated test to show displaynames instead of GUIDs (#864)
1 parent f3fc418 commit d7b521b

1 file changed

Lines changed: 53 additions & 14 deletions

File tree

src/powershell/tests/Test-Assessment.25378.ps1

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ function Test-Assessment-25378 {
2626
UserImpact = 'High'
2727
)]
2828
[CmdletBinding()]
29-
param()
29+
param(
30+
$Database
31+
)
3032

3133
#region Data Collection
3234
Write-PSFMessage '🟦 Start' -Tag Test -Level VeryVerbose
@@ -80,7 +82,7 @@ function Test-Assessment-25378 {
8082

8183
#region Assessment Logic
8284
$passed = $false
83-
$investigateFlag = $false
85+
$customStatus = $null
8486

8587
if ($null -eq $crossTenantAccessPolicy) {
8688
$testResultMarkdown = "❌ Unable to retrieve cross-tenant access policy configuration.`n`n%TestResult%"
@@ -112,7 +114,7 @@ function Test-Assessment-25378 {
112114
}
113115
else {
114116
$passed = $false
115-
$investigateFlag = $true
117+
$customStatus = 'Investigate'
116118
$testResultMarkdown = "⚠️ Default outbound B2B collaboration has partial restrictions configured; review settings to ensure they align with organizational security policies.`n`n%TestResult%"
117119
}
118120
}
@@ -122,15 +124,52 @@ function Test-Assessment-25378 {
122124
$mdInfo = ''
123125

124126
if ($null -ne $crossTenantAccessPolicy) {
125-
$reportTitle = 'Default Cross-Tenant Access Settings - Outbound B2B Collaboration'
127+
$reportTitle = 'Default Cross-tenant access settings - Outbound B2B collaboration'
126128
$portalLink = 'https://entra.microsoft.com/#view/Microsoft_AAD_IAM/CompanyRelationshipsMenuBlade/~/CrossTenantAccessSettings'
127129

128130
# Prepare display values
129131
$isServiceDefaultStr = if ($null -eq $isServiceDefault) { 'N/A' } elseif ($isServiceDefault) { 'true' } else { 'false' }
130132
$usersAndGroupsAccessTypeDisplay = if ([string]::IsNullOrEmpty($usersAndGroupsAccessType)) { 'N/A' } else { $usersAndGroupsAccessType }
131133
$applicationsAccessTypeDisplay = if ([string]::IsNullOrEmpty($applicationsAccessType)) { 'N/A' } else { $applicationsAccessType }
132-
$displayUserTarget = if ($usersAndGroupsTargets.Count -gt 0) { $usersAndGroupsTargets[0] } else { 'N/A' }
133-
$displayAppTarget = if ($applicationsTargets.Count -gt 0) { $applicationsTargets[0] } else { 'N/A' }
134+
135+
# Resolve and display users and groups (first 5)
136+
$displayUserTarget = 'N/A'
137+
if ($b2bOutbound.usersAndGroups.targets.Count -gt 0) {
138+
$targets = $b2bOutbound.usersAndGroups.targets | Select-Object -First 5
139+
140+
$userTargets = $targets | Where-Object { $_.targetType -eq 'user' } | Select-Object -ExpandProperty target
141+
$groupTargets = $targets | Where-Object { $_.targetType -eq 'group' } | Select-Object -ExpandProperty target
142+
143+
# Resolve all user and group targets at once
144+
$resolvedNames = @()
145+
146+
if ($userTargets.Count -gt 0) {
147+
$resolvedUsers = Get-UserNameFromId -TargetsArray $userTargets -Database $Database
148+
$resolvedNames += $resolvedUsers
149+
}
150+
151+
if ($groupTargets.Count -gt 0) {
152+
$resolvedGroups = Get-GroupNameFromId -TargetsArray $groupTargets
153+
$resolvedNames += $resolvedGroups
154+
}
155+
156+
$displayUserTarget = $resolvedNames -join ', '
157+
if ($b2bOutbound.usersAndGroups.targets.Count -gt 5) {
158+
$displayUserTarget += ', ...'
159+
}
160+
}
161+
162+
# Resolve and display applications (first 5)
163+
$displayAppTarget = 'N/A'
164+
if ($b2bOutbound.applications.targets.Count -gt 0) {
165+
$targets = $b2bOutbound.applications.targets | Select-Object -First 5
166+
$resolvedApps = Get-ApplicationNameFromId -TargetsArray $targets.target -Database $Database
167+
168+
$displayAppTarget = $resolvedApps -join ', '
169+
if ($b2bOutbound.applications.targets.Count -gt 5) {
170+
$displayAppTarget += ', ...'
171+
}
172+
}
134173

135174
# Calculate status indicators
136175
$isServiceDefaultStatus = if ($isServiceDefaultStr -eq 'false') { '' } else { '' }
@@ -143,17 +182,17 @@ function Test-Assessment-25378 {
143182
144183
## [{0}]({1})
145184
146-
| Setting | Configured Value | Expected Value | Status |
185+
| Setting | Configured value | Expected value | Status |
147186
| :------ | :--------------- | :------------- | :----: |
148187
{2}
149188
150189
'@
151190

152-
$tableRows = "| Is Service Default | $isServiceDefaultStr | false | $isServiceDefaultStatus |`n"
153-
$tableRows += "| Users and Groups Access Type | $usersAndGroupsAccessTypeDisplay | blocked | $usersAccessStatus |`n"
154-
$tableRows += "| Users and Groups Target | $displayUserTarget | AllUsers | $usersTargetStatus |`n"
155-
$tableRows += "| Applications Access Type | $applicationsAccessTypeDisplay | blocked | $appsAccessStatus |`n"
156-
$tableRows += "| Applications Target | $displayAppTarget | AllApplications | $appsTargetStatus |"
191+
$tableRows = "| Is service default | $isServiceDefaultStr | false | $isServiceDefaultStatus |`n"
192+
$tableRows += "| Users and groups access type | $usersAndGroupsAccessTypeDisplay | blocked | $usersAccessStatus |`n"
193+
$tableRows += "| Users and groups target | $displayUserTarget | AllUsers | $usersTargetStatus |`n"
194+
$tableRows += "| Applications access type | $applicationsAccessTypeDisplay | blocked | $appsAccessStatus |`n"
195+
$tableRows += "| Applications target | $displayAppTarget | AllApplications | $appsTargetStatus |"
157196

158197
$mdInfo = $formatTemplate -f $reportTitle, $portalLink, $tableRows
159198
}
@@ -168,8 +207,8 @@ function Test-Assessment-25378 {
168207
Result = $testResultMarkdown
169208
}
170209

171-
if ($investigateFlag) {
172-
$params.CustomStatus = 'Investigate'
210+
if ($customStatus) {
211+
$params.CustomStatus = $customStatus
173212
}
174213

175214
Add-ZtTestResultDetail @params

0 commit comments

Comments
 (0)