From 6038fcb0a106412975a68f40ddfcdaf394cd2339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20Curley?= Date: Tue, 3 Oct 2023 12:34:42 +0100 Subject: [PATCH 1/3] feat(rust): add invalid file error, separate file trait Created, implemented `StateItemFileTrait` Created, implemented `CliState::InvalidFile` --- .../ockam_api/src/cli_state/credentials.rs | 18 +++-- .../ockam_api/src/cli_state/identities.rs | 26 ++++--- .../rust/ockam/ockam_api/src/cli_state/mod.rs | 28 +++++++- .../ockam/ockam_api/src/cli_state/nodes.rs | 57 ++++++++++++---- .../ockam/ockam_api/src/cli_state/projects.rs | 16 +++-- .../ockam/ockam_api/src/cli_state/spaces.rs | 16 +++-- .../ockam/ockam_api/src/cli_state/traits.rs | 49 ++++++++++--- .../ockam_api/src/cli_state/trust_contexts.rs | 60 +++++++++------- .../ockam_api/src/cli_state/user_info.rs | 16 +++-- .../ockam/ockam_api/src/cli_state/vaults.rs | 68 +++++++++++++------ 10 files changed, 250 insertions(+), 104 deletions(-) diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/credentials.rs b/implementations/rust/ockam/ockam_api/src/cli_state/credentials.rs index 1ec52a829e4..babd72361a9 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/credentials.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/credentials.rs @@ -78,6 +78,12 @@ mod traits { } } + impl StateItemFileTrait for CredentialState { + fn path(&self) -> &PathBuf { + &self.path + } + } + #[async_trait] impl StateItemTrait for CredentialState { type Config = CredentialConfig; @@ -89,15 +95,13 @@ mod traits { Ok(Self { name, path, config }) } - fn load(path: PathBuf) -> Result { + fn load<'a>(path: PathBuf) -> Result { let name = file_stem(&path)?; let contents = std::fs::read_to_string(&path)?; - let config = serde_json::from_str(&contents)?; - Ok(Self { name, path, config }) - } - - fn path(&self) -> &PathBuf { - &self.path + match serde_json::from_str(&contents) { + Ok(config) => Ok(Self { name, path, config }), + Err(error) => Err(error.handle_file_parse_error(path)) + } } fn config(&self) -> &Self::Config { diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/identities.rs b/implementations/rust/ockam/ockam_api/src/cli_state/identities.rs index 828e2c35825..0917ac91aa7 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/identities.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/identities.rs @@ -271,6 +271,12 @@ mod traits { } } + impl StateItemFileTrait for IdentityState { + fn path(&self) -> &PathBuf { + &self.path + } + } + #[async_trait] impl StateItemTrait for IdentityState { type Config = IdentityConfig; @@ -291,18 +297,16 @@ mod traits { fn load(path: PathBuf) -> Result { let name = file_stem(&path)?; let contents = std::fs::read_to_string(&path)?; - let config = serde_json::from_str(&contents)?; let data_path = IdentityState::build_data_path(&path); - Ok(Self { - name, - path, - data_path, - config, - }) - } - - fn path(&self) -> &PathBuf { - &self.path + match serde_json::from_str(&contents) { + Ok(config) => Ok(Self { + name, + path, + data_path, + config, + }), + Err(error) => Err(error.handle_file_parse_error(path)), + } } fn config(&self) -> &Self::Config { diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/mod.rs b/implementations/rust/ockam/ockam_api/src/cli_state/mod.rs index f0fa0441ccd..95d5da4c90c 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/mod.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/mod.rs @@ -41,6 +41,13 @@ pub enum CliStateError { #[diagnostic(code("OCK500"))] Serde(#[from] serde_json::Error), + #[error("A file is invalid")] + #[diagnostic(code("OCK500"))] + InvalidFile{ + source: serde_json::Error, + file: Box + }, + #[error(transparent)] #[diagnostic(code("OCK500"))] Ockam(#[from] ockam_core::Error), @@ -99,6 +106,18 @@ impl From for ockam_core::Error { } } +// Default Invalid File struct +#[derive(Debug, Clone, Eq, PartialEq)] +struct InvalidItem { + path: PathBuf +} + +impl StateItemFileTrait for InvalidItem { + fn path(&self) -> &PathBuf { + &self.path + } +} + #[derive(Debug, Clone, Eq, PartialEq)] pub struct CliState { pub vaults: VaultsState, @@ -242,7 +261,12 @@ impl CliState { pub fn delete_identity(&self, identity_state: IdentityState) -> Result<()> { // Abort if identity is being used by some running node. for node in self.nodes.list()? { - if node.config().identity_config()?.identifier() == identity_state.identifier() { + if node + .config() + .identity_config()? + .identifier() + == identity_state.identifier() + { return Err(CliStateError::InvalidOperation(format!( "Can't delete identity '{}' as it's being used by node '{}'", &identity_state.name(), @@ -342,6 +366,7 @@ impl CliState { /// This project should be the project that is created at the end of the enrollment procedure pub fn is_enrolled(&self) -> Result { let identity_state = self.identities.default()?; + if !identity_state.is_enrolled() { return Ok(false); } @@ -570,6 +595,7 @@ mod tests { let name = random_name(); let vault_state = sut.vaults.get(&vault_name).unwrap(); let vault: Vault = vault_state.get().await.unwrap(); + let identities = Identities::builder() .with_vault(vault) .with_identities_repository(sut.identities.identities_repository().await?) diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/nodes.rs b/implementations/rust/ockam/ockam_api/src/cli_state/nodes.rs index 3de2d1cd32f..3a2f61a7c94 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/nodes.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/nodes.rs @@ -1,7 +1,7 @@ use super::Result; use crate::cli_state::{ CliState, CliStateError, IdentityConfig, IdentityState, ProjectConfig, ProjectConfigCompact, - StateDirTrait, StateItemTrait, VaultState, + StateDirTrait, StateItemFileTrait, StateItemTrait, VaultState, }; use crate::config::lookup::ProjectLookup; use crate::nodes::models::transport::CreateTransportJson; @@ -57,6 +57,19 @@ impl NodesState { } } +#[derive(Debug, Clone, Eq, PartialEq)] +struct InvalidNodeState { + path: PathBuf, +} + +impl InvalidNodeState { + fn _delete(&self) -> Result<()> { + std::fs::remove_dir_all(&self.path)?; + std::fs::remove_dir(&self.path)?; + Ok(()) + } +} + #[derive(Debug, Clone, Eq, PartialEq)] pub struct NodeState { name: String, @@ -508,6 +521,26 @@ mod traits { } } + impl StateItemFileTrait for NodeState { + fn delete(&self) -> Result<()> { + self._delete(false) + } + + fn path(&self) -> &PathBuf { + &self.path + } + } + + impl StateItemFileTrait for InvalidNodeState { + fn delete(&self) -> Result<()> { + self._delete() + } + + fn path(&self) -> &PathBuf { + &self.path + } + } + #[async_trait] impl StateItemTrait for NodeState { type Config = NodeConfig; @@ -535,10 +568,18 @@ mod traits { fn load(path: PathBuf) -> Result { let paths = NodePaths::new(&path); let name = file_stem(&path)?; - let setup = { + let (path, setup) = { let contents = std::fs::read_to_string(paths.setup())?; - serde_json::from_str(&contents)? - }; + + // I may be going overkill with trying to avoid temporarys, please forgive this humble new rustatcan + match serde_json::from_str(&contents) { + Ok(config) => Ok((path, config)), + Err(source) => Err(CliStateError::InvalidFile { + source, + file: Box::new(InvalidNodeState { path }) + }) + } + }?; let version = { let contents = std::fs::read_to_string(paths.version())?; contents.parse::()? @@ -557,14 +598,6 @@ mod traits { }) } - fn delete(&self) -> Result<()> { - self._delete(false) - } - - fn path(&self) -> &PathBuf { - &self.path - } - fn config(&self) -> &Self::Config { &self.config } diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/projects.rs b/implementations/rust/ockam/ockam_api/src/cli_state/projects.rs index 00a81869f00..caf69fea8c2 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/projects.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/projects.rs @@ -142,6 +142,12 @@ mod traits { } } + impl StateItemFileTrait for ProjectState { + fn path(&self) -> &PathBuf { + &self.path + } + } + #[async_trait] impl StateItemTrait for ProjectState { type Config = ProjectConfig; @@ -156,12 +162,10 @@ mod traits { fn load(path: PathBuf) -> Result { let name = file_stem(&path)?; let contents = std::fs::read_to_string(&path)?; - let config = serde_json::from_str(&contents)?; - Ok(Self { name, path, config }) - } - - fn path(&self) -> &PathBuf { - &self.path + match serde_json::from_str(&contents) { + Ok(config) => Ok(Self { name, path, config }), + Err(source) => Err(source.handle_file_parse_error(path)) + } } fn config(&self) -> &Self::Config { diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/spaces.rs b/implementations/rust/ockam/ockam_api/src/cli_state/spaces.rs index 8d3d8d6ce44..5390427a110 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/spaces.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/spaces.rs @@ -71,6 +71,12 @@ mod traits { } } + impl StateItemFileTrait for SpaceState { + fn path(&self) -> &PathBuf { + &self.path + } + } + #[async_trait] impl StateItemTrait for SpaceState { type Config = SpaceConfig; @@ -85,12 +91,10 @@ mod traits { fn load(path: PathBuf) -> Result { let name = file_stem(&path)?; let contents = std::fs::read_to_string(&path)?; - let config = serde_json::from_str(&contents)?; - Ok(Self { name, path, config }) - } - - fn path(&self) -> &PathBuf { - &self.path + match serde_json::from_str(&contents) { + Ok(config) => Ok(Self { name, path, config }), + Err(source) => Err(source.handle_file_parse_error(path)) + } } fn config(&self) -> &Self::Config { diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/traits.rs b/implementations/rust/ockam/ockam_api/src/cli_state/traits.rs index 4339d9bb07a..199aa9167af 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/traits.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/traits.rs @@ -1,7 +1,8 @@ -use crate::cli_state::{file_stem, CliState, CliStateError}; +use crate::cli_state::{file_stem, CliState, CliStateError, InvalidItem}; use ockam_core::errcode::{Kind, Origin}; use ockam_core::{async_trait, Error}; use serde::{Deserialize, Serialize}; +use std::fmt::Debug; use std::path::{Path, PathBuf}; use super::Result; @@ -238,10 +239,22 @@ pub trait StateDirTrait: Sized + Send + Sync { } } +/// This trait defines the methods to retrieve an file from a state directory, +/// but does not validate if it's a correct config. +/// Provides a way to delete invalid files gracefully. +#[async_trait] +pub trait StateItemFileTrait: Send + Sync + Debug { + fn delete(&self) -> Result<()> { + std::fs::remove_file(self.path())?; + Ok(()) + } + fn path(&self) -> &PathBuf; +} + /// This trait defines the methods to retrieve an item from a state directory. /// The details of the item are defined in the `Config` type. #[async_trait] -pub trait StateItemTrait: Sized + Send { +pub trait StateItemTrait: Sized + Send + StateItemFileTrait { type Config: Serialize + for<'a> Deserialize<'a> + Send; /// Create a new item with the given config. @@ -256,19 +269,29 @@ pub trait StateItemTrait: Sized + Send { std::fs::write(self.path(), contents)?; Ok(()) } - fn delete(&self) -> Result<()> { - std::fs::remove_file(self.path())?; - Ok(()) - } - fn path(&self) -> &PathBuf; fn config(&self) -> &Self::Config; } +pub trait HandleFileParseError { + fn handle_file_parse_error(self, path: PathBuf) -> CliStateError; +} + +impl HandleFileParseError for serde_json::Error { + fn handle_file_parse_error(self, path: PathBuf) -> CliStateError { + CliStateError::InvalidFile { + source: self, + file: Box::new(InvalidItem { path }), + } + } +} + #[cfg(test)] mod tests { use crate::cli_state::{StateDirTrait, StateItemTrait}; use std::path::{Path, PathBuf}; + use super::StateItemFileTrait; + #[test] fn test_is_item_path() { let config = TestConfig::new(Path::new("dir")); @@ -297,10 +320,18 @@ mod tests { } } + #[derive(Debug)] struct TestConfigItem { path: PathBuf, config: String, } + + impl StateItemFileTrait for TestConfigItem { + fn path(&self) -> &PathBuf { + &self.path + } + } + impl StateItemTrait for TestConfigItem { type Config = String; @@ -315,10 +346,6 @@ mod tests { }) } - fn path(&self) -> &PathBuf { - &self.path - } - fn config(&self) -> &Self::Config { &self.config } diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/trust_contexts.rs b/implementations/rust/ockam/ockam_api/src/cli_state/trust_contexts.rs index 67be9d0669f..7872e0ef312 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/trust_contexts.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/trust_contexts.rs @@ -1,13 +1,40 @@ -use super::Result; +use super::{Result, StateItemTrait}; use crate::config::cli::TrustContextConfig; use std::fmt::{Display, Formatter}; use std::path::PathBuf; +use crate::cli_state::traits::{StateDirTrait, StateItemFileTrait}; + #[derive(Debug, Clone, Eq, PartialEq)] pub struct TrustContextsState { dir: PathBuf, } +impl TrustContextsState { + pub fn read_config_from_path(&self, path: &str) -> Result { + let tcc = match std::fs::read_to_string(path) { + Ok(contents) => { + let mut tc = serde_json::from_str::(&contents)?; + tc.set_path(PathBuf::from(path)); + tc + } + Err(_) => { + let state = self.get(path)?; + let mut tcc = state.config().clone(); + tcc.set_path(state.path().clone()); + tcc + } + }; + Ok(tcc) + } +} + +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct TrustContextFileInfo { + name: String, + path: PathBuf, +} + #[derive(Debug, Clone, Eq, PartialEq)] pub struct TrustContextState { name: String, @@ -23,7 +50,7 @@ impl TrustContextState { impl Display for TrustContextState { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - writeln!(f, "Name: {}", self.name)?; + writeln!(f, "Name: {}", self.name())?; Ok(()) } } @@ -53,22 +80,9 @@ mod traits { } } - impl TrustContextsState { - pub fn read_config_from_path(&self, path: &str) -> Result { - let tcc = match std::fs::read_to_string(path) { - Ok(contents) => { - let mut tc = serde_json::from_str::(&contents)?; - tc.set_path(PathBuf::from(path)); - tc - } - Err(_) => { - let state = self.get(path)?; - let mut tcc = state.config().clone(); - tcc.set_path(state.path().clone()); - tcc - } - }; - Ok(tcc) + impl StateItemFileTrait for TrustContextState { + fn path(&self) -> &PathBuf { + &self.path } } @@ -86,12 +100,10 @@ mod traits { fn load(path: PathBuf) -> Result { let name = file_stem(&path)?; let contents = std::fs::read_to_string(&path)?; - let config = serde_json::from_str(&contents)?; - Ok(Self { name, path, config }) - } - - fn path(&self) -> &PathBuf { - &self.path + match serde_json::from_str(&contents) { + Ok(config) => Ok(Self { name, path, config }), + Err(source) => Err(source.handle_file_parse_error(path)) + } } fn config(&self) -> &Self::Config { diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/user_info.rs b/implementations/rust/ockam/ockam_api/src/cli_state/user_info.rs index 01b923446ef..7487d0c2977 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/user_info.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/user_info.rs @@ -47,6 +47,12 @@ mod traits { } } + impl StateItemFileTrait for UserInfoState { + fn path(&self) -> &PathBuf { + &self.path + } + } + #[async_trait] impl StateItemTrait for UserInfoState { type Config = UserInfoConfig; @@ -59,12 +65,10 @@ mod traits { fn load(path: PathBuf) -> Result { let contents = std::fs::read_to_string(&path)?; - let config = serde_json::from_str(&contents)?; - Ok(Self { path, config }) - } - - fn path(&self) -> &PathBuf { - &self.path + match serde_json::from_str(&contents) { + Ok(config) => Ok(Self { path, config }), + Err(source) => Err(source.handle_file_parse_error(path)) + } } fn config(&self) -> &Self::Config { diff --git a/implementations/rust/ockam/ockam_api/src/cli_state/vaults.rs b/implementations/rust/ockam/ockam_api/src/cli_state/vaults.rs index a1ed13af63b..5eb7d755968 100644 --- a/implementations/rust/ockam/ockam_api/src/cli_state/vaults.rs +++ b/implementations/rust/ockam/ockam_api/src/cli_state/vaults.rs @@ -34,13 +34,19 @@ impl VaultsState { } } +#[derive(Debug, Clone, Eq, PartialEq)] +pub struct InvalidVaultState { + path: PathBuf, + data_path: PathBuf, +} + #[derive(Debug, Clone, Eq, PartialEq)] pub struct VaultState { name: String, path: PathBuf, /// The path to the vault's storage config file, contained in the data directory data_path: PathBuf, - config: VaultConfig, + config: VaultConfig } impl VaultState { @@ -164,7 +170,32 @@ mod traits { } } - #[async_trait] + impl StateItemFileTrait for VaultState { + fn delete(&self) -> Result<()> { + std::fs::remove_file(&self.path)?; + std::fs::remove_file(&self.data_path)?; + std::fs::remove_file(self.data_path.with_extension("json.lock"))?; + Ok(()) + } + + fn path(&self) -> &PathBuf { + &self.path + } + } + + impl StateItemFileTrait for InvalidVaultState { + fn delete(&self) -> Result<()> { + std::fs::remove_file(&self.path)?; + std::fs::remove_file(&self.data_path)?; + std::fs::remove_file(self.data_path.with_extension("json.lock"))?; + Ok(()) + } + + fn path(&self) -> &PathBuf { + &self.path + } + } + impl StateItemTrait for VaultState { type Config = VaultConfig; @@ -185,25 +216,22 @@ mod traits { fn load(path: PathBuf) -> Result { let name = file_stem(&path)?; let contents = std::fs::read_to_string(&path)?; - let config = serde_json::from_str(&contents)?; let data_path = VaultState::build_data_path(&name, &path); - Ok(Self { - name, - path, - data_path, - config, - }) - } - - fn delete(&self) -> Result<()> { - std::fs::remove_file(&self.path)?; - std::fs::remove_file(&self.data_path)?; - std::fs::remove_file(self.data_path.with_extension("json.lock"))?; - Ok(()) - } - - fn path(&self) -> &PathBuf { - &self.path + match serde_json::from_str(&contents) { + Ok(config) => Ok(Self { + name, + path, + data_path, + config, + }), + Err(source) => Err(CliStateError::InvalidFile { + source, + file: Box::new(InvalidVaultState { + path, + data_path, + }) + }) + } } fn config(&self) -> &Self::Config { From 7b2f9da64faf6653beeed1ce4578d254e61e2ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20Curley?= Date: Tue, 3 Oct 2023 12:38:50 +0100 Subject: [PATCH 2/3] fix(rust): update trait imports Update `StateItemTrait` with `StateItemFileTrait` imports --- implementations/rust/ockam/ockam_api/src/trust_context.rs | 2 +- implementations/rust/ockam/ockam_command/src/lease/mod.rs | 2 +- implementations/rust/ockam/ockam_command/src/project/enroll.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/implementations/rust/ockam/ockam_api/src/trust_context.rs b/implementations/rust/ockam/ockam_api/src/trust_context.rs index 6cb05deaabf..1c330528c4d 100644 --- a/implementations/rust/ockam/ockam_api/src/trust_context.rs +++ b/implementations/rust/ockam/ockam_api/src/trust_context.rs @@ -1,4 +1,4 @@ -use crate::cli_state::{CliState, ProjectConfigCompact, StateDirTrait, StateItemTrait}; +use crate::cli_state::{CliState, ProjectConfigCompact, StateDirTrait, StateItemFileTrait, StateItemTrait}; use crate::cloud::project::Project; use crate::config::cli::TrustContextConfig; use miette::{IntoDiagnostic, WrapErr}; diff --git a/implementations/rust/ockam/ockam_command/src/lease/mod.rs b/implementations/rust/ockam/ockam_command/src/lease/mod.rs index 8942e291137..7e95d955150 100644 --- a/implementations/rust/ockam/ockam_command/src/lease/mod.rs +++ b/implementations/rust/ockam/ockam_command/src/lease/mod.rs @@ -10,7 +10,7 @@ pub use show::ShowCommand; use clap::{Args, Subcommand}; use miette::{miette, Context, IntoDiagnostic}; -use ockam_api::cli_state::{ProjectConfigCompact, StateDirTrait, StateItemTrait}; +use ockam_api::cli_state::{ProjectConfigCompact, StateDirTrait, StateItemFileTrait}; use ockam_api::cloud::ProjectNode; use ockam_api::config::lookup::ProjectLookup; use ockam_api::nodes::Credentials; diff --git a/implementations/rust/ockam/ockam_command/src/project/enroll.rs b/implementations/rust/ockam/ockam_command/src/project/enroll.rs index aa6783f9258..a7dad6feb09 100644 --- a/implementations/rust/ockam/ockam_command/src/project/enroll.rs +++ b/implementations/rust/ockam/ockam_command/src/project/enroll.rs @@ -5,7 +5,7 @@ use miette::Context as _; use miette::{miette, IntoDiagnostic}; use ockam::Context; -use ockam_api::cli_state::{ProjectConfigCompact, StateDirTrait, StateItemTrait}; +use ockam_api::cli_state::{ProjectConfigCompact, StateDirTrait, StateItemFileTrait, StateItemTrait}; use ockam_api::cloud::project::{OktaAuth0, Project}; use ockam_api::cloud::AuthorityNode; use ockam_api::enroll::enrollment::Enrollment; From fe9ccc4ce502732c6e9f64d97414049ed4b1acf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20Curley?= Date: Tue, 3 Oct 2023 12:42:09 +0100 Subject: [PATCH 3/3] test(rust): update trait imports in tests --- implementations/rust/ockam/ockam_command/src/identity/mod.rs | 2 +- implementations/rust/ockam/ockam_command/src/node/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/implementations/rust/ockam/ockam_command/src/identity/mod.rs b/implementations/rust/ockam/ockam_command/src/identity/mod.rs index 6990a4349d7..86d1e7b3f30 100644 --- a/implementations/rust/ockam/ockam_command/src/identity/mod.rs +++ b/implementations/rust/ockam/ockam_command/src/identity/mod.rs @@ -109,7 +109,7 @@ pub fn create_default_identity(opts: &CommandGlobalOpts) { mod tests { use super::*; use crate::GlobalArgs; - use ockam_api::cli_state::StateItemTrait; + use ockam_api::cli_state::StateItemFileTrait; #[test] fn test_initialize() { diff --git a/implementations/rust/ockam/ockam_command/src/node/mod.rs b/implementations/rust/ockam/ockam_command/src/node/mod.rs index d06d9574bd9..eb41eaf46cb 100644 --- a/implementations/rust/ockam/ockam_command/src/node/mod.rs +++ b/implementations/rust/ockam/ockam_command/src/node/mod.rs @@ -133,7 +133,7 @@ fn spawn_default_node(opts: &CommandGlobalOpts) { mod tests { use super::*; use crate::GlobalArgs; - use ockam_api::cli_state::StateItemTrait; + use ockam_api::cli_state::StateItemFileTrait; #[test] fn test_initialize() {