mirror of
https://github.com/arun11299/cpp-jwt.git
synced 2025-05-15 01:08:31 +00:00
Fix string view overload for claim value
This commit is contained in:
parent
98ea0d6e58
commit
f8eebbede0
3 changed files with 35 additions and 1 deletions
|
@ -155,6 +155,31 @@ TEST (EncodeTest, StrEncodeHS512WithKey)
|
|||
EXPECT_EQ (enc_str, expected_sign);
|
||||
}
|
||||
|
||||
TEST (EncodeTest, StrEncodeChangeAlg)
|
||||
{
|
||||
using namespace jwt::params;
|
||||
|
||||
const char* expected_none_sign =
|
||||
"eyJhbGciOiJOT05FIiwidHlwIjoiSldUIn0.eyJhdWQiOiJyaWZ0LmlvIiwiZXhwIjoxNTEzODYzMzcxLCJzdWIiOiJub3RoaW5nIG11Y2gifQ.";
|
||||
|
||||
jwt::string_view key = "00112233445566778899";
|
||||
|
||||
std::map<std::string, jwt::string_view> p;
|
||||
p["aud"] = "rift.io";
|
||||
p["sub"] = "nothing much";
|
||||
|
||||
jwt::jwt_object obj{algorithm(jwt::algorithm::HS512),
|
||||
secret(key),
|
||||
payload(std::move(p))
|
||||
};
|
||||
obj.add_claim("exp", 1513863371);
|
||||
|
||||
obj.header().algo("none");
|
||||
std::string enc_str = obj.signature();
|
||||
|
||||
EXPECT_EQ (expected_none_sign, enc_str);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue