Move TfaLoginContextTrait back to a dedicated Class and add factory.

Created on 5 October 2023, over 2 years ago
Updated 11 October 2023, over 2 years ago

Problem/Motivation

After SA-CONTRIB-2023-030 the locations where we need to access access the context data have increased.

Unit testing becomes excessively complex due to need to mock multiple An example is πŸ“Œ Decorate the user.auth service Fixed where over 70% of the LoginContextTrait ends up 'tested' in order to test the execution flow see https://git.drupalcode.org/project/tfa/-/blob/ba3a844d7cf4f61ac2690a7b0d... where we end up mocking TFA Settings, User Storage, Validation Plugins, Login Plugins, etc.

Addtionaly the current class requires several properties to be configured in the parent class, there is no clear separation in the trait.

By moving this back out to a dedicated class we can significantly simplify unit testing in additional locations and help both existing and future code contributions.

Steps to reproduce

N/A

Proposed resolution

Move TfaLoginContextTrait back to a dedicated class. Do not provide an interface as this will be an internal class. Do not make the class final so that it may be mocked in tests.
Add a factory that will configure the class. Do not add an interface as the factory will be considered an internal class.

Remaining tasks

Patch

User interface changes

None

API changes

New additions will be @internal and existing removal is already @internal.
Removal of properties for no longer needed services from TfaLoginForm.

Data model changes

None

πŸ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States cmlara

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

Comments & Activities

Production build 0.71.5 2024