Skip to content

Commit 472276d

Browse files
author
DavertMik
committed
added check for the user in auth plugin
1 parent 1298656 commit 472276d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/plugin/auth.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const store = require('../store')
88
const event = require('../event')
99
const recorder = require('../recorder')
1010
const { debug } = require('../output')
11-
const isAsyncFunction = require('../utils').isAsyncFunction
11+
const { isAsyncFunction } = require('../utils')
1212

1313
const defaultUser = {
1414
fetch: I => I.grabCookie(),
@@ -270,6 +270,12 @@ module.exports = function (config) {
270270

271271
const loginFunction = async name => {
272272
const I = container.support('I')
273+
const userSession = config.users[name]
274+
275+
if (!userSession) {
276+
throw new Error(`User '${name}' was not configured for authorization in auth plugin. Add it to the plugin config`)
277+
}
278+
273279
const test = store.currentTest
274280

275281
// we are in BeforeSuite hook
@@ -298,7 +304,6 @@ module.exports = function (config) {
298304

299305
section.start()
300306

301-
const userSession = config.users[name]
302307
const cookies = store[`${name}_session`]
303308
const shouldAwait = isAsyncFunction(userSession.login) || isAsyncFunction(userSession.restore) || isAsyncFunction(userSession.check)
304309

0 commit comments

Comments
 (0)