Skip to content

Commit 37172c4

Browse files
committed
Allow empty certificate and lookup defintions
1 parent c13cc69 commit 37172c4

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/main/java/com/axway/yamles/utils/merge/certs/CertificatesConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static CertificatesConfig loadConfig(String yaml) {
4646

4747
@JsonCreator
4848
public CertificatesConfig(@JsonProperty("certificates") Map<String, Alias> aliases) {
49-
this.aliases = Objects.requireNonNull(aliases, "no aliases defined");
49+
this.aliases = (aliases != null) ? aliases : Collections.emptyMap();
5050
this.aliases.forEach((k, v) -> {
5151
v.setName(k);
5252
});

src/main/java/com/axway/yamles/utils/spi/LookupFunctionConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static LookupFunctionConfig fromJSON(String json) {
4444

4545
@JsonCreator
4646
protected LookupFunctionConfig(@JsonProperty("lookups") Map<String, LookupSource> sources) {
47-
this.sources = Objects.requireNonNull(sources, "no sources defined");
47+
this.sources = (sources != null) ? sources : Collections.emptyMap();
4848
this.sources.forEach((k, v) -> {
4949
v.setAlias(k);
5050
});

src/test/java/com/axway/yamles/utils/merge/certs/CertificatesConfigTest.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,29 @@ void test() {
1818
+ " key: key.pem\n" //
1919
+ " pass: changeme\n" //
2020
+ "...";
21-
21+
2222
CertificatesConfig cc = CertificatesConfig.loadConfig(yaml);
2323
assertNotNull(cc.getAliases());
2424
assertNotNull(cc.getAliases().get("alias"));
25-
25+
2626
Alias a = cc.getAliases().get("alias");
2727
assertEquals("alias", a.getName());
28-
assertEquals("string", a.getConfigSource().getName());
28+
assertEquals("string", a.getConfigSource().getName());
2929
assertEquals("file", a.getProvider());
3030
assertNotNull(a.getConfig());
31-
31+
3232
assertEquals("cert.pem", a.getConfig().get("cert"));
3333
assertEquals("key.pem", a.getConfig().get("key"));
3434
assertEquals("changeme", a.getConfig().get("pass"));
3535
}
3636

37+
@Test
38+
void empty_certificate_config() {
39+
String yaml = "---\n" //
40+
+ "certificates:";
41+
42+
CertificatesConfig cc = CertificatesConfig.loadConfig(yaml);
43+
assertNotNull(cc.getAliases());
44+
assertEquals(0, cc.getAliases().size());
45+
}
3746
}

0 commit comments

Comments
 (0)