Skip to content
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

E2E Test Utils – Hardcoded administrator user/password #30736

Open
crs1138 opened this issue Apr 12, 2021 · 2 comments
Open

E2E Test Utils – Hardcoded administrator user/password #30736

crs1138 opened this issue Apr 12, 2021 · 2 comments
Labels
[Package] E2E Test Utils /packages/e2e-test-utils [Type] Bug An existing feature does not function as intended

Comments

@crs1138
Copy link

crs1138 commented Apr 12, 2021

Description

The default administrator user used for E2E testing is hardcoded as user: admin and password: password in the config.js. This gets automatically used by the testing suite if the current user is anything else but admin as you can see in switchUserToAdmin() at switch-user-to-admin.js. The suite does not actually test whether the current user has administrators rights, instead it tests for the username being admin.

This seems a strange default setting, considering that WP does not let you, by default, create a user with username admin (unless you edit directly in database).

Step-by-step reproduction instructions

  1. When running e2e tests, I try to activate a plugin…
    beforeAll(async () => {
        ...
        await activatePlugin('my-plugin');
        ...
    });
  1. This fails as the WP_USERNAME supplied by process.env.WP_USERNAME is not admin.

Expected behaviour

Either:

  1. Test for the WP_USERNAME having administrator's rights
  2. Allow to use environment variables WP_ADMIN_USERNAME and WP_ADMIN_PASSWORD for administrator's login

Actual behaviour

Uses admin and password as the administrator's login details if the WP_USERNAME is not admin.

WordPress information

  • WordPress version: 5.6.2
  • Gutenberg version: 10.3.2
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? Yes

Device information

  • Device: Desktop
  • Operating system: MacOS 11.2.3
  • Browser: Chromium 88.0.4298.0 (Developer Build) (x86_64)
@skorasaurus skorasaurus added [Type] Bug An existing feature does not function as intended [Package] E2E Test Utils /packages/e2e-test-utils labels Apr 14, 2021
@gziolo
Copy link
Member

gziolo commented Apr 16, 2021

https://github.com/WordPress/gutenberg/blob/trunk/docs/contributors/code/testing-overview.md#end-to-end-testing

Can you check with:

npm run test-e2e -- --wordpress-base-url=http://localhost:8888 --wordpress-username=admin --wordpress-password=password

@gziolo gziolo added the Needs Testing Needs further testing to be confirmed. label Apr 16, 2021
@crs1138
Copy link
Author

crs1138 commented Apr 19, 2021

I can confirm that tests run correctly when using the wp-env environment. However, that is not useful in our case as we have no WP instance running on http://localhost:8888 and in our set up we need to be able to run the tests right after deployment to stage. It is impossible (for security reasons) to have a user admin with password password in our set up, as the stage environment takes on the authoritative db dump from production.

@gziolo gziolo removed the Needs Testing Needs further testing to be confirmed. label Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] E2E Test Utils /packages/e2e-test-utils [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants