Fix Field UI tests that rely on UID1's super user behavior

Created on 10 April 2024, 8 months ago
Updated 11 August 2024, 3 months ago

Problem/Motivation

In 📌 Add a container parameter that can remove the special behavior of UID#1 Fixed an approach was taken where we can simply flag tests that are failing if we turn off user 1's super user powers, so that they can be taken care of in a followup. This issue is to collect all of these followups.

The goal is to have no tests in Drupal core that rely on UID1's special privileges so that we:

  1. Know these tests are correctly assigning the necessary permissions to run
  2. Can turn off the super user access policy in D11, knowing it won't break core
  3. Can remove the super user access policy in D12, providing an admin account recovery tool to replace it

Steps to reproduce

Go into any of the tests flagged with:

  /**
   * {@inheritdoc}
   *
   * @todo Remove and fix test to not rely on super user.
   * @see https://www.drupal.org/project/drupal/issues/3437620
   */

And:

  1. Remove the code below that sets the usesSuperUserAccessPolicy to TRUE.
  2. Run the test to see which test methods are failing

Proposed resolution

Assign the right permissions to make the test go green without the super user access policy. Those few tests that specifically test said policy can obviously stay, but will be removed along with the policy in D12.

Files that need to be fixed:

  • core/modules/field(_ui)/tests/src/
    • Functional/EntityReference/EntityReferenceXSSTest.php
    • Functional/FieldDefaultValueCallbackTest.php
    • Functional/FieldUIRouteTest.php

Remaining tasks

Commit

MR to commit

MR 8637

📌 Task
Status

Fixed

Version

10.3

Component
Field UI 

Last updated 17 days ago

Created by

🇬🇷Greece vensires

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @vensires
  • 🇮🇳India pradhumanjainOSL

    pradhumanjain2311 made their first commit to this issue’s fork.

  • Pipeline finished with Failed
    7 months ago
    Total: 991s
    #150346
  • First commit to issue fork.
  • Status changed to Needs review 7 months ago
  • 🇲🇩Moldova thebumik

    Applied necessary changes to fix these tests.

  • Pipeline finished with Failed
    7 months ago
    Total: 1078s
    #153069
  • Status changed to Needs work 7 months ago
  • 🇺🇸United States smustgrave

    Left some comments but appears to have test failures.

  • First commit to issue fork.
  • Merge request !8637Resolve #3439835 "Fix field ui tests" → (Closed) created by pooja_sharma
  • Pipeline finished with Canceled
    5 months ago
    Total: 846s
    #214184
  • Pipeline finished with Failed
    5 months ago
    Total: 164s
    #214195
  • Pipeline finished with Success
    5 months ago
    #214199
  • Pipeline finished with Success
    5 months ago
    #214210
  • Pipeline finished with Success
    5 months ago
    #214220
  • Addressed the superuser code needs to remove & added respective permissions.

    Please review MR 8637, move NR

  • Status changed to Needs review 5 months ago
  • Status changed to Needs work 5 months ago
  • 🇺🇸United States smustgrave

    Left a comment on MR.

  • Status changed to Needs review 5 months ago
  • Left a comment for suggestion, Please review, move NR

  • Status changed to Needs work 5 months ago
  • 🇺🇸United States smustgrave

    See response

  • Pipeline finished with Success
    5 months ago
    Total: 672s
    #219897
  • I quickly tried to replicate title missing issue on local & able to recall it, I have fixed that title missing issue by adding 'access content' permission, however forgot to remove $this->drupalPlaceBlock('page_title_block'); from MR.

    So Removed the unrelated change , Please review , moving NR.

  • Status changed to Needs review 5 months ago
  • Status changed to RTBC 5 months ago
  • 🇺🇸United States smustgrave

    Looks much better thanks.

  • Status changed to Needs work 4 months ago
  • 🇳🇿New Zealand quietone

    The FieldUIRouteTest is not accessing content so why does the user need 'access content' permission? And EntityReferenceXSSTest is not editing content so it shouldn't need 'edit own article content'. Setting to needs work for checking the permissions.

  • Pipeline finished with Canceled
    4 months ago
    Total: 138s
    #220719
  • Pipeline finished with Success
    4 months ago
    Total: 464s
    #220724
  • Addressed the mentioned changes & updated the MR

    Please review , moving NR

  • Status changed to Needs review 4 months ago
  • Pipeline finished with Success
    4 months ago
    #220745
  • Addressed the mentioned changes & updated the MR

    Please review , moving NR

  • Status changed to Needs work 4 months ago
  • 🇩🇪Germany FeyP

    Thanks for working on this issue. I think there are even more permissions that can be removed. Left some comments inline.

  • 🇩🇪Germany FeyP

    After conferring with @smustgrave, I filed #3460654 for a small performance optimization as a follow-up issue. For now postponed on this one so that we can get this done first.

  • Pipeline finished with Success
    4 months ago
    Total: 542s
    #221505
  • Pipeline finished with Success
    4 months ago
    Total: 466s
    #221521
  • Thanks for reviewing it, Applied the mentioned suggestions

    Please review , moving NR

  • Status changed to Needs review 4 months ago
  • Status changed to Needs work 4 months ago
  • 🇩🇪Germany FeyP

    Thanks @pooja_sharma. As far as I can see, the login in FieldUIRouteTest is still done in the setup method. Can we please move this to testFieldUIRoutes(), because I don't think it is needed for the other test in that file? Or is there a specific reason why you think it shouldn't be done?

  • @FeyP There is follow-up already created for it, may be we can keep here only minimal changes & cover these changes other follow up. Any thoughts/concerns over it?

  • 🇩🇪Germany FeyP

    There is follow-up already created for it

    No, the follow-up is to merge the to test methods, which is definitely out of scope for this issue.

    But my understanding is, also from looking at the reviews by others in this issue and other similar issues, who are a part of the same meta, that the intention is to use minimal required permissions only. And the other test in FieldUIRouteTest doesn't need any permissions at all to pass. This is also underlined by an earlier review comment from @smustgrave "The move to setup() is probably fine since this is the only test in this file." In this case we have two tests, so it is different. So I think we should move the login method into the test where it is needed as part of this issue so that the other test runs without any elevated permissions. But if you want, I can ask for a second opinion. Or wait for others to RTBC this.

  • Pipeline finished with Success
    4 months ago
    Total: 534s
    #221881
  • Pipeline finished with Success
    4 months ago
    Total: 448s
    #221893
  • Status changed to Needs review 4 months ago
  • I have applied the suggestion, there was bit confusion earlier thought of that specific 'll handle in other followup thanks for clarity got your concerns as well.

    Please review, moving NR.

  • Status changed to RTBC 4 months ago
  • 🇩🇪Germany FeyP

    Thanks @pooja_sharma, the final state is exactly what I asked for.

    Alright, I verified yesterday that the permissions now in use are the minimum required permissions. I also verified that previous review comments had been addressed. Then I looked specifically at the places where we assert that something is not on the page to make sure that this doesn't pass now just because we are missing some permissions now. Luckily those very only few places, because we mostly only assert what's there. So the code review looks good now.

    There are no super user flags left to be removed within tests in the scope of this issue. The tests pass with the changes. Rest of the pipeline also looks good.

    The issue is scoped appropriately. I'm gonna move the files from the remaining tasks section to the proposed resolution and then add the MR to commit, because we have multiple. Then the IS is fine. The issue title could be improved, but is okay as a git commit message and it makes sense to keep this similar to the other issues already committed as part of this meta. Follow up for performance optimization is filed.

    Thanks again @pooja_sharma for staying on top of this and for understanding my concerns.

    I think the issue is RTBC! „🎉

  • 🇩🇪Germany FeyP

    FeyP changed the visibility of the branch 3439835-fix-field-ui to hidden.

  • 🇫🇷France nod_ Lille
    • nod_ committed 911c2009 on 10.3.x
      Issue #3439835 by pooja_sharma, thebumik, FeyP, smustgrave, vensires:...
    • nod_ committed 554f305c on 10.4.x
      Issue #3439835 by pooja_sharma, thebumik, FeyP, smustgrave, vensires:...
  • 🇫🇷France nod_ Lille

    Committed and pushed 139bf72968 to 11.x and 35ee84ae5f to 11.0.x and 554f305ce5 to 10.4.x and 911c200988 to 10.3.x. Thanks!

    • nod_ committed 35ee84ae on 11.0.x
      Issue #3439835 by pooja_sharma, thebumik, FeyP, smustgrave, vensires:...
  • Status changed to Fixed 4 months ago
    • nod_ committed 139bf729 on 11.x
      Issue #3439835 by pooja_sharma, thebumik, FeyP, smustgrave, vensires:...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024