-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update legacy manifest file test #605
base: main
Are you sure you want to change the base?
Conversation
…ig to cover the Read() -> ReadExactly() bug (that only appears with >3kb files).
📝 WalkthroughWalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
tests/Altinn.Broker.Tests/LegacyFileControllerTests.cs (2)
562-581
: Optimize memory usage in zip file upload.The implementation correctly creates an in-memory zip file, but there's a redundant memory allocation at line 574 where
zipStream.ToArray()
is called twice.Consider this optimization:
- using (var content = new ByteArrayContent(zipStream.ToArray())) + var zipBytes = zipStream.ToArray(); + using (var content = new ByteArrayContent(zipBytes))
583-587
: Enhance GenerateDummyFile with input validation and better randomization.While the implementation works, it could be improved in terms of robustness and security.
Consider these improvements:
private async Task<byte[]> GenerateDummyFile(long bytes) { + if (bytes <= 0) + throw new ArgumentException("Bytes must be positive", nameof(bytes)); var fileBuffer = new byte[bytes]; - new Random().NextBytes(fileBuffer); + Random.Shared.NextBytes(fileBuffer); return fileBuffer; }This change:
- Adds input validation
- Uses
Random.Shared
which is both thread-safe and more efficient than creating new Random instances
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
tests/Altinn.Broker.Tests/LegacyFileControllerTests.cs
(2 hunks)
🔇 Additional comments (1)
tests/Altinn.Broker.Tests/LegacyFileControllerTests.cs (1)
562-587
: Implementation successfully meets PR objectives.
The changes effectively address the PR requirements by:
- Generating a zip file in-memory
- Ensuring the file size is at least 10kb (10240 bytes)
- Supporting testing of the Read() -> ReadExactly() functionality with files larger than 3kb
The implementation is clean and well-structured.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
Description
Change test to generate a .zip file in-memory that is at least 10kb big to cover the Read() -> ReadExactly() bug (that only appears with >3kb files).
Related Issue(s)
Verification
Documentation
Summary by CodeRabbit
New Features
Bug Fixes