15
15
*/
16
16
package org .springframework .vault .support ;
17
17
18
+ import static org .assertj .core .api .Assertions .*;
19
+
18
20
import java .io .IOException ;
19
21
import java .net .URL ;
20
22
import java .security .KeyFactory ;
27
29
import org .junit .jupiter .params .ParameterizedTest ;
28
30
import org .junit .jupiter .params .provider .ValueSource ;
29
31
30
- import static org .assertj .core .api .Assertions .*;
31
-
32
32
/**
33
33
* Unit tests for {@link CertificateBundle}.
34
34
*
@@ -97,6 +97,18 @@ void invalidEcKeySpecShouldThrowException() {
97
97
assertThat (bundle .getPrivateKeySpec ()).isNotNull ();
98
98
}
99
99
100
+ @ Test
101
+ void shouldReturnPrivateKey () {
102
+
103
+ String serialNumber = "aserialnumber" ;
104
+ String certificate = "certificate" ;
105
+ String caCertificate = "caCertificate" ;
106
+ String privateKey = "aprivatekey" ;
107
+
108
+ CertificateBundle bundle = CertificateBundle .of (serialNumber , certificate , caCertificate , privateKey );
109
+ assertThat (bundle .getPrivateKey ()).isNotNull ();
110
+ }
111
+
100
112
@ Test
101
113
void getAsKeystore () throws Exception {
102
114
@@ -115,9 +127,9 @@ void getAsKeystore() throws Exception {
115
127
}
116
128
117
129
@ ParameterizedTest
118
- @ ValueSource (strings = { "certificate-response-rsa-pem.json" , "certificate-response-rsa-der.json" ,
130
+ @ ValueSource (strings = {"certificate-response-rsa-pem.json" , "certificate-response-rsa-der.json" ,
119
131
"certificate-response-rsa-pembundle.json" , "certificate-response-ec-pem.json" ,
120
- "certificate-response-ec-der.json" , "certificate-response-ec-pembundle.json" })
132
+ "certificate-response-ec-der.json" , "certificate-response-ec-pembundle.json" })
121
133
void createKeystore (String path ) {
122
134
123
135
CertificateBundle bundle = loadCertificateBundle (path );
@@ -132,7 +144,7 @@ void createKeystore(String path) {
132
144
}
133
145
134
146
@ ParameterizedTest
135
- @ ValueSource (strings = { "certificate-response-rsa-pem-pkcs8.json" , "certificate-response-ec-pem-pkcs8.json" })
147
+ @ ValueSource (strings = {"certificate-response-rsa-pem-pkcs8.json" , "certificate-response-ec-pem-pkcs8.json" })
136
148
void shouldCreateKeystore (String path ) {
137
149
138
150
CertificateBundle bundle = loadCertificateBundle (path );
0 commit comments