Skip to content
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

Merged
merged 5 commits into from
Jul 16, 2018
Merged

add read_lease #218

merged 5 commits into from
Jul 16, 2018

Conversation

jvanbrunschot-coolblue
Copy link

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

Copy link
Member

@jeffwecan jeffwecan left a 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. 👍

@@ -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
Copy link
Member

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

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.

@jeffwecan
Copy link
Member

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.

@jvanbrunschot-coolblue
Copy link
Author

Sure, I'm fine with that. If you need any help, please let me know.

@jeffwecan jeffwecan self-assigned this Jul 13, 2018
@jeffwecan
Copy link
Member

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
@jeffwecan
Copy link
Member

Thanks again @jvanbrunschot-coolblue! I am aiming to get this released in v0.6.2 in the next day or two.

@jeffwecan jeffwecan merged commit 66bdd18 into hvac:master Jul 16, 2018
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.

2 participants