libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 59900a472fb3a474b4ba6401637dca1d550e5bca
parent 19ea65bc8fa70b410b6008d61e534c06c6e43b44
Author: MS <ms@taler.net>
Date:   Tue, 26 Sep 2023 11:12:12 +0200

Testing token default lifetime.

Diffstat:
Mbank/src/test/kotlin/LibeuFinApiTest.kt | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/bank/src/test/kotlin/LibeuFinApiTest.kt b/bank/src/test/kotlin/LibeuFinApiTest.kt @@ -141,7 +141,7 @@ class LibeuFinApiTest { application { corebankWebApp(db, ctx) } - client.post("/accounts/foo/token") { + val newTok = client.post("/accounts/foo/token") { expectSuccess = true contentType(ContentType.Application.Json) basicAuth("foo", "pw") @@ -151,6 +151,11 @@ class LibeuFinApiTest { """.trimIndent() ) } + // Checking that the token lifetime defaulted to 24 hours. + val newTokObj = Json.decodeFromString<TokenSuccessResponse>(newTok.bodyAsText()) + val newTokDb = db.bearerTokenGet(Base32Crockford.decode(newTokObj.access_token)) + val lifeTime = newTokDb!!.expirationTime - newTokDb.creationTime + assert(Duration.ofHours(24).seconds * 1000000 == lifeTime) // foo tries on bar endpoint val r = client.post("/accounts/bar/token") { expectSuccess = false @@ -171,7 +176,7 @@ class LibeuFinApiTest { ) ) ) - // Testing the bearer-token:-scheme. + // Testing the secret-token:-scheme. client.post("/accounts/foo/token") { headers.set("Authorization", "Bearer secret-token:${Base32Crockford.encode(fooTok)}") contentType(ContentType.Application.Json)