Skip to content
Snippets Groups Projects
Commit 24356126 authored by Lucas Hedding's avatar Lucas Hedding Committed by Lucas Hedding
Browse files

Issue #3126755 by heddn: Fix failing tests on 8.9.0-beta2

parent 4a790bde
No related branches found
No related tags found
No related merge requests found
...@@ -172,7 +172,7 @@ class SettingsForm extends ConfigFormBase { ...@@ -172,7 +172,7 @@ class SettingsForm extends ConfigFormBase {
$update_text = $this->t('Your site is running %version of Drupal core. No recommended update is available at this time.</i>', ['%version' => \Drupal::VERSION]); $update_text = $this->t('Your site is running %version of Drupal core. No recommended update is available at this time.</i>', ['%version' => \Drupal::VERSION]);
if ($not_recommended_version && $not_dev_core) { if ($not_recommended_version && $not_dev_core) {
$update_text = $this->t('Even with all that caution, if you want to try it out, <a href="@link">manually update now</a>.', [ $update_text = $this->t('A newer version of Drupal is available and you may <a href="@link">manually update now</a>.', [
'@link' => Url::fromRoute('automatic_updates.inplace-update', [ '@link' => Url::fromRoute('automatic_updates.inplace-update', [
'project' => 'drupal', 'project' => 'drupal',
'type' => 'core', 'type' => 'core',
...@@ -183,7 +183,6 @@ class SettingsForm extends ConfigFormBase { ...@@ -183,7 +183,6 @@ class SettingsForm extends ConfigFormBase {
} }
$form['experimental']['update'] = [ $form['experimental']['update'] = [
'#prefix' => 'This module does not have a stable release and it is recommended to not use these features on a live website. Use at your own risk.',
'#type' => 'html_tag', '#type' => 'html_tag',
'#tag' => 'p', '#tag' => 'p',
'#value' => $update_text, '#value' => $update_text,
......
...@@ -52,24 +52,6 @@ class JsonTestController extends ControllerBase { ...@@ -52,24 +52,6 @@ class JsonTestController extends ControllerBase {
'insecure' => [], 'insecure' => [],
'pubDate' => 'Tue, 19 Feb 2019 14:11:01 +0000', 'pubDate' => 'Tue, 19 Feb 2019 14:11:01 +0000',
]; ];
$feed[] = [
'title' => 'Node - Moderately critical - Access bypass - SA-CONTRIB-2019',
'link' => 'https://www.drupal.org/sa-contrib-2019',
'project' => 'node',
'type' => 'module',
'is_psa' => '0',
'insecure' => ['7.x-7.22', '8.x-8.2.0'],
'pubDate' => 'Tue, 19 Mar 2019 12:50:00 +0000',
];
$feed[] = [
'title' => 'Standard - Moderately critical - Access bypass - SA-CONTRIB-2019',
'link' => 'https://www.drupal.org/sa-contrib-2019',
'project' => 'standard',
'type' => 'profile',
'insecure' => ['8.x-8.6.13', '8.x-' . \Drupal::VERSION],
'is_psa' => '0',
'pubDate' => 'Tue, 19 Mar 2019 12:50:00 +0000',
];
$feed[] = [ $feed[] = [
'title' => 'Seven - Moderately critical - Access bypass - SA-CONTRIB-2019', 'title' => 'Seven - Moderately critical - Access bypass - SA-CONTRIB-2019',
'link' => 'https://www.drupal.org/sa-contrib-2019', 'link' => 'https://www.drupal.org/sa-contrib-2019',
......
...@@ -4,7 +4,6 @@ namespace Drupal\Tests\automatic_updates\Build; ...@@ -4,7 +4,6 @@ namespace Drupal\Tests\automatic_updates\Build;
use Drupal\automatic_updates\Services\InPlaceUpdate; use Drupal\automatic_updates\Services\InPlaceUpdate;
use Drupal\Component\FileSystem\FileSystem as DrupalFilesystem; use Drupal\Component\FileSystem\FileSystem as DrupalFilesystem;
use Drupal\Core\Archiver\Zip;
use Drupal\Tests\automatic_updates\Build\QuickStart\QuickStartTestBase; use Drupal\Tests\automatic_updates\Build\QuickStart\QuickStartTestBase;
use Drupal\Tests\automatic_updates\Traits\InstallTestTrait; use Drupal\Tests\automatic_updates\Traits\InstallTestTrait;
use GuzzleHttp\Client; use GuzzleHttp\Client;
...@@ -63,7 +62,7 @@ class InPlaceUpdateTest extends QuickStartTestBase { ...@@ -63,7 +62,7 @@ class InPlaceUpdateTest extends QuickStartTestBase {
*/ */
public function testCoreRollbackUpdate() { public function testCoreRollbackUpdate() {
$from_version = '8.7.0'; $from_version = '8.7.0';
$to_version = '8.8.0'; $to_version = '8.8.5';
$this->installCore($from_version); $this->installCore($from_version);
// Configure module to have db updates cause a rollback. // Configure module to have db updates cause a rollback.
...@@ -167,66 +166,6 @@ class InPlaceUpdateTest extends QuickStartTestBase { ...@@ -167,66 +166,6 @@ class InPlaceUpdateTest extends QuickStartTestBase {
$this->assertTrue($finder->hasResults(), "Expected version 8.8.{x} does not exist in {$this->getWorkspaceDirectory()}/core/lib/Drupal.php"); $this->assertTrue($finder->hasResults(), "Expected version 8.8.{x} does not exist in {$this->getWorkspaceDirectory()}/core/lib/Drupal.php");
} }
/**
* Prepare core for testing.
*
* @param string $starting_version
* The starting version.
*/
protected function installCore($starting_version) {
// Get tarball of drupal core.
$drupal_tarball = "drupal-$starting_version.zip";
$destination = DrupalFileSystem::getOsTemporaryDirectory() . DIRECTORY_SEPARATOR . 'drupal-' . random_int(10000, 99999) . microtime(TRUE);
$fs = new SymfonyFilesystem();
$fs->mkdir($destination);
$http_client = new Client();
$http_client->get("https://ftp.drupal.org/files/projects/$drupal_tarball", ['sink' => $destination . DIRECTORY_SEPARATOR . $drupal_tarball]);
$zip = new Zip($destination . DIRECTORY_SEPARATOR . $drupal_tarball);
$zip->extract($destination);
// Move the tarball codebase over to the test workspace.
$finder = new Finder();
$finder->files()
->ignoreUnreadableDirs()
->ignoreDotFiles(FALSE)
->in("$destination/drupal-$starting_version");
$options = ['override' => TRUE, 'delete' => FALSE];
$fs->mirror("$destination/drupal-$starting_version", $this->getWorkingPath(), $finder->getIterator(), $options);
$fs->remove("$destination/drupal-$starting_version");
// Copy in this module from the original code base.
$finder = new Finder();
$finder->files()
->ignoreUnreadableDirs()
->in($this->getDrupalRoot())
->path('automatic_updates');
$this->copyCodebase($finder->getIterator());
$fs->chmod($this->getWorkspaceDirectory() . '/sites/default', 0700);
$this->installQuickStart('minimal');
// Currently, this test has to use extension_discovery_scan_tests so we can
// install test modules.
$settings_php = $this->getWorkspaceDirectory() . '/sites/default/settings.php';
$fs->chmod($this->getWorkspaceDirectory() . '/sites/default', 0755);
$fs->chmod($settings_php, 0640);
$fs->appendToFile($settings_php, '$settings[\'extension_discovery_scan_tests\'] = TRUE;' . PHP_EOL);
// Log in so that we can install modules.
$this->formLogin($this->adminUsername, $this->adminPassword);
$this->moduleInstall('update');
$this->moduleInstall('automatic_updates');
$this->moduleInstall('test_automatic_updates');
// Confirm we are running correct Drupal version.
$finder = new Finder();
$finder->files()->in($this->getWorkspaceDirectory())->path('core/lib/Drupal.php');
$finder->contains("/const VERSION = '$starting_version'/");
$this->assertTrue($finder->hasResults(), "Expected version $starting_version does not exist in {$this->getWorkspaceDirectory()}/core/lib/Drupal.php");
// Assert that the site is functional after install.
$this->visit();
$this->assertDrupalVisit();
}
/** /**
* Core versions data provider resulting in a successful upgrade. * Core versions data provider resulting in a successful upgrade.
*/ */
...@@ -247,6 +186,10 @@ class InPlaceUpdateTest extends QuickStartTestBase { ...@@ -247,6 +186,10 @@ class InPlaceUpdateTest extends QuickStartTestBase {
'from' => '8.7.6', 'from' => '8.7.6',
'to' => '8.7.7', 'to' => '8.7.7',
]; ];
$datum[] = [
'from' => '8.9.0-beta1',
'to' => '8.9.0-beta2',
];
return $datum; return $datum;
} }
......
...@@ -39,16 +39,7 @@ class ModifiedFilesTest extends QuickStartTestBase { ...@@ -39,16 +39,7 @@ class ModifiedFilesTest extends QuickStartTestBase {
* @dataProvider coreProjectProvider * @dataProvider coreProjectProvider
*/ */
public function testCoreModified($version, array $modifications = []) { public function testCoreModified($version, array $modifications = []) {
$this->copyCodebase(); $this->installCore($version);
// We have to fetch the tags for this shallow repo. It might not be a
// shallow clone, therefore we use executeCommand instead of assertCommand.
$this->executeCommand('git fetch --unshallow --tags');
$this->symfonyFileSystem->chmod($this->getWorkspaceDirectory() . '/sites/default', 0700);
$this->executeCommand('git reset HEAD --hard');
$this->assertCommandSuccessful();
$this->executeCommand("git checkout $version -f");
$this->assertCommandSuccessful();
// Assert modifications. // Assert modifications.
$this->assertModifications('core', 'drupal', $modifications); $this->assertModifications('core', 'drupal', $modifications);
...@@ -118,32 +109,6 @@ class ModifiedFilesTest extends QuickStartTestBase { ...@@ -118,32 +109,6 @@ class ModifiedFilesTest extends QuickStartTestBase {
* The modified files to assert. * The modified files to assert.
*/ */
protected function assertModifications($project_type, $project, array $modifications) { protected function assertModifications($project_type, $project, array $modifications) {
$this->symfonyFileSystem->chmod($this->getWorkspaceDirectory() . '/sites/default', 0700);
$this->executeCommand('COMPOSER_DISCARD_CHANGES=true composer install --no-dev --no-interaction');
$this->assertErrorOutputContains('Generating autoload files');
$this->installQuickStart('minimal');
// Currently, this test has to use extension_discovery_scan_tests so we can
// install test modules.
$this->symfonyFileSystem->chmod($this->getWorkspaceDirectory() . '/sites/default', 0750);
$settings_php = $this->getWorkspaceDirectory() . '/sites/default/settings.php';
$this->symfonyFileSystem->chmod($settings_php, 0640);
$this->symfonyFileSystem->appendToFile($settings_php, PHP_EOL . '$settings[\'extension_discovery_scan_tests\'] = TRUE;' . PHP_EOL);
// Restart server for config override to apply.
$this->stopServer();
$this->standUpServer();
// Log in so that we can install modules.
$this->formLogin($this->adminUsername, $this->adminPassword);
$this->moduleInstall('update');
$this->moduleInstall('automatic_updates');
$this->moduleInstall('test_automatic_updates');
// Assert that the site is functional.
$this->visit();
$this->assertDrupalVisit();
// Validate project is not modified. // Validate project is not modified.
$this->visit("/automatic_updates/modified-files/$project_type/$project"); $this->visit("/automatic_updates/modified-files/$project_type/$project");
$assert = $this->getMink()->assertSession(); $assert = $this->getMink()->assertSession();
......
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
namespace Drupal\Tests\automatic_updates\Build\QuickStart; namespace Drupal\Tests\automatic_updates\Build\QuickStart;
use Drupal\BuildTests\Framework\BuildTestBase; use Drupal\BuildTests\Framework\BuildTestBase;
use Drupal\Component\FileSystem\FileSystem as DrupalFilesystem;
use Drupal\Core\Archiver\Zip;
use GuzzleHttp\Client;
use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpExecutableFinder;
/** /**
...@@ -43,6 +48,66 @@ abstract class QuickStartTestBase extends BuildTestBase { ...@@ -43,6 +48,66 @@ abstract class QuickStartTestBase extends BuildTestBase {
$this->assertNotEmpty($this->adminPassword = $matches[2]); $this->assertNotEmpty($this->adminPassword = $matches[2]);
} }
/**
* Prepare core for testing.
*
* @param string $starting_version
* The starting version.
*/
protected function installCore($starting_version) {
// Get tarball of drupal core.
$drupal_tarball = "drupal-$starting_version.zip";
$destination = DrupalFileSystem::getOsTemporaryDirectory() . DIRECTORY_SEPARATOR . 'drupal-' . random_int(10000, 99999) . microtime(TRUE);
$fs = new SymfonyFilesystem();
$fs->mkdir($destination);
$http_client = new Client();
$http_client->get("https://ftp.drupal.org/files/projects/$drupal_tarball", ['sink' => $destination . DIRECTORY_SEPARATOR . $drupal_tarball]);
$zip = new Zip($destination . DIRECTORY_SEPARATOR . $drupal_tarball);
$zip->extract($destination);
// Move the tarball codebase over to the test workspace.
$finder = new Finder();
$finder->files()
->ignoreUnreadableDirs()
->ignoreDotFiles(FALSE)
->in("$destination/drupal-$starting_version");
$options = ['override' => TRUE, 'delete' => FALSE];
$fs->mirror("$destination/drupal-$starting_version", $this->getWorkingPath(), $finder->getIterator(), $options);
$fs->remove("$destination/drupal-$starting_version");
// Copy in this module from the original code base.
$finder = new Finder();
$finder->files()
->ignoreUnreadableDirs()
->in($this->getDrupalRoot())
->path('automatic_updates');
$this->copyCodebase($finder->getIterator());
$fs->chmod($this->getWorkspaceDirectory() . '/sites/default', 0700);
$this->installQuickStart('minimal');
// Currently, this test has to use extension_discovery_scan_tests so we can
// install test modules.
$settings_php = $this->getWorkspaceDirectory() . '/sites/default/settings.php';
$fs->chmod($this->getWorkspaceDirectory() . '/sites/default', 0755);
$fs->chmod($settings_php, 0640);
$fs->appendToFile($settings_php, '$settings[\'extension_discovery_scan_tests\'] = TRUE;' . PHP_EOL);
// Log in so that we can install modules.
$this->formLogin($this->adminUsername, $this->adminPassword);
$this->moduleInstall('update');
$this->moduleInstall('automatic_updates');
$this->moduleInstall('test_automatic_updates');
// Confirm we are running correct Drupal version.
$finder = new Finder();
$finder->files()->in($this->getWorkspaceDirectory())->path('core/lib/Drupal.php');
$finder->contains("/const VERSION = '$starting_version'/");
$this->assertTrue($finder->hasResults(), "Expected version $starting_version does not exist in {$this->getWorkspaceDirectory()}/core/lib/Drupal.php");
// Assert that the site is functional after install.
$this->visit();
$this->assertDrupalVisit();
}
/** /**
* Helper that uses Drupal's user/login form to log in. * Helper that uses Drupal's user/login form to log in.
* *
......
...@@ -58,14 +58,12 @@ class AutomaticUpdatesTest extends BrowserTestBase { ...@@ -58,14 +58,12 @@ class AutomaticUpdatesTest extends BrowserTestBase {
$this->drupalGet(Url::fromRoute('system.admin')); $this->drupalGet(Url::fromRoute('system.admin'));
$this->assertSession()->pageTextContains('Critical Release - SA-2019-02-19'); $this->assertSession()->pageTextContains('Critical Release - SA-2019-02-19');
$this->assertSession()->pageTextContains('Critical Release - PSA-Really Old'); $this->assertSession()->pageTextContains('Critical Release - PSA-Really Old');
$this->assertSession()->pageTextContains('Seven - Moderately critical - Access bypass - SA-CONTRIB-2019');
$this->assertSession()->pageTextContains('Standard - Moderately critical - Access bypass - SA-CONTRIB-2019');
$this->assertSession()->pageTextNotContains('Node - Moderately critical - Access bypass - SA-CONTRIB-2019'); $this->assertSession()->pageTextNotContains('Node - Moderately critical - Access bypass - SA-CONTRIB-2019');
$this->assertSession()->pageTextNotContains('Views - Moderately critical - Access bypass - SA-CONTRIB-2019'); $this->assertSession()->pageTextNotContains('Views - Moderately critical - Access bypass - SA-CONTRIB-2019');
// Test site status report. // Test site status report.
$this->drupalGet(Url::fromRoute('system.status')); $this->drupalGet(Url::fromRoute('system.status'));
$this->assertSession()->pageTextContains('4 urgent announcements require your attention:'); $this->assertSession()->pageTextContains('3 urgent announcements require your attention:');
// Test cache. // Test cache.
$end_point = $this->buildUrl(Url::fromRoute('test_automatic_updates.json_test_denied_controller')); $end_point = $this->buildUrl(Url::fromRoute('test_automatic_updates.json_test_denied_controller'));
...@@ -106,7 +104,7 @@ class AutomaticUpdatesTest extends BrowserTestBase { ...@@ -106,7 +104,7 @@ class AutomaticUpdatesTest extends BrowserTestBase {
$this->assertSession()->pageTextContains('Your site does not pass some readiness checks for automatic updates. Depending on the nature of the failures, it might effect the eligibility for automatic updates.'); $this->assertSession()->pageTextContains('Your site does not pass some readiness checks for automatic updates. Depending on the nature of the failures, it might effect the eligibility for automatic updates.');
// Ignore specific file paths to see no readiness issues. // Ignore specific file paths to see no readiness issues.
$ignore_paths = "core/*\nmodules/*\nthemes/*\nprofiles/*"; $ignore_paths = "vendor/*\ncore/*\nmodules/*\nthemes/*\nprofiles/*\ncomposer.*\nautoload.php\nLICENSE.txt";
$this->config('automatic_updates.settings')->set('ignored_paths', $ignore_paths) $this->config('automatic_updates.settings')->set('ignored_paths', $ignore_paths)
->save(); ->save();
$this->drupalGet(Url::fromRoute('automatic_updates.settings')); $this->drupalGet(Url::fromRoute('automatic_updates.settings'));
......
...@@ -73,7 +73,7 @@ class NotifyTest extends BrowserTestBase { ...@@ -73,7 +73,7 @@ class NotifyTest extends BrowserTestBase {
$notify = $this->container->get('automatic_updates.psa_notify'); $notify = $this->container->get('automatic_updates.psa_notify');
$notify->send(); $notify->send();
$this->assertCount(1, $this->getMails()); $this->assertCount(1, $this->getMails());
$this->assertMailString('subject', '4 urgent Drupal announcements require your attention', 1); $this->assertMailString('subject', '3 urgent Drupal announcements require your attention', 1);
$this->assertMailString('body', 'Critical Release - SA-2019-02-19', 1); $this->assertMailString('body', 'Critical Release - SA-2019-02-19', 1);
// No email should be sent if PSA's are disabled. // No email should be sent if PSA's are disabled.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment