mirror of
https://github.com/arun11299/cpp-jwt.git
synced 2025-05-15 01:08:31 +00:00
Added signature validation test
This commit is contained in:
parent
cb1847142e
commit
204092e588
6 changed files with 75 additions and 2 deletions
23
tests/test_jwt_decode.cc
Normal file
23
tests/test_jwt_decode.cc
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <iostream>
|
||||
#include "gtest/gtest.h"
|
||||
#include "jwt/jwt.hpp"
|
||||
|
||||
TEST (DecodeTest, InvalidFinalDotForNoneAlg)
|
||||
{
|
||||
using namespace jwt::params;
|
||||
const char* inv_enc_str =
|
||||
"eyJhbGciOiJOT05FIiwidHlwIjoiSldUIn0.eyJhdWQiOiJyaWZ0LmlvIiwiZXhwIjoxNTEzODYzMzcxLCJzdWIiOiJub3RoaW5nIG11Y2gifQ";
|
||||
|
||||
std::error_code ec;
|
||||
auto obj = jwt::decode(inv_enc_str, "", algorithms({"none", "hs256"}), ec);
|
||||
|
||||
ASSERT_TRUE (ec);
|
||||
EXPECT_EQ (ec.value(), static_cast<int>(jwt::DecodeErrc::SignatureFormatError));
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue