Created
January 20, 2021 20:37
-
-
Save cdbattags/7dfab7ab6691359588df512bf1c0663c to your computer and use it in GitHub Desktop.
openresty json string comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test::Nginx::Socket::Lua; | |
repeat_each(2); | |
plan tests => repeat_each() * (3 * blocks()); | |
our $HttpConfig = <<'_EOC_'; | |
lua_package_path 'lib/?.lua;;'; | |
_EOC_ | |
no_long_string(); | |
run_tests(); | |
__DATA__ | |
=== TEST 1: Verify A256CBC-HS512 Direct Encryption with a Shared Symmetric Key | |
--- http_config eval: $::HttpConfig | |
--- config | |
location /t { | |
content_by_lua ' | |
local jwt = require "resty.jwt" | |
local cjson = require "cjson" | |
local shared_key = "12341234123412341234123412341234" .. | |
"12341234123412341234123412341234" | |
local jwt_obj = jwt:verify( | |
shared_key, | |
"eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIn0." .. | |
".M927Z_hNTmumFQE0rtRQCQ.nnd7AoE_2dgvws2-iay8qA.d" .. | |
"kyZuuks4Qm9Cd7VfEVSs07pi_Kyt0INVHTTesUC2BM" | |
) | |
ngx.say( | |
cjson.encode(jwt_obj) | |
) | |
'; | |
} | |
--- request | |
GET /t | |
--- response_body | |
{"reason":"everything is awesome~ :p","valid":true,"payload":{"foo":"bar"},"header":{"alg":"dir","enc":"A256CBC-HS512"},"verified":true} | |
--- no_error_log | |
[error] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment