Skip to content

Commit

Permalink
file renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
kkohbrok committed Aug 3, 2023
1 parent bb4aa6b commit a51028c
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions test_harness/src/test_scenarios/basic_group_operations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// SPDX-FileCopyrightText: 2023 Phoenix R&D GmbH <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

use phnxbackend::qs::Fqdn;

use crate::utils::setup::TestBed;

pub(super) const NUMBER_OF_SERVERS: usize = 2;

impl TestBed {
async fn create_alice_and_bob(&mut self, domains: &[Fqdn]) -> (String, String) {
let alice_name = format!("alice@{}", domains[0]);
self.add_user(alice_name.clone()).await;
let bob_name = format!("bob@{}", domains[1]);
self.add_user(bob_name.clone()).await;
(alice_name, bob_name)
}

pub(crate) async fn create_and_connect_alice_and_bob(
&mut self,
domains: &[Fqdn],
) -> (String, String) {
let (alice_name, bob_name) = self.create_alice_and_bob(domains).await;
self.connect_users(&alice_name, &bob_name).await;
(alice_name, bob_name)
}
}

/// This function is meant to be called from the test container. It registers
/// two clients, one on each test server and makes them perform the requests
/// required to connect the two. Before running the test, it waits for the
/// health check to succeed on both servers.
pub async fn connect_users_runner(domains: &[Fqdn]) {
let mut test_bed = TestBed::new().await;
test_bed.create_and_connect_alice_and_bob(domains).await;
}

pub async fn invite_to_group_runner(domains: &[Fqdn]) {
let mut test_bed = TestBed::new().await;
let (alice_name, bob_name) = test_bed.create_and_connect_alice_and_bob(domains).await;
let conversation_id = test_bed.create_group(&alice_name).await;
test_bed
.invite_to_group(conversation_id, &alice_name, vec![&bob_name])
.await;
}

pub async fn remove_from_group_runner(domains: &[Fqdn]) {
let mut test_bed = TestBed::new().await;
let (alice_name, bob_name) = test_bed.create_and_connect_alice_and_bob(domains).await;
let conversation_id = test_bed.create_group(&alice_name).await;
test_bed
.invite_to_group(conversation_id, &alice_name, vec![&bob_name])
.await;
test_bed
.remove_from_group(conversation_id, &alice_name, vec![&bob_name])
.await;
}

pub async fn leave_group_runner(domains: &[Fqdn]) {
let mut test_bed = TestBed::new().await;
let (alice_name, bob_name) = test_bed.create_and_connect_alice_and_bob(domains).await;
let conversation_id = test_bed.create_group(&alice_name).await;
test_bed
.invite_to_group(conversation_id, &alice_name, vec![&bob_name])
.await;
test_bed.leave_group(conversation_id, &bob_name).await
}

0 comments on commit a51028c

Please sign in to comment.