Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
3236a6af
Commit
3236a6af
authored
3 years ago
by
Sébastien Blin
Committed by
Adrien Béraud
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
account_archive: add test for import/export on DHT
Change-Id: I547dfeaf1734873ac9f8db82a181769de11a2bb6
parent
a5aed459
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/unitTest/account_archive/account_archive.cpp
+58
-1
58 additions, 1 deletion
test/unitTest/account_archive/account_archive.cpp
with
58 additions
and
1 deletion
test/unitTest/account_archive/account_archive.cpp
+
58
−
1
View file @
3236a6af
...
...
@@ -64,18 +64,23 @@ public:
std
::
string
aliceId
;
std
::
string
bobId
;
std
::
string
bob2Id
;
private
:
void
testExportImportNoPassword
();
void
testExportImportNoPasswordDoubleGunzip
();
void
testExportImportPassword
();
void
testExportImportPasswordDoubleGunzip
();
void
testExportDht
();
void
testExportDhtWrongPassword
();
CPPUNIT_TEST_SUITE
(
AccountArchiveTest
);
CPPUNIT_TEST
(
testExportImportNoPassword
);
CPPUNIT_TEST
(
testExportImportNoPasswordDoubleGunzip
);
CPPUNIT_TEST
(
testExportImportPassword
);
CPPUNIT_TEST
(
testExportImportPasswordDoubleGunzip
);
CPPUNIT_TEST
(
testExportDht
);
CPPUNIT_TEST
(
testExportDhtWrongPassword
);
CPPUNIT_TEST_SUITE_END
();
};
...
...
@@ -92,7 +97,10 @@ AccountArchiveTest::setUp()
void
AccountArchiveTest
::
tearDown
()
{
wait_for_removal_of
({
aliceId
,
bobId
});
if
(
!
bob2Id
.
empty
())
wait_for_removal_of
({
aliceId
,
bob2Id
,
bobId
});
else
wait_for_removal_of
({
aliceId
,
bobId
});
}
void
...
...
@@ -173,6 +181,55 @@ AccountArchiveTest::testExportImportPasswordDoubleGunzip()
wait_for_removal_of
(
accountId
);
}
void
AccountArchiveTest
::
testExportDht
()
{
std
::
mutex
mtx
;
std
::
unique_lock
<
std
::
mutex
>
lk
{
mtx
};
std
::
condition_variable
cv
;
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
DRing
::
CallbackWrapperBase
>>
confHandlers
;
std
::
string
pin
;
confHandlers
.
insert
(
DRing
::
exportable_callback
<
DRing
::
ConfigurationSignal
::
ExportOnRingEnded
>
(
[
&
](
const
std
::
string
&
accountId
,
int
status
,
const
std
::
string
&
p
)
{
if
(
accountId
==
bobId
&&
status
==
0
)
pin
=
p
;
cv
.
notify_one
();
}));
DRing
::
registerSignalHandlers
(
confHandlers
);
CPPUNIT_ASSERT
(
DRing
::
exportOnRing
(
bobId
,
"test"
));
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
std
::
chrono
::
seconds
(
10
),
[
&
]
{
return
!
pin
.
empty
();
}));
auto
bobAccount
=
Manager
::
instance
().
getAccount
<
JamiAccount
>
(
bobId
);
std
::
map
<
std
::
string
,
std
::
string
>
details
=
DRing
::
getAccountTemplate
(
"RING"
);
details
[
ConfProperties
::
ARCHIVE_PIN
]
=
pin
;
details
[
ConfProperties
::
ARCHIVE_PASSWORD
]
=
"test"
;
bob2Id
=
jami
::
Manager
::
instance
().
addAccount
(
details
);
wait_for_announcement_of
(
bob2Id
);
auto
bob2Account
=
Manager
::
instance
().
getAccount
<
JamiAccount
>
(
bob2Id
);
CPPUNIT_ASSERT
(
bob2Account
->
getUsername
()
==
bobAccount
->
getUsername
());
}
void
AccountArchiveTest
::
testExportDhtWrongPassword
()
{
std
::
mutex
mtx
;
std
::
unique_lock
<
std
::
mutex
>
lk
{
mtx
};
std
::
condition_variable
cv
;
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
DRing
::
CallbackWrapperBase
>>
confHandlers
;
int
status
;
confHandlers
.
insert
(
DRing
::
exportable_callback
<
DRing
::
ConfigurationSignal
::
ExportOnRingEnded
>
(
[
&
](
const
std
::
string
&
accountId
,
int
s
,
const
std
::
string
&
)
{
if
(
accountId
==
bobId
)
status
=
s
;
cv
.
notify_one
();
}));
DRing
::
registerSignalHandlers
(
confHandlers
);
CPPUNIT_ASSERT
(
DRing
::
exportOnRing
(
bobId
,
"wrong"
));
CPPUNIT_ASSERT
(
cv
.
wait_for
(
lk
,
std
::
chrono
::
seconds
(
10
),
[
&
]
{
return
status
==
1
;
}));
}
}
// namespace test
}
// namespace jami
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment