-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[Entitlements] Test ScopeResolver based on TestBuildInfo (parser + resolver) #127719
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
base: main
Are you sure you want to change the base?
Conversation
…icsearch into entitlement/test-resolver
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.
LGTM! Just one question.
try { | ||
scopeMap.put( | ||
getCodeSource(codeSource, location.className()), | ||
PolicyManager.PolicyScope.plugin(pluginBuildInfo.componentName(), location.moduleName()) |
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.
What happens if there is no policy for this specific module? This will just end up with an empty policy?
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.
Reading policies and parsing them will happen separately - I still have to do that. It will work like in production code, a policy can be missing and we just have the default.
Here it is about the resolver, mapping classes and locations to a scope.
But that's a good question on the build infos - what happens if there is no build info for a specific module or plugin? I assumed that build infos will be for all plugins and modules and server, and they will cover all modules; if we miss something, that will fall back to the "unknown" case - similar to what we do in prod code - and that will likely lead to a NotEntitledException.
I think this is correct, but if we feel that should never happen in tests maybe we should have an early assert
?
I'm going to add additional logging, but let me know if we should add an assert
too.
…icsearch into entitlement/test-resolver
Note: this should be merged after #127486, in case the JSON file formats or locations are changed meanwhile. |
This PR introduces a test-specific ScopeResolver to use with PolicyManager for checking entitlements within test code running in a test runner (unit tests and integ tests, where code is running withing the same JVM).
The information for resolving component and module names is derived from the file created in #127486
Some parts are still WIP (e.g. where to place the code that looks for all test-build-info files, or code to read server-specific test-build-info); these are clearly marked with a TODO and possibly will be dealt with in a follow-up PR.