AB#119563 Enhance User Access Tokens CSV job to include tokens with extended expiration and add tests for lifetime rules#49
Merged
Conversation
…piration and add tests for lifetime rules
Deploying account-reports with
|
| Latest commit: |
4d2e9de
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b8b2f945.account-reports.pages.dev |
| Branch Preview URL: | https://ab-119563.account-reports.pages.dev |
There was a problem hiding this comment.
Pull request overview
Refines the inclusion criteria used by the User Access Tokens CSV job so that it surfaces only user-generated tokens that either never expire or have a lifetime (expiration − creation) of more than one year. Also adds the first unit tests for this job covering the new rules.
Changes:
- Replace the previous "created within last year" / "expires over a year from now" checks with a single rule comparing
expiration − creation > 1 year, while preserving the "Never expires" case. - Add
UserAccessTokensCSVJob.test.jswith three cases: never-expiring token included, long-lived token included, short-lived token excluded.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/jobs/UserAccessTokensCSVJob.js | Reworks the token-inclusion logic to be based on token lifetime rather than absolute dates relative to "now". |
| src/jobs/UserAccessTokensCSVJob.test.js | New vitest suite mocking ReportApi and parseCsv/toCsv to verify the updated inclusion rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+74
to
+82
| if (token.expiration === "never") { | ||
| reasons.push("Never expires"); | ||
| } else if (createdAt && expiresAt) { | ||
| const lifetimeMs = expiresAt.getTime() - createdAt.getTime(); | ||
| const oneYearMs = 365 * 24 * 60 * 60 * 1000; | ||
| if (lifetimeMs > oneYearMs) { | ||
| reasons.push("Expires more than a year after creation"); | ||
| } | ||
| } |
Contributor
Author
There was a problem hiding this comment.
@copilot apply changes based on this feedback
Contributor
There was a problem hiding this comment.
Removed the unused oneYearAgo variable in commit 4d2e9de.
Agent-Logs-Url: https://github.com/oxctl/account-reports/sessions/d856fdff-c390-4bf9-9cec-239edbea82bc Co-authored-by: sebastianchristopher <40264653+sebastianchristopher@users.noreply.github.com>
buckett
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Check whether diff between created and expired is > 1 year