Subscription name now shown in role assignment summary
This patch fixes the azurerm_role_assignment summary line so that a mapped subscription display name is used instead of the raw subscription ID when the scope is at the subscription level.
๐ Bug fixes
Fixed subscription-level role assignment summary showing raw ID instead of display name
Problem: When an azurerm_role_assignment resource had a subscription-level scope (e.g., scope = /subscriptions/12345678-...) and a subscription name mapping was configured, the <summary> line still showed the raw subscription ID instead of the friendly display name.
For example, with a mapping of { "id": "sub-123", "displayName": "Production" }, the summary incorrectly rendered as:
โ azurerm_role_assignment my_assignment โ ๐ค Jane Doe โ ๐ก๏ธ Contributor on subscription ๐ sub-123
Fix: The BuildScopeSummary() method in RoleAssignmentViewModelFactory now consults the scope formatter for a subscription display name before falling back to the raw subscription ID โ consistent with how the management group scope and the table scope attribute already behaved.
After the fix, the summary correctly renders as:
โ azurerm_role_assignment my_assignment โ ๐ค Jane Doe โ ๐ก๏ธ Contributor on subscription ๐ Production
The table scope attribute continues to show the full ๐ Production (sub-123) format (name + ID), unchanged.
Backward compatible: When no mapping exists, or when no scope formatter is provided, the summary falls back to the raw subscription ID as before.
Affected components
AzureEntityMapperโ AddedGetSubscriptionName()method that returns just the display name (falling back to the raw ID when unmapped)EnrichedAzureScopeFormatterโ AddedGetSubscriptionName()delegating methodRoleAssignmentViewModelFactoryโ UpdatedBuildScopeSummary()to usescopeFormatter.GetSubscriptionName()for subscription-level scopes
๐งช Test coverage
Added 5 new unit tests:
Build_WhenSubscriptionScopeAndMappingProvided_UsesMappedNameInSummaryโ verifies the summary shows the display name when a subscription mapping existsBuild_WhenSubscriptionScopeAndNoMapping_UsesIdInSummaryโ verifies fallback to raw ID when no mapping is configuredBuild_WhenSubscriptionScopeAndNoScopeFormatter_UsesIdInSummaryโ verifies fallback to raw ID when no scope formatter is providedAzureEntityMapper_GetSubscriptionName_ReturnsMappedDisplayNameโ verifiesAzureEntityMapper.GetSubscriptionNamereturns just the display name (no ID suffix) when a mapping existsAzureEntityMapper_GetSubscriptionName_FallsBackToRawIdโ verifiesAzureEntityMapper.GetSubscriptionNamereturns the raw ID when no mapping is found
Added 2 subscription-level entries to the snapshot test data (role-assignments.json) and regenerated the snapshot:
subscription_scope_mappedโ scope/subscriptions/sub-123with a display name ofProduction; summary shows๐ Productionsubscription_scope_unmappedโ scope/subscriptions/sub-unmapped-idwith no mapping; summary shows๐ sub-unmapped-id
All 1230 tests passing.