Skip to content

[BUG]: Reporter generates Portal URLs with hardcoded Microsoft tenant instead of actual tenant ID #216

Description

@dannyorientsoftware

Description

The Azure Playwright reporter (@azure/playwright/reporter) generates Portal URLs with a hardcoded @microsoft.onmicrosoft.com tenant, which causes authentication failures for users whose Azure subscriptions are in different tenants.

Environment

  • Package: @azure/playwright@1.1.1
  • Platform: Node.js
  • Authentication: Azure Service Principal with DefaultAzureCredential

Steps to Reproduce

  1. Set up Azure Playwright Workspaces in a non-Microsoft tenant (e.g., organization's own Azure AD tenant)
  2. Configure tests to use @azure/playwright/reporter
  3. Run tests with Azure authentication
  4. Observe the "Published report URL" in the output

Expected Behavior

The generated URL should use the actual tenant ID from the workspace metadata:
https://ms.portal.azure.com/#@{actual-tenant-id}/resource/subscriptions/.../TestRuns

Actual Behavior

The URL is generated with a hardcoded Microsoft tenant:
https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/.../TestRuns

Root Cause

File: dist/*/utils/utils.js (all build outputs: commonjs, esm, browser, react-native)

Function: getPortalTestRunUrl(workspaceMetadata) (around line 397-410)

Issue: The tenant is hardcoded on line 409:

return `https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/${encodeURIComponent(subscriptionId)}/...`;

The WorkspaceMetaData type already includes tenantId field (line 180 of types.d.ts), but the function doesn't use it.

Proposed Fix

Extract and use the tenantId from workspaceMetadata:

function getPortalTestRunUrl(workspaceMetadata) {
    const { subscriptionId, resourceId, name, tenantId } = workspaceMetadata ?? {};
    // ... validation logic ...
    
    // Use tenant ID from metadata, fallback to microsoft.onmicrosoft.com if not provided
    const tenant = tenantId || 'microsoft.onmicrosoft.com';
    return `https://ms.portal.azure.com/#@${tenant}/resource/subscriptions/${encodeURIComponent(subscriptionId)}/...`;
}
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions