-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix: marshall and unmarshall actions on endpoint permissions #148
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #148 +/- ##
==========================================
+ Coverage 45.38% 54.14% +8.76%
==========================================
Files 44 44
Lines 3962 3991 +29
==========================================
+ Hits 1798 2161 +363
+ Misses 1827 1374 -453
- Partials 337 456 +119
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Looks good overall, but given the context that we're fixing something we broke before it seems like we should be updating or adding tests which will protect this against future regressions. What are your thoughts?
It skips them if RBAC is not available, which we expect for community. It should be on for Enterprise, but for some reason Lines 63 to 66 in bd63e50
Dunno when/why that stopped working, but I suppose there's no reason to not just set them in the Action environment instead; they're all static anyway... Except that doesn't appear to work either. If it did, go-kong/kong/rbac_user_service_test.go Lines 120 to 123 in bd63e50
|
IDK why those variables are getting ignored (they do show up in However fixing this exposes that there were several (mostly) unrelated broken tests lurking around: /~https://github.com/Kong/go-kong/runs/5636336474?check_suite_focus=true |
Also, those variable were set even before your commit: /~https://github.com/Kong/go-kong/blob/main/.ci/setup_kong.sh#L65-L66 How do we want to proceed here? Add these vars directly in the invocation and fix those failing tests? |
Kong returns a list of actions with GET requests, but it expects a comma-separated string with POST/PUT requests. This fixes the marshalling for this entity.
Instead of exporting Enterprise values, set them inline with the appropriate command. Kong wasn't seeing the exported variables previously, and wasn't actually running tests that require them.
Apply the endpoint path transform (prepend '/' if the path is '*') to all endpoint permission calls, not just Get(). Update the endpoint permission test to create a client for the test endpoint workspace and use it for all operations on that endpoint.
Provide entity type for permission that requires it. Expand default entity permissions to all actions, to not actually limit the admin's ability to interact with objects. We care that we can interact with permissions; enforcing them is the Gateway's domain.
Run the role tests in dedicated workspaces. Otherwise, they can interfere with one another or other tests. We do not want to delete the default super-admin permission.
Compare an endpoint permissions actions across the posted object and the retrieved object to ensure they are the same set. Kong's API uses a CSV string for the GET, so we must transform it.
Reduce the expected role count, as this test no longer operates in the workspace that contains the default roles.
Skip the consumer list and credential list on Enterprise. The presence of admins (which wrap hidden consumers and credentials) affects those resources' pagination. The tests require very specific pagination behavior based on the set of consumers they create, and we cannot isolate the admin in its own test, as it's used in all Enterprise tests.
Yeah--I don't really much care what the setup script looks like so long as it works, and inline does. I'm curious why that's the case (sudo would be my first guess, but sudo does inherit the environment of its caller by default, which a run of With that and a bunch of new changes unrelated to the original PR, tests pass, add (and actually run) a regression test for this, and fixes any tests that were broken. 430956c tests the original fix condition, as I understand it. The rest of the changes fix broken tests that were hidden by Enterprise tests not actually running for the most part. Other than c35a1dd, they do not change library code, only test code. Most fixes are unremarkable; 6ae5da8 is the exception. The implementation of admin consumers and credentials is weird, and apparently changes the way those resources paginate even though the created resources don't exist from the perspective of the admin API. We had acknowledged as much before but apparently didn't actually fix it there and didn't notice because of the skips. Checking for specific pagination behavior isn't something anyone should need to do in practice--all you should care about as a library user is that you can pass in a next value and get the expected page. We should consider reworking our tests to not require specific pagination behavior, but IMO it's fairly low-value: this endpoint exists in community doesn't change its behavior on Enterprise, so there's no pressing reason to test it on Enterprise. The specific pages change depending on your consumer set, but that's expected--right now our test requires a specific consumer set, and it arguably shouldn't. |
For endpoint permissions's
actions
, Kong returns a list with GET requests, but it expects acomma-separated string with POST/PUT requests.
This fixes the marshalling for this entity (reverting #131)
Sample script attempting to configure
actions
as a list:The
actions
field is ignored. While it works if theactions
field is a string: