diff --git a/http/http-advanced-reactive/src/main/resources/application.properties b/http/http-advanced-reactive/src/main/resources/application.properties index 59ebbc627..d8d050011 100644 --- a/http/http-advanced-reactive/src/main/resources/application.properties +++ b/http/http-advanced-reactive/src/main/resources/application.properties @@ -27,7 +27,7 @@ HttpVersionClientServiceAsync/mp-rest/trustStorePassword=password quarkus.grpc.clients.hello.host=localhost quarkus.grpc.clients.hello.port=${quarkus.grpc.server.port} # authZ -quarkus.keycloak.policy-enforcer.enable=true +#quarkus.keycloak.policy-enforcer.enable=true # Non-application endpoints. Required because we are going to force a redirection, otherwise use `/q/*` instead quarkus.keycloak.policy-enforcer.paths.health-redirection.path=/api/q/* quarkus.keycloak.policy-enforcer.paths.health-redirection.enforcement-mode=DISABLED @@ -68,4 +68,7 @@ pl-container-request-filter.enabled=false quarkus.index-dependency.resteasy-multipart.group-id=org.jboss.resteasy quarkus.index-dependency.resteasy-multipart.artifact-id=resteasy-multipart-provider -quarkus.qe.test.value=42 +qe.test.value=42 +quarkus.oidc.enabled = false +quarkus.keycloak.policy-enforcer.enable = false +quarkus.keycloak.devservices.enabled = false diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/AbstractDevModeIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/AbstractDevModeIT.java new file mode 100644 index 000000000..c97ba46b0 --- /dev/null +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/AbstractDevModeIT.java @@ -0,0 +1,113 @@ +package io.quarkus.ts.http.advanced.reactive; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.jboss.logging.Logger; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.DomElement; +import com.gargoylesoftware.htmlunit.html.HtmlPage; + +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.services.URILike; +import io.quarkus.test.utils.AwaitilityUtils; + +public abstract class AbstractDevModeIT { + private static final Logger LOG = Logger.getLogger(AbstractDevModeIT.class); + protected static final String PROPERTY = "qe.test.value"; + protected WebClient webClient; + + @BeforeEach + void setUp() { + webClient = new WebClient(); + + webClient.getOptions().setRedirectEnabled(true); //required for the test case + //The execution breaks without the option below + webClient.getOptions().setWebSocketEnabled(false); + + //make sure, that the cache doesn't affect us + webClient.getCookieManager().clearCookies(); + webClient.getCookieManager().setCookiesEnabled(false); + webClient.getCache().clear(); + webClient.getCache().setMaxSize(0); + + //disable everything, that we don't need + webClient.getOptions().setDownloadImages(false); + webClient.getOptions().setGeolocationEnabled(false); + webClient.getOptions().setAppletEnabled(false); + webClient.getOptions().setCssEnabled(false); + } + + @Test + @Disabled("https://github.com/quarkusio/quarkus/issues/30511") + public void uiChange() throws IOException { + RestService app = getApp(); + URILike uri = getUri(); + + HtmlPage before = webClient.getPage(uri.withPath("/q/dev/io.quarkus.quarkus-vertx-http/config").toString()); + QuarkusUIField field = new QuarkusUIField(before.getElementById(PROPERTY)); + assertEquals("42", field.getValue(), "Wrong initial value shown in UI!"); + assertEquals("42", app.getProperty(PROPERTY, ""), "Properties contain wrong initial value!"); + + field.setValue("23"); + HtmlPage saved = field.getSaveButton().click(); + QuarkusUIField updated = new QuarkusUIField(saved.getElementById(PROPERTY)); + assertEquals("23", updated.getValue(), "The value was not updated in UI"); + + AwaitilityUtils.untilIsTrue(() -> app.getLogs().stream().anyMatch(log -> log.contains("File change detected"))); + try (Stream lines = Files + .lines(app.getServiceFolder().resolve("src/main/resources/application.properties"))) { + List properties = lines + .filter(line -> line.contains(PROPERTY)) + .collect(Collectors.toList()); + if (properties.size() != 1) { + LOG.warn("There should be only one property with name " + PROPERTY + ", but found these " + properties); + } + } + assertEquals("23", app.getProperty(PROPERTY, ""), "Wrong value was read from application properties"); + } + + protected abstract URILike getUri(); + + protected abstract RestService getApp(); + + @AfterEach + void tearDown() { + webClient.close(); + } + + protected class QuarkusUIField { + private final DomElement element; + + public QuarkusUIField(DomElement element) { + this.element = element; + } + + public String getValue() { + return element.getAttribute("value"); + } + + public void setValue(String newValue) { + element.setAttribute("value", newValue); + } + + public DomElement getSaveButton() { + for (DomElement sibling : element.getParentNode().getDomElementDescendants()) { + if (sibling.getAttribute("class").equals("input-group-text formInputButton")) { + return sibling; + } + } + throw new IllegalStateException("Save button was not found!"); + } + } +} diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeHttpIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeHttpIT.java new file mode 100644 index 000000000..16c3c37a5 --- /dev/null +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeHttpIT.java @@ -0,0 +1,28 @@ +package io.quarkus.ts.http.advanced.reactive; + +import io.quarkus.test.bootstrap.DevModeQuarkusService; +import io.quarkus.test.bootstrap.Protocol; +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.services.DevModeQuarkusApplication; +import io.quarkus.test.services.URILike; + +@QuarkusScenario +public class DevModeHttpIT extends AbstractDevModeIT { + + @DevModeQuarkusApplication(ssl = false) + static RestService app = new DevModeQuarkusService() + .withProperty("quarkus.oidc.enabled", "false") + .withProperty("quarkus.keycloak.policy-enforcer.enable", "false") + .withProperty("quarkus.keycloak.devservices.enabled", "false"); + + @Override + protected URILike getUri() { + return app.getURI(Protocol.HTTP); + } + + @Override + protected RestService getApp() { + return app; + } +} diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeHttpsIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeHttpsIT.java index fb93d8710..842322aa8 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeHttpsIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/DevModeHttpsIT.java @@ -1,16 +1,6 @@ package io.quarkus.ts.http.advanced.reactive; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.io.IOException; - -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import com.gargoylesoftware.htmlunit.WebClient; -import com.gargoylesoftware.htmlunit.html.DomElement; -import com.gargoylesoftware.htmlunit.html.HtmlPage; import io.quarkus.test.bootstrap.DevModeQuarkusService; import io.quarkus.test.bootstrap.Protocol; @@ -18,11 +8,9 @@ import io.quarkus.test.scenarios.QuarkusScenario; import io.quarkus.test.services.DevModeQuarkusApplication; import io.quarkus.test.services.URILike; -import io.quarkus.test.utils.AwaitilityUtils; @QuarkusScenario -public class DevModeHttpsIT { - private static final String PROPERTY = "quarkus.qe.test.value"; +public class DevModeHttpsIT extends AbstractDevModeIT { @DevModeQuarkusApplication(ssl = true) static RestService app = new DevModeQuarkusService() @@ -30,75 +18,20 @@ public class DevModeHttpsIT { .withProperty("quarkus.keycloak.policy-enforcer.enable", "false") .withProperty("quarkus.keycloak.devservices.enabled", "false"); - private WebClient webClient; - @BeforeEach void setUp() { - webClient = new WebClient(); - - webClient.getOptions().setRedirectEnabled(true); //required for the test case - //The execution breaks without the two options below + super.setUp(); + //The execution breaks without the option below webClient.getOptions().setUseInsecureSSL(true); - webClient.getOptions().setWebSocketEnabled(false); - - //make sure, that the cache doesn't affect us - webClient.getCookieManager().clearCookies(); - webClient.getCookieManager().setCookiesEnabled(false); - webClient.getCache().clear(); - webClient.getCache().setMaxSize(0); - - //disable everything, that we don't need - webClient.getOptions().setDownloadImages(false); - webClient.getOptions().setGeolocationEnabled(false); - webClient.getOptions().setAppletEnabled(false); - webClient.getOptions().setCssEnabled(false); - } - - @AfterEach - void tearDown() { - webClient.close(); - } - - @Test - public void uiChange() throws IOException { - URILike uri = app.getURI(Protocol.HTTPS); - - HtmlPage before = webClient.getPage(uri.withPath("/q/dev/io.quarkus.quarkus-vertx-http/config").toString()); - QuarkusUIField field = new QuarkusUIField(before.getElementById(PROPERTY)); - assertEquals("42", field.getValue()); - assertEquals("42", app.getProperty(PROPERTY, "")); - - field.setValue("23"); - HtmlPage saved = field.getSaveButton().click(); - QuarkusUIField updated = new QuarkusUIField(saved.getElementById(PROPERTY)); - assertEquals("23", updated.getValue()); - - AwaitilityUtils.untilIsTrue(() -> app.getLogs().stream().anyMatch(log -> log.contains("File change detected"))); - assertEquals("23", app.getProperty(PROPERTY, "")); - } -} - -class QuarkusUIField { - private final DomElement element; - - QuarkusUIField(DomElement element) { - this.element = element; - } - - public String getValue() { - return element.getAttribute("value"); } - public void setValue(String newValue) { - element.setAttribute("value", newValue); + @Override + protected URILike getUri() { + return app.getURI(Protocol.HTTPS); } - public DomElement getSaveButton() { - for (DomElement sibling : element.getParentNode().getDomElementDescendants()) { - if (sibling.getAttribute("class").equals("input-group-text formInputButton")) { - return sibling; - } - } - throw new IllegalStateException("Save button was not found!"); + @Override + protected RestService getApp() { + return app; } }