|
1 | 1 | package com.marklogic.appdeployer.command.security; |
2 | 2 |
|
3 | | -import org.junit.Test; |
4 | | - |
5 | 3 | import com.marklogic.appdeployer.AbstractAppDeployerTest; |
| 4 | +import com.marklogic.appdeployer.command.ResourceFilenameFilter; |
6 | 5 | import com.marklogic.mgmt.resource.security.CertificateAuthorityManager; |
7 | 6 | import com.marklogic.rest.util.ResourcesFragment; |
| 7 | +import org.junit.Test; |
| 8 | + |
| 9 | +import java.util.Set; |
8 | 10 |
|
9 | 11 | /** |
10 | 12 | * All we can reliably do from a file-driven approach is create a certificate authority. The Management REST API in |
|
14 | 16 | */ |
15 | 17 | public class ManageCertificateAuthoritiesTest extends AbstractAppDeployerTest { |
16 | 18 |
|
17 | | - @Test |
18 | | - public void test() { |
19 | | - // Run the command to create a certificate authority |
20 | | - initializeAppDeployer(new DeployCertificateAuthoritiesCommand()); |
21 | | - appDeployer.deploy(appConfig); |
22 | | - |
23 | | - // Get the ID of the created certificate authority |
24 | | - CertificateAuthorityManager mgr = new CertificateAuthorityManager(manageClient); |
25 | | - ResourcesFragment resources = mgr.getAsXml(); |
26 | | - String id = resources.getListItemValue("MarkLogic TX Engineering", "idref"); |
27 | | - assertNotNull("The certificate authority should have been created", id); |
28 | | - |
29 | | - // Delete the certificate authority |
30 | | - mgr.delete(id); |
31 | | - |
32 | | - // And then verify that it's gone |
33 | | - resources = mgr.getAsXml(); |
34 | | - id = resources.getListItemValue("MarkLogic TX Engineering", "idref"); |
35 | | - assertNull("The certificate authority should no longer exist", id); |
36 | | - } |
| 19 | + @Test |
| 20 | + public void test() { |
| 21 | + // Run the command to create a certificate authority |
| 22 | + initializeAppDeployer(new DeployCertificateAuthoritiesCommand()); |
| 23 | + appDeployer.deploy(appConfig); |
| 24 | + |
| 25 | + // Get the ID of the created certificate authority |
| 26 | + CertificateAuthorityManager mgr = new CertificateAuthorityManager(manageClient); |
| 27 | + ResourcesFragment resources = mgr.getAsXml(); |
| 28 | + String id = resources.getListItemValue("MarkLogic TX Engineering", "idref"); |
| 29 | + assertNotNull("The certificate authority should have been created", id); |
| 30 | + |
| 31 | + // Delete the certificate authority |
| 32 | + mgr.delete(id); |
| 33 | + |
| 34 | + // And then verify that it's gone |
| 35 | + resources = mgr.getAsXml(); |
| 36 | + id = resources.getListItemValue("MarkLogic TX Engineering", "idref"); |
| 37 | + assertNull("The certificate authority should no longer exist", id); |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + public void verifyFileExtensions() { |
| 42 | + DeployCertificateAuthoritiesCommand command = new DeployCertificateAuthoritiesCommand(); |
| 43 | + ResourceFilenameFilter filter = (ResourceFilenameFilter) command.getResourceFilenameFilter(); |
| 44 | + Set<String> extensions = filter.getSupportedFilenameExtensions(); |
| 45 | + |
| 46 | + for (String extension : new String[]{".cer", ".crt", ".der", ".p12", ".p7b", ".p7r", ".pem", ".pfx", ".spc"}) { |
| 47 | + assertTrue(extensions.contains(extension)); |
| 48 | + } |
| 49 | + } |
37 | 50 | } |
0 commit comments