Remove case insensitive compare for has_claim API

This commit is contained in:
Arun M 2017-12-28 16:39:49 +05:30
parent 4a4217a9f4
commit e813a75e27
5 changed files with 8 additions and 6 deletions

View file

@ -563,7 +563,7 @@ public: // Exposed APIs
/**
* Checks whether a claim is present in the payload
* or not.
* @note: Claim name is case insensitive for this API.
* @note: Claim name is case sensitive for this API.
*/
//TODO: Not all libc++ version agrees with this
//because count() is not made const for is_transparent
@ -659,25 +659,25 @@ private:
bool operator()(const std::string& lhs, const std::string& rhs) const
{
int ret = strcasecmp(lhs.c_str(), rhs.c_str());
int ret = strcmp(lhs.c_str(), rhs.c_str());
return (ret < 0);
}
bool operator()(const jwt::string_view lhs, const jwt::string_view rhs) const
{
int ret = strcasecmp(lhs.data(), rhs.data());
int ret = strcmp(lhs.data(), rhs.data());
return (ret < 0);
}
bool operator()(const std::string& lhs, const jwt::string_view rhs) const
{
int ret = strcasecmp(lhs.data(), rhs.data());
int ret = strcmp(lhs.data(), rhs.data());
return (ret < 0);
}
bool operator()(const jwt::string_view lhs, const std::string& rhs) const
{
int ret = strcasecmp(lhs.data(), rhs.data());
int ret = strcmp(lhs.data(), rhs.data());
return (ret < 0);
}
};

Binary file not shown.

View file

@ -93,7 +93,9 @@ TEST (DecodeTest, DecodeHS256)
EXPECT_TRUE (obj.has_claim("iss"));
EXPECT_TRUE (obj.payload().has_claim_with_value("iss", "arun.muralidharan"));
EXPECT_TRUE (obj.has_claim("IAT"));
//Case sensitive search
EXPECT_FALSE (obj.has_claim("IAT"));
EXPECT_TRUE (obj.payload().has_claim_with_value(jwt::registered_claims::issued_at, 1513862371));
EXPECT_FALSE (obj.payload().has_claim_with_value(jwt::registered_claims::issued_at, 1513862372));

Binary file not shown.