tests: oauth2: Windows support#11506
Conversation
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
📝 WalkthroughWalkthroughModified the OAuth2 test suite to replace hard-coded temporary file paths with dynamically allocated temporary directories using Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/internal/oauth2.c (1)
540-548:⚠️ Potential issue | 🟡 MinorTighten failure cleanup to remove partially created files.
If a write fails after file creation, temp artifacts can remain. Please unlink both targets on their respective failure paths.
🧹 Suggested patch
ret = write_text_file(key_path, TEST_PRIVATE_KEY_PEM); if (ret != 0) { + unlink(key_path); return -1; } ret = write_text_file(cert_path, TEST_CERT_PEM); if (ret != 0) { unlink(key_path); + unlink(cert_path); return -1; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/internal/oauth2.c` around lines 540 - 548, When write_text_file fails you must remove any partially created temp files: after the first write_text_file(key_path, ...) failure call unlink(key_path) before returning, and after the second write_text_file(cert_path, ...) failure call unlink(cert_path) as well as unlink(key_path) before returning; update the error paths in the block handling write_text_file, referencing write_text_file, key_path, cert_path and using unlink() (ignore unlink errors) so neither artifact remains on failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@tests/internal/oauth2.c`:
- Around line 540-548: When write_text_file fails you must remove any partially
created temp files: after the first write_text_file(key_path, ...) failure call
unlink(key_path) before returning, and after the second
write_text_file(cert_path, ...) failure call unlink(cert_path) as well as
unlink(key_path) before returning; update the error paths in the block handling
write_text_file, referencing write_text_file, key_path, cert_path and using
unlink() (ignore unlink errors) so neither artifact remains on failure.
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
Support of Windows in tests for OAuth 2.0 (fix of issue introduced in #11485).
Testing
TEST_PRESET=valgrind SKIP_TESTS='flb-rt-out_td flb-it-network' ./run_code_analysis.shok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit