Fix tests to compile #9

This commit is contained in:
Arun M 2018-04-25 12:06:10 +05:30
parent 32099f6691
commit d60dd2c926
18 changed files with 14 additions and 10 deletions

View file

@ -46,6 +46,7 @@ SOFTWARE.
#include "jwt/exceptions.hpp"
#include "jwt/string_view.hpp"
#include "jwt/error_codes.hpp"
#include "jwt/base64.hpp"
namespace jwt {

Binary file not shown.

Binary file not shown.

View file

@ -1,7 +1,7 @@
#include <stdio.h>
#include <openssl/evp.h>
#include <openssl/evp.h>
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
EVP_MD_CTX *mdctx;
const EVP_MD *md;

Binary file not shown.

Binary file not shown.

View file

@ -14,11 +14,14 @@ void basic_decode_test()
jp.add_claim("admin", true);
jwt::jwt_signature sgn{"secret"};
auto res = sgn.encode(hdr, jp);
std::error_code ec{};
auto res = sgn.encode(hdr, jp, ec);
std::cout << res << std::endl;
using namespace jwt::params;
std::cout << "DECODE: \n";
jwt::jwt_decode(res, "secret");
jwt::decode(res, algorithms({"none", "hs256"}), ec, verify(false), secret("secret"));
}
int main() {

Binary file not shown.

Binary file not shown.

View file

@ -45,7 +45,7 @@ void basic_jwt_object_test()
obj3.secret("secret");
obj3.header().algo("hs256");
auto dec_obj = jwt::decode(obj3.signature(), "secret", algorithms({"hs256"}));
auto dec_obj = jwt::decode(obj3.signature(), algorithms({"hs256"}), secret("secret"));
}
void jwt_object_pem_test()
@ -82,8 +82,7 @@ MIGkAgEBBDBeLCgapjZmvTatMHaYX3A02+0Ys3Tr8kda+E9DFnmCSiCOEig519fT
std::cout << "Get claim value for exp: " <<
obj.payload().get_claim_value<uint64_t>("exp") << std::endl;
sleep(4);
auto dec_obj = jwt::decode(obj.signature(), pub_key, algorithms({"es256"}));
auto dec_obj = jwt::decode(obj.signature(), algorithms({"es256"}), secret(pub_key));
std::cout << dec_obj.payload() << std::endl;
}

Binary file not shown.

Binary file not shown.

View file

@ -14,7 +14,8 @@ void basic_sign_test()
jp.add_claim("admin", true);
jwt::jwt_signature sgn{"secret"};
auto res = sgn.sign(hdr, jp);
std::error_code ec{};
auto res = sgn.encode(hdr, jp, ec);
std::cout << res << std::endl;
}

Binary file not shown.

Binary file not shown.

View file

@ -1,6 +1,6 @@
#include <iostream>
#include <vector>
#include "./stack_alloc.hpp"
#include "jwt/stack_alloc.hpp"
template <typename T, size_t SZ = 2>
using SmallVector = std::vector<T, jwt::stack_alloc<T, SZ, alignof(T)>>;

Binary file not shown.

View file

@ -2,7 +2,7 @@
#include <cassert>
#include <cstring>
#include <memory>
#include "./string_view.hpp"
#include "jwt/string_view.hpp"
using string_view = jwt::basic_string_view<char>;