Fix string view overload for claim value

This commit is contained in:
Arun M 2017-12-25 12:42:38 +05:30
parent 98ea0d6e58
commit f8eebbede0
3 changed files with 35 additions and 1 deletions

View file

@ -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);