UNPKG

cumulocity-cypress

Version:
53 lines (52 loc) 2.56 kB
import { getAuthOptionsFromCypressEnv } from "../utils"; import { C8yAuthOptions, C8yAuthentication, isAuthOptions } from "../../shared/auth"; export { C8yAuthOptions, C8yAuthentication, isAuthOptions, getAuthOptionsFromCypressEnv, getAuthEnvVariables, }; declare global { namespace Cypress { interface Chainable extends ChainableWithState { /** * Get `C8yAuthOptions` from arguments or environment variables. If no arguments are * provided, getAuth() will try to get the authentication from `C8Y_TOKEN` or * `C8Y_USERNAME` and `C8Y_PASSWORD` environment variables. * * By providing a user alias, getAuth() will look for environment variables with the * following pattern: `${userAlias}_token` (preferred) or `${userAlias}_username` and * `${userAlias}_password`. If there is no such environment variable, an error will be thrown. * * @example * cy.getAuth("admin", "password").login(); * cy.getAuth("admin").login(); * cy.getAuth().login(); */ getAuth(): Chainable<C8yAuthOptions | undefined>; getAuth(user: string): Chainable<C8yAuthOptions | undefined>; getAuth(user: string, password: string): Chainable<C8yAuthOptions | undefined>; getAuth(auth: C8yAuthOptions): Chainable<C8yAuthOptions | undefined>; /** * Use `C8yAuthOptions` for all commands of this library requiring authentication * within the current test context (it). * * @example * cy.useAuth("admin", "password"); * cy.login(); * cy.createUser(...); */ useAuth(): Chainable<C8yAuthOptions | undefined>; useAuth(user: string): Chainable<C8yAuthOptions | undefined>; useAuth(user: string, password: string): Chainable<C8yAuthOptions | undefined>; useAuth(auth: C8yAuthOptions): Chainable<C8yAuthOptions | undefined>; } interface SuiteConfigOverrides { auth?: C8yAuthConfig; } interface TestConfigOverrides { auth?: C8yAuthConfig; } interface RuntimeConfigOptions { auth?: C8yAuthConfig; } } type C8yAuthConfig = string | C8yAuthOptions; type C8yAuthArgs = [user: string] | [user: string, password: string] | [authOptions: C8yAuthOptions]; } declare const getAuthEnvVariables: () => any;