|
27 | 27 | import java.io.File; |
28 | 28 | import java.io.IOException; |
29 | 29 | import java.lang.reflect.Field; |
30 | | -import java.net.URLEncoder; |
31 | 30 | import java.util.ArrayList; |
32 | 31 | import java.util.List; |
33 | 32 | import java.util.UUID; |
34 | 33 |
|
| 34 | +import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd; |
| 35 | +import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd; |
| 36 | +import org.apache.cloudstack.context.CallContext; |
35 | 37 | import org.junit.After; |
36 | 38 | import org.junit.Assume; |
37 | 39 | import org.junit.Before; |
38 | 40 | import org.junit.Test; |
39 | 41 | import org.mockito.Mockito; |
40 | 42 |
|
41 | | -import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd; |
42 | | -import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd; |
43 | | -import org.apache.cloudstack.context.CallContext; |
44 | | - |
45 | 43 | import com.cloud.network.dao.LoadBalancerCertMapDao; |
46 | 44 | import com.cloud.network.dao.LoadBalancerCertMapVO; |
47 | 45 | import com.cloud.network.dao.LoadBalancerVO; |
@@ -101,9 +99,9 @@ public void runUploadSslCertWithCAChain() throws Exception { |
101 | 99 | String chainFile = getClass().getResource("/certs/root_chain.crt").getFile(); |
102 | 100 | String password = "user"; |
103 | 101 |
|
104 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
105 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
106 | | - String chain = URLEncoder.encode(readFileToString(new File(chainFile)), "UTF-8"); |
| 102 | + String cert = readFileToString(new File(certFile)); |
| 103 | + String key = readFileToString(new File(keyFile)); |
| 104 | + String chain = readFileToString(new File(chainFile)); |
107 | 105 |
|
108 | 106 | CertServiceImpl certService = new CertServiceImpl(); |
109 | 107 |
|
@@ -153,8 +151,8 @@ public void runUploadSslCertSelfSignedWithPassword() throws Exception { |
153 | 151 | String keyFile = getClass().getResource("/certs/rsa_self_signed_with_pwd.key").getFile(); |
154 | 152 | String password = "test"; |
155 | 153 |
|
156 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
157 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
| 154 | + String cert = readFileToString(new File(certFile)); |
| 155 | + String key = readFileToString(new File(keyFile)); |
158 | 156 |
|
159 | 157 | CertServiceImpl certService = new CertServiceImpl(); |
160 | 158 |
|
@@ -199,8 +197,8 @@ public void runUploadSslCertSelfSignedNoPassword() throws Exception { |
199 | 197 | String certFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile(); |
200 | 198 | String keyFile = getClass().getResource("/certs/rsa_self_signed.key").getFile(); |
201 | 199 |
|
202 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
203 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
| 200 | + String cert = readFileToString(new File(certFile)); |
| 201 | + String key = readFileToString(new File(keyFile)); |
204 | 202 |
|
205 | 203 | CertServiceImpl certService = new CertServiceImpl(); |
206 | 204 |
|
@@ -239,9 +237,9 @@ public void runUploadSslCertBadChain() throws IOException, IllegalAccessExceptio |
239 | 237 | String chainFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile(); |
240 | 238 | String password = "user"; |
241 | 239 |
|
242 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
243 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
244 | | - String chain = URLEncoder.encode(readFileToString(new File(chainFile)), "UTF-8"); |
| 240 | + String cert = readFileToString(new File(certFile)); |
| 241 | + String key = readFileToString(new File(keyFile)); |
| 242 | + String chain = readFileToString(new File(chainFile)); |
245 | 243 |
|
246 | 244 | CertServiceImpl certService = new CertServiceImpl(); |
247 | 245 |
|
@@ -291,9 +289,9 @@ public void runUploadSslCertNoRootCert() throws IOException, IllegalAccessExcept |
291 | 289 | String chainFile = getClass().getResource("/certs/rsa_ca_signed2.crt").getFile(); |
292 | 290 | String password = "user"; |
293 | 291 |
|
294 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
295 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
296 | | - String chain = URLEncoder.encode(readFileToString(new File(chainFile)), "UTF-8"); |
| 292 | + String cert = readFileToString(new File(certFile)); |
| 293 | + String key = readFileToString(new File(keyFile)); |
| 294 | + String chain = readFileToString(new File(chainFile)); |
297 | 295 |
|
298 | 296 | CertServiceImpl certService = new CertServiceImpl(); |
299 | 297 |
|
@@ -343,8 +341,8 @@ public void runUploadSslCertNoChain() throws IOException, IllegalAccessException |
343 | 341 | String keyFile = getClass().getResource("/certs/rsa_ca_signed.key").getFile(); |
344 | 342 | String password = "user"; |
345 | 343 |
|
346 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
347 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
| 344 | + String cert = readFileToString(new File(certFile)); |
| 345 | + String key = readFileToString(new File(keyFile)); |
348 | 346 |
|
349 | 347 | CertServiceImpl certService = new CertServiceImpl(); |
350 | 348 |
|
@@ -388,8 +386,8 @@ public void runUploadSslCertBadPassword() throws IOException, IllegalAccessExcep |
388 | 386 | String keyFile = getClass().getResource("/certs/rsa_self_signed_with_pwd.key").getFile(); |
389 | 387 | String password = "bad_password"; |
390 | 388 |
|
391 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
392 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
| 389 | + String cert = readFileToString(new File(certFile)); |
| 390 | + String key = readFileToString(new File(keyFile)); |
393 | 391 |
|
394 | 392 | CertServiceImpl certService = new CertServiceImpl(); |
395 | 393 |
|
@@ -432,8 +430,8 @@ public void runUploadSslCertBadkeyPair() throws IOException, IllegalAccessExcept |
432 | 430 | String certFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile(); |
433 | 431 | String keyFile = getClass().getResource("/certs/rsa_random_pkey.key").getFile(); |
434 | 432 |
|
435 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
436 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
| 433 | + String cert = readFileToString(new File(certFile)); |
| 434 | + String key = readFileToString(new File(keyFile)); |
437 | 435 |
|
438 | 436 | CertServiceImpl certService = new CertServiceImpl(); |
439 | 437 |
|
@@ -471,8 +469,8 @@ public void runUploadSslCertBadkeyAlgo() throws IOException, IllegalAccessExcept |
471 | 469 | String certFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile(); |
472 | 470 | String keyFile = getClass().getResource("/certs/dsa_self_signed.key").getFile(); |
473 | 471 |
|
474 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
475 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
| 472 | + String cert = readFileToString(new File(certFile)); |
| 473 | + String key = readFileToString(new File(keyFile)); |
476 | 474 |
|
477 | 475 | CertServiceImpl certService = new CertServiceImpl(); |
478 | 476 |
|
@@ -511,8 +509,8 @@ public void runUploadSslCertExpiredCert() throws IOException, IllegalAccessExcep |
511 | 509 | String certFile = getClass().getResource("/certs/expired_cert.crt").getFile(); |
512 | 510 | String keyFile = getClass().getResource("/certs/rsa_self_signed.key").getFile(); |
513 | 511 |
|
514 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
515 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
| 512 | + String cert = readFileToString(new File(certFile)); |
| 513 | + String key = readFileToString(new File(keyFile)); |
516 | 514 |
|
517 | 515 | CertServiceImpl certService = new CertServiceImpl(); |
518 | 516 |
|
@@ -550,8 +548,8 @@ public void runUploadSslCertNotX509() throws IOException, IllegalAccessException |
550 | 548 | String certFile = getClass().getResource("/certs/non_x509_pem.crt").getFile(); |
551 | 549 | String keyFile = getClass().getResource("/certs/rsa_self_signed.key").getFile(); |
552 | 550 |
|
553 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
554 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
| 551 | + String cert = readFileToString(new File(certFile)); |
| 552 | + String key = readFileToString(new File(keyFile)); |
555 | 553 |
|
556 | 554 | CertServiceImpl certService = new CertServiceImpl(); |
557 | 555 |
|
@@ -590,8 +588,8 @@ public void runUploadSslCertBadFormat() throws IOException, IllegalAccessExcepti |
590 | 588 | String certFile = getClass().getResource("/certs/bad_format_cert.crt").getFile(); |
591 | 589 | String keyFile = getClass().getResource("/certs/rsa_self_signed.key").getFile(); |
592 | 590 |
|
593 | | - String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8"); |
594 | | - String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8"); |
| 591 | + String cert = readFileToString(new File(certFile)); |
| 592 | + String key = readFileToString(new File(keyFile)); |
595 | 593 |
|
596 | 594 | CertServiceImpl certService = new CertServiceImpl(); |
597 | 595 |
|
|
0 commit comments