|
3 | 3 | import static com.github.tomakehurst.wiremock.client.WireMock.*; |
4 | 4 | import static org.junit.jupiter.api.Assertions.*; |
5 | 5 |
|
6 | | -import java.nio.file.Path; |
7 | 6 | import java.util.List; |
8 | 7 | import java.util.concurrent.TimeUnit; |
9 | 8 |
|
10 | | -import org.htmlunit.DefaultCredentialsProvider; |
11 | | -import org.htmlunit.WebClient; |
12 | | -import org.htmlunit.html.HtmlPage; |
13 | 9 | import org.junit.jupiter.api.AfterEach; |
14 | 10 | import org.junit.jupiter.api.BeforeEach; |
15 | | -import org.junit.jupiter.api.Disabled; |
16 | 11 | import org.junit.jupiter.api.Test; |
17 | 12 | import org.junit.jupiter.api.Timeout; |
18 | 13 | import org.junit.jupiter.api.condition.EnabledIf; |
|
42 | 37 | class WireMockAemProxyEndpointTest extends AbstractAemProxyEndpointTest { |
43 | 38 | private static final boolean WIREMOCK_RECORDING = false; |
44 | 39 |
|
45 | | - private static final Path RESOURCES_DIR = Path.of("src", "test", "resources"); |
46 | | - private static final Path SAMPLE_FILES_DIR = RESOURCES_DIR.resolve("SampleFiles"); |
| 40 | + private static final String CRX_CONTENT_ROOT = "crx:/content/dam/formsanddocuments/sample-forms/"; |
47 | 41 |
|
48 | 42 | public WireMockAemProxyEndpointTest() { |
49 | | - super(SAMPLE_FILES_DIR.resolve(SAMPLE_XDP_FILENAME_PATH).toAbsolutePath().toString()); |
| 43 | + super(CRX_CONTENT_ROOT + SAMPLE_XDP_FILENAME_PATH); |
50 | 44 | } |
51 | 45 |
|
52 | 46 | @BeforeEach |
@@ -84,46 +78,4 @@ protected void verifyProxyTest() { |
84 | 78 | ) |
85 | 79 | .forEach(url->verify(getRequestedFor(urlPathEqualTo(url)))); |
86 | 80 | } |
87 | | - |
88 | | - |
89 | | - // In order to re-record the AEM interactions for Wiremock emulation, you need to: |
90 | | - // 1) run a local AEM server |
91 | | - // 2) set the WIREMOCK_RECORDING variable to true |
92 | | - // 3) then run this test. |
93 | | - // |
94 | | - // It will record the interactions with the AEM server. |
95 | | - // Don't forget to set the WIREMOCK_RECORDING variable back to false after you are done. |
96 | | - // |
97 | | - // Note: THe recordings may require modification. As of AEM 6.5 LTS, the required changes are: |
98 | | - // * Two calls to /content/xfaforms/profiles/default.html - One returns a 401, the other returns the form. |
99 | | - // This is because this HTMLUnit emulates a browser. The 401 recording can be deleted since the FluentForms code |
100 | | - // sends a pre-emptive authentication header. |
101 | | - // * the /etc.clientlibs/fd/xfaforms/clientlibs/I18N/en_US recording must be modified to make the _US optional. |
102 | | - // It appears that the FluentForms call does not include the _US suffix. |
103 | | - @Disabled("This test is not really a test but it is used to record interactions with the AEM server.") |
104 | | - @Test |
105 | | - void aemTest(WireMockRuntimeInfo wmRuntimeInfo) throws Exception { |
106 | | - DefaultCredentialsProvider userCredentials = new DefaultCredentialsProvider(); |
107 | | - userCredentials.addCredentials("admin", "admin".toCharArray()); |
108 | | - try (final WebClient webClient = new WebClient()) { |
109 | | - webClient.setCredentialsProvider(userCredentials); |
110 | | - String baseUri = "http://localhost:" + wmRuntimeInfo.getHttpPort() + "/content/xfaforms/profiles/default.html?contentRoot=crx:///content/dam/formsanddocuments/sample-forms&template=SampleForm.xdp"; |
111 | | - final HtmlPage page = webClient.getPage(baseUri); |
112 | | - assertEquals("LC Forms", page.getTitleText()); |
113 | | - |
114 | | -// final String pageAsXml = page.asXml(); |
115 | | -// assertTrue(pageAsXml.contains("<body class=\"topBarDisabled\">"), "Does not contain topBarDisabled"); |
116 | | -// |
117 | | -// final String pageAsText = page.asNormalizedText(); |
118 | | -// assertTrue(pageAsText.contains("Support for the HTTP and HTTPS protocols")); |
119 | | - } |
120 | | - List.of("/content/xfaforms/profiles/default.html", |
121 | | - "/etc.clientlibs/toggles.json", |
122 | | - "/libs/granite/csrf/token.json", |
123 | | - "/etc.clientlibs/fd/xfaforms/clientlibs/I18N/en_US.js", |
124 | | - "/etc.clientlibs/fd/xfaforms/clientlibs/profile.css", |
125 | | - "/etc.clientlibs/fd/xfaforms/clientlibs/profile.js" |
126 | | - ) |
127 | | - .forEach(url->verify(getRequestedFor(urlPathEqualTo(url)))); |
128 | | - } |
129 | 81 | } |
0 commit comments