Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
field system
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Sep 2021 at 09:32 UTC
Updated:
11 Oct 2021 at 12:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
alexpottHere's the fix that is in [ #3220021] - I think maybe we can refactor a little bit more for clarity.
Comment #3
longwaveThis makes the logic easier to follow anyway, so +1 from me.
Comment #4
alexpottI'm working on an explicit test because we don't have any test coverage. I agree that the logic is slightly better but I want a unit test to ensure we've not changed behaviour in a way that affects security.
Comment #5
alexpottHere's a test that covers most of \Drupal\Core\Field\Plugin\Field\FieldType\PasswordItem::preSave() - found a bug when saving a password that trims to an empty string. This doesn't really affect the UI because the UI trims the password input but it does affect JSON:API - so will file a follow-up issue to address this.
The test only patch should pass to show that the behaviour has not changed.
In order to test the field type we need to fix the fact that the config schema is missing for the field type.
Comment #6
alexpottFixing the @todo to link to #3238399: \Drupal\Core\Field\Plugin\Field\FieldType\PasswordItem can save an unhashed value in error
Comment #7
alexpottAdding the test group :( - as before the test only patch exists to prove behaviour has not changed and is expected to pass.
Comment #9
alexpottOops didn't mean to leave the changes to core/modules/user/tests/src/Functional/Rest/UserResourceTestBase.php in. That was part of investigating #3238399: \Drupal\Core\Field\Plugin\Field\FieldType\PasswordItem can save an unhashed value in error and determining that it is an issue for jsonapi. Removing those changes here...
As before the test only patch exists to prove behaviour has not changed and is expected to pass.
Comment #10
andyposttest-only passes
Comment #11
alexpott@andypost test-only is supposed to pass. See earlier comments. The test is being added to prove that behaviour is not changed. The fact we have to add schema here proves we are lacking test coverage of using PasswordItem as a configurable field. All of the current test coverage of this code is on the User entity level and not the field type level.
Comment #12
andypostSorry, missed second part of comment
Comment #13
catchThis isn't a datetime range field.
Comment #14
alexpottIndeed it is not. That comment and others in this test are not really necessary. They're not adding to the code. Setting back to rtbc as this is only removing comments.
Comment #16
catchCommitted b6e74cf and pushed to 9.3.x. Thanks!