|
4 | 4 | package oracle.weblogic.kubernetes.assertions.impl;
|
5 | 5 |
|
6 | 6 | import java.io.IOException;
|
| 7 | +import java.net.http.HttpResponse; |
7 | 8 | import java.time.OffsetDateTime;
|
8 | 9 |
|
9 |
| -import com.gargoylesoftware.htmlunit.WebClient; |
10 |
| -import com.gargoylesoftware.htmlunit.html.HtmlElement; |
11 |
| -import com.gargoylesoftware.htmlunit.html.HtmlForm; |
12 |
| -import com.gargoylesoftware.htmlunit.html.HtmlPage; |
13 | 10 | import io.kubernetes.client.openapi.ApiException;
|
14 | 11 | import io.kubernetes.client.openapi.Configuration;
|
15 | 12 | import io.kubernetes.client.openapi.apis.ApiextensionsV1Api;
|
|
19 | 16 | import oracle.weblogic.domain.DomainResource;
|
20 | 17 | import oracle.weblogic.kubernetes.actions.impl.primitive.Command;
|
21 | 18 | import oracle.weblogic.kubernetes.actions.impl.primitive.CommandParams;
|
22 |
| -import oracle.weblogic.kubernetes.logging.LoggingFacade; |
| 19 | +import oracle.weblogic.kubernetes.utils.OracleHttpClient; |
23 | 20 |
|
24 | 21 | import static oracle.weblogic.kubernetes.TestConstants.ADMIN_PASSWORD_DEFAULT;
|
25 | 22 | import static oracle.weblogic.kubernetes.TestConstants.ADMIN_USERNAME_DEFAULT;
|
|
32 | 29 | import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger;
|
33 | 30 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
34 | 31 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
35 |
| -import static org.junit.jupiter.api.Assertions.assertTrue; |
36 | 32 |
|
37 | 33 | public class Domain {
|
38 | 34 |
|
@@ -146,41 +142,27 @@ public static boolean adminT3ChannelAccessible(String domainUid, String namespac
|
146 | 142 | }
|
147 | 143 |
|
148 | 144 | /**
|
149 |
| - * Verify admin node port(default/t3channel) is accessible by login to WebLogic console |
150 |
| - * using the node port and validate its the Home page. |
| 145 | + * Verify admin node port(default/t3channel) is accessible with readyapp url. |
151 | 146 | *
|
152 | 147 | * @param nodePort the node port that needs to be tested for access
|
153 | 148 | * @param userName WebLogic administration server user name
|
154 | 149 | * @param password WebLogic administration server password
|
155 | 150 | * @param routeHost For OKD - name of the route for external admin service. Can be empty for non OKD env
|
156 |
| - * @return true if login to WebLogic administration console is successful |
| 151 | + * @return true if /weblogic/ready returns 200 http status |
157 | 152 | * @throws IOException when connection to console fails
|
158 | 153 | */
|
159 | 154 | public static boolean adminNodePortAccessible(int nodePort, String userName, String password, String routeHost)
|
160 |
| - throws IOException { |
161 |
| - |
162 |
| - LoggingFacade logger = getLogger(); |
163 |
| - |
| 155 | + throws Exception { |
164 | 156 | String hostAndPort = getHostAndPort(routeHost, nodePort);
|
165 | 157 | String readyAppUrl = new StringBuffer()
|
166 | 158 | .append("http://")
|
167 | 159 | .append(hostAndPort)
|
168 | 160 | .append("/weblogic/ready").toString();
|
169 | 161 |
|
170 |
| - getLogger().info("Accessing WebLogic console with url {0}", readyAppUrl); |
171 |
| - final WebClient webClient = new WebClient(); |
172 |
| - //final HtmlPage loginPage = assertDoesNotThrow(() -> webClient.getPage(readyAppUrl), |
173 |
| - final HtmlPage loginPage = assertDoesNotThrow(() -> webClient.getPage(readyAppUrl), |
174 |
| - "connection to the WebLogic admin console failed"); |
175 |
| - HtmlForm form = loginPage.getFormByName("loginData"); |
176 |
| - form.getInputByName("j_username").type(userName); |
177 |
| - form.getInputByName("j_password").type(password); |
178 |
| - HtmlElement submit = form.getOneHtmlElementByAttribute("input", "type", "submit"); |
179 |
| - getLogger().info("Clicking login button"); |
180 |
| - HtmlPage home = submit.click(); |
181 |
| - assertTrue(home.asNormalizedText().contains("Persistent Stores"), "Home does not contain Persistent Stores text"); |
182 |
| - getLogger().info("Console login passed"); |
183 |
| - return true; |
| 162 | + getLogger().info("Accessing WebLogic readyapp with url {0}", readyAppUrl); |
| 163 | + HttpResponse<String> response; |
| 164 | + response = OracleHttpClient.get(readyAppUrl, null, true); |
| 165 | + return response.statusCode() == 200; |
184 | 166 | }
|
185 | 167 |
|
186 | 168 | /**
|
|
0 commit comments