mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
#3549; replace assert with assertTrue
This commit is contained in:
parent
4ca3f5ca02
commit
c5b38f45fe
@ -42,7 +42,7 @@ void SerializerTest::testSerializeEmpty()
|
||||
{
|
||||
Poco::JSON::Object::Ptr pObject = new Poco::JSON::Object;
|
||||
std::string str = Serializer::serialize(*pObject);
|
||||
assert (str == "e30");
|
||||
assertTrue(str == "e30");
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ void SerializerTest::testSerializeAlgNone()
|
||||
Poco::JSON::Object::Ptr pObject = new Poco::JSON::Object;
|
||||
pObject->set("alg", std::string("none"));
|
||||
std::string str = Serializer::serialize(*pObject);
|
||||
assert (str == "eyJhbGciOiJub25lIn0");
|
||||
assertTrue(str == "eyJhbGciOiJub25lIn0");
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ void SerializerTest::testSerializeAlgHS256()
|
||||
pObject->set("alg", std::string("HS256"));
|
||||
pObject->set("typ", std::string("JWT"));
|
||||
std::string str = Serializer::serialize(*pObject);
|
||||
assert (str == "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9");
|
||||
assertTrue(str == "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9");
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ void SerializerTest::testDeserializeEmpty()
|
||||
{
|
||||
std::string serialized("e30");
|
||||
Poco::JSON::Object::Ptr pObject = Serializer::deserialize(serialized);
|
||||
assert (pObject->size() == 0);
|
||||
assertTrue(pObject->size() == 0);
|
||||
}
|
||||
|
||||
|
||||
@ -77,8 +77,8 @@ void SerializerTest::testDeserializeAlgNone()
|
||||
{
|
||||
std::string serialized("eyJhbGciOiJub25lIn0");
|
||||
Poco::JSON::Object::Ptr pObject = Serializer::deserialize(serialized);
|
||||
assert (pObject->size() == 1);
|
||||
assert (pObject->getValue<std::string>("alg") == "none");
|
||||
assertTrue(pObject->size() == 1);
|
||||
assertTrue(pObject->getValue<std::string>("alg") == "none");
|
||||
}
|
||||
|
||||
|
||||
@ -86,9 +86,9 @@ void SerializerTest::testDeserializeAlgHS256()
|
||||
{
|
||||
std::string serialized("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9");
|
||||
Poco::JSON::Object::Ptr pObject = Serializer::deserialize(serialized);
|
||||
assert (pObject->size() == 2);
|
||||
assert (pObject->getValue<std::string>("alg") == "HS256");
|
||||
assert (pObject->getValue<std::string>("typ") == "JWT");
|
||||
assertTrue(pObject->size() == 2);
|
||||
assertTrue(pObject->getValue<std::string>("alg") == "HS256");
|
||||
assertTrue(pObject->getValue<std::string>("typ") == "JWT");
|
||||
}
|
||||
|
||||
|
||||
@ -96,10 +96,10 @@ void SerializerTest::testSplit()
|
||||
{
|
||||
std::string jwt("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");
|
||||
std::vector<std::string> parts = Serializer::split(jwt);
|
||||
assert (parts.size() == 3);
|
||||
assert (parts[0] == "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9");
|
||||
assert (parts[1] == "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ");
|
||||
assert (parts[2] == "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");
|
||||
assertTrue(parts.size() == 3);
|
||||
assertTrue(parts[0] == "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9");
|
||||
assertTrue(parts[1] == "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ");
|
||||
assertTrue(parts[2] == "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");
|
||||
}
|
||||
|
||||
|
||||
@ -107,10 +107,10 @@ void SerializerTest::testSplitEmptySig()
|
||||
{
|
||||
std::string jwt("eyJhbGciOiJub25lIn0.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.");
|
||||
std::vector<std::string> parts = Serializer::split(jwt);
|
||||
assert (parts.size() == 3);
|
||||
assert (parts[0] == "eyJhbGciOiJub25lIn0");
|
||||
assert (parts[1] == "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ");
|
||||
assert (parts[2] == "");
|
||||
assertTrue(parts.size() == 3);
|
||||
assertTrue(parts[0] == "eyJhbGciOiJub25lIn0");
|
||||
assertTrue(parts[1] == "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ");
|
||||
assertTrue(parts[2] == "");
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/JWT/Signer.h"
|
||||
#include "Poco/JWT/JWTException.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace Poco::JWT;
|
||||
@ -111,7 +112,7 @@ void SignerTest::testSignHS256()
|
||||
Signer signer("0123456789ABCDEF0123456789ABCDEF");
|
||||
std::string jwt = signer.sign(token, Signer::ALGO_HS256);
|
||||
|
||||
assert (jwt == "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.qn9G7NwFEOjIh-7hfCUDZA1aJeQmf7I7YvzCBcdenGw");
|
||||
assertTrue(jwt == "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.qn9G7NwFEOjIh-7hfCUDZA1aJeQmf7I7YvzCBcdenGw");
|
||||
}
|
||||
|
||||
|
||||
@ -126,7 +127,7 @@ void SignerTest::testSignHS384()
|
||||
Signer signer("0123456789ABCDEF0123456789ABCDEF");
|
||||
std::string jwt = signer.sign(token, Signer::ALGO_HS384);
|
||||
|
||||
assert (jwt == "eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.9NsI7ahPhCd3itTewXb0GNZi08fuUHXLx0qeBscteMXJiug1PyQ_teA9v7zLgg1W");
|
||||
assertTrue(jwt == "eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.9NsI7ahPhCd3itTewXb0GNZi08fuUHXLx0qeBscteMXJiug1PyQ_teA9v7zLgg1W");
|
||||
}
|
||||
|
||||
|
||||
@ -141,7 +142,7 @@ void SignerTest::testSignHS512()
|
||||
Signer signer("0123456789ABCDEF0123456789ABCDEF");
|
||||
std::string jwt = signer.sign(token, Signer::ALGO_HS512);
|
||||
|
||||
assert (jwt == "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.WG4y8U_bDN4T3Vu3L5Q5C4pqssrH4wqBtdrFLVuS8k-BLycCq8_bjYGgo7BCzVt4DFXs3BFUIJQdWBzuJwXHtg");
|
||||
assertTrue(jwt == "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.WG4y8U_bDN4T3Vu3L5Q5C4pqssrH4wqBtdrFLVuS8k-BLycCq8_bjYGgo7BCzVt4DFXs3BFUIJQdWBzuJwXHtg");
|
||||
}
|
||||
|
||||
|
||||
@ -153,12 +154,12 @@ void SignerTest::testVerifyHS256()
|
||||
try
|
||||
{
|
||||
Token token = signer.verify(jwt);
|
||||
assert (token.getAlgorithm() == "HS256");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "qn9G7NwFEOjIh-7hfCUDZA1aJeQmf7I7YvzCBcdenGw");
|
||||
assertTrue(token.getAlgorithm() == "HS256");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "qn9G7NwFEOjIh-7hfCUDZA1aJeQmf7I7YvzCBcdenGw");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -176,12 +177,12 @@ void SignerTest::testVerifyHS384()
|
||||
try
|
||||
{
|
||||
Token token = signer.verify(jwt);
|
||||
assert (token.getAlgorithm() == "HS384");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "9NsI7ahPhCd3itTewXb0GNZi08fuUHXLx0qeBscteMXJiug1PyQ_teA9v7zLgg1W");
|
||||
assertTrue(token.getAlgorithm() == "HS384");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "9NsI7ahPhCd3itTewXb0GNZi08fuUHXLx0qeBscteMXJiug1PyQ_teA9v7zLgg1W");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -199,12 +200,12 @@ void SignerTest::testVerifyHS512()
|
||||
try
|
||||
{
|
||||
Token token = signer.verify(jwt);
|
||||
assert (token.getAlgorithm() == "HS512");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "WG4y8U_bDN4T3Vu3L5Q5C4pqssrH4wqBtdrFLVuS8k-BLycCq8_bjYGgo7BCzVt4DFXs3BFUIJQdWBzuJwXHtg");
|
||||
assertTrue(token.getAlgorithm() == "HS512");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "WG4y8U_bDN4T3Vu3L5Q5C4pqssrH4wqBtdrFLVuS8k-BLycCq8_bjYGgo7BCzVt4DFXs3BFUIJQdWBzuJwXHtg");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -259,7 +260,7 @@ void SignerTest::testSignRS256()
|
||||
Signer signer(pKey);
|
||||
std::string jwt = signer.sign(token, Signer::ALGO_RS256);
|
||||
|
||||
assert (jwt == "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.a27BSSEBTaQZFA1tVX4IZHgyG5HIXcJVZpbpB5LQ_rPTalJjvhDDuWC1dM0G0tUACrzPtUN4BhSd-dygJsX4b35DnWm_gPUNDI3HMm7Ck52mM_2Y6445B6aa_pPPuFk6AWql8WWLzQqo9kjQh8AmbMw2A9bciA1smEEsHVw4-VX1tEtupbhJsXO2FnwkQNhJF_Pp4nuX282UV_4DtZ9LW3jLoEYFytKrM4fhkNKVMY52Cn0DJA89fQYe7098gduCjzqoGtaoKKDngbADn2h_1P8VLZrZEd4UROEHviVLm_qxHrWY8-tB0L7i_JMXxw1qMKAavWA-WbnNDdXpOn_o2Q");
|
||||
assertTrue(jwt == "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.a27BSSEBTaQZFA1tVX4IZHgyG5HIXcJVZpbpB5LQ_rPTalJjvhDDuWC1dM0G0tUACrzPtUN4BhSd-dygJsX4b35DnWm_gPUNDI3HMm7Ck52mM_2Y6445B6aa_pPPuFk6AWql8WWLzQqo9kjQh8AmbMw2A9bciA1smEEsHVw4-VX1tEtupbhJsXO2FnwkQNhJF_Pp4nuX282UV_4DtZ9LW3jLoEYFytKrM4fhkNKVMY52Cn0DJA89fQYe7098gduCjzqoGtaoKKDngbADn2h_1P8VLZrZEd4UROEHviVLm_qxHrWY8-tB0L7i_JMXxw1qMKAavWA-WbnNDdXpOn_o2Q");
|
||||
}
|
||||
|
||||
|
||||
@ -277,7 +278,7 @@ void SignerTest::testSignRS384()
|
||||
Signer signer(pKey);
|
||||
std::string jwt = signer.sign(token, Signer::ALGO_RS384);
|
||||
|
||||
assert (jwt == "eyJhbGciOiJSUzM4NCIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.L-34N4v5kLa94Llz-XakGIwL9M00ERciAzZSqxgGIJ2dw9VrIodfK-U00wZZwSA2UEZWIm-LJ7wQBiuUw8oMl_fYsufT8W6dWiGZQ2c24AjGKwpXmypPKjh5yRnylkK-8ZRC1AJuZDsY8DJE7vse1w2eAE_Jw0XRJ-u_lq9Hgxz58ZonV1YzUdyVPtD3gWdhyjnlzPCH7lQM4copVUFN6mFTZzt4WQ2i1O1qW1cD_F4Jul9_5z5BYe7-bK3DoV79AgfbEewdnc4yatLQWMIAkrc2LM_tFe83ABhFYhM0qIH8nOuk3WKyKwtjh15f3h3Fn-JnriSfcC79v-M5UpEsZg");
|
||||
assertTrue(jwt == "eyJhbGciOiJSUzM4NCIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.L-34N4v5kLa94Llz-XakGIwL9M00ERciAzZSqxgGIJ2dw9VrIodfK-U00wZZwSA2UEZWIm-LJ7wQBiuUw8oMl_fYsufT8W6dWiGZQ2c24AjGKwpXmypPKjh5yRnylkK-8ZRC1AJuZDsY8DJE7vse1w2eAE_Jw0XRJ-u_lq9Hgxz58ZonV1YzUdyVPtD3gWdhyjnlzPCH7lQM4copVUFN6mFTZzt4WQ2i1O1qW1cD_F4Jul9_5z5BYe7-bK3DoV79AgfbEewdnc4yatLQWMIAkrc2LM_tFe83ABhFYhM0qIH8nOuk3WKyKwtjh15f3h3Fn-JnriSfcC79v-M5UpEsZg");
|
||||
}
|
||||
|
||||
|
||||
@ -295,7 +296,7 @@ void SignerTest::testSignRS512()
|
||||
Signer signer(pKey);
|
||||
std::string jwt = signer.sign(token, Signer::ALGO_RS512);
|
||||
|
||||
assert (jwt == "eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.XQTBYo2zqxcyUGs0H-74tfBY6l8PxBQK7-IAJ1NgEVIeoMDX3zQJu5BQX2_VhjOESOPqGNN-FtiNLD1G-LCvSV1fxJwIVEilT7CTBs5iNii6Jrpha5YPnzETqBiz1zdnyNh_QVbtdRIv2ORlp_OIYNZJrxiRfOGvm2_Z3htDoqgv_Lm8SZqelOntox96GrV6GaXhpKBbLjBSU-XPkSOcm5VuXDCz8tltJ_d5cKxbFDUtS6FBYNMaLEqIL4-_aJU_Ld5TcPQT7MqWlHHZZufA5zzmfKEEgddco6uzCBLOz3B6E4Z5VZDoweCM5R7hnLiZOlK0kYsFoaDCVcK_TZhDNw");
|
||||
assertTrue(jwt == "eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.XQTBYo2zqxcyUGs0H-74tfBY6l8PxBQK7-IAJ1NgEVIeoMDX3zQJu5BQX2_VhjOESOPqGNN-FtiNLD1G-LCvSV1fxJwIVEilT7CTBs5iNii6Jrpha5YPnzETqBiz1zdnyNh_QVbtdRIv2ORlp_OIYNZJrxiRfOGvm2_Z3htDoqgv_Lm8SZqelOntox96GrV6GaXhpKBbLjBSU-XPkSOcm5VuXDCz8tltJ_d5cKxbFDUtS6FBYNMaLEqIL4-_aJU_Ld5TcPQT7MqWlHHZZufA5zzmfKEEgddco6uzCBLOz3B6E4Z5VZDoweCM5R7hnLiZOlK0kYsFoaDCVcK_TZhDNw");
|
||||
}
|
||||
|
||||
|
||||
@ -311,12 +312,12 @@ void SignerTest::testVerifyRS256()
|
||||
try
|
||||
{
|
||||
Token token = signer.verify(jwt);
|
||||
assert (token.getAlgorithm() == "RS256");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "a27BSSEBTaQZFA1tVX4IZHgyG5HIXcJVZpbpB5LQ_rPTalJjvhDDuWC1dM0G0tUACrzPtUN4BhSd-dygJsX4b35DnWm_gPUNDI3HMm7Ck52mM_2Y6445B6aa_pPPuFk6AWql8WWLzQqo9kjQh8AmbMw2A9bciA1smEEsHVw4-VX1tEtupbhJsXO2FnwkQNhJF_Pp4nuX282UV_4DtZ9LW3jLoEYFytKrM4fhkNKVMY52Cn0DJA89fQYe7098gduCjzqoGtaoKKDngbADn2h_1P8VLZrZEd4UROEHviVLm_qxHrWY8-tB0L7i_JMXxw1qMKAavWA-WbnNDdXpOn_o2Q");
|
||||
assertTrue(token.getAlgorithm() == "RS256");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "a27BSSEBTaQZFA1tVX4IZHgyG5HIXcJVZpbpB5LQ_rPTalJjvhDDuWC1dM0G0tUACrzPtUN4BhSd-dygJsX4b35DnWm_gPUNDI3HMm7Ck52mM_2Y6445B6aa_pPPuFk6AWql8WWLzQqo9kjQh8AmbMw2A9bciA1smEEsHVw4-VX1tEtupbhJsXO2FnwkQNhJF_Pp4nuX282UV_4DtZ9LW3jLoEYFytKrM4fhkNKVMY52Cn0DJA89fQYe7098gduCjzqoGtaoKKDngbADn2h_1P8VLZrZEd4UROEHviVLm_qxHrWY8-tB0L7i_JMXxw1qMKAavWA-WbnNDdXpOn_o2Q");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -337,12 +338,12 @@ void SignerTest::testVerifyRS384()
|
||||
try
|
||||
{
|
||||
Token token = signer.verify(jwt);
|
||||
assert (token.getAlgorithm() == "RS384");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "L-34N4v5kLa94Llz-XakGIwL9M00ERciAzZSqxgGIJ2dw9VrIodfK-U00wZZwSA2UEZWIm-LJ7wQBiuUw8oMl_fYsufT8W6dWiGZQ2c24AjGKwpXmypPKjh5yRnylkK-8ZRC1AJuZDsY8DJE7vse1w2eAE_Jw0XRJ-u_lq9Hgxz58ZonV1YzUdyVPtD3gWdhyjnlzPCH7lQM4copVUFN6mFTZzt4WQ2i1O1qW1cD_F4Jul9_5z5BYe7-bK3DoV79AgfbEewdnc4yatLQWMIAkrc2LM_tFe83ABhFYhM0qIH8nOuk3WKyKwtjh15f3h3Fn-JnriSfcC79v-M5UpEsZg");
|
||||
assertTrue(token.getAlgorithm() == "RS384");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "L-34N4v5kLa94Llz-XakGIwL9M00ERciAzZSqxgGIJ2dw9VrIodfK-U00wZZwSA2UEZWIm-LJ7wQBiuUw8oMl_fYsufT8W6dWiGZQ2c24AjGKwpXmypPKjh5yRnylkK-8ZRC1AJuZDsY8DJE7vse1w2eAE_Jw0XRJ-u_lq9Hgxz58ZonV1YzUdyVPtD3gWdhyjnlzPCH7lQM4copVUFN6mFTZzt4WQ2i1O1qW1cD_F4Jul9_5z5BYe7-bK3DoV79AgfbEewdnc4yatLQWMIAkrc2LM_tFe83ABhFYhM0qIH8nOuk3WKyKwtjh15f3h3Fn-JnriSfcC79v-M5UpEsZg");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -363,12 +364,12 @@ void SignerTest::testVerifyRS512()
|
||||
try
|
||||
{
|
||||
Token token = signer.verify(jwt);
|
||||
assert (token.getAlgorithm() == "RS512");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "XQTBYo2zqxcyUGs0H-74tfBY6l8PxBQK7-IAJ1NgEVIeoMDX3zQJu5BQX2_VhjOESOPqGNN-FtiNLD1G-LCvSV1fxJwIVEilT7CTBs5iNii6Jrpha5YPnzETqBiz1zdnyNh_QVbtdRIv2ORlp_OIYNZJrxiRfOGvm2_Z3htDoqgv_Lm8SZqelOntox96GrV6GaXhpKBbLjBSU-XPkSOcm5VuXDCz8tltJ_d5cKxbFDUtS6FBYNMaLEqIL4-_aJU_Ld5TcPQT7MqWlHHZZufA5zzmfKEEgddco6uzCBLOz3B6E4Z5VZDoweCM5R7hnLiZOlK0kYsFoaDCVcK_TZhDNw");
|
||||
assertTrue(token.getAlgorithm() == "RS512");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "XQTBYo2zqxcyUGs0H-74tfBY6l8PxBQK7-IAJ1NgEVIeoMDX3zQJu5BQX2_VhjOESOPqGNN-FtiNLD1G-LCvSV1fxJwIVEilT7CTBs5iNii6Jrpha5YPnzETqBiz1zdnyNh_QVbtdRIv2ORlp_OIYNZJrxiRfOGvm2_Z3htDoqgv_Lm8SZqelOntox96GrV6GaXhpKBbLjBSU-XPkSOcm5VuXDCz8tltJ_d5cKxbFDUtS6FBYNMaLEqIL4-_aJU_Ld5TcPQT7MqWlHHZZufA5zzmfKEEgddco6uzCBLOz3B6E4Z5VZDoweCM5R7hnLiZOlK0kYsFoaDCVcK_TZhDNw");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -402,11 +403,11 @@ void SignerTest::testSignVerifyES256()
|
||||
try
|
||||
{
|
||||
Token token2 = verifier.verify(jwt);
|
||||
assert (token2.getAlgorithm() == "ES256");
|
||||
assert (token2.getType() == "JWT");
|
||||
assert (token2.getSubject() == "1234567890");
|
||||
assert (token2.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token2.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token2.getAlgorithm() == "ES256");
|
||||
assertTrue(token2.getType() == "JWT");
|
||||
assertTrue(token2.getSubject() == "1234567890");
|
||||
assertTrue(token2.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token2.payload().getValue<std::string>("name") == "John Doe");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -427,12 +428,12 @@ void SignerTest::testVerifyES256()
|
||||
try
|
||||
{
|
||||
Token token = signer.verify(jwt);
|
||||
assert (token.getAlgorithm() == "ES256");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "kLfRdCmR-qewMgzhCtqJrXVoagoh7es0yWsn3VunuS51FMBBcxLTKRDfdgHih0os4gvBdLMYkJu61_IQqoIYZw");
|
||||
assertTrue(token.getAlgorithm() == "ES256");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "kLfRdCmR-qewMgzhCtqJrXVoagoh7es0yWsn3VunuS51FMBBcxLTKRDfdgHih0os4gvBdLMYkJu61_IQqoIYZw");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -466,11 +467,11 @@ void SignerTest::testSignVerifyES384()
|
||||
try
|
||||
{
|
||||
Token token2 = verifier.verify(jwt);
|
||||
assert (token2.getAlgorithm() == "ES384");
|
||||
assert (token2.getType() == "JWT");
|
||||
assert (token2.getSubject() == "1234567890");
|
||||
assert (token2.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token2.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token2.getAlgorithm() == "ES384");
|
||||
assertTrue(token2.getType() == "JWT");
|
||||
assertTrue(token2.getSubject() == "1234567890");
|
||||
assertTrue(token2.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token2.payload().getValue<std::string>("name") == "John Doe");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -491,12 +492,12 @@ void SignerTest::testVerifyES384()
|
||||
try
|
||||
{
|
||||
Token token = signer.verify(jwt);
|
||||
assert (token.getAlgorithm() == "ES384");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "kLfRdCmR-qewMgzhCtqJrXVoagoh7es0yWsn3VunuS51FMBBcxLTKRDfdgHih0os4gvBdLMYkJu61_IQqoIYZw");
|
||||
assertTrue(token.getAlgorithm() == "ES384");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "ROGmzbopY2GfjSUKih4MmgZ5_1jLQdEc2db3ITYCDOZSHzeGM_14KtY-61qvx4BXxmeUiXfoInPZWlA75VL6dA");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -530,11 +531,11 @@ void SignerTest::testSignVerifyES512()
|
||||
try
|
||||
{
|
||||
Token token2 = verifier.verify(jwt);
|
||||
assert (token2.getAlgorithm() == "ES512");
|
||||
assert (token2.getType() == "JWT");
|
||||
assert (token2.getSubject() == "1234567890");
|
||||
assert (token2.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token2.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token2.getAlgorithm() == "ES512");
|
||||
assertTrue(token2.getType() == "JWT");
|
||||
assertTrue(token2.getSubject() == "1234567890");
|
||||
assertTrue(token2.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token2.payload().getValue<std::string>("name") == "John Doe");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
@ -555,12 +556,12 @@ void SignerTest::testVerifyES512()
|
||||
try
|
||||
{
|
||||
Token token = signer.verify(jwt);
|
||||
assert (token.getAlgorithm() == "ES512");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "kLfRdCmR-qewMgzhCtqJrXVoagoh7es0yWsn3VunuS51FMBBcxLTKRDfdgHih0os4gvBdLMYkJu61_IQqoIYZw");
|
||||
assertTrue(token.getAlgorithm() == "ES512");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "8AYb9WDk3x2U-69Hi2DHou06L8VavXJlMqyH8dF-uiekm926CNM7D3pkgnWD6e_OfV_p2XIkdfIV018PjZtfuA");
|
||||
}
|
||||
catch (JWTException&)
|
||||
{
|
||||
|
@ -43,12 +43,12 @@ void TokenTest::testParse()
|
||||
std::string jwt("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");
|
||||
|
||||
Token token(jwt);
|
||||
assert (token.getAlgorithm() == "HS256");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");
|
||||
assertTrue(token.getAlgorithm() == "HS256");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");
|
||||
}
|
||||
|
||||
|
||||
@ -57,12 +57,12 @@ void TokenTest::testParseNoSig()
|
||||
std::string jwt("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.");
|
||||
|
||||
Token token(jwt);
|
||||
assert (token.getAlgorithm() == "HS256");
|
||||
assert (token.getType() == "JWT");
|
||||
assert (token.getSubject() == "1234567890");
|
||||
assert (token.getIssuedAt().epochTime() == 1516239022);
|
||||
assert (token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assert (token.signature() == "");
|
||||
assertTrue(token.getAlgorithm() == "HS256");
|
||||
assertTrue(token.getType() == "JWT");
|
||||
assertTrue(token.getSubject() == "1234567890");
|
||||
assertTrue(token.getIssuedAt().epochTime() == 1516239022);
|
||||
assertTrue(token.payload().getValue<std::string>("name") == "John Doe");
|
||||
assertTrue(token.signature() == "");
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ void TokenTest::testSerialize()
|
||||
token.setIssuedAt(Poco::Timestamp::fromEpochTime(1516239022));
|
||||
|
||||
std::string jwt = token.toString();
|
||||
assert (jwt == "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.");
|
||||
assertTrue(jwt == "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjIsIm5hbWUiOiJKb2huIERvZSIsInN1YiI6IjEyMzQ1Njc4OTAifQ.");
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ void TokenTest::testAssign()
|
||||
Token token(jwt);
|
||||
Token token2(token);
|
||||
|
||||
assert (token.toString() == token2.toString());
|
||||
assertTrue(token.toString() == token2.toString());
|
||||
}
|
||||
|
||||
|
||||
@ -96,20 +96,20 @@ void TokenTest::testAudience()
|
||||
Token token;
|
||||
|
||||
token.setAudience("11111");
|
||||
assert (token.payload().getValue<std::string>(Token::CLAIM_AUDIENCE) == "11111");
|
||||
assertTrue(token.payload().getValue<std::string>(Token::CLAIM_AUDIENCE) == "11111");
|
||||
|
||||
std::vector<std::string> audience = token.getAudience();
|
||||
assert (audience.size() == 1);
|
||||
assert (audience[0] == "11111");
|
||||
assertTrue(audience.size() == 1);
|
||||
assertTrue(audience[0] == "11111");
|
||||
|
||||
audience.push_back("22222");
|
||||
token.setAudience(audience);
|
||||
|
||||
assert (token.payload().isArray(Token::CLAIM_AUDIENCE));
|
||||
assertTrue(token.payload().isArray(Token::CLAIM_AUDIENCE));
|
||||
audience = token.getAudience();
|
||||
assert (audience.size() == 2);
|
||||
assert (audience[0] == "11111");
|
||||
assert (audience[1] == "22222");
|
||||
assertTrue(audience.size() == 2);
|
||||
assertTrue(audience[0] == "11111");
|
||||
assertTrue(audience[1] == "22222");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user