Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: security-oauth2 and security-oauth2-quickstart Guide #37745

Open
jcarranzan opened this issue Dec 14, 2023 · 2 comments
Open

Docs: security-oauth2 and security-oauth2-quickstart Guide #37745

jcarranzan opened this issue Dec 14, 2023 · 2 comments

Comments

@jcarranzan
Copy link
Contributor

jcarranzan commented Dec 14, 2023

Describe the bug

I went through https://quarkus.io/version/main/guides/security-oauth2 guide and found the following issues:

  1. Unused import in TokenSecuredResource class: import jakarta.inject.Inject;
    And we should add the import import jakarta.enterprise.context.ApplicationScoped; because @ApplicationScoped annotation is there.

  2. It would be good to have a link reference to show how to obtain the oAuth2 server up and get the token. I think, a more detailed explanation could be provided on using the OAuth2 introspection endpoint URL to validate the token and collect authentication information. This enhancement would contribute to a better user experience when following the guide.

  3. Also, should be added the next dependency used in the TokenSecuredResourceTest:
    <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <scope>test</scope> </dependency>

  4. Following all the guide and creating the classes from the guide if I execute:
    ./mvnw quarkus:dev and execute the tests [r] I got the next error trace:

2023-12-14 15:48:28,903 ERROR [io.qua.test] (Test runner thread) Test TokenSecuredResourceTest#testRolesAllowed() failed 
: java.lang.RuntimeException: java.lang.RuntimeException: Unable to start Quarkus test resource class org.acme.security.oauth2.MockAuthorizationServerTestResource
        at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:638)
        at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:722)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.RuntimeException: Unable to start Quarkus test resource class org.acme.security.oauth2.MockAuthorizationServerTestResource
        at io.quarkus.test.common.TestResourceManager$TestResourceEntryRunnable.run(TestResourceManager.java:506)
        at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
        Suppressed: java.lang.RuntimeException: Unable to stop Quarkus test resource org.acme.security.oauth2.MockAuthorizationServerTestResource@1c5c7fef
                at io.quarkus.test.common.TestResourceManager.close(TestResourceManager.java:179)
                at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:321)
                at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:605)
                at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:655)
                at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: STOPPED
                at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
                at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096)
                at org.eclipse.jetty.server.Server.doStop(Server.java:490)
                at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:132)
                at com.github.tomakehurst.wiremock.jetty.JettyHttpServer.stop(JettyHttpServer.java:228)
                at com.github.tomakehurst.wiremock.WireMockServer.stop(WireMockServer.java:157)
                at org.acme.security.oauth2.MockAuthorizationServerTestResource.stop(MockAuthorizationServerTestResource.java:31)
                at io.quarkus.test.common.TestResourceManager.close(TestResourceManager.java:177)
                ... 4 more
        Caused by: java.lang.IllegalStateException: STOPPED
                at org.eclipse.jetty.server.handler.ContextHandler.shutdown(ContextHandler.java:774)
                at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
                at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
                at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
                at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
                at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
                at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
                at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
                at org.eclipse.jetty.util.component.Graceful.shutdown(Graceful.java:146)
                ... 10 more
Caused by: com.github.tomakehurst.wiremock.common.FatalStartupException: java.lang.RuntimeException: java.io.IOException: Failed to bind to /0.0.0.0:8080
        at com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:166)
        at org.acme.security.oauth2.MockAuthorizationServerTestResource.start(MockAuthorizationServerTestResource.java:17)
        at io.quarkus.test.common.TestResourceManager$TestResourceEntryRunnable.run(TestResourceManager.java:500)
        ... 4 more
Caused by: java.lang.RuntimeException: java.io.IOException: Failed to bind to /0.0.0.0:8080
        at com.github.tomakehurst.wiremock.jetty.JettyHttpServer.start(JettyHttpServer.java:198)
        at com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:164)
        ... 6 more
Caused by: java.io.IOException: Failed to bind to /0.0.0.0:8080
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:304)
        at org.eclipse.jetty.server.Server.lambda$doStart$0(Server.java:402)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at org.eclipse.jetty.server.Server.doStart(Server.java:398)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
        at com.github.tomakehurst.wiremock.jetty.JettyHttpServer.start(JettyHttpServer.java:196)
        ... 7 more
Caused by: java.net.BindException: Address already in use
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:555)
        at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)
        ... 22 more


2023-12-14 15:48:28,906 ERROR [io.qua.test] (Test runner thread) >>>>>>>>>>>>>>>>>>>> Summary: <<<<<<<<<<<<<<<<<<<<
TokenSecuredResourceTest#testRolesAllowed() java.lang.RuntimeException: Unable to start Quarkus test resource class org.acme.security.oauth2.MockAuthorizationServerTestResource
2023-12-14 15:48:28,909 ERROR [io.qua.test] (Test runner thread) >>>>>>>>>>>>>>>>>>>> 1 TEST FAILED <<<<<<<<<<<<<<<<<<<<


--
1 test failed (0 passing, 1 skipped), 1 test was run in 1343ms. Tests completed at 15:48:28.

Maybe I am missing something or how should be executed correctly to do it works?

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@jcarranzan jcarranzan added the kind/bug Something isn't working label Dec 14, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Dec 14, 2023

/cc @sberyozkin (security)

@jcarranzan
Copy link
Contributor Author

Also, area/documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants