MCPcopy Create free account
hub / github.com/Thalhammer/jwt-cpp / TEST

Function TEST

tests/ClaimTest.cpp:4–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include <gtest/gtest.h>
3
4TEST(ClaimTest, AudienceAsString) {
5 std::string const token =
6 "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZXN0In0.WZnM3SIiSRHsbO3O7Z2bmIzTJ4EC32HRBKfLznHhrh4";
7 auto decoded = jwt::decode(token);
8
9 ASSERT_TRUE(decoded.has_algorithm());
10 ASSERT_TRUE(decoded.has_type());
11 ASSERT_FALSE(decoded.has_content_type());
12 ASSERT_FALSE(decoded.has_key_id());
13 ASSERT_FALSE(decoded.has_issuer());
14 ASSERT_FALSE(decoded.has_subject());
15 ASSERT_TRUE(decoded.has_audience());
16 ASSERT_FALSE(decoded.has_expires_at());
17 ASSERT_FALSE(decoded.has_not_before());
18 ASSERT_FALSE(decoded.has_issued_at());
19 ASSERT_FALSE(decoded.has_id());
20
21 ASSERT_EQ("HS256", decoded.get_algorithm());
22 ASSERT_EQ("JWT", decoded.get_type());
23 auto aud = decoded.get_audience();
24 ASSERT_EQ(1, aud.size());
25 ASSERT_EQ("test", *aud.begin());
26}
27
28TEST(ClaimTest, SetAudienceAsString) {
29 auto token = jwt::create().set_type("JWT").set_audience("test").sign(jwt::algorithm::hs256("test"));

Callers

nothing calls this directly

Calls 15

hs256Class · 0.85
valueClass · 0.85
has_typeMethod · 0.80
has_content_typeMethod · 0.80
has_issuerMethod · 0.80
has_subjectMethod · 0.80
has_audienceMethod · 0.80
has_expires_atMethod · 0.80
has_not_beforeMethod · 0.80
has_issued_atMethod · 0.80
has_idMethod · 0.80
get_audienceMethod · 0.80

Tested by

no test coverage detected