Skip to content

Commit

Permalink
Merge pull request #385 from gocd/trim-cert-to-null
Browse files Browse the repository at this point in the history
Treat blank CA Cert data as not set
  • Loading branch information
chadlwilson authored Jan 6, 2024
2 parents e73f7d1 + a8499d5 commit 1734c76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public String getClusterUrl() {
}

public String getCaCertData() {
return clusterCACertData;
return isBlank(clusterCACertData) ? null : clusterCACertData;
}

public Integer getClusterRequestTimeout() {
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/cd/go/contrib/elasticagent/PluginSettingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,14 @@ public void shouldConsiderBlankStringAsNull() {

assertThat(pluginSettings.getNamespace()).isEqualTo("default");
}

@Test
public void shouldConsiderBlankCertAsNull() {
final Map<String, Object> pluginSettingsMap = new HashMap<>();
pluginSettingsMap.put("kubernetes_cluster_ca_cert", " ");

PluginSettings pluginSettings = PluginSettings.fromJSON(new Gson().toJson(pluginSettingsMap));

assertThat(pluginSettings.getCaCertData()).isNull();
}
}

0 comments on commit 1734c76

Please sign in to comment.