Fixes #59 - This PR opens up a number of functions to allow for some more comprehensive user switching and authentication. switchUser() has been expanded upon to allow for passwords to be defined so a manual login can take place, and logout() is added to allow for logging out the current user. With both methods, they will first attempt to remove the .userid file which is used for by-passing authentication and then clear cookies before redirecting back to the login page.
In addition to changing the user switchUser() will perform a manual login attempt via completing the login form. This will also check for Jetpack SSO and click the login link if found. This happens by providing a second parameter on switchUser() of a password. If a password is used then a login attempt will be made.
Usage Example
Spec
describe("Posts.", () => {
it("I can add a new post as an author.", () => {
cy.switchUser('author', 'password');
cy.visit("/wp-admin/post-new.php");
// ...
cy.logout();
});
});
Change Log
Add --logout flag to wp-cypress-set-user to remove .userid file (logout).
Change wp_validate_auth_cookie so only defined if .userid file exists.
Remove fallback user id of 1 from wp_validate_auth_cookie.
Add additional/optional password parameter to switchUser() method.
Add manual login process to switchUser() routine when password is defined.
Add logout() method for strictly logging out.
Screenshots/Videos
If PR includes visual changes, please include a screenshot (or short video if applicable).
Types of changes (if applicable):
[x] Bug fix (non-breaking change which fixes an issue).
[ ] New feature (non-breaking change which adds functionality).
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected).
Description
Fixes #59 - This PR opens up a number of functions to allow for some more comprehensive user switching and authentication.
switchUser()
has been expanded upon to allow for passwords to be defined so a manual login can take place, andlogout()
is added to allow for logging out the current user. With both methods, they will first attempt to remove the.userid
file which is used for by-passing authentication and then clear cookies before redirecting back to the login page.In addition to changing the user
switchUser()
will perform a manual login attempt via completing the login form. This will also check for Jetpack SSO and click the login link if found. This happens by providing a second parameter onswitchUser()
of a password. If a password is used then a login attempt will be made.Usage Example
Spec
Change Log
--logout
flag towp-cypress-set-user
to remove.userid
file (logout).wp_validate_auth_cookie
so only defined if.userid
file exists.1
fromwp_validate_auth_cookie
.password
parameter toswitchUser()
method.switchUser()
routine whenpassword
is defined.logout()
method for strictly logging out.Screenshots/Videos
If PR includes visual changes, please include a screenshot (or short video if applicable).
Types of changes (if applicable):
Checklist (if applicable):