mirror of
https://github.com/allankoechke/jwt-cpp.git
synced 2026-11-30 10:18:40 +00:00
adding tests to cmake
This commit is contained in:
@@ -29,3 +29,5 @@ set(JWT_HEADERS
|
||||
${JWT_INCLUDE_PATH}/jwt-cpp/jwt.h)
|
||||
|
||||
install(FILES ${JWT_HEADERS} DESTINATION include/jwt-cpp)
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "include/jwt-cpp/base.h"
|
||||
#include "jwt-cpp/base.h"
|
||||
|
||||
TEST(BaseTest, Base64Decode) {
|
||||
ASSERT_EQ("1", jwt::base::decode<jwt::alphabet::base64>("MQ=="));
|
||||
|
||||
18
tests/CMakeLists.txt
Normal file
18
tests/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
enable_testing()
|
||||
|
||||
find_package(GTest CONFIG REQUIRED)
|
||||
|
||||
set(TEST_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BaseTest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ClaimTest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/HelperTest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestMain.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TokenFormatTest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TokenTest.cpp
|
||||
)
|
||||
|
||||
add_executable(jwt-cpp-test ${TEST_SOURCES})
|
||||
|
||||
target_link_libraries(jwt-cpp-test PRIVATE jwt-cpp GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
|
||||
|
||||
add_test(AllTests jwt-cpp-test)
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "include/jwt-cpp/jwt.h"
|
||||
#include "jwt-cpp/jwt.h"
|
||||
|
||||
TEST(ClaimTest, AudienceAsString) {
|
||||
std::string token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZXN0In0.WZnM3SIiSRHsbO3O7Z2bmIzTJ4EC32HRBKfLznHhrh4";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "include/jwt-cpp/jwt.h"
|
||||
#include "jwt-cpp/jwt.h"
|
||||
|
||||
namespace {
|
||||
extern std::string google_cert;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "include/jwt-cpp/jwt.h"
|
||||
#include "jwt-cpp/jwt.h"
|
||||
|
||||
TEST(TokenFormatTest, MissingDot) {
|
||||
ASSERT_THROW(jwt::decode("eyJhbGciOiJub25lIiwidHlwIjoiSldTIn0.eyJpc3MiOiJhdXRoMCJ9"), std::invalid_argument);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "include/jwt-cpp/jwt.h"
|
||||
#include "jwt-cpp/jwt.h"
|
||||
|
||||
namespace {
|
||||
extern std::string rsa_priv_key;
|
||||
|
||||
Reference in New Issue
Block a user