Skip to content

Conversation

jajeffries
Copy link
Contributor

@jajeffries jajeffries commented Sep 2, 2025

Fixes #174

This pull request improves the handling and testing of YAML serialization and validation for the AuthAppRole struct in the Vault authentication code. The main focus is on ensuring that optional fields are correctly omitted from YAML output when empty and that required fields are validated during unmarshaling. Comprehensive unit tests have been added to verify these behaviors.

Improvements to YAML serialization and validation

  • Fixed the struct tags for WrappingToken and MountPath in AuthAppRole to use the correct omitempty option, ensuring empty values are omitted during YAML marshaling.

Enhancements to unit testing

  • Added new tests in vault_auth_test.go to verify that YAML marshaling omits empty fields and that unmarshaling correctly reconstructs the struct, including edge cases for optional and required fields.
  • Added tests to validate that missing required fields (role_id, secret_id) in the YAML input result in appropriate errors during unmarshaling.

Test infrastructure updates

  • Imported the yaml.v3 package to support YAML marshaling and unmarshaling in tests.
  • Added a helper function stringPtr to simplify pointer creation for test cases.

Copy link

github-actions bot commented Sep 2, 2025

Go test coverage

STATUS ELAPSED PACKAGE COVER PASS FAIL SKIP
🟢 PASS 0.14s github.com/netboxlabs/orb-agent/agent 0.0% 0 0 0
🟢 PASS 0.14s github.com/netboxlabs/orb-agent/agent/backend 0.0% 0 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/devicediscovery 76.0% 3 0 0
🟢 PASS 0.01s github.com/netboxlabs/orb-agent/agent/backend/mocks 0.0% 0 0 0
🟢 PASS 8.04s github.com/netboxlabs/orb-agent/agent/backend/networkdiscovery 76.2% 7 0 0
🟢 PASS 4.02s github.com/netboxlabs/orb-agent/agent/backend/otel 76.4% 2 0 0
🟢 PASS 3.02s github.com/netboxlabs/orb-agent/agent/backend/pktvisor 65.6% 2 0 0
🟢 PASS 8.04s github.com/netboxlabs/orb-agent/agent/backend/snmpdiscovery 75.8% 7 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/worker 76.0% 3 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/config 100.0% 6 0 0
🟢 PASS 1.06s github.com/netboxlabs/orb-agent/agent/configmgr 49.2% 9 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/policies 100.0% 15 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/policymgr 70.3% 10 0 0
🟢 PASS 26.28s github.com/netboxlabs/orb-agent/agent/secretsmgr 48.9% 54 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/version 100.0% 1 0 0

Total coverage: 58.7%

@jajeffries jajeffries merged commit f86bc3f into develop Sep 2, 2025
5 checks passed
@jajeffries jajeffries deleted the fix/OBS-1393-fix-vault-config branch September 2, 2025 08:34
Copy link

github-actions bot commented Sep 2, 2025

🎉 This PR is included in version 2.4.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic with auth: approle

2 participants