diff options
Diffstat (limited to 'gentoobrowse-api/unittests/testUsers.cpp')
-rw-r--r-- | gentoobrowse-api/unittests/testUsers.cpp | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/gentoobrowse-api/unittests/testUsers.cpp b/gentoobrowse-api/unittests/testUsers.cpp index 7f9eaee..a894e95 100644 --- a/gentoobrowse-api/unittests/testUsers.cpp +++ b/gentoobrowse-api/unittests/testUsers.cpp @@ -54,24 +54,75 @@ BOOST_AUTO_TEST_CASE( create ) BOOST_REQUIRE_EQUAL("testuser", user->username); BOOST_REQUIRE_EQUAL("Test User", user->userrealname); BOOST_REQUIRE_EQUAL("test@user.com", user->useremail); - BOOST_REQUIRE(user->signedup.length() > 19); + BOOST_REQUIRE_GE(user->signedup.length(), 19); BOOST_REQUIRE(!user->lastmailshot); BOOST_REQUIRE_EQUAL(36, user->verifyguid.length()); - auto verified = u->verify(user->username, user->verifyguid); - BOOST_REQUIRE(verified); } BOOST_AUTO_TEST_CASE( get ) { - auto user = u->get(3); + auto user = u->get(1); + BOOST_REQUIRE(user); + 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_REQUIRE_EQUAL("2015-10-01T12:13:14", user->signedup); + BOOST_REQUIRE(!user->lastmailshot); +} + +BOOST_AUTO_TEST_CASE( getNotVerified ) +{ + // Is not verified, doesn't exist + BOOST_REQUIRE_THROW(u->get(3), Slicer::NoRowsReturned); +} + +BOOST_AUTO_TEST_CASE( getNew ) +{ + auto user = u->getNew("testuser", "testpass"); + BOOST_REQUIRE(user); BOOST_REQUIRE_EQUAL(3, user->userid); BOOST_REQUIRE_EQUAL("testuser", user->username); BOOST_REQUIRE_EQUAL("Test User", user->userrealname); BOOST_REQUIRE_EQUAL("test@user.com", user->useremail); - BOOST_REQUIRE(user->signedup.length() > 19); + BOOST_REQUIRE_GE(user->signedup.length(), 19); + BOOST_REQUIRE_EQUAL(36, user->verifyguid.length()); BOOST_REQUIRE(!user->lastmailshot); } +BOOST_AUTO_TEST_CASE( getNewVerified ) +{ + // Is verified, not new + BOOST_REQUIRE_THROW(u->getNew("randomdan", "p@55w0rd"), Slicer::NoRowsReturned); +} + +BOOST_AUTO_TEST_CASE( createAgain ) +{ + /* + * Should (unverified): + * * return original user + * * resend verification + */ + auto ms = getProxy<Gentoo::MockMailServerPrx>("mailserver"); + BOOST_REQUIRE(ms); + auto user = u->create("testuser", "testpass", "Test User", "recreate@user.com"); + BOOST_REQUIRE_EQUAL(2, ms->getSentEmails().size()); + BOOST_REQUIRE_EQUAL("Gentoo Browse: Welcome", ms->getSentEmails()[1]->subject); + BOOST_REQUIRE_EQUAL("test@user.com", ms->getSentEmails()[1]->to.address); + BOOST_REQUIRE_EQUAL(3, user->userid); + BOOST_REQUIRE_EQUAL(36, user->verifyguid.length()); +} + +BOOST_AUTO_TEST_CASE( verify ) +{ + auto user = u->getNew("testuser", "testpass"); + BOOST_REQUIRE(user); + auto verified = u->verify(user->username, user->verifyguid); + BOOST_REQUIRE(verified); + BOOST_REQUIRE_THROW(u->getNew("testuser", "testpass"), Slicer::NoRowsReturned); + BOOST_REQUIRE(u->get(3)); +} + BOOST_AUTO_TEST_CASE( sendmailshot ) { auto user = u->get(3); |