Closed jetersen closed 5 years ago
Hmm, yes, I agree that is not really a good behavior. I can think of two changes - we can still error when a list() call is being made, or modify the list() method to return a structure (ListResults or something similar) with the API status and the results list. I actually like the second idea better, but its a pretty big api change. Let me know which approach you prefer and I’ll create a new PR with the changes.
-Barry
On Aug 25, 2019, at 7:56 AM, Joseph Petersen notifications@github.com wrote:
@casz commented on this pull request.
In src/test-integration/java/com/bettercloud/vault/api/LogicalTests.java https://github.com/BetterCloud/vault-java-driver/pull/187#discussion_r317401873:
final Vault vault = container.getVault(NONROOT_TOKEN);
- vault.logical().list("secret/null");
- List
list = vault.logical().list("secret/null"); - assertEquals(list.size(), 0); @bklawans https://github.com/bklawans not sure this is desirable, see #176 (comment) https://github.com/BetterCloud/vault-java-driver/pull/176#issuecomment-524583812 In src/test-integration/java/com/bettercloud/vault/util/DbContainer.java https://github.com/BetterCloud/vault-java-driver/pull/187#discussion_r317402015:
public DbContainer() {
- container = new GenericContainer("postgres:11.3-alpine")
- super("postgres:11.3-alpine");
- this.withNetwork(CONTAINER_NETWORK)
.withNetworkAliases(hostname) This should fix up the database networking problem the two merges created. @denglertai https://github.com/denglertai @steve-perkins https://github.com/steve-perkins In src/test-integration/java/com/bettercloud/vault/util/VaultContainer.java https://github.com/BetterCloud/vault-java-driver/pull/187#discussion_r317402078:
runCommand("vault", "login", "-ca-cert=" + CONTAINER_CERT_PEMFILE, rootToken);
- runCommand("sh", "-c", "cat <
> " + CONTAINER_CLIENT_CERT_PEMFILE + "\n" + cert + "\nEOL"); Running on CI against Travis or Github it seems the vault container's uid/gid is the only one with permissions to this file. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BetterCloud/vault-java-driver/pull/187?email_source=notifications&email_token=AANPQFCFKUDXQCIRTAVLFTLQGKMSLA5CNFSM4IPJHEKKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCCTGHOQ#pullrequestreview-279339962, or mute the thread https://github.com/notifications/unsubscribe-auth/AANPQFDK4INICBGBFWXEUQTQGKMSLANCNFSM4IPJHEKA.
Do you have a preference between enhancing LogicalResponse to have a new method (getListData()) vs creating a new response class that holds the list?
-Barry
On Aug 25, 2019, at 7:56 AM, Joseph Petersen notifications@github.com wrote:
@casz commented on this pull request.
In src/test-integration/java/com/bettercloud/vault/api/LogicalTests.java https://github.com/BetterCloud/vault-java-driver/pull/187#discussion_r317401873:
final Vault vault = container.getVault(NONROOT_TOKEN);
- vault.logical().list("secret/null");
- List
list = vault.logical().list("secret/null"); - assertEquals(list.size(), 0); @bklawans https://github.com/bklawans not sure this is desirable, see #176 (comment) https://github.com/BetterCloud/vault-java-driver/pull/176#issuecomment-524583812 In src/test-integration/java/com/bettercloud/vault/util/DbContainer.java https://github.com/BetterCloud/vault-java-driver/pull/187#discussion_r317402015:
public DbContainer() {
- container = new GenericContainer("postgres:11.3-alpine")
- super("postgres:11.3-alpine");
- this.withNetwork(CONTAINER_NETWORK)
.withNetworkAliases(hostname) This should fix up the database networking problem the two merges created. @denglertai https://github.com/denglertai @steve-perkins https://github.com/steve-perkins In src/test-integration/java/com/bettercloud/vault/util/VaultContainer.java https://github.com/BetterCloud/vault-java-driver/pull/187#discussion_r317402078:
runCommand("vault", "login", "-ca-cert=" + CONTAINER_CERT_PEMFILE, rootToken);
- runCommand("sh", "-c", "cat <
> " + CONTAINER_CLIENT_CERT_PEMFILE + "\n" + cert + "\nEOL"); Running on CI against Travis or Github it seems the vault container's uid/gid is the only one with permissions to this file. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BetterCloud/vault-java-driver/pull/187?email_source=notifications&email_token=AANPQFCFKUDXQCIRTAVLFTLQGKMSLA5CNFSM4IPJHEKKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCCTGHOQ#pullrequestreview-279339962, or mute the thread https://github.com/notifications/unsubscribe-auth/AANPQFDK4INICBGBFWXEUQTQGKMSLANCNFSM4IPJHEKA.
If I’m reading the code right, this turned out to be pretty easy. I moved the code that builds the list into LogicalResponse, and it only triggers when the operation is ListV1 or ListV2. I’ve updated all the unit tests and they still pass, and changed the assert in testListExceptionMessageIncludesErrorsReturnedByVault to check for a 404.
-Barry
On Aug 25, 2019, at 1:56 PM, Joseph Petersen notifications@github.com wrote:
@casz commented on this pull request.
In src/test-integration/java/com/bettercloud/vault/api/LogicalTests.java https://github.com/BetterCloud/vault-java-driver/pull/187#discussion_r317414446:
final Vault vault = container.getVault(NONROOT_TOKEN);
- vault.logical().list("secret/null");
- List
list = vault.logical().list("secret/null"); - assertEquals(list.size(), 0); getListData seems responsible to me as you already have getData but that is not the same as read so perhaps we need a new response class.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BetterCloud/vault-java-driver/pull/187?email_source=notifications&email_token=AANPQFHGDOXHECZSGMUXJLDQGLWYBA5CNFSM4IPJHEKKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCCTJLPI#discussion_r317414446, or mute the thread https://github.com/notifications/unsubscribe-auth/AANPQFBPPFWSNS3FZXKGWXTQGLWYBANCNFSM4IPJHEKA.
Feel free to send a PR to my branch @bklawans 😓 That way it gets tested on CI at least 😆
@casz Do you mean casz:chore/overallCodeHealth instead of BetterCloud/master?
Yup casz:chore/overallCodeHealth
otherwise I would have to do the whole merge dance and I already did plenty to cleanup commit history. 😆
Will do. I'm walking out the door now, but will turn that around this evening (Pacific time zone...)
In no hurry :)
New PR issued to merge my changes to your branch, and I revoked the PR to the main BetterCloud repo.
Cheers @bklawans :)
I wonder though @steve-perkins if you would prefer if we keep the old method with @deprecated
I thought about that, but since the only difference is the return type we can't have both the old and the new method, since Java doesn't consider the return type to be part of the method signature. We will have to rename the new method if we want to keep the old.
Right the will bump to v5 and see compile issues 😊 I can live with that
Fixing the merge conflict 😅
If you want me to squash/rebase/rewrite history before merging please say so :)
Ehh... the intermingling of getListData(...)
from @bklawans work, and the other general code cleanup, is a little confusing to sort through. But a squash won't help that. I think this is good.
@steve-perkins would you mind enabling Travis so we can have CI on pull requests 😄
Post-merge, the integration test LogicalTests.testListPermissionDeniedReturnedByVault()
is failing, because it's expecting a 404
response code from Vault instead of a 403.
In context, I assume this has to be a typo. I'll change the expected response to 403.
https://github.com/BetterCloud/vault-java-driver/pull/187/commits/3231da3f3739cbbb3cfabecd3a04eeecca4bcfe3 definitely a typo honestly missed that in the merge.
Looking into that now. Virtually all of my recent-enough-to-be-relevant CI experience is with Jenkins, so Travis is a bit unfamiliar.
You just need to enable it. I already added a .travis.yml file for you in this PR. https://github.com/marketplace/travis-ci FYI free for open source.
Incredibly frustrating. I believe that Travis is choking on the fact that this repository is owned by an organization. I've gone through all of the commonly-recommended troubleshooting steps (e.g. making sure that my membership in the organization is set to publicly visible). But the repo is still not available for Travis to use.
I'm going to call it a day, and start cutting a release for Maven Central. I may ping Travis support tomorrow. I've also signed up for the beta of GitHub's native CI system. That sign-up request is still pending, but anyone is welcome to write a ci.yaml
for that if they like.
Version 5.0.0 has been published, and should appear on Maven Central within the next few hours.
@steve-perkins the PR already added a GitHub CI file: https://github.com/BetterCloud/vault-java-driver/blob/master/.github/workflows/gradle.yml
As for you issue enabling Travis, it could be that the project is actually still on travis-ci.org
the open-source one and has yet to be migrated to travis-ci.com
So if you head here: https://travis-ci.org/BetterCloud/vault-java-driver you should be able to get it the needed permissions/
Here is the Travis announcement for travis-ci.org moving to travis-ci.com 😓 https://docs.travis-ci.com/user/migrate/open-source-on-travis-ci-com/
Had to rewrite most of
SSLUtils
only to figure out much later it was because Travis/Github CI had issues with whether the container or java had created thessl
folder used for passing files around.For code style, I still have some issues. The com.bettercloud.vault.json package is mostly written in 2 spacing while the rest is written in 4 spacing.
Personally, I would switch to 4 spacing and 4 continuation spacing instead of 8 for continuation spacing.