mirror of
https://github.com/ysoftdevs/oauth-playground-server.git
synced 2026-04-17 22:29:47 +02:00
Device Auth. Grant - test
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -64,6 +64,11 @@
|
|||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
<version>1.16.0</version>
|
<version>1.16.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jsoup</groupId>
|
||||||
|
<artifactId>jsoup</artifactId>
|
||||||
|
<version>1.10.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
@@ -6,15 +6,14 @@ import com.ysoft.geecon.dto.User;
|
|||||||
import com.ysoft.geecon.repo.ClientsRepo;
|
import com.ysoft.geecon.repo.ClientsRepo;
|
||||||
import com.ysoft.geecon.repo.UsersRepo;
|
import com.ysoft.geecon.repo.UsersRepo;
|
||||||
import io.quarkus.test.junit.QuarkusTest;
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
import io.restassured.path.xml.XmlPath;
|
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static io.restassured.RestAssured.given;
|
import static io.restassured.RestAssured.given;
|
||||||
import static io.restassured.http.ContentType.JSON;
|
import static io.restassured.http.ContentType.JSON;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
@QuarkusTest
|
@QuarkusTest
|
||||||
public class DeviceAuthGrantTest {
|
public class DeviceAuthGrantTest {
|
||||||
@@ -49,22 +48,26 @@ public class DeviceAuthGrantTest {
|
|||||||
.body("expires_in", is(notNullValue()))
|
.body("expires_in", is(notNullValue()))
|
||||||
.extract().body().as(DeviceResponse.class);
|
.extract().body().as(DeviceResponse.class);
|
||||||
|
|
||||||
String sessionId = given().formParam("code", deviceResponse.userCode()).
|
String deviceLogin = given().formParam("code", deviceResponse.userCode()).
|
||||||
when().post("/auth/device-login").
|
when().post("/auth/device-login").
|
||||||
then().statusCode(200)
|
then().statusCode(200)
|
||||||
.extract().body().xmlPath(XmlPath.CompatibilityMode.HTML)
|
.extract().body().asString();
|
||||||
.getString("html.body.div.form.input");
|
|
||||||
|
|
||||||
String body = given().
|
String sessionId = Jsoup.parse(deviceLogin).getElementsByAttributeValue("name", "sessionId").first().attr("value");
|
||||||
|
|
||||||
|
given().
|
||||||
formParam("sessionId", sessionId).
|
formParam("sessionId", sessionId).
|
||||||
formParam("username", "bob").
|
formParam("username", "bob").
|
||||||
formParam("password", "password").
|
formParam("password", "password").
|
||||||
when().
|
when().
|
||||||
post("auth")
|
post("auth")
|
||||||
.then().statusCode(200).extract().body().asString();
|
.then().statusCode(200);
|
||||||
|
|
||||||
assertEquals("aaa", body);
|
|
||||||
|
|
||||||
|
given().
|
||||||
|
formParam("sessionId", sessionId).
|
||||||
|
when().
|
||||||
|
post("auth/consent")
|
||||||
|
.then().statusCode(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user