Problem/Motivation

In #2804155: If the next minor version of core has a security release, status still says "Security update required!" even if the site is on an equivalent, secure release already we are adding a bunch of tests cases for security updates. Currently there is almost no test coverage these cases.

Proposed resolution

We should add all the currently passing test cases now to make that issue smaller.

Remaining tasks

Do it

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#47 2990511-47.patch66.49 KBtedbow
#47 interdiff-44-47.txt1.38 KBtedbow
#44 2990511-44.patch66.74 KBtedbow
#44 interdiff-43-44.txt10.23 KBtedbow
#43 2990511-43.patch68.85 KBtedbow
#43 interdiff-39-43.txt4.07 KBtedbow
#39 interdiff-34-39.txt8.35 KBtedbow
#39 2990511-39.patch69.51 KBtedbow
#39 core_pre_release_downgrade.png96.49 KBtedbow
#39 core_8.0.2_downgrade.png87.35 KBtedbow
#39 beta_downgrade.png92.59 KBtedbow
#39 1.2_downgrade.png78.19 KBtedbow
#39 real_drupal_update.xml_.txt130.52 KBtedbow
#34 2990511-34.patch66 KBtedbow
#34 interdiff-33-34.txt31.18 KBtedbow
#33 2990511-33.patch65.77 KBtedbow
#33 interdiff-30-33.txt2.59 KBtedbow
#30 2990511-30.patch65.54 KBtedbow
#30 interdiff-28-30.txt3.85 KBtedbow
#28 2990511-28.patch65.76 KBtedbow
#28 interdiff-27-28.txt4.07 KBtedbow
#27 2990511-27.patch62.91 KBtedbow
#27 interdiff-23-27.txt1.3 KBtedbow
#23 2990511-23.patch62.87 KBtedbow
#23 interdiff-20-23.txt17.85 KBtedbow
#23 2990511-23-test_update_only.patch64.9 KBtedbow
#20 2990511-20-pass.patch66.48 KBtedbow
#20 2990511-20-contrib-not-supported-FAIL.patch73.16 KBtedbow
#20 interdiff-19-20.txt27.45 KBtedbow
#19 2990511-19.patch243.84 KBtedbow
#19 interdiff-16-19.txt26.36 KBtedbow
#16 2990511-16.patch252.62 KBtedbow
#16 interdiff-13-16.txt11.14 KBtedbow
#13 2990511-13.patch51.92 KBtedbow
#8 interdiff-6-7.txt932 bytestedbow
#8 2990511-8.patch46.94 KBtedbow
#6 2990511-5.patch47.14 KBtedbow
#6 interdiff-3-5.txt6.79 KBtedbow
#3 2990511-3.patch47.42 KBtedbow
#2 2990511-2.patch47.51 KBtedbow

Comments

tedbow created an issue. See original summary.

tedbow’s picture

Status: Active » Needs review
StatusFileSize
new47.51 KB

Here are the current tests from #2804155: If the next minor version of core has a security release, status still says "Security update required!" even if the site is on an equivalent, secure release already

Some will fail. but just wanted to start with all cases.

I marked this as critical issue because @xjm said we should get this 1 in first and the other issue is critical.

tedbow’s picture

StatusFileSize
new47.42 KB

removed debug line

The last submitted patch, 2: 2990511-2.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 3: 2990511-3.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new6.79 KB
new47.14 KB

Removed 2 core tests cases that are broken and will be fixed in #2804155: If the next minor version of core has a security release, status still says "Security update required!" even if the site is on an equivalent, secure release already

  1. Site on latest security release for minor which is not insecure but next minor has security release.
  2. No security release available for site minor release 0 but release not marked as insecure. Security release available for next minor.

Removed 4 contrib test cases that are broken they might not be in #2804155

  1. Security release available for module major release 1. No future releases for next major.

    The page says "Security update required!" but link to update is not shown.

  2. Site on latest security release for minor. Next minor has security release.

    No update shown.

  3. Site on latest security release for minor. Previous minor has security release.

    Not supported! shown 😕

  4. No security release available for module major release 1. Security release available for next major.

    The page says "Security update required!" but link to update is not shown.

Also to get a quick test result I am only testing "update" group. I don't know how to test 2 classes.

Status: Needs review » Needs work

The last submitted patch, 6: 2990511-5.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new46.94 KB
new932 bytes
+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -459,6 +458,7 @@ public function testSecurityUpdateAvailability($module_version, $security_releas
+    file_put_contents('/Users/ted.bowman/Sites/www/contrib' . $module_version . implode('__', $security_releases) . "__$expected_security_release---$fixture", $this->getSession()->getPage()->getOuterHtml());

Nooooooooooooooooo!

saurabh-chugh’s picture

@tedbow I am testing the patch.

Can you please elaborate this second point

No security release available for site minor release 0 but release not marked as insecure. Security release available for next minor.

tedbow’s picture

+++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
@@ -274,15 +266,6 @@ public function securityUpdateAvailabilityProvider() {
-      // No security release available for site minor release 0 but release not
-      // marked as insecure.
-      // Security release available for next minor.
-      '0.0, 1.2, not insecure' => [
-        'site_patch_version' => '0.0',
-        'security_releases' => ['1.2'],
-        'expected_security_release' => NULL,
-        'fixture' => '1.2-sec',
-      ],

This test case.
which uses this test xml file core/modules/update/tests/modules/update_test/drupal.1.2-sec.xml

If you look at that test case there is

  1. 8.1.2 security update
  2. 8.1.0, 8.1.1 marked as insecure: <term><name>Release type</name><value>Insecure</value></term>
  3. 8.0.0, 8.0.1, 8.0.2 not marked as insecure

meaning if you are 8.0.* you don't have security problem(in this test case). This mimics a security problem that was introduced in the 8.1.x branch but doesn't exist in the 8.0.x branch(probably because it is new feature added to 8.1.x)

A new feature on Drupal.org update xml is to explicitly mark releases as insecure. This should be the authority on what is secure vs insecure.

saurabh-chugh’s picture

@tedbow Thanks for explaination.

xjm’s picture

Status: Needs review » Needs work
+++ b/core/drupalci.yml
@@ -3,53 +3,13 @@
 build:
   assessment:
-    validate_codebase:
-      phplint:
-      # Re-run composer install to ensure the dependencies resolve for the
-      # containerized PHP version.
-      container_composer:
-        options: ' install --prefer-dist --no-suggest --no-progress --no-interaction'
-        halt-on-fail: true
-      csslint:
-        halt-on-fail: false
-      eslint:
-        # A test must pass eslinting standards check in order to continue processing.
-        halt-on-fail: false
-      phpcs:
-        # phpcs will use core's specified version of Coder.
-        sniff-all-files: false
-        halt-on-fail: false
     testing:
       # run_tests task is executed several times in order of performance speeds.
       # halt-on-fail can be set on the run_tests tasks in order to fail fast.
       # suppress-deprecations is false in order to be alerted to usages of
       # deprecated code.
-      run_tests.phpunit:
-        types: 'PHPUnit-Unit'
-        testgroups: '--all'
-        suppress-deprecations: false
-        halt-on-fail: false
-      run_tests.kernel:
-        types: 'PHPUnit-Kernel'
-        testgroups: '--all'
-        suppress-deprecations: false
-        halt-on-fail: false
-      run_tests.simpletest:
-         types: 'Simpletest'
-         testgroups: '--all'
-         suppress-deprecations: false
-         halt-on-fail: false
       run_tests.functional:
         types: 'PHPUnit-Functional'
-        testgroups: '--all'
-        suppress-deprecations: false
-        halt-on-fail: false
-      run_tests.javascript:
-        concurrency: 15
-        types: 'PHPUnit-FunctionalJavascript'
-        testgroups: '--all'
+        testgroups: '--module update'
         suppress-deprecations: false
         halt-on-fail: false
-      # Run nightwatch testing.
-      # @see https://www.drupal.org/project/drupal/issues/2869825
-      nightwatchjs:

I don't think these changes should be here?

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new51.92 KB
+++ b/core/drupalci.yml
@@ -3,53 +3,13 @@
+        testgroups: '--module update'

@xjm I was just adding changes to this file so that I could run few tests and get the results faster while I working on this issue.

Will remove them now.

Added beta tests.

samuel.mortenson’s picture

Nice work so far!

I don't see test coverage for going from alpha -> beta, or beta -> beta, or alpha -> rc. Also don't see a test for when there's a security update for a previous branch, i.e. if you're on 8.x-2.0 and there's a security update in 8.x-1.2, there should be no expected security release.

xjm’s picture

Also don't see a test for when there's a security update for a previous branch, i.e. if you're on 8.x-2.0 and there's a security update in 8.x-1.2, there should be no expected security release.

So this is an interesting case now that the "insecure" metadata has been populated. 8.x-2.0 might be secure, or it might be insecure. If it's insecure and there's no secure version on 8.x-2.x, then what do we expect to happen? What is the current behavior in HEAD?

tedbow’s picture

StatusFileSize
new11.14 KB
new252.62 KB

if you're on 8.x-2.0 and there's a security update in 8.x-1.2, there should be no expected security release.

I added a test for this case
Site on 8.x-2.2
No 8.x-2.x releases marked as insecure
8.x-1.2 has security release
8.x-1.1. 8.x-1.0 marked as insecure

This fails now because it says 8.x-2.2 is unsupported.
I think we could fix this in #2989616: The update report does not honor drupal.org's info about what releases are secure or not

xjm’s picture

  1. Re: #16, yeah, let's exclude failing cases from this issue and put them in their own issues. Not sure #2989616: The update report does not honor drupal.org's info about what releases are secure or not is the right place though unless we rescope it; that sounds like maybe a regression for contrib?
  2. +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,110 @@ public function testHookUpdateStatusAlter() {
    +      // Security release available for module major release 2.
    +      // Security release also available for previous minor.
    +      '8.x-2.0, 8.x-1.2 8.x-2.2' => [
    +        'module_patch_version' => '8.x-2.0',
    +        'security_releases' => ['8.x-1.2', '8.x-2.2'],
    +        'expected_security_release' => '8.x-2.2',
    +        'fixture' => '8.x-1.2_8.x-2.2-sec',
    +      ],
    

    The second inline comment here looks incorrect; should it be "Security release also available for the previous major"?

  3. +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,110 @@ public function testHookUpdateStatusAlter() {
    +      // No security release available for module major release 1 but release
    +      // not marked as insecure.
    +      // Security release available for next major.
    

    That's a lot of negatives. :)

    Does this imply that in the prior cases, all security releases besides the latest were marked as insecure? (The default behavior, but only since a couple months ago.)

    Maybe it'd be helpful to just list a quick summary the releases in the fixture in the docs, e.g.:

    // Fixture 8.2_1.2_1.1.0.11 contains:
    // - 8.x-1.0, insecure,
    // - 8.x-1.1, security release, insecure 
    // - 8.x-1.2, security release
    // - 8.x-2.0, insecure
    // - 8.x-2.1, security release
    

Status: Needs review » Needs work

The last submitted patch, 16: 2990511-16.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new26.36 KB
new243.84 KB

@xjm thanks for review!
1. Yeah just want to upload failing tests here so we can make sure we cover them in other issues.
2. fixed
3. Added the list of which releases each fixture file has to the phpdoc for the @dataProvider methods.

Removing a fixture file that should have been removed in #6 when I removed the failing test.

Also renamed the security fixtures files to be [project_name].sec.*.xml because this groups them together and makes them easier to find.

I guess this fixtures there test classes were made before we used /[module]/tests/fixtures folders? This makes the listing confusing.

tedbow’s picture

Whoops looks #19 had a bunch of unrelated changes.

re #14

  1. I don't see test coverage for going from alpha -> beta, or beta -> beta, or alpha -> rc.

    I have added this just as relates to security releases.

    If you are any one of these releases and it is tagged as insecure the expected security release should be the 1 from the previous minor.

  2. if you're on 8.x-2.0 and there's a security update in 8.x-1.2, there should be no expected security

    This gets the same mentioned in #6

    Site on latest security release for minor. Previous minor has security release.
    Not supported! shown

    I am adding the failing so we can back through issue and make sure all currently failing test will be in a followup.

    This test cases has a passing test for core.

  3. I also added a check to make sure "Not Supported" is not on any test cases.

The last submitted patch, 20: 2990511-20-contrib-not-supported-FAIL.patch, failed testing. View results

samuel.mortenson’s picture

  1. +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,234 @@ public function testMajorUpdateAvailable() {
    +      // Site on 2.0-beta1 which is insecure.2.0-beta2 is not insecure but
    +      // because beta/alpha/RC releases are not supported the latest security
    +      // from the previous major is the expected security release.
    +      '2.0-beta1, 0.2 1.2 2.0-beta2' => [
    +        'site_patch_version' => '2.0-beta1',
    +        'expected_security_release' => '1.2',
    +        'update_available' => TRUE,
    +        'fixture' => 'sec.0.2-rc2',
    +      ],
    

    This doesn't make sense to me - we should never suggest that users downgrade. Is this just how the current behavior is? I have the same comment for the other new tests that do this.

tedbow’s picture

StatusFileSize
new64.9 KB
new17.85 KB
new62.87 KB

#22 makes sense. It looks like the current behavior is wrong. This patch will add pre-release tests that currently pass and are the correct behavior.

This patch adds

  1. Added test cases where all pre-releases alpha/beta/RC are insecure except RC-2 which is a security update. Expected update is RC-2
  2. Added test cases where all pre-releases alpha/beta/RC are secure and no pre-release security update. No expected security update
  3. Updates fixtures for above
  4. Fixes release and download links in test fixtures
  5. Re-orders pre-releases in text fixtures
samuel.mortenson’s picture

Status: Needs review » Reviewed & tested by the community

This looks like a good amount of tests to start from when working on test logic changes. Marking as RTBC assuming the full test run passes.

xjm’s picture

Thanks @tedbow and @samuel.mortenson! I'll finish reviewing this tomorrow. Meanwhile:

+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -487,6 +487,30 @@ public function testSecurityUpdateAvailability($module_version, $security_releas
+   *     8.x-3.0-beta1 1nsecure

1nsecure would be an excellent name for a boyband.

xjm’s picture

+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -438,4 +438,144 @@ public function testHookUpdateStatusAlter() {
+   *   Contains releases
+   *     8.x-1.2 Security Update
+   *     8.x-1.1, 8.x-1.2 insecure

Last line also looks to contain a typo here.

tedbow’s picture

StatusFileSize
new1.3 KB
new62.91 KB
  1. Fixed #25(though who's to say if this an error or stroke of genius) and #26
  2. Made the capitalization uniform in this listing.
tedbow’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.07 KB
new65.76 KB

I was working on re-rolling the patch for #2804155: If the next minor version of core has a security release, status still says "Security update required!" even if the site is on an equivalent, secure release already on top of this patch and I was adding the test cases I removed in this issue that should be passing with the fix in the other

In #6 I removed the contrib test case

Security release available for module major release 1. No future releases for next major.

This was actually because of

+++ b/core/modules/update/tests/modules/update_test/aaa_update_test.8.x-1.2-sec.xml
@@ -0,0 +1,72 @@
+   <release_link>http://example.com/aaa_update_test-8-x-1-2-release</release_link>
+   <download_link>http://example.com/aaa_update_test-8.x-1.2.tar.gz</download_link>
+   <date>1250424521</date>
+   <mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
+   <filesize>1073741824</filesize>
+   <terms>
+    <term><name>Release type</name><value>New features</value></term>
+    <term><name>Release type</name><value>Bug fixes</value></term>
+    <term><name>Release type</name><value>Security update</value></term>
+    <term><name>Release type</name><value>Insecure</value></term>

These release in the fixture from #3 should not have both terms Security update and Insecure

So that is why the tested failed. I added the test case back.

I looked at all of the test cases removed in this issue and none of the others have a problem.

samuel.mortenson’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC assuming tests pass.

tedbow’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.85 KB
new65.54 KB
  1. +++ b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2_8.x-2.2.xml
    @@ -0,0 +1,169 @@
    +   <release_link>http://example.com/project/drupal/releases/8.x-3.0-beta2</release_link>
    +   <download_link>http://example.com/files/projects/drupal-8.x-3.0-beta2.tar.gz</download_link>
    ...
    +   <release_link>http://example.com/project/drupal/releases/8.x-3.0-beta1</release_link>
    +   <download_link>http://example.com/files/projects/drupal-8.x-3.0-beta1.tar.gz</download_link>
    

    This links are set up incorrectly and aren't in the format that test would look for them.

  2. +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,153 @@ public function testHookUpdateStatusAlter() {
    +      // Site on 8.x-2.0-beta1 and 8.x-2.0-beta2 is a security release but
    +      // because beta/alpha/RC releases are not supported the latest security
    +      // from previous minor is the expected security release.
    +      '8.x-2.0-beta1, 8.x-1.2 8.x-2.2 8.x-2.0-beta2' => [
    +        'module_patch_version' => '8.x-2.0-beta1',
    +        'expected_security_release' => '8.x-2.2',
    

    This test case was set up for 8.x-2.*.beta releases but actually in the fixture files it is 8.x-3.*.beta

    8.x-3.*.beta was intended.

  3. +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,153 @@ public function testHookUpdateStatusAlter() {
    +      $assert_session->linkByHrefExists("http://example.com/aaa_update_test-$expected_url_version-release");
    +      $assert_session->linkByHrefExists("http://example.com/aaa_update_test-$expected_security_release.tar.gz");
    +      $assert_session->linkByHrefExists("http://example.com/aaa_update_test-$expected_url_version-release");
    

    The 1st and third line here are actually the same assertion. Deleting

samuel.mortenson’s picture

Status: Needs review » Reviewed & tested by the community

This still looks good to me - hopefully my credibility isn't getting dinged! :-)

xjm’s picture

Status: Reviewed & tested by the community » Needs review

Really great work on this. Thanks @tedbow for your careful attention to detail here. I am really glad we split this issue out.

I finally read through this carefully from the top. I want to read over the providers one more time but here are my notes from the rest (don't want to lose the review).

  1. Regarding:

    This links are set up incorrectly and aren't in the format that test would look for them.

    Why didn't this cause a fail before? (Or did it -- is that the source of the fail in #20?)

  2. +++ b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-1.2_8.x-2.2.xml
    @@ -0,0 +1,169 @@
    + <recommended_major>1</recommended_major>
    + <supported_majors>1</supported_majors>
    + <default_major>1</default_major>
    

    Hmm. Is this correct? This fixture has stable releases for 8.x-2.x too. Wouldn't this include both major versions? Why is the test passing if so? Maybe this doesn't actually affect the part of the behavior that we're testing? Need to double-check against the provider.

  3. +++ b/core/modules/update/tests/modules/update_test/aaa_update_test.sec.8.x-2.2_1.x_secure.xml
    @@ -0,0 +1,123 @@
    + <recommended_major>1</recommended_major>
    + <supported_majors>1</supported_majors>
    + <default_major>1</default_major>
    

    Same question here.

  4. +++ b/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2-b.xml
    @@ -0,0 +1,263 @@
    +  <name>drupal 8.2.0-rc1</name>
    +  <version>8.2.0-rc1</version>
    +  <tag>8.2.0-rc1</tag>
    ...
    +  <security>
    +   Beta releases are not covered by Drupal security advisories.
    +  </security>
    

    Is this <security> message a c&p error? This is actually an RC if I'm reading the XML right.

    This probably has no impact on the test results and I'm not even sure if/how it's used in core, but could cause confusion with the fixture in the future. Maybe we should check what d.o actually outputs and verify this is still there as such.

    Aside: I have trouble typing "XML" because it's too close to my username. :P

  5. +++ b/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2-b.xml
    @@ -0,0 +1,263 @@
    +  <name>drupal 8.2.0-alpha2</name>
    +  <version>8.2.0-alpha2</version>
    +  <tag>8.2.0-alpha2</tag>
    ...
    +  <security>
    +   Beta releases are not covered by Drupal security advisories.
    +  </security>
    

    Same thing, except this one is an alpha.

  6. +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,149 @@ public function testHookUpdateStatusAlter() {
    +   * @param string $expected_security_release
    +   *   The expected security release. If NULL then no security release is
    +   *   expected.
    
    +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,208 @@ public function testMajorUpdateAvailable() {
    +   * @param string $expected_security_release
    +   *   The expected security release.
    

    I still think "expected security release" is unclear. Should this maybe say something like:

    The security release, if any, that the status report should recommend.

    Is that accurate?

    Also, this implies that only one security release is "expected". That's the default behavior with the changes to d.o's metadata and will likely be the preferred behavior based on UX review on #2865920: Add tests for when a single supported branch has 2 security updates that are both not insecure, but previously, multiple security releases were "expected". Are we sure we want to hardcode that there is only one? I think it's still technically possible for d.o to output multiple ones under certain circumstances. Should it be a string[] instead, single-value everywhere for now, and add a reference/@todo for #2865920: Add tests for when a single supported branch has 2 security updates that are both not insecure? That way we can keep that out of the scope here.

    The other option is just calling it something like $expected_latest_security_release.

  7. Also, the copy should be the same for both of these, right? Which makes me wonder if we should have a trait or something for the code semi-duplication to avoid unintended divergence/errors/etc.

    OTOH, since there are only two cases (core and contrib) the duplication might be NBD or something that a normal followup could address. What do you think?

  8. +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,149 @@ public function testHookUpdateStatusAlter() {
    +   *     8.x-1.2 Security Update
    +   *     8.x-1.1 Security Update, Insecure
    
    +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,208 @@ public function testMajorUpdateAvailable() {
    +   *     8.0.2 Security Update
    +   *     8.0.1 Security Update, Insecure
    ...
    +   *     8.0.2 Security Update
    ...
    +   *     8.2.0-rc2 Security Update
    ...
    +   *     8.1.2 Security Update
    ...
    +   *     8.0.2 Security Update
    ...
    +   *     8.1.2 Security Update
    ...
    +   *     8.1.2 Security Update
    

    Nit: I think the correct case is Security update. Either that or the other ones are cased incorrectly. :)

tedbow’s picture

StatusFileSize
new2.59 KB
new65.77 KB

@xjm thanks for the detailed review!

1. The bad links didn't cause a test failure because none of the test cases had at that point a beta version as the expected_security_release so none went on to check these links. It was important to fix them anyways because we may add test cases that point to them. As I did in #30

2. Good catch. No it is not correct fixing.

It didn't cause test failures I believe because from update_calculate_project_update_status (my . comments in all CAPS)

  if (in_array($existing_major, $supported_majors)) { // ***** THIS WOULD FAIL
    // Still supported, stay at the current major version.
    $target_major = $existing_major;
  }
  elseif (isset($available['recommended_major'])) { // **** THIS WOULD PASS
    // Since 'recommended_major' is defined, we know this is the new XML
    // format. Therefore, we know the current release is unsupported since
    // its major version was not in the 'supported_majors' list. We should
    // find the best release from the recommended major version.
    $target_major = $available['recommended_major']; // ***** WHEN ON MAJOR  2  THIS WOULD SET $target_major TO 1
    $project_data['status'] = UPDATE_NOT_SUPPORTED; // ***** SET TO UNSUPPORTED
  }
  elseif (isset($available['default_major'])) {
    // Older release history XML file without recommended, so recommend
    // the currently defined "default_major" version.
    $target_major = $available['default_major'];
  }
  else {
    // Malformed XML file? Stick with the current version.
    $target_major = $existing_major;
  }

  // Make sure we never tell the admin to downgrade. If we recommended an
  // earlier version than the one they're running, they'd face an
  // impossible data migration problem, since Drupal never supports a DB
  // downgrade path. In the unfortunate case that what they're running is
  // unsupported, and there's nothing newer for them to upgrade to, we
  // can't print out a "Recommended version", but just have to tell them
  // what they have is unsupported and let them figure it out.
  $target_major = max($existing_major, $target_major); // BUT THEN HERE IT WOULD SET IT BACK TO 2 BECAUSE IT IS GREATER THAN

But that leads to the question in the above logic we hit:
$project_data['status'] = UPDATE_NOT_SUPPORTED;

But then why doesn't this fail?

+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -438,4 +438,149 @@ public function testHookUpdateStatusAlter() {
+    $assert_session->elementTextNotContains('css', $update_element_css_locator, 'Not supported');

Because after this we loop through all the releases

foreach ($available['releases'] as $version => $release) {
    // First, if this is the existing release, check a few conditions.
    if ($project_data['existing_version'] === $version) {
      if (isset($release['terms']['Release type']) &&
          in_array('Insecure', $release['terms']['Release type'])) {
        $project_data['status'] = UPDATE_NOT_SECURE;
      }

And all our tests case where the module_patch_version was 2 it was on an insecure release. So UPDATE_NOT_SECURE over wrote UPDATE_NOT_SUPPORTED.

But this is why this previous test case that I removed in #6

Site on latest security release for minor. Previous minor has security release.
Not supported! shown 😕

+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -532,30 +524,6 @@ public function securityUpdateAvailabilityProvider() {
-      '8.x-2.2, 8.x-1.2 8.x-2.2' => [
-        'module_patch_version' => '8.x-2.2',
-        'security_releases' => ['8.x-1.2', '8.x-2.2'],
-        'expected_security_release' => NULL,
-        'fixture' => '8.x-1.2_8.x-2.2-sec',

I will add back this test case

3. same problem fixed

sorry that is all I have time to review now. Will look at the rest of your points as soon as I can.

tedbow’s picture

StatusFileSize
new31.18 KB
new66 KB

Continuing to address #32

4. Fixed

5. Fixed

6. Changes to multiple releases.

7.

Which makes me wonder if we should have a trait or something for the code semi-duplication to avoid unintended divergence/errors/etc.

The classes already both extend UpdateTestBase so I am moving the logic for checking the security updates on the report page to the base class. This remove duplicate logic.

The only change I had to make to the fixtures for this is change download links for aaa_update_test to dashes in the file names so they are the same for the core fixtures.

8. changed all to "Security update"

xjm’s picture

Those changes all look pretty good; thanks @tedbow.

  1. +++ b/core/modules/update/tests/modules/update_test/drupal.sec.0.2-rc2-b.xml
    @@ -54,7 +54,7 @@
    -   Beta releases are not covered by Drupal security advisories.
    +   RC releases are not covered by Drupal security advisories.
    

    Can we confirm that this is what d.o actually outputs for RCs? I would expect "Release candidates" but I don't know what, if anything, is actually there in the XML.

  2. +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -453,8 +452,7 @@ public function testHookUpdateStatusAlter() {
    -  public function testSecurityUpdateAvailability($module_version, $expected_security_release, $update_available, $fixture) {
    ...
    +  public function testSecurityUpdateAvailability($module_version, $expected_security_releases, $update_available, $fixture) {
    

    This one could have the array typehint too, right?

  3. +++ b/core/modules/update/tests/src/Functional/UpdateTestBase.php
    @@ -81,4 +81,42 @@ protected function standardTests() {
    +      foreach ($expected_security_releases as $expected_security_release) {
    +        $assert_session->elementTextNotContains('css', $update_element_css_locator, 'Up to date');
    +        $assert_session->elementTextNotContains('css', $update_element_css_locator, 'Update available');
    +        $assert_session->elementTextContains('css', $update_element_css_locator, 'Security update required!');
    +        $expected_url_version = str_replace('.', '-', $expected_security_release);
    +        $assert_session->linkByHrefExists("http://example.com/$project-$expected_url_version-release");
    +        $assert_session->linkByHrefExists("http://example.com/$project-$expected_url_version.tar.gz");
    +        $assert_session->responseContains('error.svg', 'Error icon was found.');
    +      }
    

    Now that we have an array, should we also be asserting that no security releases other than the expected security releases are shown?

xjm’s picture

+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -438,4 +438,131 @@ public function testHookUpdateStatusAlter() {
+   * - aaa_update_test.sec.8.x-1.1_8.x-1.2.xml
+   *   Contains releases
+   *     8.x-1.2 Security update
+   *     8.x-1.1 Security update, Insecure
+   *     8.x-1.2 Insecure

For these to be formatted correctly as a nested list, the releases should have a - at the beginning too. I think we can get rid of the line "contains releases" and instead say something like:

These test cases rely on the following fixtures containing the following releases:

xjm’s picture

+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -438,4 +438,131 @@ public function testHookUpdateStatusAlter() {
+   *     8.x-1.2 Security update
+   *     8.x-1.1 Security update, Insecure
+   *     8.x-1.2 Insecure

Looks like a typo as the same release is listed twice?

xjm’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,131 @@ public function testHookUpdateStatusAlter() {
    +   * - aaa_update_test.sec.8.x-1.1_8.x-1.2.xml
    ...
    +   * - aaa_update_test.sec.8.x-1.2_8.x-2.2.xml
    +   *   Contains releases
    ...
    +   * - aaa_update_test.sec.8.x-2.2_1.x_secure.xml
    ...
    +        'fixture' => 'sec.8.x-1.2',
    

    This fixture name doesn't appear in the docblock above?

  2. +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,131 @@ public function testHookUpdateStatusAlter() {
    +      // 2 security releases available for module major release 1.
    
    +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,185 @@ public function testMajorUpdateAvailable() {
    +      // 2 security releases available for site minor release 0.
    

    Nit: When "2" is a word in a sentence (as in the quantity of something) rather than a string, we should spell it out as "two".

  3. +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,185 @@ public function testMajorUpdateAvailable() {
    +      // Security release available for site minor release 1.
    +      // Security release also available for previous minor.
    ...
    +      // Site on latest security release for minor. Previous minor has security
    +      // release.
    

    Nit: Should the second example look more like the first for easier scanning of the test cases?

  4. +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,185 @@ public function testMajorUpdateAvailable() {
    +    $pre_releases = [
    +      '2.0-alpha1',
    +      '2.0-alpha2',
    +      '2.0-beta1',
    +      '2.0-beta2',
    +      '2.0-rc1',
    +    ];
    ...
    +    $pre_releases[] = '2.0-rc2';
    

    Adding an item to the array after the fact is a bit brittle. I'd rather just have a separate test case for 8.2.0-rc2 after the foreach. That would also allow combining the two foreach loops into one.

  5. +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,185 @@ public function testMajorUpdateAvailable() {
    +    // Add test cases to confirm that all alpha/beta/RC releases will
    +    // have the expected security update of 8.2.0-rc2 which is the only
    +    // alpha/beta/RC release in sec.0.2-rc2 that is not insecure and is a
    +    // security release.
    

    Hm, quite the run-on. How about:

    If:
    - 8.2.0-rc2 is a security release.
    - All other pre-release milestones are marked insecure.
    Then any 8.2.x release prior to 8.2.0-rc2 should show 8.2.0-rc2 as a security update.

  6. +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,185 @@ public function testMajorUpdateAvailable() {
    +    // Add test cases to confirm that all alpha/beta/RC releases will have no
    ...
    +    foreach ($pre_releases as $pre_release) {
    

    I had to read this a couple times to understand it on account of the double negative. Maybe:

    If the site is on an alpha/beta/RC of an upcoming minor and none of the alpha/beta/RC versions are marked insecure, no security update should be required.

    This is interesting especially as a passing test case because it raises that release managers/sec team members need to remember to manually mark such pre-release milestones as insecure as I did when I rolled 8.6.0-beta2. By default, I think d.o only presents previous releases to be marked insecure on the security release publishing form. That's not relevant to this issue, but definitely something we need to keep in mind going forward.

tedbow’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new130.52 KB
new78.19 KB
new92.59 KB
new87.35 KB
new96.49 KB
new69.51 KB
new8.35 KB

1. Confirmed, yes this how it is output from d.o. I uploaded real_drupal_update.xml.txt file that I made from step debugging. So we can have it for future questions. Probably made a couple days ago.

2. Fixed and fixed for assertSecurityUpdates

3. Yes adding

  1. Ensure that no other links are shown as security links.
  2. Ensure that all the expected security links are actually marked as security links(are test before just ensured the link was present)

This points out failures in our test case that weren't detected before. A couple can be fixed by updating the dataprovider cases but I think most point to bugs. They could be problem with the fixtures also.

For contrib

  1. Contrib fail case 1

    +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,131 @@ public function testHookUpdateStatusAlter() {
    +      '8.x-1.0, 8.x-1.2 8.x-2.2' => [
    +        'module_patch_version' => '8.x-1.0',
    +        'expected_security_releases' => ['8.x-1.2', '8.x-2.2'],
    +        'update_available' => FALSE,
    +        'fixture' => 'sec.8.x-1.2_8.x-2.2',
    +      ],
    

    Removing 8.x-2.2 as expected release.
    This shown as "Also available" which I think makes sense the installed version 8.x-1.0 and there is security release for this major. but would like @xjm and @samuel.mortenson's opinion.

  2. Contrib fail case 2

    +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,131 @@ public function testHookUpdateStatusAlter() {
    +      '8.x-2.0, 8.x-1.2 8.x-2.2' => [
    +        'module_patch_version' => '8.x-2.0',
    +        'expected_security_releases' => ['8.x-2.2'],
    +        'update_available' => FALSE,
    +        'fixture' => 'sec.8.x-1.2_8.x-2.2',
    +      ],
    

    The expected release is correct in this data set but the test fails because it will also show 8.x-1.2 as a security release.

    This would be a downgrade.

    shows downgrade test case

  3. Contrib fail case 3

    +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
    @@ -438,4 +438,131 @@ public function testHookUpdateStatusAlter() {
    +      '8.x-3.0-beta1, 8.x-1.2 8.x-2.2 8.x-3.0-beta2' => [
    +        'module_patch_version' => '8.x-3.0-beta1',
    +        'expected_security_releases' => ['8.x-3.0-beta2'],
    +        'update_available' => TRUE,
    +        'fixture' => 'sec.8.x-1.2_8.x-2.2',
    +      ],
    

    Removing the expected security release here.

    The beta is not marked as a security release.

    This case will still fail because 8.x-2.2 and 8.x-1.2 still shows as security releases.

    Since these would both be downgrade this does not make sense


    We should make a follow up. And remove this test case(leaving to show for now)

For core:

  1. Core fail case 1

    +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,185 @@ public function testMajorUpdateAvailable() {
    +      '1.0, 0.2 1.2' => [
    +        'site_patch_version' => '1.0',
    +        'expected_security_releases' => ['1.2'],
    +        'update_available' => FALSE,
    +        'fixture' => 'sec.0.2-rc2',
    +      ],
    

    This needs the 2.0-rc2 to be added to the expected security releases.

    but it will still fail because 8.0.2 will be shown as a security release, a downgrade.

  2. Core fail case 2

    +++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
    @@ -160,20 +160,185 @@ public function testMajorUpdateAvailable() {
    +    foreach ($pre_releases as $pre_release) {
    +      $test_cases["Pre-release:$pre_release: 2.0-rc2"] = [
    +        'site_patch_version' => $pre_release,
    +        'expected_security_releases' => ['2.0-rc2'],
    +        'update_available' => TRUE,
    +        'fixture' => 'sec.0.2-rc2',
    +      ];
    +    }
    

    All these will fail because 8.0.2 and 8.1.2 will be shown as security updates, both downgrades.

If these failures are not a problem with the fixtures then there is problem with showing security releases for previous minors.

I will investigate more but could use a sanity check. Will address the rest of @xjm's review afterwards.

Also adding back the changes to core/drupalci.yml to speed the testing cycle.

Status: Needs review » Needs work

The last submitted patch, 39: 2990511-39.patch, failed testing. View results

xjm’s picture

Going to add some headers to Ted's review above just to make sure I'm not mixing stuff together.

xjm’s picture

  • I think "Contrib fail case 1" makes sense as explained.
  • "Contrib fail case 2" sounds like whatever's left over of #2865920: Add tests for when a single supported branch has 2 security updates that are both not insecure
  • "Contrib fail case 3" is a harder call. Since there is no stable release version of 8.x-3.0 and since pre-release versions do not receive security coverage, it makes sense for the site to recommend a known secure version. So I believe that one is probably works as designed.
  • "Core fail case 1" seems to have the same bug as Contrib fail case 2.
  • "Core fail case 3" might arguably have the same issue as "Contrib fail case 3", where our pre-release milestones don't receive security coverage, and so it makes sense to show security releases that aren't marked insecure for older branches.
tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new4.07 KB
new68.85 KB

fixing failures in #39

  1. Contrib fail case 1

    fixed in #39

  2. Contrib fail case 2

    removing test case and adding @todo for https://www.drupal.org/project/drupal/issues/2865920

  3. Contrib fail case 3

    Adding 8.x-2.2 and 8.x-1.2 as expected security updates as per @xjm comment in #42

  4. Core fail case 1

    removing test case and adding @todo for https://www.drupal.org/project/drupal/issues/2865920

  5. Core fail case 2

    re @xjm

    might arguably have the same issue as "Contrib fail case 3", where our pre-release milestones don't receive security coverage, and so it makes sense to show security releases that aren't marked insecure for older branches.

    Chatted with @xjm and actually core RC(not contrib) can be security updates according to policy. this doesn't happen right now because of bugs with the update module would cause problem with the previous minor to show it needing a security update even if it didn't.

    So removing test case and adding @todo for https://www.drupal.org/project/drupal/issues/2865920

tedbow’s picture

StatusFileSize
new10.23 KB
new66.74 KB

Back to the rest of @xjm's review

  1. #36 fixed
  2. #37 fixed
  3. #38.1 added
  4. #38.2 fixed
  5. #38.3 fixed. And fixe wording on a couple other comments here.
    Also changed No future releases for next minor to just No releases for next minor. Next minor releases could actually be have been released in the past depending on how behind a site is.
  6. #38.4 N/A first loop has been removed.
  7. #38.5 N/A code has been removed.
  8. #38.6 fixed

Also removing changes to drupalci.yml

samuel.mortenson’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Can we attach a patch with the removed test cases to #2865920: Add tests for when a single supported branch has 2 security updates that are both not insecure? It won't apply yet but "Test with" can be set to "Do not test" on upload.

+++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php
@@ -558,10 +550,14 @@ public function securityUpdateAvailabilityProvider() {
       // 8.x-3.0-beta2 is not insecure but is not a security release.
       '8.x-3.0-beta1, 8.x-1.2 8.x-2.2 8.x-3.0-beta2' => [
         'module_patch_version' => '8.x-3.0-beta1',
-        'expected_security_releases' => [],
+        'expected_security_releases' => ['8.x-1.2', '8.x-2.2'],
         'update_available' => TRUE,
         'fixture' => 'sec.8.x-1.2_8.x-2.2',

Hm, so even if it shows 2.2 it definitely should not be showing 1.2. So let's remove this test cases as well, insert the @todo, and include it in the patch for #2865920: Add tests for when a single supported branch has 2 security updates that are both not insecure.

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new1.38 KB
new66.49 KB
samuel.mortenson’s picture

Status: Needs review » Reviewed & tested by the community

Recent changes look good to me.

xjm’s picture

+++ b/core/modules/update/tests/src/Functional/UpdateCoreTest.php
@@ -160,20 +160,169 @@ public function testMajorUpdateAvailable() {
+        'fixture' => 'sec.0.2-rc2',
+
+      ],

Nit: extra blank line.

Saving issue credit.

  • xjm committed 5de039f on 8.7.x
    Issue #2990511 by tedbow, xjm, samuel.mortenson: Add comprehensive test...

  • xjm committed 3c6d1f2 on 8.6.x
    Issue #2990511 by tedbow, xjm, samuel.mortenson: Add comprehensive test...

  • xjm committed 5dae1bf on 8.5.x
    Issue #2990511 by tedbow, xjm, samuel.mortenson: Add comprehensive test...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

I fixed the blank line on commit. Committed and pushed to 8.7.x, 8.6.x, and 8.5.x since we may need to backport code related to this for security coverage.

Thanks everyone for your patience on this issue! I feel a lot safer now about fixing the various bugs and changes needed with the update status report.

idebr’s picture

Version: 8.7.x-dev » 8.5.x-dev

@xjm I updated the 'Version' to the earliest branch this commit is available in. This information relevant for projects that are built with patches from Drupal.org and that update to a new minor version (8.5.x -> 8.6.x), since it indicates the issue has been fixed in the project itself and the patch can be removed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.