Skip to content

Latest commit

 

History

History
53 lines (36 loc) · 1.43 KB

File metadata and controls

53 lines (36 loc) · 1.43 KB

AuthApiHelper API

Retrieves Backstage identity tokens from a running RHDH auth API.

Import

import { AuthApiHelper } from '@red-hat-developer-hub/e2e-test-utils/helpers';

Constructor

new AuthApiHelper(page: Page)
Parameter Type Description
page Page Playwright Page with an active RHDH session

Methods

getToken()

async getToken(
  provider?: string,
  environment?: string
): Promise<string>
Parameter Type Default Description
provider string "oidc" Auth provider name configured in RHDH
environment string "production" Auth environment

Returns Promise<string> — the Backstage identity token string.

Throws Error if the HTTP response is not OK, or TypeError if the token is absent from the response body.

Example

import { AuthApiHelper } from '@red-hat-developer-hub/e2e-test-utils/helpers';

const authApiHelper = new AuthApiHelper(page);

// Default provider (oidc) and environment (production)
const token = await authApiHelper.getToken();

// Custom provider
const token = await authApiHelper.getToken('github');