Skip to content

Commit 103c51a

Browse files
committed
Test for the DigiCert error messages with a string value (#304)
1 parent 5ec3e60 commit 103c51a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ See https://ebourg.github.io/jsign for more information.
5959
* ECS container credentials are now supported when signing with AWS KMS (contributed by Alejandro González)
6060
* The `keystore` parameter can now be specified with the `ETOKEN` storetype to distinguish between multiple connected devices
6161
* The command line tool on Windows now works even if the installation path contains a space (contributed by Tres Finocchiaro)
62+
* The error handling with DigiCert ONE has been improved (contributed by Alejandro González)
6263

6364
#### Version 7.1 (2025-02-14)
6465

jsign-crypto/src/test/java/net/jsign/jca/DigiCertOneSigningServiceTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void testGetCertificateChainWithInvalidAlias() {
120120
}
121121

122122
@Test
123-
public void testGetCertificateChainWithError() {
123+
public void testGetCertificateChainWithEmptyError() {
124124
onRequest()
125125
.havingMethodEqualTo("GET")
126126
.havingPathEqualTo("/signingmanager/api/v1/certificates")
@@ -133,6 +133,23 @@ public void testGetCertificateChainWithError() {
133133
assertEquals("message", "Unable to retrieve DigiCert ONE certificate 'jsign-1995-cert'", e.getMessage());
134134
}
135135

136+
@Test
137+
public void testGetCertificateChainWithStringError() {
138+
onRequest()
139+
.havingMethodEqualTo("GET")
140+
.havingPathEqualTo("/signingmanager/api/v1/certificates")
141+
.respond()
142+
.withStatus(510)
143+
.withContentType("application/json")
144+
.withBody("{\"status\":\"500\",\"error\":\"Internal Server Error\",\"path\":\"/signingmanager/api/v1/certificates\"}");
145+
146+
SigningService service = getTestService();
147+
148+
Exception e = assertThrows(KeyStoreException.class, () -> service.getCertificateChain("jsign-1995-cert"));
149+
assertEquals("message", "Unable to retrieve DigiCert ONE certificate 'jsign-1995-cert'", e.getMessage());
150+
assertEquals("cause", "Internal Server Error", e.getCause().getMessage());
151+
}
152+
136153
@Test
137154
public void testGetCertificateChainWithInvalidEndpoint() {
138155
onRequest()

0 commit comments

Comments
 (0)