Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPAL-1126 Remove check which fails if lastLogin > 5 years ago #1292

Merged
merged 1 commit into from Jan 4, 2023

Conversation

townxelliot
Copy link
Contributor

@townxelliot townxelliot commented Jan 4, 2023

Unit tests were failing because of a condition which sets the last login for the user to 'now' if the supplied last login datetime is more than 5 years ago. This was tripped when we passed 2023-01-04, as some of the tests set the last login date to 2018-01-02.

Remove this condition and instead set a default lastLogin if one is not available for a user during an authentication attempt. Also allow the lastLogin to be null when constructing a User, and default to 'now' if this is the case. As we only construct users in LpaAuthAdapter, we shouldn't hit this case, but it is covered anyway.

In LpaAuthAdapter, default the last login to null if the user doesn't have one. Then, when constructing the last login datetime, a null value will mean we default to 'now'.

Purpose

Fixes LPAL-1126

Approach

Explain how your code addresses the purpose of the change

Learning

Any tips and tricks, blog posts or tools which helped you. Plus anything notable you've discovered about the LPA service

Checklist

  • I have performed a self-review of my own code
  • I have updated documentation (Confluence/GitHub wiki/tech debt doc) where relevant
  • I have added tests to prove my work
  • I have added mandatory tags to terraformed resources, where possible
  • If I have a new OPG component dependency, I have updated the metadata.json with the repo location.
  • If I added a package.json or composer.json, I also made sure this is included in the script in .github/workflows/dependabot-update.yml
  • The product team have tested these changes

Unit tests were failing because of a condition which sets the
last login for the user to 'now' if the supplied last login
datetime is more than 5 years ago. This was tripped when we
passed 2023-01-04, as some of the tests set the last login
date to 2018-01-02.

Remove this condition and instead set a default lastLogin if one
is not available for a user during an authentication attempt.
Also allow the lastLogin to be null when constructing a User,
and default to 'now' if this is the case. As we only construct
users in LpaAuthAdapter, we shouldn't hit this case, but it is
covered anyway.

In LpaAuthAdapter, default the last login to null if the user
doesn't have one. Then, when constructing the last login datetime,
a null value will mean we default to 'now'.
@townxelliot townxelliot requested a review from a team as a code owner January 4, 2023 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants