Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
- uses: actions/checkout@v4

- name: Test
run: cargo test --workspace --lib --bins
run: cargo test --workspace --bins
env:
STORIFY_SKIP_BEHAVIOR: "1"
RUST_LOG: DEBUG
RUST_BACKTRACE: full
2 changes: 1 addition & 1 deletion .github/workflows/test_behavior.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
echo "MinIO not ready" >&2; exit 1

- name: Run Behavior Tests
run: cargo test --test behavior --quiet
run: cargo test tests::behavior_suite -- --quiet
env:
RUST_LOG: info

Expand Down
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,3 @@ predicates = "3.1.3"
rand = "0.9.2"
tracing-subscriber = { version = "0.3.20", features = ["env-filter", "tracing-log"] }
tempfile = "3.14.0"

[[test]]
harness = false
name = "behavior"
path = "tests/behavior/main.rs"
4 changes: 1 addition & 3 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ pub mod entry;
pub mod prompts;
pub mod storage;

pub use context::CliContext;
pub use entry::{Args, Command, ConfigCommand, GlobalOptions, run, run_with_prompt};
pub use prompts::Prompt;
pub use entry::{Args, run};
9 changes: 2 additions & 7 deletions src/cli/prompts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use tokio::task;
use crate::error::{Error, Result};

/// Interactive prompt mode for CLI operations
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Default)]
pub enum Prompt {
/// Console-based interactive prompts using dialoguer
#[default]
Console,
/// Non-interactive mode that uses defaults or fails
NonInteractive,
Expand Down Expand Up @@ -77,12 +78,6 @@ impl Prompt {
}
}

impl Default for Prompt {
fn default() -> Self {
Self::Console
}
}

fn join_error(err: task::JoinError) -> Error {
Error::Io {
source: io::Error::other(err.to_string()),
Expand Down
22 changes: 0 additions & 22 deletions src/config/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,28 +332,6 @@ pub fn resolve(request: ConfigRequest) -> Result<ResolvedConfig> {
Ok(resolved)
}

/// Load storage configuration using environment variables only.
pub fn load_storage_config() -> Result<StorageConfig> {
let resolved = resolve(ConfigRequest {
profile: None,
profile_store_path: None,
non_interactive: false,
require_storage: true,
master_password: None,
})?;

let storage = resolved.storage.ok_or_else(|| Error::NoConfiguration {
profiles: "none".to_string(),
})?;
Ok(storage)
}

pub fn load_env_storage_config(provider_hint: Option<String>) -> Result<StorageConfig> {
load_env_config(&env_value, provider_hint)
.and_then(build_config)
.map_err(with_config_hint)
}

fn load_env_config(
get: &dyn Fn(&str) -> Option<String>,
provider_hint: Option<String>,
Expand Down
22 changes: 1 addition & 21 deletions src/config/profile_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,6 @@ impl ProfileStore {
default_store_path()
}

pub fn open_default() -> Result<Self> {
Self::open_with_options(ProfileStoreOpenOptions::default())
}

pub fn open(path: Option<PathBuf>) -> Result<Self> {
Self::open_with_options(ProfileStoreOpenOptions {
path,
..ProfileStoreOpenOptions::default()
})
}

pub fn open_with_password(
path: Option<PathBuf>,
master_password: Option<SecretString>,
Expand Down Expand Up @@ -350,15 +339,6 @@ impl ProfileStore {
self.persist()
}

/// Re-derive encryption key (for key rotation or master password change)
pub fn set_encryption(&mut self, master_password: Option<SecretString>) -> Result<()> {
let password = resolve_master_password(master_password, &self.path);
let salt = generate_salt();
let key = derive_master_key(&password, &salt)?;
self.encryption = EncryptionMetadata::new(key, salt.to_vec());
self.persist()
}

fn persist(&mut self) -> Result<()> {
let mut payload = self.file.clone();
payload.normalize_default();
Expand Down Expand Up @@ -389,7 +369,7 @@ impl ProfileStore {
write_atomic(&self.path, serialized.as_bytes())?;

// Synchronize salt file to ensure it matches the in-memory state
// This is critical for operations like set_encryption() that generate a new salt
// This is critical for operations that regenerate the encryption metadata
let salt_path = Self::salt_file_path(&self.path);
Self::write_salt_file(&salt_path, salt)?;

Expand Down
5 changes: 0 additions & 5 deletions src/lib.rs

This file was deleted.

11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
mod cli;
mod config;
mod error;
mod storage;
mod utils;

#[cfg(test)]
mod tests;

use clap::Parser;

use storify::cli::{Args, run};
use crate::cli::{Args, run};

#[tokio::main]
async fn main() {
Expand Down
4 changes: 4 additions & 0 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ impl StorageClient {
Ok(Self { operator, provider })
}

#[cfg(test)]
#[allow(dead_code)]
pub fn provider(&self) -> StorageProvider {
self.provider
}

#[cfg(test)]
#[allow(dead_code)]
pub fn operator(&self) -> &Operator {
&self.operator
}
Expand Down
1 change: 0 additions & 1 deletion src/storage/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ pub const PROGRESS_UPDATE_INTERVAL: u64 = 100;
pub const DEFAULT_FS_ROOT: &str = "./storage";
pub const DEFAULT_HDFS_ROOT: &str = "/";
pub const DEFAULT_COS_ENDPOINT: &str = "https://cos.myqcloud.com";
pub const CAT_CONFIRM_SIZE_THRESHOLD: u64 = 10 * 1024 * 1024;
21 changes: 21 additions & 0 deletions src/tests/behavior/macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
macro_rules! register_behavior_tests {
($($test:ident),+ $(,)?) => {
pub fn tests(client: &StorageClient, tests: &mut Vec<Trial>) {
tests.extend(async_trials!(client, $( $test ),+));
}

#[cfg(test)]
mod case_tests {
$(
#[test]
fn $test() {
if let Err(err) = crate::tests::behavior::run_behavior_case(
Comment thread
QuakeWang marked this conversation as resolved.
concat!("behavior::", stringify!($test)),
) {
panic!("behavior case {} failed: {err}", stringify!($test));
}
}
)*
}
};
}
Loading