comparison spec/util_jwt_spec.lua @ 11200:bf8f2da84007

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 05 Nov 2020 22:31:25 +0100
parents 4eee1aaa9405
children 27a72982e331
comparison
equal deleted inserted replaced
11199:6c7c50a4de32 11200:bf8f2da84007
1 local jwt = require "util.jwt";
2
3 describe("util.jwt", function ()
4 it("validates", function ()
5 local key = "secret";
6 local token = jwt.sign(key, { payload = "this" });
7 assert.string(token);
8 local ok, parsed = jwt.verify(key, token);
9 assert.truthy(ok)
10 assert.same({ payload = "this" }, parsed);
11 end);
12 it("rejects invalid", function ()
13 local key = "secret";
14 local token = jwt.sign("wrong", { payload = "this" });
15 assert.string(token);
16 local ok = jwt.verify(key, token);
17 assert.falsy(ok)
18 end);
19 end);
20