Skip to content

Commit

Permalink
Fix Base64Url decoding of JWT in tests
Browse files Browse the repository at this point in the history
The mime module expects padded Base64 value, so add missing padding.

Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
  • Loading branch information
oldium committed Dec 29, 2023
1 parent 1553a39 commit a83609b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/spec/token_request_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ local function extract_jwt_from_error_log()
local enc_hdr, enc_payload, enc_sign = string.match(encoded_jwt, '^(.+)%.(.+)%.(.*)$')
local base64_url_decode = function(s)
local mime = require "mime"
return mime.unb64(s:gsub('-','+'):gsub('_','/'))
local padding = (4 - #s % 4) % 4
return mime.unb64(s:gsub('-','+'):gsub('_','/') .. string.rep("=", padding))
end
local dkjson = require "dkjson"
return {
Expand Down

0 comments on commit a83609b

Please sign in to comment.