-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2sar_lbcp_test.cpp
72 lines (52 loc) · 1.82 KB
/
e2sar_lbcp_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#define BOOST_TEST_MODULE CPUnitTests
#include <stdlib.h>
#include <fstream>
#include <iostream>
#include <filesystem>
#include <boost/asio.hpp>
#include <boost/test/included/unit_test.hpp>
#include "e2sar.hpp"
using namespace e2sar;
std::string uri_string1{"ejfat://[email protected]:18020/lb/36?sync=192.188.29.6:19020&data=192.188.29.20"};
BOOST_AUTO_TEST_SUITE(CPUnitTestSuite)
BOOST_AUTO_TEST_CASE(LBMTest1)
{
// test generating ssl options
std::string root{"root cert"}, priv{"priv key"}, cert{"cert chain"};
std::cout << root << "|" << priv << "|" << cert << std::endl;
result<grpc::SslCredentialsOptions> opts{LBManager::makeSslOptions(root, priv, cert)};
BOOST_TEST(!opts.has_error());
std::cout << root << "|" << priv << "|" << cert << std::endl;
BOOST_TEST(opts.value().pem_root_certs == "root cert"s);
BOOST_TEST(opts.value().pem_private_key == "priv key"s);
BOOST_TEST(opts.value().pem_cert_chain == "cert chain"s);
}
BOOST_AUTO_TEST_CASE(LBMTest2)
{
// test generating ssl options from files
std::string rootn{"/tmp/root.pem"};
std::ofstream rootf{rootn};
rootf << "root cert";
rootf.close();
std::string privn{"/tmp/priv.pem"};
std::ofstream privf{privn};
privf << "priv key";
privf.close();
std::string certn{"/tmp/cert.pem"};
std::ofstream certf{certn};
certf << "cert chain";
certf.close();
result<grpc::SslCredentialsOptions> opts{LBManager::makeSslOptionsFromFiles(rootn, privn, certn)};
if (opts.has_error())
std::cout << opts.error().msg << std::endl;
BOOST_TEST(!opts.has_error());
std::filesystem::remove(rootn);
std::filesystem::remove(privn);
std::filesystem::remove(certn);
}
BOOST_AUTO_TEST_CASE(LBMTest3)
{
EjfatURI uri(uri_string1);
LBManager lbm(uri);
}
BOOST_AUTO_TEST_SUITE_END()