Software /
code /
prosody
Comparison
spec/util_jwt_spec.lua @ 11120:b2331f3dfeea
Merge 0.11->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 30 Sep 2020 09:50:33 +0100 |
parent | 10661:4eee1aaa9405 |
child | 12696:27a72982e331 |
comparison
equal
deleted
inserted
replaced
11119:68df52bf08d5 | 11120:b2331f3dfeea |
---|---|
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 |