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

fix: redact S3 URLs in tests #3421

Merged
merged 4 commits into from
Jan 13, 2025
Merged

fix: redact S3 URLs in tests #3421

merged 4 commits into from
Jan 13, 2025

Conversation

jayachandhar
Copy link
Contributor

@jayachandhar jayachandhar commented Jan 13, 2025

Clickup

https://app.clickup.com/t/86cxnebry

Code Coverage

Please add code coverage here

UI Preview

Please add screenshots for UI changes

Summary by CodeRabbit

  • Chores

    • Updated various mock data and test URL references from specific S3 storage locations to generic placeholder URLs
    • Standardized URL formats across multiple service and component test files
    • Replaced hardcoded S3 bucket-specific URLs with more generic URL structures
  • Security

    • Obscured specific storage bucket details in test and mock data files
    • Enhanced URL anonymization across different components and services

Copy link

coderabbitai bot commented Jan 13, 2025

Walkthrough

In a spectacular display of digital transformation, this pull request revolutionizes file-related mock data and test configurations across multiple components. The primary focus is updating S3 storage URLs from specific bucket locations to more generic, placeholder URLs. These changes span mock data files, service tests, and page specifications, ensuring a consistent and anonymized approach to file URL handling.

Changes

File Change Summary
src/app/core/mock-data/file-object.data.ts Updated fileObjectAdv and fileObjectAdv1 constants with new generic S3 URLs
src/app/core/services/file.service.spec.ts Replaced specific S3 URLs with placeholder URLs in test cases
src/app/core/services/report.service.spec.ts Modified downloadSummaryPdfUrl() method with new S3 URL
src/app/fyle/add-edit-advance-request/add-edit-advance-request-2.page.spec.ts Updated receipt thumbnail URL for 'png' extensions
src/app/fyle/my-view-advance-request/my-view-advance-request.page.spec.ts Changed 'png' file thumbnail URL to generic placeholder

Possibly related PRs

Suggested Labels

size/S

Suggested Reviewers

  • Chethan-Fyle
  • arjunaj5

Poem

In the realm of bytes and bits so bright, 🌟
URLs dance with magical might! 💃
From S3 buckets old and worn,
To placeholders freshly born,
Code transforms with stylish flair,
Rajinikanth's tech-magic everywhere! 🚀

Extra Rajinikanth Swagger

Thalaiva style announcement: These URL changes? They're not just updates, they're a MASS TRANSFORMATION! 😎 One line of code can change the entire digital universe, and that's how we roll in the world of software! 💥🔥

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09a3422 and 4bf67e7.

📒 Files selected for processing (5)
  • src/app/core/mock-data/file-object.data.ts (1 hunks)
  • src/app/core/services/file.service.spec.ts (1 hunks)
  • src/app/core/services/report.service.spec.ts (1 hunks)
  • src/app/fyle/add-edit-advance-request/add-edit-advance-request-2.page.spec.ts (1 hunks)
  • src/app/fyle/my-view-advance-request/my-view-advance-request.page.spec.ts (1 hunks)
🔇 Additional comments (3)
src/app/fyle/add-edit-advance-request/add-edit-advance-request-2.page.spec.ts (1)

220-220: Superstar level consistency in URL redaction!

The test case uses the same redacted S3 URL format as the mock data, maintaining consistency across the codebase.

src/app/core/services/file.service.spec.ts (1)

154-154: Style-ah style-ah! Perfect URL redaction in test cases!

The test cases for getReceiptExtension use properly redacted S3 URLs while maintaining test coverage for both JPEG and PDF extensions.

Also applies to: 161-161

src/app/core/services/report.service.spec.ts (1)

435-435: Thalaiva level attention to detail in URL redaction!

The test case for downloadSummaryPdfUrl uses properly redacted S3 URL while maintaining all necessary query parameters for testing PDF download functionality.

Comment on lines +106 to +109
url: 'https://xyz.s3.amazonaws.com/2023-02-23/orexample/receipts/fiSSsy2Bf4Se.000.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230223T151537Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=XXXX%2F20230223%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=d79c2711892e7cb3f072e223b7b416408c252da38e7df0995e3d256cd8509fee',
type: 'image',
thumbnail:
'https://fyle-storage-mumbai-3.s3.amazonaws.com/2023-02-23/orrjqbDbeP9p/receipts/fiSSsy2Bf4Se.000.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230223T151537Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=AKIA54Z3LIXTX6CFH4VG%2F20230223%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=d79c2711892e7cb3f072e223b7b416408c252da38e7df0995e3d256cd8509fee',
'https://xyz.s3.amazonaws.com/2023-02-23/orexample/receipts/fiSSsy2Bf4Se.000.jpeg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230223T151537Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=XXXX%2F20230223%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=d79c2711892e7cb3f072e223b7b416408c252da38e7df0995e3d256cd8509fee',
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Mind-blowing redaction, but let's maintain consistency across all mock data!

The S3 URLs have been properly redacted in fileObjectAdv and fileObjectAdv1, but I notice similar unredacted S3 URLs in other mock objects within this file.

For complete consistency, consider redacting S3 URLs in other mock objects like fileObjectData, fileObjectData1, etc. using the same pattern:

-  s3url: '2023-02-01/orNVthTo2Zyo/receipts/fiHPZUiichAS.000.jpeg',
+  s3url: '2023-02-01/orexample/receipts/fiHPZUiichAS.000.jpeg',

Also applies to: 117-120

@@ -158,7 +158,7 @@ describe('MyViewAdvanceRequestPage', () => {
expect(result).toEqual({
type: 'image',
thumbnail:
'https://fyle-storage-mumbai-3.s3.amazonaws.com/2023-02-23/orrjqbDbeP9p/receipts/fiSSsy2Bf4Se.000.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230223T151537Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=AKIA54Z3LIXTX6CFH4VG%2F20230223%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=d79c2711892e7cb3f072e223b7b416408c252da38e7df0995e3d256cd8509fee',
'https://xyz.s3.amazonaws.com/2023-02-23/orrjqbDbeP9p/receipts/fiSSsy2Bf4Se.000.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230223T151537Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=XXXX%2F20230223%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=d79c2711892e7cb3f072e223b7b416408c252da38e7df0995e3d256cd8509fee',
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Listen up, partner! Let's make this URL more stylish and secure! 😎

The URL still contains sensitive information like AWS credentials and internal paths. Mind-it! Even in test files, we should be extra careful.

Here's a power-packed solution that'll knock your socks off:

-          'https://xyz.s3.amazonaws.com/2023-02-23/orrjqbDbeP9p/receipts/fiSSsy2Bf4Se.000.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230223T151537Z&X-Amz-SignedHeaders=host&X-Amz-Expires=604800&X-Amz-Credential=XXXX%2F20230223%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=d79c2711892e7cb3f072e223b7b416408c252da38e7df0995e3d256cd8509fee',
+          'https://dummy-s3.amazonaws.com/test-file.pdf',

And for extra style points, create a constant for these test URLs:

// Add this at the top with other test constants
export const TEST_FILE_URL = 'https://dummy-s3.amazonaws.com/test-file.pdf';

Because that's how we roll in the testing world! 🌟

@github-actions github-actions bot added the size/XS Extra Small PR label Jan 13, 2025
Copy link

PR description must contain a link to a ClickUp (case-insensitive)

@arjunaj5 arjunaj5 self-assigned this Jan 13, 2025
Copy link

PR description must contain a link to a ClickUp (case-insensitive)

Copy link

Unit Test Coverage % values
Statements 95.96% ( 19295 / 20106 )
Branches 91.11% ( 10660 / 11700 )
Functions 94.24% ( 5735 / 6085 )
Lines 96% ( 18421 / 19188 )

@jayachandhar jayachandhar merged commit 383ca54 into master Jan 13, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Extra Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants