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

Make tests compatible with Vault 0.10 #497

Merged
merged 3 commits into from
Sep 19, 2018

Conversation

pschultz
Copy link
Member

When starting a new, empty Vault server, the mount at /secret will be
the K/V Version 2 backend by default. The API paths are subtly
different, but the new paths happen to also work with the Version 1
backend, so we can just always use the new paths in the test.

See https://www.vaultproject.io/docs/secrets/kv/kv-v2.html#acl-rules

@pschultz
Copy link
Member Author

With this patch all tests passed for me with Consul 1.0.6, 1.0.7, and 1.1.0, so this may fix #494 entirely.

@magiconair
Copy link
Contributor

hmm, why doesn't codeship pick this one up?

@magiconair
Copy link
Contributor

When I change the versions in Makefile

diff --git a/Makefile b/Makefile
index 6d2ff11..3a9ca94 100644
--- a/Makefile
+++ b/Makefile
@@ -27,8 +27,8 @@ GOVENDOR = $(shell which govendor)
 VENDORFMT = $(shell which vendorfmt)

 # pin versions for CI builds
-CI_CONSUL_VERSION=1.0.6
-CI_VAULT_VERSION=0.9.6
+CI_CONSUL_VERSION=1.1.0
+CI_VAULT_VERSION=0.10.1
 CI_GO_VERSION=1.10.2

 # all is the default target

and run make docker-test I still get this:

--- FAIL: TestConsulSource (12.17s)
	source_test.go:240: Starting consul: Consul v1.1.0
	source_test.go:261: Timeout waiting for consul server after 12.0 seconds
=== RUN   TestVaultSource
--- FAIL: TestVaultSource (0.31s)
	source_test.go:305: Starting vault: "Vault v0.10.1 ('756fdc4587350daf1c65b93647b2cc31a6f119cd')\n"
	source_test.go:429: logical.Write failed: Error making API request.

		URL: PUT http://127.0.0.1:58421/v1/secret/data/fabio/cert/localhost
		Code: 400. Errors:

		* no data provided

pschultz added 2 commits May 17, 2018 17:34
Detect if a KV backend uses the new v2 versioning features and rewrite
request paths and bodies if necessary.

The new API uses additional /data/ and /metadata/ for GET/PUT and LIST
operations, respectively. To facilitate versioning, v2 wraps the actual
payload in a JSON object with "data" and "metadata" keys:

    {
      "data": {<payload (same as v1)>},
      "metadata": { <versioning info> }
    }
Consul added suppported for compressed HTTP responses in 1.0.7, which
means we can no longer rely on the Content-Length response header when
checking if the server is ready yet.
@pschultz pschultz force-pushed the vault-0.10-tests branch from d1ac0be to ac2a9a2 Compare May 17, 2018 15:41
@pschultz
Copy link
Member Author

Turns out the API isn't directly backward compatible after all. I amended my commit, so that Fabio detects a v2 backend and modifies Vault requests accordingly. It's not exactly pretty but it works. The new methods are almost verbatim copies from Vault's cli implementation.

This makes Fabio support the v2 backend automatically; no config change is required. The Vault policy must be updated, but that's not unique to Fabio. I seem to remember that a working sample policy is documented somewhere (in the wiki perhaps?) but I can't find it right now.

The Consul tests failed because your sneaky readiness check stopped working when they introduced gzip support, and I addressed that too.

@magiconair magiconair merged commit 123054d into fabiolb:master Sep 19, 2018
@magiconair magiconair added this to the 1.5.10 milestone Sep 19, 2018
@pschultz pschultz mentioned this pull request Jan 17, 2019
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