Skip to content

Commit

Permalink
AI code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Aug 19, 2024
1 parent df72312 commit 9350dca
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/test/java/oidc/endpoints/DeviceAuthorizationEndpointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
import java.nio.charset.Charset;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.IntStream;

import static io.restassured.RestAssured.given;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class DeviceAuthorizationEndpointTest extends AbstractIntegrationTest {

Expand All @@ -39,8 +42,8 @@ public void deviceAuthorization() {
.formParam("scope", String.join(",", List.of("openid", "groups")))
.post("oidc/device_authorization")
.as(mapTypeRef);
assertEquals(body.get("expires_in"), 900);
assertEquals(body.get("interval"), 1);
assertEquals((int) body.get("expires_in"), 900);
assertEquals((int) body.get("interval"), 1);

String deviceCode = (String) body.get("device_code");
assertEquals(deviceCode, UUID.fromString(deviceCode).toString());
Expand Down Expand Up @@ -71,7 +74,7 @@ public void deviceAuthorizationInvalidClient() {
.formParam("client_id", "nope")
.post("oidc/device_authorization")
.as(mapTypeRef);
assertEquals(body.get("status"), 401);
assertEquals((int) body.get("status"), 401);
assertEquals(body.get("error"), "unauthorized");
}

Expand Down Expand Up @@ -200,7 +203,7 @@ public void deviceAuthorizationInvalidScope() {
.formParam("scope", String.join(",", List.of("not-granted")))
.post("oidc/device_authorization")
.as(mapTypeRef);
assertEquals(body.get("status"), 401);
assertEquals((int) body.get("status"), 401);
assertEquals(body.get("error"), "invalid_scope");
}

Expand Down Expand Up @@ -234,7 +237,7 @@ public void deviceTokenRequest() {
.post("oidc/token")
.as(mapTypeRef);

assertEquals(400, pendingTokenResult.get("status"));
assertEquals(400, (int) pendingTokenResult.get("status"));
assertEquals("authorization_pending", pendingTokenResult.get("error"));

DeviceAuthorization deviceAuthorization = mongoTemplate
Expand All @@ -251,7 +254,7 @@ public void deviceTokenRequest() {
.post("oidc/token")
.as(mapTypeRef);

assertEquals(400, slowDownTokenResult.get("status"));
assertEquals(400, (int) slowDownTokenResult.get("status"));
assertEquals("slow_down", slowDownTokenResult.get("error"));

//Mock - see FakeSamlAuthenticationFilter#authorizeEndpoints - the successful user authentication
Expand Down Expand Up @@ -296,7 +299,7 @@ public void deviceTokenRequestWrongDeviceCode() {
.post("oidc/token")
.as(mapTypeRef);

assertEquals(400, pendingTokenResult.get("status"));
assertEquals(400, (int) pendingTokenResult.get("status"));
assertEquals("expired_token", pendingTokenResult.get("error"));
}

Expand All @@ -322,7 +325,7 @@ public void deviceTokenRequestWrongClientID() {
.post("oidc/token")
.as(mapTypeRef);

assertEquals(400, pendingTokenResult.get("status"));
assertEquals(400, (int) pendingTokenResult.get("status"));
assertEquals("access_denied", pendingTokenResult.get("error"));
}
}

0 comments on commit 9350dca

Please sign in to comment.