Skip to content

Commit

Permalink
test: test DB migration from 0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
beltram committed Nov 27, 2023
1 parent d145775 commit 9c1e201
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
20 changes: 20 additions & 0 deletions extras/keystore-regression-versions/cc-keystore-09/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "cc-keystore-09"
version = "0.0.0"
edition = "2021"
resolver = "2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
core-crypto-keystore = { git = "https://github.com/wireapp/core-crypto.git", tag = "v0.9.2", package = "core-crypto-keystore" }
cc-keystore-support = { path = "../cc-keystore-support"}

[patch.crates-io.rexie]
git = "https://github.com/wireapp/rexie"
branch = "feat/api-expansion"

[patch.crates-io.openmls_traits]
package = "openmls_traits"
git = "https://github.com/wireapp/openmls"
tag = "v0.5.6-pre.core-crypto-0.7.0"
29 changes: 29 additions & 0 deletions extras/keystore-regression-versions/cc-keystore-09/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use cc_keystore_support::*;
use core_crypto_keystore::Connection;
pub struct CoreCryptoKeystore09(Connection);

#[async_trait::async_trait(?Send)]
impl CoreCryptoKeystore for CoreCryptoKeystore09 {
async fn open(path: &str, key: &str) -> Result<Self>
where
Self: Sized,
{
Ok(Self(Connection::open_with_key(path, key).await?))
}
async fn close(self) -> Result<()> {
self.0.close().await?;
Ok(())
}
async fn wipe(self) -> Result<()> {
self.0.wipe().await?;
Ok(())
}
}

#[tokio::main]
async fn main() -> Result<()> {
use clap::Parser as _;
let args = CliArgs::<CoreCryptoKeystore09>::parse();
args.run().await?;
Ok(())
}
44 changes: 44 additions & 0 deletions extras/keystore-regression-versions/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ async fn warmup_build() -> Result<()> {
let cwd = std::env::current_dir()?;
let bins = [
"cc-keystore-08",
"cc-keystore-09",
"cc-keystore-10p",
"cc-keystore-10r",
"cc-keystore-current",
Expand Down Expand Up @@ -97,6 +98,8 @@ async fn main() -> Result<()> {

let spinner_10p = init_spinner();

// === Android ===

// Initialize a Keystore on version 0.8.2, let this keystore as ks-08
spinner_wrap_err(&spinner_10p, run_init_with_bin("cc-keystore-08", &ks_10p).await)?;
spinner_10p.set_message("0.8.2");
Expand Down Expand Up @@ -136,5 +139,46 @@ async fn main() -> Result<()> {
tokio::fs::remove_file(&ks_08).await?;
spinner_current.finish_with_message("0.8.2 -> develop ✅");

// === iOS ===

// Initialize a Keystore on version 0.8.2, let this keystore as ks-09
spinner_wrap_err(&spinner_10p, run_init_with_bin("cc-keystore-09", &ks_10p).await)?;
spinner_10p.set_message("0.9.2");
// Try to open and migrate ks-09 to version 1.0.0-pre, let this keystore as ks-10p
spinner_wrap_err(&spinner_10p, run_init_with_bin("cc-keystore-10p", &ks_10p).await)?;
spinner_10p.set_message("0.9.2 -> 1.0.0-pre");

// Try to open and migrate ks-10p to version 1.0.0-rc, let this keystore as ks-10pr
spinner_wrap_err(&spinner_10p, run_init_with_bin("cc-keystore-10r", &ks_10p).await)?;
spinner_10p.set_message("0.9.2 -> 1.0.0-pre -> 1.0.0-rc");

spinner_wrap_err(&spinner_10p, run_init_with_bin("cc-keystore-current", &ks_10p).await)?;
spinner_10p.finish_with_message("0.9.2 -> 1.0.0-pre -> 1.0.0-rc -> develop ✅");
tokio::fs::remove_file(&ks_10p).await?;

let spinner_10r = init_spinner();

// Try to open and migrate ks-08 to version 1.0.0-rc, let this keystore as ks-10r
spinner_wrap_err(&spinner_10r, run_init_with_bin("cc-keystore-09", &ks_10r).await)?;
spinner_10r.set_message("0.9.2");

spinner_wrap_err(&spinner_10r, run_init_with_bin("cc-keystore-10r", &ks_10r).await)?;
spinner_10r.set_message("0.9.2 -> 1.0.0-rc");

spinner_wrap_err(&spinner_10r, run_init_with_bin("cc-keystore-current", &ks_10r).await)?;
tokio::fs::remove_file(&ks_10r).await?;

spinner_10r.finish_with_message("0.9.2 -> 1.0.0-rc -> develop ✅");

let spinner_current = init_spinner();

// Try to open and migrate a ks08 directly to current version
spinner_wrap_err(&spinner_current, run_init_with_bin("cc-keystore-09", &ks_08).await)?;
spinner_current.set_message("0.9.2");

spinner_wrap_err(&spinner_current, run_init_with_bin("cc-keystore-current", &ks_08).await)?;
tokio::fs::remove_file(&ks_08).await?;
spinner_current.finish_with_message("0.9.2 -> develop ✅");

Ok(())
}

0 comments on commit 9c1e201

Please sign in to comment.