Skip to content

AB#119563 Enhance User Access Tokens CSV job to include tokens with extended expiration and add tests for lifetime rules#49

Merged
sebastianchristopher merged 3 commits into
mainfrom
AB#119563
May 20, 2026
Merged

AB#119563 Enhance User Access Tokens CSV job to include tokens with extended expiration and add tests for lifetime rules#49
sebastianchristopher merged 3 commits into
mainfrom
AB#119563

Conversation

@sebastianchristopher
Copy link
Copy Markdown
Contributor

Check whether diff between created and expired is > 1 year

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 18, 2026

Deploying account-reports with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4d2e9de
Status: ✅  Deploy successful!
Preview URL: https://b8b2f945.account-reports.pages.dev
Branch Preview URL: https://ab-119563.account-reports.pages.dev

View logs

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js with 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");
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the unused oneYearAgo variable in commit 4d2e9de.

Comment thread src/jobs/UserAccessTokensCSVJob.js
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>
@sebastianchristopher sebastianchristopher merged commit 0ea7718 into main May 20, 2026
1 check passed
@sebastianchristopher sebastianchristopher deleted the AB#119563 branch May 20, 2026 07:34
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.

4 participants