Added documentation comments to jwt.hpp

This commit is contained in:
Arun M 2017-12-27 11:25:33 +05:30
parent a5e18cc4f4
commit 3d9e15b5c8
5 changed files with 310 additions and 44 deletions

View file

@ -1,8 +1,30 @@
#include <iostream>
#include <map>
#include <chrono>
#include "gtest/gtest.h"
#include "jwt/jwt.hpp"
TEST (EncodeTest, TestRemoveClaim)
{
using namespace jwt::params;
jwt::jwt_object obj{algorithm("hs256"), secret("secret")};
obj.add_claim("iss", "arun.muralidharan")
.add_claim("sub", "admin")
.add_claim("id", "a-b-c-d-e-f-1-2-3")
.add_claim("iat", 1513862371)
.add_claim("exp", std::chrono::system_clock::now());
EXPECT_TRUE (obj.has_claim(jwt::registered_claims::expiration));
obj.remove_claim("exp");
EXPECT_FALSE (obj.has_claim(jwt::registered_claims::expiration));
obj.remove_claim(jwt::registered_claims::subject);
EXPECT_FALSE (obj.has_claim("sub"));
}
TEST (EncodeTest, StrEncodeHS256_1)
{
using namespace jwt::params;