account_archive: add test to validate changeAccountPassword

Change-Id: I7380645f022b1b08d2a961e191c3dd978916fe0e
This commit is contained in:
Sébastien Blin
2022-01-05 16:37:36 -05:00
parent 7c73d69c7e
commit 523b2780bf

View File

@ -73,6 +73,7 @@ private:
void testExportImportPasswordDoubleGunzip();
void testExportDht();
void testExportDhtWrongPassword();
void testChangePassword();
CPPUNIT_TEST_SUITE(AccountArchiveTest);
CPPUNIT_TEST(testExportImportNoPassword);
@ -81,6 +82,7 @@ private:
CPPUNIT_TEST(testExportImportPasswordDoubleGunzip);
CPPUNIT_TEST(testExportDht);
CPPUNIT_TEST(testExportDhtWrongPassword);
CPPUNIT_TEST(testChangePassword);
CPPUNIT_TEST_SUITE_END();
};
@ -230,6 +232,19 @@ AccountArchiveTest::testExportDhtWrongPassword()
CPPUNIT_ASSERT(cv.wait_for(lk, std::chrono::seconds(10), [&] { return status == 1; }));
}
void
AccountArchiveTest::testChangePassword()
{
// Test wrong password, should fail
CPPUNIT_ASSERT(!DRing::changeAccountPassword(aliceId, "wrong", "new"));
// Test correct password, should succeed
CPPUNIT_ASSERT(DRing::changeAccountPassword(aliceId, "", "new"));
// Now it should fail
CPPUNIT_ASSERT(!DRing::changeAccountPassword(aliceId, "", "new"));
// Remove password again (should succeed)
CPPUNIT_ASSERT(DRing::changeAccountPassword(aliceId, "new", ""));
}
} // namespace test
} // namespace jami