quarkusio / quarkus-quickstarts

Quarkus quickstart code
https://quarkus.io
Apache License 2.0
1.96k stars 1.46k forks source link

security-openid-connect-web-authentication-quickstart fails as Quarkus webpage not found #1461

Open gtroitsk opened 2 weeks ago

gtroitsk commented 2 weeks ago

CodeFlowTest fails after deleting index.html in https://github.com/quarkusio/quarkus-quickstarts/pull/1459.

Stack trace

com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 Not Found for http://localhost:8081/index.html

    at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:595)
    at com.gargoylesoftware.htmlunit.WebClient.loadDownloadedResponses(WebClient.java:2277)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:914)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.processPostponedActions(JavaScriptEngine.java:1002)
    at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:1047)
    at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:989)
    at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:897)
    at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:878)
    at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:859)
    at org.acme.security.openid.connect.web.authentication.CodeFlowTest.testTokenTimeoutLogout(CodeFlowTest.java:71)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:971)
    at io.quarkus.test.junit.QuarkusTestExtension.interceptTestMethod(QuarkusTestExtension.java:821)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

Expected Behavior: The test should successfully access Quarkus main page

phillip-kruger commented 2 weeks ago

The test will have to change, index.html is not available in test scope anymore. The test will have to provide it's own page to test against

gtroitsk commented 2 weeks ago

@phillip-kruger Quarkus provides dynamic page at http://localhost:8080. I expect that after I set KC auth credentials I can access page, but app gives me an error 403 CORS Rejected - Invalid origin for http://localhost:8080/q/dev-ui/welcome, because of redirection. I tried quarkus.dev-ui.cors.enabled=false, but I have no luck. Can you please give me some hint what should I do?

phillip-kruger commented 2 weeks ago

The dynamic page is only available in Dev Mode. So if your test is not a dev mode test, it should return 404. If it's a dev mode test you should get the redirection. quarkus.dev-ui.cors.enabled=false should work from CORS. You can also try and set the origin header in your test. But I would suggest to not test against this and rather include your own test html in your test case app that you test against.

gtroitsk commented 2 weeks ago

If I understand your correctly, for this QS we need to get html page back to the state before https://github.com/quarkusio/quarkus-quickstarts/pull/1459

phillip-kruger commented 2 weeks ago

Any basic HTML file will do, it does not have to be the one from before