mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
jamiaccount: check if uri is valid before adding contact
Else, if a client calls addContact with an invalid uri, it will create a conversation with an invalid contact and the client will be in a bugguy state. git.jami.net/savoirfairelinux/jami-client-android/-/issues/1681 Change-Id: Id6227c45c279c78aac0a191b6ae688ebe0d3d1c4
This commit is contained in:
@ -2175,7 +2175,7 @@ ConversationTest::testRemoveOneToOneNotInDetails()
|
||||
auto firstConv = aliceData.conversationId;
|
||||
// Create a duplicate
|
||||
std::this_thread::sleep_for(2s); // Avoid to get same id
|
||||
aliceAccount->convModule()->startConversation(ConversationMode::ONE_TO_ONE, bobUri);
|
||||
aliceAccount->convModule()->startConversation(ConversationMode::ONE_TO_ONE, dht::InfoHash(bobUri));
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return firstConv != aliceData.conversationId; }));
|
||||
|
||||
// Assert that repository exists
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
const std::string& convId,
|
||||
const std::string& uri);
|
||||
|
||||
void testAddInvalidUri();
|
||||
void testRemoveConversationNoMember();
|
||||
void testRemoveConversationWithMember();
|
||||
void testAddMember();
|
||||
@ -125,6 +126,7 @@ public:
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE(ConversationMembersEventTest);
|
||||
CPPUNIT_TEST(testAddInvalidUri);
|
||||
CPPUNIT_TEST(testRemoveConversationNoMember);
|
||||
CPPUNIT_TEST(testRemoveConversationWithMember);
|
||||
CPPUNIT_TEST(testAddMember);
|
||||
@ -389,7 +391,9 @@ ConversationMembersEventTest::connectSignals()
|
||||
}));
|
||||
confHandlers.insert(libjami::exportable_callback<libjami::ConfigurationSignal::ContactAdded>(
|
||||
[&](const std::string& accountId, const std::string&, bool) {
|
||||
if (accountId == bobId) {
|
||||
if (accountId == aliceId) {
|
||||
aliceData.contactAdded = true;
|
||||
} else if (accountId == bobId) {
|
||||
bobData.contactAdded = true;
|
||||
} else if (accountId == bob2Id) {
|
||||
bob2Data.contactAdded = true;
|
||||
@ -445,6 +449,17 @@ ConversationMembersEventTest::generateFakeInvite(std::shared_ptr<JamiAccount> ac
|
||||
"");
|
||||
}
|
||||
|
||||
void
|
||||
ConversationMembersEventTest::testAddInvalidUri()
|
||||
{
|
||||
connectSignals();
|
||||
|
||||
auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId);
|
||||
aliceAccount->addContact("Shitty/Uri");
|
||||
CPPUNIT_ASSERT(!cv.wait_for(lk, 5s, [&]() { return aliceData.contactAdded; }));
|
||||
CPPUNIT_ASSERT(aliceData.conversationId.empty());
|
||||
}
|
||||
|
||||
void
|
||||
ConversationMembersEventTest::testRemoveConversationNoMember()
|
||||
{
|
||||
|
Reference in New Issue
Block a user