Issue #3059356 by finnsky, mogtofu33, klausi, jibran, justafish, joaogarin: [Security] Update yarn packages to fix 19 vulnerabilities by updating nightwatch

merge-requests/55/head
Lee Rowlands 2019-08-29 13:06:12 +10:00
parent 0192048dca
commit 4936a17225
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
8 changed files with 1325 additions and 1648 deletions

View File

@ -26,7 +26,7 @@
"babel-preset-env": "^1.4.0",
"chalk": "^2.3.0",
"chokidar": "^2.0.0",
"chromedriver": "^2.35.0",
"chromedriver": "^75.1.0",
"cross-env": "^5.1.3",
"dotenv-safe": "^5.0.1",
"eslint": "^4.19.1",
@ -39,12 +39,12 @@
"glob": "^7.1.2",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"nightwatch": "^0.9.20",
"nightwatch": "^1.2.1",
"prettier": "^1.14.0",
"stylelint": "^9.10.1",
"stylelint-checkstyle-formatter": "^0.1.1",
"stylelint-config-standard": "^18.2.0",
"stylelint-no-browser-hacks": "^1.1.0",
"stylelint-no-browser-hacks": "^1.2.1",
"stylelint-order": "^2.1.0"
},
"//": "'development is the default environment, and legacy is for transpiling the old jQuery codebase",

View File

@ -25,14 +25,12 @@ exports.command = function drupalInstall({ setupFile = '' } = {}, callback) {
: '';
const install = execSync(
commandAsWebserver(
`php ./scripts/test-site.php install ${setupFile} --base-url ${
process.env.DRUPAL_TEST_BASE_URL
} ${dbOption} --json`,
`php ./scripts/test-site.php install ${setupFile} --base-url ${process.env.DRUPAL_TEST_BASE_URL} ${dbOption} --json`,
),
);
const installData = JSON.parse(install.toString());
this.drupalDbPrefix = installData.db_prefix;
this.drupalSitePath = installData.site_path;
this.globals.drupalDbPrefix = installData.db_prefix;
this.globals.drupalSitePath = installData.site_path;
const url = new URL(process.env.DRUPAL_TEST_BASE_URL);
this.url(process.env.DRUPAL_TEST_BASE_URL).setCookie({
name: 'SIMPLETEST_USER_AGENT',

View File

@ -18,9 +18,7 @@ exports.command = function drupalLoginAsAdmin(callback) {
}
const userLink = execSync(
commandAsWebserver(
`php ./scripts/test-site.php user-login 1 --site-path ${
this.drupalSitePath
}`,
`php ./scripts/test-site.php user-login 1 --site-path ${this.globals.drupalSitePath}`,
),
);

View File

@ -11,7 +11,7 @@ import { commandAsWebserver } from '../globals';
*/
exports.command = function drupalUninstal(callback) {
const self = this;
const prefix = self.drupalDbPrefix;
const prefix = this.globals.drupalDbPrefix;
// Check for any existing errors, because running this will cause Nightwatch to hang.
if (!this.currentTest.results.errors && !this.currentTest.results.failed) {

View File

@ -5,13 +5,16 @@ import mkdirp from 'mkdirp';
import chromedriver from 'chromedriver';
import nightwatchSettings from './nightwatch.conf';
const commandAsWebserver = command => {
export const commandAsWebserver = command => {
if (process.env.DRUPAL_TEST_WEBSERVER_USER) {
return `sudo -u ${process.env.DRUPAL_TEST_WEBSERVER_USER} ${command}`;
}
return command;
};
export const drupalDbPrefix = null;
export const drupalSitePath = null;
module.exports = {
before: done => {
if (JSON.parse(process.env.DRUPAL_TEST_CHROMEDRIVER_AUTOSTART)) {
@ -35,9 +38,7 @@ module.exports = {
) {
const resultPath = path.join(
__dirname,
`../../../${nightwatchSettings.output_folder}/consoleLogs/${
browser.currentTest.module
}`,
`../../../${nightwatchSettings.output_folder}/consoleLogs/${browser.currentTest.module}`,
);
const status =
browser.currentTest.results.errors > 0 ||

View File

@ -50,7 +50,7 @@ module.exports = {
custom_commands_path: collectedFolders.Commands,
custom_assertions_path: collectedFolders.Assertions,
page_objects_path: collectedFolders.Pages,
globals_path: 'tests/Drupal/Nightwatch/globals.js',
globals_path: 'globals.js',
selenium: {
start_process: false,
},
@ -63,6 +63,31 @@ module.exports = {
browserName: 'chrome',
acceptSslCerts: true,
chromeOptions: {
w3c: false,
args: process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS
? process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS.split(' ')
: [],
},
},
screenshots: {
enabled: true,
on_failure: true,
on_error: true,
path: `${process.env.DRUPAL_NIGHTWATCH_OUTPUT}/screenshots`,
},
end_session_on_fail: false,
},
local: {
webdriver: {
start_process: process.env.DRUPAL_TEST_CHROMEDRIVER_AUTOSTART,
port: process.env.DRUPAL_TEST_WEBDRIVER_PORT,
server_path: 'node_modules/.bin/chromedriver',
},
desiredCapabilities: {
browserName: 'chrome',
acceptSslCerts: true,
chromeOptions: {
w3c: false,
args: process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS
? process.env.DRUPAL_TEST_WEBDRIVER_CHROME_ARGS.split(' ')
: [],

View File

@ -76,14 +76,17 @@ chromedriver using port 4444, and keep it running:
(e.g. by running `composer install`)
* Install [Node.js](https://nodejs.org/en/download/) and
[yarn](https://yarnpkg.com/en/docs/install). The versions required are
specificed inside core/package.json in the `engines` field
specified inside core/package.json in the `engines` field. You can use
[nvm](https://github.com/nvm-sh/nvm) and [yvm](https://github.com/tophat/yvm)
to manage your local versions of these.
* Install
[Google Chrome](https://www.google.com/chrome/browser/desktop/index.html)
* Inside the `core` folder, run `yarn install`
* Configure the nightwatch settings by copying `.env.example` to `.env` and
editing as necessary.
* Ensure you have a web server running (as instructed in `.env`)
* Again inside the `core` folder, run `yarn test:nightwatch` to run the tests.
* Again inside the `core` folder, run `yarn test:nightwatch --env local` to run
the tests.
By default this will output reports to `core/reports`
* Nightwatch will run tests for core, as well as contrib and custom modules and
themes. It will search for tests located under folders with the pattern

File diff suppressed because it is too large Load Diff