Skip to content
Snippets Groups Projects
Commit 6f0793db authored by Riabokon Stanislav(EPAM)[GCP]'s avatar Riabokon Stanislav(EPAM)[GCP]
Browse files

Added a flag 'security.https.certificate.trust' for int tests.

parent f7538fa7
No related branches found
No related tags found
1 merge request!68Elastic 7
......@@ -147,6 +147,8 @@ You will need to have the following environment variables defined.
| `SEARCH_INTEGRATION_TESTER` | `********` | Service account for API calls. Note: this user must have entitlements configured already | yes | https://console.cloud.google.com/iam-admin/serviceaccounts |
| `SEARCH_HOST` | ex `http://localhost:8080/api/search/v2/` | Endpoint of search service | no | - |
| `STORAGE_HOST` | ex `http://os-storage-dot-opendes.appspot.com/api/storage/v2/schemas` | Storage API endpoint | Storage Host | no | output of infrastructure deployment |
| `security.https.certificate.trust` | ex `false` | Elastic client connection uses TrustSelfSignedStrategy(), if it is 'true' | false | output of infrastructure deployment |
**Entitlements configuration for integration accounts**
......
......@@ -22,6 +22,8 @@ public class Config {
private static final String DEFAULT_ENTITLEMENTS_DOMAIN = "";
private static final String DEFAULT_SECURITY_HTTPS_CERTIFICATE_TRUST = "false";
public static int getPort() {
return Integer.parseInt(getEnvironmentVariableOrDefaultValue("ELASTIC_PORT", String.valueOf(PORT)));
......@@ -99,6 +101,12 @@ public class Config {
return getEnvironmentVariableOrDefaultValue("AWS_COGNITO_AUTH_PARAMS_PASSWORD", "");
}
public static boolean isSecurityHttpsCertificateTrust() {
return Boolean.parseBoolean(
getEnvironmentVariableOrDefaultValue("SECURITY_HTTPS_CERTIFICATE_TRUST",
DEFAULT_SECURITY_HTTPS_CERTIFICATE_TRUST));
}
private static String getEnvironmentVariableOrDefaultValue(String key, String defaultValue) {
String environmentVariable = getEnvironmentVariable(key);
if (environmentVariable == null) {
......
......@@ -319,7 +319,13 @@ public class ElasticUtils {
new BasicHeader("Authorization", String.format("Basic %s", Base64.getEncoder().encodeToString(usernameAndPassword.getBytes()))),
};
if ("https".equals(scheme) && true) {
boolean isSecurityHttpsCertificateTrust = Config.isSecurityHttpsCertificateTrust();
log.info(String.format(
"Elastic client connection uses protocolScheme = %s with a flag "
+ "'security.https.certificate.trust' = %s",
scheme, isSecurityHttpsCertificateTrust));
if ("https".equals(scheme) && isSecurityHttpsCertificateTrust) {
log.warning("Elastic client connection uses TrustSelfSignedStrategy()");
SSLContext sslContext = createSSLContext();
builder.setHttpClientConfigCallback(httpClientBuilder ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment