-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Entitlements] Add support for IT tests of always allowed actions (take 2) #124429
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
[Entitlements] Add support for IT tests of always allowed actions (take 2) #124429
Conversation
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
| return entries.stream(); | ||
| } | ||
|
|
||
| private static CheckedConsumer<Environment, Exception> createConsumerForMethod(Method method) { |
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.
This is pretty neat. Your own tiny DI framework!
| } | ||
| if (parameters.length == 1 && parameters[0].equals(Environment.class)) { | ||
| return env -> method.invoke(null, env); | ||
| } |
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.
(If we ever acquire a second injectable parameter here, I'd probably change this to loop over the parameters, building the argument list based on the parameter types, much like a real DI framework would.)
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.
++
But for now all the "extra" info we use is in the environment (e.g. dirs).
But yes, if we need to add more, we can either do that or have "fixed" patterns (either arg-less, or all the additional args in the right order).
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 don't really see the value in forcing the args to be in a certain order. Like, what if I want to inject A and C? Do I need to declare B for no reason just so I have the right args in the right order? Also, why is (A, C) ok but (C, A) is not?
It will not surprise you that I'd prefer just to have DI. 😂
…lways-allowed-actions-2
…lways-allowed-actions-2
…ke 2) (elastic#124429) Writing tests for elastic#123861, turns out that elastic#124195 is not enough. We really need new IT test cases for "always allowed" actions: in order to be sure they are allowed, we need to setup the plugin with no policy. This PR adds test cases for that, plus the support for writing test functions that accept one Environment parameter: many test paths we test and allow/deny are relative to paths in Environment, so it's useful to have access to it (see readAccessConfigDirectory as an example)
💔 Backport failed
You can use sqren/backport to manually backport by running |
…ke 2) (#124429) (#124627) Writing tests for #123861, turns out that #124195 is not enough. We really need new IT test cases for "always allowed" actions: in order to be sure they are allowed, we need to setup the plugin with no policy. This PR adds test cases for that, plus the support for writing test functions that accept one Environment parameter: many test paths we test and allow/deny are relative to paths in Environment, so it's useful to have access to it (see readAccessConfigDirectory as an example)
…ke 2) (elastic#124429) Writing tests for elastic#123861, turns out that elastic#124195 is not enough. We really need new IT test cases for "always allowed" actions: in order to be sure they are allowed, we need to setup the plugin with no policy. This PR adds test cases for that, plus the support for writing test functions that accept one Environment parameter: many test paths we test and allow/deny are relative to paths in Environment, so it's useful to have access to it (see readAccessConfigDirectory as an example)
…ke 2) (elastic#124429) Writing tests for elastic#123861, turns out that elastic#124195 is not enough. We really need new IT test cases for "always allowed" actions: in order to be sure they are allowed, we need to setup the plugin with no policy. This PR adds test cases for that, plus the support for writing test functions that accept one Environment parameter: many test paths we test and allow/deny are relative to paths in Environment, so it's useful to have access to it (see readAccessConfigDirectory as an example)
…ke 2) (#124429) (#124703) Writing tests for #123861, turns out that #124195 is not enough. We really need new IT test cases for "always allowed" actions: in order to be sure they are allowed, we need to setup the plugin with no policy. This PR adds test cases for that, plus the support for writing test functions that accept one Environment parameter: many test paths we test and allow/deny are relative to paths in Environment, so it's useful to have access to it (see readAccessConfigDirectory as an example)
…ke 2) (#124429) (#124704) Writing tests for #123861, turns out that #124195 is not enough. We really need new IT test cases for "always allowed" actions: in order to be sure they are allowed, we need to setup the plugin with no policy. This PR adds test cases for that, plus the support for writing test functions that accept one Environment parameter: many test paths we test and allow/deny are relative to paths in Environment, so it's useful to have access to it (see readAccessConfigDirectory as an example)
…ke 2) (elastic#124429) Writing tests for elastic#123861, turns out that elastic#124195 is not enough. We really need new IT test cases for "always allowed" actions: in order to be sure they are allowed, we need to setup the plugin with no policy. This PR adds test cases for that, plus the support for writing test functions that accept one Environment parameter: many test paths we test and allow/deny are relative to paths in Environment, so it's useful to have access to it (see readAccessConfigDirectory as an example)
…ke 2) (elastic#124429) Writing tests for elastic#123861, turns out that elastic#124195 is not enough. We really need new IT test cases for "always allowed" actions: in order to be sure they are allowed, we need to setup the plugin with no policy. This PR adds test cases for that, plus the support for writing test functions that accept one Environment parameter: many test paths we test and allow/deny are relative to paths in Environment, so it's useful to have access to it (see readAccessConfigDirectory as an example)
Writing tests for #123861, turns out that #124195 is not enough.
We really need new IT test cases for "always allowed" actions: in order to be sure they are allowed, we need to setup the plugin with no policy.
This PR adds test cases for that, plus the support for writing test functions that accept one Environment parameter: many test paths we test and allow/deny are relative to paths in Environment, so it's useful to have access to it (see
readAccessConfigDirectoryas an example)