+16
-11
@@ -15,8 +15,10 @@ import java.util.Map as JMap
|
|||||||
class InternalAuthEnabledProfile extends QuarkusTestProfile:
|
class InternalAuthEnabledProfile extends QuarkusTestProfile:
|
||||||
override def getConfigOverrides(): JMap[String, String] =
|
override def getConfigOverrides(): JMap[String, String] =
|
||||||
JMap.of(
|
JMap.of(
|
||||||
"nowchess.internal.auth.enabled", "true",
|
"nowchess.internal.auth.enabled",
|
||||||
"nowchess.internal.secret", "test-secret-123",
|
"true",
|
||||||
|
"nowchess.internal.secret",
|
||||||
|
"test-secret-123",
|
||||||
)
|
)
|
||||||
|
|
||||||
@QuarkusTest
|
@QuarkusTest
|
||||||
@@ -36,32 +38,35 @@ class InternalAuthFilterHttpTest:
|
|||||||
@Test
|
@Test
|
||||||
@DisplayName("POST /api/board/game without secret returns 401")
|
@DisplayName("POST /api/board/game without secret returns 401")
|
||||||
def rejectNoSecret(): Unit =
|
def rejectNoSecret(): Unit =
|
||||||
RestAssured.`given`()
|
RestAssured
|
||||||
|
.`given`()
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.body("{}")
|
.body("{}")
|
||||||
.when()
|
.when()
|
||||||
.post("/api/board/game")
|
.post("/api/board/game")
|
||||||
.`then`()
|
.`then`()
|
||||||
.statusCode(401)
|
.statusCode(401)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("POST /api/board/game with wrong secret returns 401")
|
@DisplayName("POST /api/board/game with wrong secret returns 401")
|
||||||
def rejectWrongSecret(): Unit =
|
def rejectWrongSecret(): Unit =
|
||||||
RestAssured.`given`()
|
RestAssured
|
||||||
|
.`given`()
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("X-Internal-Secret", "wrong-secret")
|
.header("X-Internal-Secret", "wrong-secret")
|
||||||
.body("{}")
|
.body("{}")
|
||||||
.when()
|
.when()
|
||||||
.post("/api/board/game")
|
.post("/api/board/game")
|
||||||
.`then`()
|
.`then`()
|
||||||
.statusCode(401)
|
.statusCode(401)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("GET /api/board/game/{id} without secret returns 404 not 401")
|
@DisplayName("GET /api/board/game/{id} without secret returns 404 not 401")
|
||||||
def nonInternalEndpointNotBlocked(): Unit =
|
def nonInternalEndpointNotBlocked(): Unit =
|
||||||
RestAssured.`given`()
|
RestAssured
|
||||||
.when()
|
.`given`()
|
||||||
|
.when()
|
||||||
.get("/api/board/game/nonexistent")
|
.get("/api/board/game/nonexistent")
|
||||||
.`then`()
|
.`then`()
|
||||||
.statusCode(404)
|
.statusCode(404)
|
||||||
// scalafix:on
|
// scalafix:on
|
||||||
|
|||||||
Reference in New Issue
Block a user