UNPKG

askui

Version:

Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on

21 lines (20 loc) 1.49 kB
import { logger } from '../lib'; import { envCredentials } from './read-environment-credentials'; export function readCredentials(clientArgs) { const environmentCredentials = envCredentials(); const inCodeCredentials = clientArgs.credentials; const credentials = inCodeCredentials !== null && inCodeCredentials !== void 0 ? inCodeCredentials : environmentCredentials; if (!credentials) { throw new Error('No credentials are defined! Please define a token and a Workspace ID in the environment variables ASKUI_TOKEN and ASKUI_WORKSPACE_ID or define them in the UiControlClient.build.'); } if (!(credentials === null || credentials === void 0 ? void 0 : credentials.token)) { throw new Error('No Token is defined! Please define a token in the environment variable ASKUI_TOKEN or define a token in the UiControlClient.'); } if (!(credentials === null || credentials === void 0 ? void 0 : credentials.workspaceId)) { throw new Error('No Workspace ID is defined! Please define a workspace ID in the environment variable ASKUI_WORKSPACE_ID or define a workspace ID in the UiControlClient.'); } if (environmentCredentials && inCodeCredentials) { logger.warn('In-code credentials in UiControlClient.build and ENV variables(ASKUI_WORKSPACE_ID und ASKUI_TOKEN) are defined! We recommend to remove the in-code credentials for security reason! In-code credentials will be used for this execution.'); } return credentials; }