diff options
Diffstat (limited to 'gentoobrowse-api/unittests/testUsers.cpp')
-rw-r--r-- | gentoobrowse-api/unittests/testUsers.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gentoobrowse-api/unittests/testUsers.cpp b/gentoobrowse-api/unittests/testUsers.cpp new file mode 100644 index 0000000..93c8fdd --- /dev/null +++ b/gentoobrowse-api/unittests/testUsers.cpp @@ -0,0 +1,45 @@ +#define BOOST_TEST_MODULE TestUsers +#include <boost/test/unit_test.hpp> + +#include "mockDefs.h" + +BOOST_GLOBAL_FIXTURE( Service ); + +BOOST_FIXTURE_TEST_SUITE(tp, TestClient) + +BOOST_AUTO_TEST_CASE( authenticateGood ) +{ + auto user = u->authenticate("randomdan", "p@55w0rd"); + BOOST_REQUIRE_EQUAL(1, user->userid); + BOOST_REQUIRE_EQUAL("randomdan", user->username); + BOOST_REQUIRE_EQUAL("Dan Goodliffe", user->userrealname); + BOOST_REQUIRE_EQUAL("dan@randomdan.homeip.net", user->useremail); +} + +BOOST_AUTO_TEST_CASE( authenticateBad ) +{ + BOOST_REQUIRE_THROW(u->authenticate("bad", "login"), Slicer::NoRowsReturned); +} + +BOOST_AUTO_TEST_CASE( authenticateUnverified ) +{ + BOOST_REQUIRE_THROW(u->authenticate("unverified", "p@55w0rd"), Slicer::NoRowsReturned); +} + +BOOST_AUTO_TEST_CASE( authenticateVerifyBad ) +{ + BOOST_REQUIRE_THROW(u->verify("unverified", "c2075a2e-8a45-11e6-bb50-c86000a60e12"), Slicer::NoRowsReturned); +} + +BOOST_AUTO_TEST_CASE( authenticateVerify ) +{ + auto verified = u->verify("unverified", "a24eb4fa-8a42-11e6-a04e-c86000a60e12"); + BOOST_REQUIRE(verified); + auto user = u->authenticate("unverified", "p@55w0rd"); + BOOST_REQUIRE(user); + BOOST_REQUIRE_EQUAL(verified->userid, user->userid); + BOOST_REQUIRE_THROW(u->verify("unverified", "a24eb4fa-8a42-11e6-a04e-c86000a60e12"), Slicer::NoRowsReturned); +} + +BOOST_AUTO_TEST_SUITE_END() + |