-
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: extract logic from cert manager to use cases #128
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
@SuppressWarnings("PMD.AvoidCatchingGenericException") | ||
private Pair<PrivateKey, X509Certificate[]> getCertificateChain(URI privateKeyUri, URI certChainUri) { |
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 a temporary spot for this we ideally don't have this logic inside use cases
certificateStore.setCaCertificateChain(result.getB()); | ||
configuration.updateCACertificates( | ||
Collections.singletonList(CertificateHelper.toPem(certificateStore.getCaCertificateChain()))); | ||
} catch (CertificateEncodingException | KeyStoreException | IOException e) { |
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 about InvalidCertificateAuthorityException
?
.../greengrass/clientdevices/auth/certificate/usecases/ConfigureCustomCertificateAuthority.java
Outdated
Show resolved
Hide resolved
3ad6f7b
to
1feb011
Compare
1feb011
to
fa055d7
Compare
Unit Tests Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against fa055d7 |
} | ||
|
||
@SuppressWarnings("PMD.AvoidCatchingGenericException") | ||
private Pair<PrivateKey, X509Certificate[]> getCertificateChain(URI privateKeyUri, URI certChainUri) { |
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.
getKeyAndCertificateChain
?
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.
True, I will change in the next PR
|
||
topics = Topics.of(new Context(), CLIENT_DEVICES_AUTH_SERVICE_NAME, null); |
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.
context must always be closed at the end of a test. It starts a thread and we don't want that to run forever. Make sure you always shutdown any context you create.
@SuppressWarnings("PMD.AvoidCatchingGenericException") | ||
private Pair<PrivateKey, X509Certificate[]> getCertificateChain(URI privateKeyUri, URI certChainUri) { | ||
// TODO: Move retry logic out of useCases | ||
RetryUtils.RetryConfig retryConfig = RetryUtils.RetryConfig.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.
If this retry eventually gives up, then what happens?
200ms * 3 may not be enough time for some providers to initalize.
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.
+1 to this. I've commented on this several times as well. Since this is just a refactor, we can probably tackle that in a follow up. We'll want an event listener that listens to config update events and handles retries
@@ -116,22 +120,27 @@ void GIVEN_customCAConfiguration_WHEN_configureCustomCA_THEN_returnsCustomCA() t | |||
URI privateKeyUri = new URI("file:///private.key"); | |||
URI certificateUri = new URI("file:///certificate.pem"); | |||
|
|||
Topics configurationTopics = Topics.of(new Context(), CLIENT_DEVICES_AUTH_SERVICE_NAME, null); | |||
configurationTopics.lookup(CONFIGURATION_CONFIG_KEY, CERTIFICATE_AUTHORITY_TOPIC, CA_PRIVATE_KEY_URI) | |||
Topics topics = Topics.of(new Context(), CLIENT_DEVICES_AUTH_SERVICE_NAME, null); |
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.
likewise, close context
Description of changes:
Now we have use cases in place we can start extracting logic from the cert manager into use cases. Eventually certManager will not exist since it is just acting as a proxy for application logic and we already have a construct that better first that logic (use cases)
Why is this change necessary:
Continuation on the refactor work we have been doing
How was this change tested:
Ensure tests are passing