Skip to content

test(agent): add test coverage for loadSecret - #913

Open
Fathia-tech14 wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
Fathia-tech14:test/817-load-secret-coverage
Open

test(agent): add test coverage for loadSecret#913
Fathia-tech14 wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
Fathia-tech14:test/817-load-secret-coverage

Conversation

@Fathia-tech14

Copy link
Copy Markdown

Resolves #817

Summary of Changes

  • Exported loadSecret from agent/agent.js.
  • Added a comprehensive unit test suite in agent/loadSecret.test.js (30 tests) testing:
    • Environment Variable Secret (AGENT_STELLAR_SECRET): Valid string return and character preservation.
    • Configuration Validation & Conflicts: Proper errors when neither or both variables are set.
    • File Secret (AGENT_STELLAR_SECRET_FILE):
      • File reading failures (ENOENT, EACCES).
      • Whitespace, newline, and carriage return trimming.
      • POSIX permission checking and numeric bitmask boundaries (0o040 group read and 0o004 other read boundaries).
      • Safe modes permitted (0o600, 0o400, 0o700, 0o620, etc.).
      • Insecure modes rejected (0o640, 0o604, 0o644, 0o666, 0o777, etc.).
      • Windows platform (win32) permission bypass behavior.
    • Isolation & Mocking: Network and contract calls remain uninvoked, and process.env / process.platform are restored after every test.

Verification

Ran npx vitest run in agent/:

✓ runSummary.test.js (20 tests)
✓ loadSecret.test.js (30 tests)
✓ agent.test.js (30 tests)

Test Files  3 passed (3)
     Tests  80 passed (80)

- Export loadSecret from agent/agent.js
- Add agent/loadSecret.test.js with 30 unit tests covering env secrets, file secrets, file error handling, POSIX permission numeric boundaries (0o040 and 0o004 bitmasks), and Windows platform compatibility
- Resolves Stellar-Ecosystem#817
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Fathia-tech14 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b38e131-3cca-4969-b08f-ae6552313078


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Fathia-tech14

Copy link
Copy Markdown
Author

@Stellar-Ecosystem Hi! This PR is open and ready for review — happy to address any feedback. Thanks!

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.

Agent: add test coverage for loadSecret

1 participant