-
-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/auth plugin #4783
Feat/auth plugin #4783
Conversation
lib/plugin/auth.js
Outdated
const event = require('../event') | ||
const recorder = require('../recorder') | ||
const { debug } = require('../output') | ||
const isAsyncFunction = require('../utils').isAsyncFunction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { isAsyncFunction } = require('../utils')
just a code style I guess to make everything look consistant.
} | ||
|
||
if (isPlaywrightSession() && test?.opts?.cookies) { | ||
if (test.opts.user == name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Double equals (==) will perform a type conversion when comparing two things, and will handle NaN, -0, and +0 specially to conform to IEEE 754 (so NaN != NaN, and -0 == +0);
- Triple equals (===) will do the same comparison as double equals (including the special handling for NaN, -0, and +0) but without type conversion; if the types differ, false is returned.
i'm not sure if we would try to do strict equality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this matters for 2 strings....
} | ||
|
||
if (!config.saveToFile) return | ||
const cookieFile = path.join(global.output_dir, `${name}_session.json`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may you think we shall store this output_dir
in Store
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I was thinking about it... Probably we need to switch to this
but it's too much of refactoring to do
loadCookiesFromFile(config) | ||
} | ||
|
||
const loginFunction = async name => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could be wrong but what if user just puts some name that is not defined in config, shall we handle that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, this should be handled
autoLogin
plugin toauth
pluginloginAs
function to work fromBeforeSuite
In this case cookies can be preloaded into Playwright when creating new browser session for faster access