-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLI] Add test for mount_realm_export.
- Loading branch information
1 parent
b67f04b
commit b8d7ed2
Showing
5 changed files
with
109 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,12 @@ use std::{ | |
}; | ||
|
||
use libparsec::{ | ||
authenticated_cmds::{latest::device_create, latest::user_create}, | ||
authenticated_cmds::latest::{device_create, user_create}, | ||
AuthenticatedCmds, Bytes, CertificateSignerOwned, ClientConfig, DateTime, DeviceAccessStrategy, | ||
DeviceCertificate, DeviceID, DeviceLabel, DevicePurpose, HumanHandle, LocalDevice, | ||
MaybeRedacted, OrganizationID, ParsecAddr, PrivateKeyAlgorithm, ProxyConfig, SigningKey, | ||
SigningKeyAlgorithm, UserCertificate, UserProfile, PARSEC_BASE_CONFIG_DIR, | ||
PARSEC_BASE_DATA_DIR, PARSEC_BASE_HOME_DIR, PARSEC_SCHEME, | ||
MaybeRedacted, OrganizationID, ParsecAddr, PrivateKeyAlgorithm, ProxyConfig, | ||
SequesterVerifyKeyDer, SigningKey, SigningKeyAlgorithm, UserCertificate, UserProfile, | ||
PARSEC_BASE_CONFIG_DIR, PARSEC_BASE_DATA_DIR, PARSEC_BASE_HOME_DIR, PARSEC_SCHEME, | ||
}; | ||
|
||
use crate::{ | ||
|
@@ -39,6 +39,7 @@ pub async fn initialize_test_organization( | |
client_config: ClientConfig, | ||
addr: ParsecAddr, | ||
organization_id: OrganizationID, | ||
sequester_key: Option<SequesterVerifyKeyDer>, | ||
) -> anyhow::Result<TestOrganization> { | ||
// Create organization | ||
let organization_addr = | ||
|
@@ -51,6 +52,7 @@ pub async fn initialize_test_organization( | |
"laptop".parse().expect("Unreachable"), | ||
HumanHandle::new("[email protected]", "Alice").expect("Unreachable"), | ||
DEFAULT_DEVICE_PASSWORD.to_string().into(), | ||
sequester_key, | ||
) | ||
.await?; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use std::{env::current_dir, io::Read}; | ||
|
||
use libparsec::{tmp_path, SequesterKeySize, SequesterSigningKeyDer, TmpPath}; | ||
|
||
use crate::{ | ||
integration_tests::{bootstrap_cli_test_with_sequester, spawn_interactive_command}, | ||
std_cmd, | ||
testenv_utils::TestOrganization, | ||
utils::start_client, | ||
}; | ||
|
||
#[rstest::rstest] | ||
#[tokio::test] | ||
async fn mount_realm_export(tmp_path: TmpPath) { | ||
let (seq_sign_key, seq_verification_key) = | ||
SequesterSigningKeyDer::generate_pair(SequesterKeySize::_1024Bits); | ||
|
||
let (_, TestOrganization { alice, .. }, org_id) = | ||
bootstrap_cli_test_with_sequester(&tmp_path, seq_verification_key) | ||
.await | ||
.unwrap(); | ||
let client = start_client(alice.clone()).await.unwrap(); | ||
|
||
// Create the workspace used to copy the file to | ||
let wid = client | ||
.create_workspace("new-workspace".parse().unwrap()) | ||
.await | ||
.unwrap(); | ||
client.ensure_workspaces_bootstrapped().await.unwrap(); | ||
|
||
// TODO update when realm export available from here | ||
|
||
let mut parsec_dir = current_dir().unwrap(); | ||
assert!(parsec_dir.pop()); // got to parsec-cloud | ||
let parsec_dir = dbg!(parsec_dir.join("server")); | ||
let output = std::process::Command::new("poetry") | ||
.current_dir(parsec_dir) | ||
.arg("run") | ||
.arg("parsec") | ||
.arg("export_realm") | ||
.arg(format!("--organization={org_id}")) | ||
.arg(format!("--realm={wid}")) | ||
.arg("--db=MOCKED") | ||
.arg("--blockstore=MOCKED") | ||
.spawn() | ||
.unwrap(); | ||
|
||
let mut buf = String::new(); | ||
dbg!(output) | ||
.stdout | ||
.unwrap() | ||
.read_to_string(&mut buf) | ||
.unwrap(); | ||
let db_export = buf.lines().next().unwrap(); | ||
assert_eq!("Creating ", &db_export[0..9]); | ||
let db_export_path = dbg!(&db_export[9..]); | ||
|
||
let cmd = std_cmd!( | ||
"mount-realm-export", | ||
db_export_path, | ||
&format!("{seq_sign_key:?}"), | ||
"mounted_workspace" | ||
); | ||
|
||
let mut p = spawn_interactive_command(cmd, Some(1500)).unwrap(); | ||
|
||
p.exp_string("Mounted workspace at mounted_workspace") | ||
.unwrap(); | ||
} |