-
Notifications
You must be signed in to change notification settings - Fork 390
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
add read_lease #218
add read_lease #218
Conversation
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 @jvanbrunschot-coolblue, thanks for the contribution!
Could you also see about adding an integration/unit test cases for this new method? If you have any questions about how to construct that kind of addition (or if you would like me to push up some example test cases to your branch), please just let me know. Once this fella has some tests we can get it merged in. 👍
hvac/v1/__init__.py
Outdated
@@ -271,6 +271,15 @@ def ha_status(self): | |||
""" | |||
return self._get('/v1/sys/leader').json() | |||
|
|||
def read_lease(self, lease_id): | |||
""" | |||
PUT /sys/leases/lookup |
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.
Could you please expand these docstrings a bit to capture the relevant information from the linked Vault documentation? E.g.: https://github.com/ianunruh/hvac/blob/master/hvac/v1/__init__.py#L670-L680
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.
Added the additional docstrings..
about the integration tests: Looks like the lease_id
is only available with dynamic secrets, from something like the database
secrets engine.
Enabling the database
secrets engine and using it in the integration tests means that we need to spin up a mysql/postgres database to retreive a dynamic secret.
2f48886
to
0230e31
Compare
0230e31
to
e0dd647
Compare
That's a fair point. If you don't mind sitting on this PR a few days, I'll try to come up with some potential solutions to more easily add test coverage for this sort of thing. |
Sure, I'm fine with that. If you need any help, please let me know. |
Ended up finding this pro tip from the lead Vault developer re: easiest way to generate a lease ID without a bunch of extra setup being required: hashicorp/vault#877 (comment) With that, I've added in an integration test case as well as a basic sort of unit test and opened a PR against your branch with those additions: jvanbrunschot-coolblue#1. If you're down to merge in those test additions to the source branch on this PR, I can get everything merged and released. 👍 |
Adding Tests for read_lease() Addition
Thanks again @jvanbrunschot-coolblue! I am aiming to get this released in v0.6.2 in the next day or two. |
This PR will add the 'read_lease' function so you can check how long it takes before you lease expires:
https://www.vaultproject.io/api/system/leases.html#read-lease