-
Notifications
You must be signed in to change notification settings - Fork 3
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
refactor: policy validation on config change #418
Conversation
We identified new issues on unchanged lines of code. Navigate to the Amazon CodeGuru Reviewer console to view the recommendations to fix them. |
src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java
Fixed
Show fixed
Hide fixed
Benchmark Results
|
ae23c35
to
b939c4e
Compare
Code Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against f32d9d5 |
b939c4e
to
ac76c33
Compare
@@ -68,6 +71,15 @@ | |||
@ImplementsService(name = ClientDevicesAuthService.CLIENT_DEVICES_AUTH_SERVICE_NAME) | |||
public class ClientDevicesAuthService extends PluginService { | |||
public static final String CLIENT_DEVICES_AUTH_SERVICE_NAME = "aws.greengrass.clientdevices.Auth"; | |||
private static final ObjectMapper MAPPER = JsonMapper.builder() |
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.
use the mappers we already have in the utils. We have one already for recipes which does case insensitive stuff
src/main/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthService.java
Outdated
Show resolved
Hide resolved
src/test/java/com/aws/greengrass/clientdevices/auth/ClientDevicesAuthServiceTest.java
Outdated
Show resolved
Hide resolved
@@ -68,6 +70,8 @@ | |||
@ImplementsService(name = ClientDevicesAuthService.CLIENT_DEVICES_AUTH_SERVICE_NAME) | |||
public class ClientDevicesAuthService extends PluginService { | |||
public static final String CLIENT_DEVICES_AUTH_SERVICE_NAME = "aws.greengrass.clientdevices.Auth"; | |||
private static final ObjectMapper MAPPER = SerializerFactory.getRecipeSerializerJson(); |
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 you want getConfigurationSerializerJson
to avoid changing capitalization
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 like we were relying on FAIL_ON_UNKNOWN_PROPERTIES
before (which is why there's a test failure right now). so we'd have to use the existing objectmapper for backwards compat; otherwise if customers set group policy w/ extra stuff they can't rollback
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.
We shouldn't fail on unknown though. That prevents forward compatibility
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.
yeah, ok if we're fine with that behavior change then yeah can add it in
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.
done
* | ||
* @throws PolicyException if an invalid policy is detected | ||
*/ | ||
public void validate() throws PolicyException { |
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.
Should we also validate that policy variables in the policy document are supported by the PolicyVariableResolver
since the resolver doesn't handle unsupported policy variables?
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.
yep, wanted to do that in a follow-up, this PR is meant to be a refactor
Issue #, if available:
Description of changes:
Add an explicit
GroupConfiguration#validate
method, which is used to validate incoming policy config changes before applying them to CDA.Making this change as the foundation for adding more validations in the future (for policy variable feature).
Why is this change necessary:
How was this change tested:
Any additional information or context required to review the change:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.