Skip to content
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

Support certificate content in Opensearch Source configuration to sup… #4184

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

dinujoh
Copy link
Member

@dinujoh dinujoh commented Feb 26, 2024

Support certificate content in Opensearch Source configuration to support TLS and Truststore for Opensearch client.

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…port TLS and truststore on the client.

Signed-off-by: Dinu John <[email protected]>
@Test
void provideOpenSearchClient_with_self_signed_certificate() {
try (MockedStatic<TrustStoreProvider> trustStoreProviderMockedStatic = mockStatic(TrustStoreProvider.class)) {
final Path path = mock(Path.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend moving as much out of the try block as possible to make the mocking easier to understand. I believe you can move lines 225-230 out of here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Test
void provideElasticSearchClient_with_self_signed_certificate() {
try (MockedStatic<TrustStoreProvider> trustStoreProviderMockedStatic = mockStatic(TrustStoreProvider.class)) {
final Path path = mock(Path.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the above, please move lines 243-248 to sit before the try block.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Test
void createSdkAsyncHttpClient_with_self_signed_certificate() {
try (MockedStatic<TrustStoreProvider> trustStoreProviderMockedStatic = mockStatic(TrustStoreProvider.class)) {
final Path path = mock(Path.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the above, please move lines 261-269 to sit before the try block.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -14,6 +14,9 @@ public class ConnectionConfiguration {
@JsonProperty("cert")
private Path certPath;

@JsonProperty("certificate_content")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a validation on mutual exclusivity?

@AssertTrue
public boolean certificateFileAndContentAreMutuallyExclusive() {
  if(certPath == null && certificateContent == null)
    return true;
  return certPath != null ^ certificateContent != null;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dinujoh dinujoh requested a review from dlvenable February 26, 2024 19:39
@dinujoh dinujoh merged commit 9cdc5af into opensearch-project:main Feb 26, 2024
69 of 71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants