hidden contact invite
This commit is contained in:
1 parent
ce44ee48b3
commit
7eace57528
6 files changed
+172
-37
No files matched your search
@@ -92,9 +92,12 @@ async fn file_and_server_invitations_then_messaging() {
|
||||
let mut remote = client(&dir, "remote", &servers).await;
|
||||
|
||||
// ── file invitation ──
|
||||
let offer = bob.create_invitation("alice", &[], "hello alice", 3600).await.unwrap();
|
||||
let offer = bob
|
||||
.create_invitation("alice", &[], "hello alice", 3600, None)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(alice.inspect_invitation(&offer).unwrap().initiator_name, "bob");
|
||||
let answer = alice.answer_invitation(&offer, None, &[]).await.unwrap();
|
||||
let answer = alice.answer_invitation(&offer, None, &[], None).await.unwrap();
|
||||
let confirm = bob.accept_answer(&answer).await.unwrap();
|
||||
assert_eq!(bob.contact("alice").unwrap().state, State::ConfirmSent);
|
||||
bob.send_text("alice", "sent before finalize").await.unwrap();
|
||||
@@ -143,15 +146,15 @@ async fn file_and_server_invitations_then_messaging() {
|
||||
|
||||
// ── server invitation ──
|
||||
let url = bob
|
||||
.publish_invitation("remote", &[], "via server", "secret", 3600)
|
||||
.publish_invitation("remote", &[], "via server", "secret", 3600, None)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(remote
|
||||
.accept_published_invitation(&url, "wrong", None, &[])
|
||||
.accept_published_invitation(&url, "wrong", None, &[], None)
|
||||
.await
|
||||
.is_err());
|
||||
let who = remote
|
||||
.accept_published_invitation(&url, "secret", None, &[])
|
||||
.accept_published_invitation(&url, "secret", None, &[], None)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(who, "bob");
|
||||
@@ -330,8 +333,8 @@ async fn no_message_lost_when_the_client_dies() {
|
||||
// This test counts what stays on the server: no receipts traffic.
|
||||
no_receipt_settings(&mut bob).await;
|
||||
no_receipt_settings(&mut alice).await;
|
||||
let offer = bob.create_invitation("alice", &[], "", 3600).await.unwrap();
|
||||
let answer = alice.answer_invitation(&offer, None, &[]).await.unwrap();
|
||||
let offer = bob.create_invitation("alice", &[], "", 3600, None).await.unwrap();
|
||||
let answer = alice.answer_invitation(&offer, None, &[], None).await.unwrap();
|
||||
let confirm = bob.accept_answer(&answer).await.unwrap();
|
||||
alice.finalize_invitation(&confirm).await.unwrap();
|
||||
bob.sync(Duration::ZERO).await.unwrap();
|
||||
@@ -370,8 +373,11 @@ async fn no_message_lost_when_the_client_dies() {
|
||||
// the temporary answer mailbox of a server invitation...
|
||||
let mut carol = client(&dir, "carol", &servers).await;
|
||||
no_receipt_settings(&mut carol).await;
|
||||
let link = bob.publish_invitation("carol", &[], "", "", 3600).await.unwrap();
|
||||
carol.accept_published_invitation(&link, "", None, &[]).await.unwrap();
|
||||
let link = bob.publish_invitation("carol", &[], "", "", 3600, None).await.unwrap();
|
||||
carol
|
||||
.accept_published_invitation(&link, "", None, &[], None)
|
||||
.await
|
||||
.unwrap();
|
||||
bob.sync(Duration::ZERO).await.unwrap(); // step 2 → 3, answer mailbox retired
|
||||
carol.sync(Duration::ZERO).await.unwrap(); // step 3 → 4
|
||||
bob.sync(Duration::ZERO).await.unwrap(); // ack
|
||||
@@ -395,8 +401,8 @@ async fn no_message_lost_when_the_client_dies() {
|
||||
|
||||
/// File invitation from `a` to `b`, completed.
|
||||
async fn connect(a: &mut MeowClient, b: &mut MeowClient, b_name: &str) {
|
||||
let offer = a.create_invitation(b_name, &[], "", 3600).await.unwrap();
|
||||
let answer = b.answer_invitation(&offer, None, &[]).await.unwrap();
|
||||
let offer = a.create_invitation(b_name, &[], "", 3600, None).await.unwrap();
|
||||
let answer = b.answer_invitation(&offer, None, &[], None).await.unwrap();
|
||||
let confirm = a.accept_answer(&answer).await.unwrap();
|
||||
b.finalize_invitation(&confirm).await.unwrap();
|
||||
a.sync(Duration::ZERO).await.unwrap();
|
||||
@@ -707,3 +713,61 @@ async fn background_sync_publishes_events() {
|
||||
assert_eq!(texts(&bob.sync(Duration::ZERO).await.unwrap()), vec!["after stop"]);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
// ───────────── invitations straight into hidden spaces (roadmap lot 5.10) ─────────────
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn invitations_straight_into_hidden_spaces() {
|
||||
let servers = vec![spawn_server().await];
|
||||
let dir = tmpdir();
|
||||
let mut alice = client(&dir, "alice", &servers).await;
|
||||
let mut bob = client(&dir, "bob", &servers).await;
|
||||
|
||||
// Server flow, hidden on both sides.
|
||||
let url = alice
|
||||
.publish_invitation("bob", &[], "", "", 3600, Some("a-secret"))
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(alice.is_hidden("bob").unwrap());
|
||||
assert_eq!(
|
||||
bob.accept_published_invitation(&url, "", None, &[], Some("b-secret"))
|
||||
.await
|
||||
.unwrap(),
|
||||
"alice"
|
||||
);
|
||||
assert!(bob.is_hidden("alice").unwrap());
|
||||
assert_eq!(
|
||||
no_receipts(alice.sync(Duration::ZERO).await.unwrap()),
|
||||
vec![Event::InvitationAccepted { contact: "bob".into() }]
|
||||
);
|
||||
bob.sync(Duration::ZERO).await.unwrap();
|
||||
alice.sync(Duration::ZERO).await.unwrap();
|
||||
bob.send_text("alice", "secret hello").await.unwrap();
|
||||
assert_eq!(texts(&alice.sync(Duration::ZERO).await.unwrap()), vec!["secret hello"]);
|
||||
|
||||
// File flow, hidden on the answering side only.
|
||||
let mut carol = client(&dir, "carol", &servers).await;
|
||||
let offer = alice.create_invitation("carol", &[], "", 3600, None).await.unwrap();
|
||||
carol
|
||||
.answer_invitation(&offer, None, &[], Some("c-secret"))
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(carol.is_hidden("alice").unwrap());
|
||||
|
||||
// Reopened without the space passwords: nothing; with them: the contacts.
|
||||
drop((alice, bob, carol));
|
||||
let path = |name: &str| dir.join(format!("{name}.mwid2"));
|
||||
let mut alice = MeowClient::open(&path("alice"), "pw").await.unwrap();
|
||||
let mut bob = MeowClient::open(&path("bob"), "pw").await.unwrap();
|
||||
let carol = MeowClient::open(&path("carol"), "pw").await.unwrap();
|
||||
assert_eq!(names(&alice), vec!["carol"]);
|
||||
assert!(names(&bob).is_empty());
|
||||
assert!(names(&carol).is_empty());
|
||||
assert!(alice.unlock("a-secret").await.unwrap());
|
||||
assert!(bob.unlock("b-secret").await.unwrap());
|
||||
assert_eq!(alice.contact("bob").unwrap().state, State::Active);
|
||||
assert_eq!(alice.history("bob").unwrap().len(), 1);
|
||||
alice.send_text("bob", "still secret").await.unwrap();
|
||||
assert_eq!(texts(&bob.sync(Duration::ZERO).await.unwrap()), vec!["still secret"]);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
Reference in new issue
Block a user