mirror of
https://github.com/allankoechke/jwt-cpp.git
synced 2026-11-30 10:18:40 +00:00
* Add error_code support to algorithm::verify * Add error_code support for signing * Add error_code overloads to verifying * Fix missing throw * Improvements * Remove unused throwing overloads * Fix test on older gtest * Found bug and added more testing * Move exceptions into error namespace
16 lines
723 B
C++
16 lines
723 B
C++
#include <gtest/gtest.h>
|
|
#include "jwt-cpp/jwt.h"
|
|
|
|
TEST(TokenFormatTest, MissingDot) {
|
|
ASSERT_THROW(jwt::decode("eyJhbGciOiJub25lIiwidHlwIjoiSldTIn0.eyJpc3MiOiJhdXRoMCJ9"), std::invalid_argument);
|
|
ASSERT_THROW(jwt::decode("eyJhbGciOiJub25lIiwidHlwIjoiSldTIn0eyJpc3MiOiJhdXRoMCJ9."), std::invalid_argument);
|
|
ASSERT_THROW(jwt::decode("eyJhbGciOiJub25lIiwidHlwIjoiSldTIn0eyJpc3MiOiJhdXRoMCJ9"), std::invalid_argument);
|
|
}
|
|
|
|
TEST(TokenFormatTest, InvalidChar) {
|
|
ASSERT_THROW(jwt::decode("eyJhbGciOiJub25lIiwidHlwIjoiSldTIn0().eyJpc3MiOiJhdXRoMCJ9."), std::runtime_error);
|
|
}
|
|
|
|
TEST(TokenFormatTest, InvalidJSON) {
|
|
ASSERT_THROW(jwt::decode("YXsiYWxnIjoibm9uZSIsInR5cCI6IkpXUyJ9YQ.eyJpc3MiOiJhdXRoMCJ9."), std::runtime_error);
|
|
} |