Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This seems weird but I'm creating this PR as a record of something I tried and abandoned. This way when I'm tempted to try it again (or ask why we didn't do it this way) I can go read why not.
This PR was an attempt to create an end-to-end test that verifies the behavior of authz roles. The idea was to create an actual resource hierarchy using the external API (so, creating a real Organization, Project, Instance, etc.), assign every possible role on each resource in the hierarchy (using separate users), and verify what API calls each user was able to do. This sounds great, but it has a bunch of problems:
While writing this test, I decided a better approach is to decompose this into two or three problems:
With the first two things tested, we can have a lot of confidence that we're correctly enforcing the authz policy. There are a few advantages to breaking things down this way:
authorize()
bit. Plus we have to do all the database operations to set up (and tear down and re-set-up) the resource hierarchy in the first place. By separating it as proposed, part (1) doesn't do any of that extra work. It just does the authz check for each user and resource (rather than a whole API call) and it doesn't need to set up or tear down any database resources.There may still be room for an end-to-end test ((3) above). For example, it's conceivable that an implementation passes both of the first two tests but that the API call does not correctly bail out on some particular authz check. (e.g., if somebody called
authorize()
but forgot the?
after it). This test could probably be limited to verifying only failure cases, which makes things a lot easier. Much (but not all) of this is in turn covered by the existing "unauthorized" test.