-
Notifications
You must be signed in to change notification settings - Fork 2k
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
E2E: test enforcement of ACL system #16796
Conversation
This changeset provides a matrix test of ACL enforcement across several dimensions: * anonymous vs bogus vs valid tokens * permitted vs not permitted by policy * request sent to server vs sent to client (and forwarded)
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.
I think the test*Requests
function signatures can remove passing the unused t *testing.T
first argument. Otherwise LGTM!
It also seems the ACL tokens don't get cleaned up, which I don't believe is a problem, so merely noting.
[e2e-auth-test][~/Projects/Go/nomad/e2e]$ go test -v -count 1 -run '^TestAuth$' ./auth
=== RUN TestAuth
=== RUN TestAuth/AnonServerRequests
=== RUN TestAuth/BogusServerRequests
=== RUN TestAuth/InvalidPermissionsServerRequests
=== RUN TestAuth/ValidPermissionsServerRequests
=== RUN TestAuth/AnonClientRequests
=== RUN TestAuth/BogusClientRequests
=== RUN TestAuth/InvalidPermissionsClientRequests
=== RUN TestAuth/ValidPermissionsClientRequests
--- PASS: TestAuth (0.42s)
--- PASS: TestAuth/AnonServerRequests (0.06s)
--- PASS: TestAuth/BogusServerRequests (0.00s)
--- PASS: TestAuth/InvalidPermissionsServerRequests (0.00s)
--- PASS: TestAuth/ValidPermissionsServerRequests (0.00s)
--- PASS: TestAuth/AnonClientRequests (0.05s)
--- PASS: TestAuth/BogusClientRequests (0.04s)
--- PASS: TestAuth/InvalidPermissionsClientRequests (0.04s)
--- PASS: TestAuth/ValidPermissionsClientRequests (0.04s)
PASS
ok github.com/hashicorp/nomad/e2e/auth 0.690s
[e2e-auth-test][~/Projects/Go/nomad/e2e]$ nomad acl token list
Name Type Global Accessor ID Expired
Bootstrap Token management true 5c153f9b-e7e9-5697-2b5b-ed77aa61f4db false
6ddfcf0b-035b-e88c-0771-4eba9c453c5b client false f8c50de1-af0d-4db4-2d96-282c5fbae5f5 false
e8d8c4cb-6db9-4eb8-7ff9-fa65efd7f7fb client false 735ecf62-2552-d923-5aff-0be0d0fb2613 false
6ddfcf0b-035b-e88c-0771-4eba9c453c5b client false 21cccf0c-7428-844a-fd80-1edc421ca2b6 false
e8d8c4cb-6db9-4eb8-7ff9-fa65efd7f7fb client false 9c19c6c3-c261-07a0-8e87-d36d4fced556 false
[e2e-auth-test][~/Projects/Go/nomad/e2e]$ nomad acl policy list
No policies found
[e2e-auth-test][~/Projects/Go/nomad/e2e]$
t.Cleanup(func() { | ||
// no test should ever write this variable, so we don't expect delete to | ||
// work either but need it for cleanup just in case we did write it | ||
nomadClient.Variables().Delete("other/"+t.Name(), opts) |
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.
nomadClient.Variables().Delete("other/"+t.Name(), opts) | |
_, _ = nomadClient.Variables().Delete("other/"+t.Name(), opts) |
Good catch, fixed
I didn't want to leave resources lying around, so the tokens the test creates are all marked with 1min expiration. I think they'll get cleaned up in a reasonable amount of time automatically? |
This changeset provides a matrix test of ACL enforcement across several dimensions: * anonymous vs bogus vs valid tokens * permitted vs not permitted by policy * request sent to server vs sent to client (and forwarded)
Follow-up to #16775
Closes #16483
This changeset provides a matrix test of ACL enforcement across several dimensions:
In order for this test to be meaningful for anonymous requests, I also had to reduce the permissions of the anonymous policy on the E2E cluster. The test runner uses a management token unless there's a test that overrides it that I've missed. I've spot-checked this didn't cause any new breakage on E2E tests but we have a few things like #16803 floating around that make it hard to be sure without digging into all the existing failures we need to work thru.
Test against Nomad 1.5.2, showing how this would have caught #16775:
Test against 1.5.3: