mirror of
https://github.com/veeso/termscp.git
synced 2025-12-06 17:15:35 -08:00
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
Released on ??
|
Released on ??
|
||||||
|
|
||||||
|
- [issue 308](https://github.com/veeso/termscp/issues/308): added `--wno-keyring` flag to disable keyring
|
||||||
- [issue 316](https://github.com/veeso/termscp/issues/316): Local directory path is not switching to what's specified in the bookmark. Now the local directory path is correctly set following this hierarchy:
|
- [issue 316](https://github.com/veeso/termscp/issues/316): Local directory path is not switching to what's specified in the bookmark. Now the local directory path is correctly set following this hierarchy:
|
||||||
1. Local directory path specified for the host bridge
|
1. Local directory path specified for the host bridge
|
||||||
2. Local directory path specified in the bookmark
|
2. Local directory path specified in the bookmark
|
||||||
|
|||||||
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -1125,6 +1125,7 @@ dependencies = [
|
|||||||
"futures-util",
|
"futures-util",
|
||||||
"num",
|
"num",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
"openssl",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2334,6 +2335,7 @@ dependencies = [
|
|||||||
"byteorder",
|
"byteorder",
|
||||||
"dbus-secret-service",
|
"dbus-secret-service",
|
||||||
"log",
|
"log",
|
||||||
|
"openssl",
|
||||||
"security-framework 2.11.1",
|
"security-framework 2.11.1",
|
||||||
"security-framework 3.2.0",
|
"security-framework 3.2.0",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
@@ -2472,6 +2474,7 @@ version = "0.2.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72"
|
checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"cc",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -41,10 +41,11 @@ dirs = "^6"
|
|||||||
edit = "^0.1"
|
edit = "^0.1"
|
||||||
filetime = "^0.2"
|
filetime = "^0.2"
|
||||||
hostname = "^0.4"
|
hostname = "^0.4"
|
||||||
keyring = { version = "^3", optional = true, features = [
|
keyring = { version = "^3", features = [
|
||||||
"apple-native",
|
"apple-native",
|
||||||
"windows-native",
|
"windows-native",
|
||||||
"sync-secret-service",
|
"sync-secret-service",
|
||||||
|
"vendored",
|
||||||
] }
|
] }
|
||||||
lazy-regex = "^3"
|
lazy-regex = "^3"
|
||||||
lazy_static = "^1"
|
lazy_static = "^1"
|
||||||
@@ -92,11 +93,11 @@ vergen-git2 = { version = "1", features = ["build", "cargo", "rustc", "si"] }
|
|||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["smb", "with-keyring"]
|
default = ["smb", "keyring"]
|
||||||
github-actions = []
|
github-actions = []
|
||||||
isolated-tests = []
|
isolated-tests = []
|
||||||
smb = ["remotefs-smb"]
|
smb = ["dep:remotefs-smb"]
|
||||||
with-keyring = ["keyring"]
|
keyring = []
|
||||||
|
|
||||||
[target."cfg(not(target_os = \"macos\"))".dependencies]
|
[target."cfg(not(target_os = \"macos\"))".dependencies]
|
||||||
remotefs-smb = { version = "^0.3", optional = true }
|
remotefs-smb = { version = "^0.3", optional = true }
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ sudo <span class="function">dpkg</span> -i <span class="string">termscp.deb</spa
|
|||||||
</p>
|
</p>
|
||||||
<pre><span class="function">cargo</span> install --locked --no-default-features --features smb <span class="string">termscp</span></pre>
|
<pre><span class="function">cargo</span> install --locked --no-default-features --features smb <span class="string">termscp</span></pre>
|
||||||
<p translate="getStarted.cargo.noSMB" class="pt-4 pb-2"></p>
|
<p translate="getStarted.cargo.noSMB" class="pt-4 pb-2"></p>
|
||||||
<pre><span class="function">cargo</span> install --locked --no-default-features --features with-keyring <span class="string">termscp</span></pre>
|
<pre><span class="function">cargo</span> install --locked --no-default-features --features keyring <span class="string">termscp</span></pre>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ pub struct ActivityManager {
|
|||||||
|
|
||||||
impl ActivityManager {
|
impl ActivityManager {
|
||||||
/// Initializes a new Activity Manager
|
/// Initializes a new Activity Manager
|
||||||
pub fn new(ticks: Duration) -> Result<ActivityManager, HostError> {
|
pub fn new(ticks: Duration, keyring: bool) -> Result<ActivityManager, HostError> {
|
||||||
// Prepare Context
|
// Prepare Context
|
||||||
// Initialize configuration client
|
// Initialize configuration client
|
||||||
let (config_client, error_config): (ConfigClient, Option<String>) =
|
let (config_client, error_config): (ConfigClient, Option<String>) =
|
||||||
@@ -61,7 +61,7 @@ impl ActivityManager {
|
|||||||
(ConfigClient::degraded(), Some(err))
|
(ConfigClient::degraded(), Some(err))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let (bookmarks_client, error_bookmark) = match Self::init_bookmarks_client() {
|
let (bookmarks_client, error_bookmark) = match Self::init_bookmarks_client(keyring) {
|
||||||
Ok(cli) => (cli, None),
|
Ok(cli) => (cli, None),
|
||||||
Err(err) => (None, Some(err)),
|
Err(err) => (None, Some(err)),
|
||||||
};
|
};
|
||||||
@@ -447,7 +447,7 @@ impl ActivityManager {
|
|||||||
|
|
||||||
// -- misc
|
// -- misc
|
||||||
|
|
||||||
fn init_bookmarks_client() -> Result<Option<BookmarksClient>, String> {
|
fn init_bookmarks_client(keyring: bool) -> Result<Option<BookmarksClient>, String> {
|
||||||
// Get config dir
|
// Get config dir
|
||||||
match environment::init_config_dir() {
|
match environment::init_config_dir() {
|
||||||
Ok(path) => {
|
Ok(path) => {
|
||||||
@@ -456,16 +456,21 @@ impl ActivityManager {
|
|||||||
let bookmarks_file: PathBuf =
|
let bookmarks_file: PathBuf =
|
||||||
environment::get_bookmarks_paths(config_dir_path.as_path());
|
environment::get_bookmarks_paths(config_dir_path.as_path());
|
||||||
// Initialize client
|
// Initialize client
|
||||||
BookmarksClient::new(bookmarks_file.as_path(), config_dir_path.as_path(), 16)
|
BookmarksClient::new(
|
||||||
.map(Option::Some)
|
bookmarks_file.as_path(),
|
||||||
.map_err(|e| {
|
config_dir_path.as_path(),
|
||||||
format!(
|
16,
|
||||||
"Could not initialize bookmarks (at \"{}\", \"{}\"): {}",
|
keyring,
|
||||||
bookmarks_file.display(),
|
)
|
||||||
config_dir_path.display(),
|
.map(Option::Some)
|
||||||
e
|
.map_err(|e| {
|
||||||
)
|
format!(
|
||||||
})
|
"Could not initialize bookmarks (at \"{}\", \"{}\"): {}",
|
||||||
|
bookmarks_file.display(),
|
||||||
|
config_dir_path.display(),
|
||||||
|
e
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ pub struct Args {
|
|||||||
/// print version
|
/// print version
|
||||||
#[argh(switch, short = 'v')]
|
#[argh(switch, short = 'v')]
|
||||||
pub version: bool,
|
pub version: bool,
|
||||||
|
/// disable keyring support
|
||||||
|
#[argh(switch)]
|
||||||
|
pub wno_keyring: bool,
|
||||||
// -- positional
|
// -- positional
|
||||||
#[argh(positional, description = "address1 address2 local-wrkdir")]
|
#[argh(positional, description = "address1 address2 local-wrkdir")]
|
||||||
pub positional: Vec<String>,
|
pub positional: Vec<String>,
|
||||||
@@ -94,6 +97,7 @@ pub struct LoadThemeArgs {
|
|||||||
|
|
||||||
pub struct RunOpts {
|
pub struct RunOpts {
|
||||||
pub remote: RemoteArgs,
|
pub remote: RemoteArgs,
|
||||||
|
pub keyring: bool,
|
||||||
pub ticks: Duration,
|
pub ticks: Duration,
|
||||||
pub log_level: LogLevel,
|
pub log_level: LogLevel,
|
||||||
pub task: Task,
|
pub task: Task,
|
||||||
@@ -127,6 +131,7 @@ impl Default for RunOpts {
|
|||||||
Self {
|
Self {
|
||||||
remote: RemoteArgs::default(),
|
remote: RemoteArgs::default(),
|
||||||
ticks: Duration::from_millis(10),
|
ticks: Duration::from_millis(10),
|
||||||
|
keyring: true,
|
||||||
log_level: LogLevel::Info,
|
log_level: LogLevel::Info,
|
||||||
task: Task::Activity(NextActivity::Authentication),
|
task: Task::Activity(NextActivity::Authentication),
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/main.rs
12
src/main.rs
@@ -76,6 +76,7 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
|
|||||||
Some(ArgsSubcommands::Config(_)) => RunOpts::config(),
|
Some(ArgsSubcommands::Config(_)) => RunOpts::config(),
|
||||||
None => {
|
None => {
|
||||||
let mut run_opts: RunOpts = RunOpts::default();
|
let mut run_opts: RunOpts = RunOpts::default();
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
if args.version {
|
if args.version {
|
||||||
run_opts.task = Task::Version;
|
run_opts.task = Task::Version;
|
||||||
@@ -87,6 +88,10 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
|
|||||||
} else if args.quiet {
|
} else if args.quiet {
|
||||||
run_opts.log_level = LogLevel::Off;
|
run_opts.log_level = LogLevel::Off;
|
||||||
}
|
}
|
||||||
|
// set keyring
|
||||||
|
if args.wno_keyring {
|
||||||
|
run_opts.keyring = false;
|
||||||
|
}
|
||||||
// Match ticks
|
// Match ticks
|
||||||
run_opts.ticks = Duration::from_millis(args.ticks);
|
run_opts.ticks = Duration::from_millis(args.ticks);
|
||||||
// Remote argument
|
// Remote argument
|
||||||
@@ -124,7 +129,9 @@ fn run(run_opts: RunOpts) -> MainResult<()> {
|
|||||||
match run_opts.task {
|
match run_opts.task {
|
||||||
Task::ImportTheme(theme) => run_import_theme(&theme),
|
Task::ImportTheme(theme) => run_import_theme(&theme),
|
||||||
Task::InstallUpdate => run_install_update(),
|
Task::InstallUpdate => run_install_update(),
|
||||||
Task::Activity(activity) => run_activity(activity, run_opts.ticks, run_opts.remote),
|
Task::Activity(activity) => {
|
||||||
|
run_activity(activity, run_opts.ticks, run_opts.remote, run_opts.keyring)
|
||||||
|
}
|
||||||
Task::Version => print_version(),
|
Task::Version => print_version(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,9 +175,10 @@ fn run_activity(
|
|||||||
activity: NextActivity,
|
activity: NextActivity,
|
||||||
ticks: Duration,
|
ticks: Duration,
|
||||||
remote_args: RemoteArgs,
|
remote_args: RemoteArgs,
|
||||||
|
keyring: bool,
|
||||||
) -> MainResult<()> {
|
) -> MainResult<()> {
|
||||||
// Create activity manager (and context too)
|
// Create activity manager (and context too)
|
||||||
let mut manager: ActivityManager = match ActivityManager::new(ticks) {
|
let mut manager: ActivityManager = match ActivityManager::new(ticks, keyring) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Could not start activity manager: {err}");
|
eprintln!("Could not start activity manager: {err}");
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use std::string::ToString;
|
|||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use super::keys::filestorage::FileStorage;
|
use super::keys::filestorage::FileStorage;
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
use super::keys::keyringstorage::KeyringStorage;
|
use super::keys::keyringstorage::KeyringStorage;
|
||||||
use super::keys::{KeyStorage, KeyStorageError};
|
use super::keys::{KeyStorage, KeyStorageError};
|
||||||
// Local
|
// Local
|
||||||
@@ -39,42 +38,13 @@ impl BookmarksClient {
|
|||||||
bookmarks_file: &Path,
|
bookmarks_file: &Path,
|
||||||
storage_path: &Path,
|
storage_path: &Path,
|
||||||
recents_size: usize,
|
recents_size: usize,
|
||||||
|
keyring: bool,
|
||||||
) -> Result<BookmarksClient, SerializerError> {
|
) -> Result<BookmarksClient, SerializerError> {
|
||||||
// Create default hosts
|
// Create default hosts
|
||||||
let default_hosts: UserHosts = UserHosts::default();
|
let default_hosts: UserHosts = UserHosts::default();
|
||||||
debug!("Setting up bookmarks client...");
|
debug!("Setting up bookmarks client...");
|
||||||
// Make a key storage (with-keyring)
|
// Get key storage
|
||||||
#[cfg(feature = "with-keyring")]
|
let (key_storage, service_id) = Self::keyring(storage_path, keyring);
|
||||||
let (key_storage, service_id): (Box<dyn KeyStorage>, &str) = {
|
|
||||||
debug!("Setting up KeyStorage");
|
|
||||||
let username: String = whoami::username();
|
|
||||||
let storage: KeyringStorage = KeyringStorage::new(username.as_str());
|
|
||||||
// Check if keyring storage is supported
|
|
||||||
#[cfg(not(test))]
|
|
||||||
let app_name: &str = "termscp";
|
|
||||||
#[cfg(test)] // NOTE: when running test, add -test
|
|
||||||
let app_name: &str = "termscp-test";
|
|
||||||
match storage.is_supported() {
|
|
||||||
true => {
|
|
||||||
debug!("Using KeyringStorage");
|
|
||||||
(Box::new(storage), app_name)
|
|
||||||
}
|
|
||||||
false => {
|
|
||||||
warn!("KeyringStorage is not supported; using FileStorage");
|
|
||||||
(Box::new(FileStorage::new(storage_path)), "bookmarks")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// Make a key storage (wno-keyring)
|
|
||||||
#[cfg(not(feature = "with-keyring"))]
|
|
||||||
let (key_storage, service_id): (Box<dyn KeyStorage>, &str) = {
|
|
||||||
#[cfg(not(test))]
|
|
||||||
let app_name: &str = "bookmarks";
|
|
||||||
#[cfg(test)] // NOTE: when running test, add -test
|
|
||||||
let app_name: &str = "bookmarks-test";
|
|
||||||
debug!("Using FileStorage");
|
|
||||||
(Box::new(FileStorage::new(storage_path)), app_name)
|
|
||||||
};
|
|
||||||
// Load key
|
// Load key
|
||||||
let key: String = match key_storage.get_key(service_id) {
|
let key: String = match key_storage.get_key(service_id) {
|
||||||
Ok(k) => {
|
Ok(k) => {
|
||||||
@@ -130,6 +100,37 @@ impl BookmarksClient {
|
|||||||
Ok(client)
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the key storage
|
||||||
|
fn keyring(storage_path: &Path, keyring: bool) -> (Box<dyn KeyStorage>, &'static str) {
|
||||||
|
if keyring && cfg!(feature = "keyring") {
|
||||||
|
debug!("Setting up KeyStorage");
|
||||||
|
let username: String = whoami::username();
|
||||||
|
let storage: KeyringStorage = KeyringStorage::new(username.as_str());
|
||||||
|
// Check if keyring storage is supported
|
||||||
|
#[cfg(not(test))]
|
||||||
|
let app_name: &str = "termscp";
|
||||||
|
#[cfg(test)] // NOTE: when running test, add -test
|
||||||
|
let app_name: &str = "termscp-test";
|
||||||
|
match storage.is_supported() {
|
||||||
|
true => {
|
||||||
|
debug!("Using KeyringStorage");
|
||||||
|
(Box::new(storage), app_name)
|
||||||
|
}
|
||||||
|
false => {
|
||||||
|
warn!("KeyringStorage is not supported; using FileStorage");
|
||||||
|
(Box::new(FileStorage::new(storage_path)), "bookmarks")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
#[cfg(not(test))]
|
||||||
|
let app_name: &str = "bookmarks";
|
||||||
|
#[cfg(test)] // NOTE: when running test, add -test
|
||||||
|
let app_name: &str = "bookmarks-test";
|
||||||
|
debug!("Using FileStorage");
|
||||||
|
(Box::new(FileStorage::new(storage_path)), app_name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Iterate over bookmarks keys
|
/// Iterate over bookmarks keys
|
||||||
pub fn iter_bookmarks(&self) -> impl Iterator<Item = &String> + '_ {
|
pub fn iter_bookmarks(&self) -> impl Iterator<Item = &String> + '_ {
|
||||||
Box::new(self.hosts.bookmarks.keys())
|
Box::new(self.hosts.bookmarks.keys())
|
||||||
@@ -389,7 +390,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let client: BookmarksClient =
|
let client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Verify client
|
// Verify client
|
||||||
assert_eq!(client.hosts.bookmarks.len(), 0);
|
assert_eq!(client.hosts.bookmarks.len(), 0);
|
||||||
assert_eq!(client.hosts.recents.len(), 0);
|
assert_eq!(client.hosts.recents.len(), 0);
|
||||||
@@ -405,7 +406,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add some bookmarks
|
// Add some bookmarks
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"raspberry",
|
"raspberry",
|
||||||
@@ -430,7 +431,7 @@ mod tests {
|
|||||||
let key: String = client.key.clone();
|
let key: String = client.key.clone();
|
||||||
// Re-initialize a client
|
// Re-initialize a client
|
||||||
let client: BookmarksClient =
|
let client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Verify it loaded parameters correctly
|
// Verify it loaded parameters correctly
|
||||||
assert_eq!(client.key, key);
|
assert_eq!(client.key, key);
|
||||||
let bookmark = ftparams_to_tup(client.get_bookmark("raspberry").unwrap());
|
let bookmark = ftparams_to_tup(client.get_bookmark("raspberry").unwrap());
|
||||||
@@ -453,7 +454,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add s3 bookmark
|
// Add s3 bookmark
|
||||||
client.add_bookmark("my-bucket", make_s3_ftparams(), true);
|
client.add_bookmark("my-bucket", make_s3_ftparams(), true);
|
||||||
// Verify bookmark
|
// Verify bookmark
|
||||||
@@ -473,7 +474,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add s3 bookmark
|
// Add s3 bookmark
|
||||||
client.add_bookmark("my-bucket", make_s3_ftparams(), false);
|
client.add_bookmark("my-bucket", make_s3_ftparams(), false);
|
||||||
// Verify bookmark
|
// Verify bookmark
|
||||||
@@ -494,7 +495,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add s3 bookmark
|
// Add s3 bookmark
|
||||||
client.add_recent(make_s3_ftparams());
|
client.add_recent(make_s3_ftparams());
|
||||||
// Verify bookmark
|
// Verify bookmark
|
||||||
@@ -517,7 +518,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"raspberry",
|
"raspberry",
|
||||||
@@ -568,7 +569,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"",
|
"",
|
||||||
@@ -589,7 +590,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"raspberry",
|
"raspberry",
|
||||||
@@ -617,7 +618,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_recent(make_generic_ftparams(
|
client.add_recent(make_generic_ftparams(
|
||||||
FileTransferProtocol::Sftp,
|
FileTransferProtocol::Sftp,
|
||||||
@@ -653,7 +654,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_recent(make_generic_ftparams(
|
client.add_recent(make_generic_ftparams(
|
||||||
FileTransferProtocol::Sftp,
|
FileTransferProtocol::Sftp,
|
||||||
@@ -680,7 +681,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 2).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 2, true).unwrap();
|
||||||
// Add recent, wait 1 second for each one (cause the name depends on time)
|
// Add recent, wait 1 second for each one (cause the name depends on time)
|
||||||
// 1
|
// 1
|
||||||
client.add_recent(make_generic_ftparams(
|
client.add_recent(make_generic_ftparams(
|
||||||
@@ -748,7 +749,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
// Add bookmark
|
// Add bookmark
|
||||||
client.add_bookmark(
|
client.add_bookmark(
|
||||||
"",
|
"",
|
||||||
@@ -769,7 +770,7 @@ mod tests {
|
|||||||
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
|
||||||
// Initialize a new bookmarks client
|
// Initialize a new bookmarks client
|
||||||
let mut client: BookmarksClient =
|
let mut client: BookmarksClient =
|
||||||
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16).unwrap();
|
BookmarksClient::new(cfg_path.as_path(), key_path.as_path(), 16, true).unwrap();
|
||||||
client.key = "MYSUPERSECRETKEY".to_string();
|
client.key = "MYSUPERSECRETKEY".to_string();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
client.decrypt_str("z4Z6LpcpYqBW4+bkIok+5A==").ok().unwrap(),
|
client.decrypt_str("z4Z6LpcpYqBW4+bkIok+5A==").ok().unwrap(),
|
||||||
|
|||||||
@@ -4,29 +4,24 @@
|
|||||||
|
|
||||||
// Storages
|
// Storages
|
||||||
pub mod filestorage;
|
pub mod filestorage;
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
pub mod keyringstorage;
|
pub mod keyringstorage;
|
||||||
// ext
|
// ext
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
use keyring::Error as KeyringError;
|
use keyring::Error as KeyringError;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
/// defines the error type for the `KeyStorage`
|
/// defines the error type for the `KeyStorage`
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum KeyStorageError {
|
pub enum KeyStorageError {
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
#[error("Key has a bad syntax")]
|
#[error("Key has a bad syntax")]
|
||||||
BadSytax,
|
BadSytax,
|
||||||
#[error("Provider service error")]
|
#[error("Provider service error")]
|
||||||
ProviderError,
|
ProviderError,
|
||||||
#[error("No such key")]
|
#[error("No such key")]
|
||||||
NoSuchKey,
|
NoSuchKey,
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
#[error("keyring error: {0}")]
|
#[error("keyring error: {0}")]
|
||||||
KeyringError(KeyringError),
|
KeyringError(KeyringError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
impl From<KeyringError> for KeyStorageError {
|
impl From<KeyringError> for KeyStorageError {
|
||||||
fn from(e: KeyringError) -> Self {
|
fn from(e: KeyringError) -> Self {
|
||||||
Self::KeyringError(e)
|
Self::KeyringError(e)
|
||||||
@@ -58,7 +53,6 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_system_keys_mod_errors() {
|
fn test_system_keys_mod_errors() {
|
||||||
#[cfg(feature = "with-keyring")]
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
KeyStorageError::BadSytax.to_string(),
|
KeyStorageError::BadSytax.to_string(),
|
||||||
String::from("Key has a bad syntax")
|
String::from("Key has a bad syntax")
|
||||||
|
|||||||
Reference in New Issue
Block a user