Skip to content

Commit

Permalink
Unit tests for 'unknown' source system input
Browse files Browse the repository at this point in the history
  • Loading branch information
TomJKing committed Aug 13, 2024
1 parent c5afced commit c8ec8bc
Showing 1 changed file with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ class TransferServiceServerSpec extends ExternalServicesSpec with Matchers {
)
.unsafeRunSync()

val expectedResponse = Json.obj(
"message" := "Invalid token issuer. Expected 'http://localhost:8000/auth/realms/tdr'"
)

response.status shouldBe Status.Unauthorized
response.as[Json].unsafeRunSync() shouldEqual invalidTokenExpectedResponse
}
Expand Down Expand Up @@ -125,4 +121,39 @@ class TransferServiceServerSpec extends ExternalServicesSpec with Matchers {
response.status shouldBe Status.Unauthorized
response.as[Json].unsafeRunSync() shouldEqual invalidTokenExpectedResponse
}

"unknown source system in endpoint" should "return 400 response with correct authorisation header" in {
graphqlOkJson()
val validToken = validUserToken()
val bearer = CIString("Authorization")
val authHeader = Header.Raw.apply(bearer, s"$validToken")
val fakeHeaders = Headers.apply(authHeader)
val response = LoadController
.apply()
.initiateLoadRoute
.orNotFound
.run(
Request(method = Method.POST, uri = uri"/load/unknown/initiate", headers = fakeHeaders)
)
.unsafeRunSync()

response.status shouldBe Status.BadRequest
}

"unknown source system in endpoint endpoint" should "return 400 response with incorrect authorisation header" in {
val token = invalidToken
val bearer = CIString("Authorization")
val authHeader = Header.Raw.apply(bearer, s"$token")
val fakeHeaders = Headers.apply(authHeader)
val response = LoadController
.apply()
.initiateLoadRoute
.orNotFound
.run(
Request(method = Method.POST, uri = uri"/load/unknown/initiate", headers = fakeHeaders)
)
.unsafeRunSync()

response.status shouldBe Status.BadRequest
}
}

0 comments on commit c8ec8bc

Please sign in to comment.