summaryrefslogtreecommitdiffhomepage
path: root/tests/test-auth.cpp
blob: 8397b351f53bd697dc3c69def69d41069863597b (plain)
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
#include <boost/test/unit_test.hpp>
#include <boost/test/data/dataset.hpp>
#include <boost/test/data/monomorphic.hpp>
#include <boost/test/data/test_case.hpp>

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

#include <sstream>
#include <string>

#include "auth.h"

using namespace std::string_literals;

class AuthFixture
{
public:
 AuthFixture(){}
 ~AuthFixture(){}
 void setup(){}
 void teardown(){}
};

BOOST_FIXTURE_TEST_CASE(generate, AuthFixture)
{
 std::string pw0 {Auth::generate("")};
 BOOST_CHECK_GT(pw0.size(), 0);
 std::string pw1 {Auth::generate("abc")};
 BOOST_CHECK_GT(pw1.size(), 0);

 BOOST_CHECK_NE(pw0, pw1);
}

BOOST_FIXTURE_TEST_CASE(validate, AuthFixture)
{
 BOOST_CHECK(Auth::validate("t5MMkLQXzYkdw", "abc"));

 BOOST_CHECK(!Auth::validate("abc", "abc"));
 BOOST_CHECK(!Auth::validate("t5MNkLQXzYkdw", "abc"));
}