|
| 1 | +package in.erail.route; |
| 2 | + |
| 3 | +import com.google.common.net.HttpHeaders; |
| 4 | +import in.erail.glue.Glue; |
| 5 | +import in.erail.server.Server; |
| 6 | +import io.vertx.ext.auth.DummyAuthProvider; |
| 7 | +import io.vertx.junit5.VertxExtension; |
| 8 | +import io.vertx.junit5.VertxTestContext; |
| 9 | +import io.vertx.reactivex.ext.auth.AuthProvider; |
| 10 | +import io.vertx.reactivex.ext.web.client.WebClient; |
| 11 | +import org.junit.jupiter.api.Test; |
| 12 | +import static org.junit.jupiter.api.Assertions.*; |
| 13 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 14 | + |
| 15 | +/** |
| 16 | + * |
| 17 | + * @author vinay |
| 18 | + */ |
| 19 | +@ExtendWith(VertxExtension.class) |
| 20 | +public class OIDCCallbackRouteBuilderTest { |
| 21 | + |
| 22 | + @Test |
| 23 | + public void testHandle(VertxTestContext testContext) { |
| 24 | + Server server = Glue.instance().resolve("/in/erail/server/Server"); |
| 25 | + OIDCCallbackRouteBuilder oid = Glue.instance().resolve("/in/erail/route/OIDCCallbackRouteBuilder"); |
| 26 | + oid.setAuthProvider(new AuthProvider(new DummyAuthProvider())); |
| 27 | + |
| 28 | + WebClient |
| 29 | + .create(server.getVertx()) |
| 30 | + .get(server.getHttpServerOptions().getPort(), server.getHttpServerOptions().getHost(), "/callback") |
| 31 | + .addQueryParam("code", "nothing") |
| 32 | + .rxSend() |
| 33 | + .doOnSuccess(req -> assertEquals(302, req.statusCode())) |
| 34 | + .doOnSuccess(req -> assertTrue(req.getHeader(HttpHeaders.LOCATION).endsWith("?login=success"))) |
| 35 | + .subscribe(req -> testContext.completeNow(), err -> testContext.failNow(err)); |
| 36 | + } |
| 37 | +} |
0 commit comments