Skip to content

Commit 2a9824f

Browse files
committed
fix: test is sync and send
1 parent ac2533a commit 2a9824f

File tree

10 files changed

+69
-25
lines changed

10 files changed

+69
-25
lines changed

.github/workflows/coverage.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@ jobs:
1616
- name: Setup containers
1717
run: docker compose -f "tests/docker-compose.yml" up -d --build
1818
- name: Setup nightly toolchain
19-
uses: actions-rs/toolchain@v1
19+
uses: dtolnay/rust-toolchain@stable
2020
with:
2121
toolchain: nightly
2222
override: true
2323
- name: Run tests (nightly)
24-
uses: actions-rs/cargo@v1
25-
with:
26-
command: test
27-
args: --lib --no-default-features --features find,github-actions,with-containers --no-fail-fast
24+
run: cargo test --lib --no-default-features --features find,github-actions,with-containers --no-fail-fast
2825
env:
2926
RUST_LOG: trace
3027
CARGO_INCREMENTAL: "0"

.github/workflows/linux.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
run: sudo apt update && sudo apt install -y libssh2-1-dev libssl-dev
1616
- name: Setup containers
1717
run: docker compose -f "tests/docker-compose.yml" up -d --build
18-
- uses: actions-rs/toolchain@v1
18+
- uses: dtolnay/rust-toolchain@stable
1919
with:
2020
toolchain: stable
2121
override: true
@@ -24,14 +24,11 @@ jobs:
2424
run: cargo build --all-features
2525
- name: Build (unsecure)
2626
run: cargo build --no-default-features
27-
- name: Run tests
28-
uses: actions-rs/cargo@v1
29-
with:
30-
command: test
31-
args: --no-default-features --features find,github-actions,with-containers --no-fail-fast
32-
env:
33-
RUST_LOG: trace
3427
- name: Format
3528
run: cargo fmt --all -- --check
3629
- name: Clippy
3730
run: cargo clippy --features find -- -Dwarnings
31+
- name: Run tests
32+
run: cargo test --all-features --features find,github-actions,with-containers
33+
env:
34+
RUST_LOG: trace

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
- [Changelog](#changelog)
4+
- [0.5.0](#050)
45
- [0.4.1](#041)
56
- [0.4.0](#040)
67
- [0.3.1](#031)
@@ -16,6 +17,12 @@
1617

1718
---
1819

20+
## 0.5.0
21+
22+
Released on 26/102/2024
23+
24+
- `SshKeyStorage` must be `Sync` and `Send`
25+
1926
## 0.4.1
2027

2128
Released on 07/10/2024

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ license = "MIT"
1010
name = "remotefs-ssh"
1111
readme = "README.md"
1212
repository = "https://github.com/remotefs-rs/remotefs-rs-ssh"
13-
version = "0.4.1"
13+
version = "0.5.0"
14+
rust-version = "1.71.1"
1415

1516
[dependencies]
1617
chrono = "^0.4"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<p align="center">~ Remotefs SSH client ~</p>
1212

1313
<p align="center">Developed by <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
14-
<p align="center">Current version: 0.4.1 (07/10/2024)</p>
14+
<p align="center">Current version: 0.5.0 (26/10/2024)</p>
1515

1616
<p align="center">
1717
<a href="https://opensource.org/licenses/MIT"
@@ -82,7 +82,7 @@ First of all, add `remotefs-ssh` to your project dependencies:
8282

8383
```toml
8484
remotefs = "0.3"
85-
remotefs-ssh = "^0.4"
85+
remotefs-ssh = "^0.5"
8686
```
8787

8888
these features are supported:

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
//! First of all you need to add **remotefs** and the client to your project dependencies:
1111
//!
1212
//! ```toml
13-
//! remotefs = "^0.2"
14-
//! remotefs-ssh = "^0.3"
13+
//! remotefs = "^0.3"
14+
//! remotefs-ssh = "^0.5"
1515
//! ```
1616
//!
1717
//! these features are supported:

src/ssh/commons.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::SshAgentIdentity;
1717

1818
// -- connect
1919

20-
/// Establish connection with remote server and in case of success, return the generated `Session`
20+
/// Establish connection with remote server and in case of success, return the generated [`Session`]
2121
pub fn connect(opts: &SshOpts) -> RemoteResult<Session> {
2222
// parse configuration
2323
let ssh_config = Config::try_from(opts)?;

src/ssh/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ use stream::{SftpReadStream, SftpWriteStream};
2222
// -- Ssh key storage
2323

2424
/// This trait must be implemented in order to use ssh keys for authentication for sftp/scp.
25-
pub trait SshKeyStorage {
25+
pub trait SshKeyStorage: Send + Sync {
2626
/// Return RSA key path from host and username
2727
fn resolve(&self, host: &str, username: &str) -> Option<PathBuf>;
2828
}
2929

3030
// -- key method
3131

3232
/// Ssh key method.
33-
/// Defined by `MethodType` (see ssh2 docs) and the list of supported algorithms.
33+
/// Defined by [`MethodType`] (see ssh2 docs) and the list of supported algorithms.
3434
pub struct KeyMethod {
3535
pub(crate) method_type: MethodType,
3636
algos: Vec<String>,
3737
}
3838

3939
impl KeyMethod {
40-
/// Instantiates a new `KeyMethod`
40+
/// Instantiates a new [`KeyMethod`]
4141
pub fn new(method_type: MethodType, algos: &[String]) -> Self {
4242
Self {
4343
method_type,
@@ -77,7 +77,7 @@ impl From<&[u8]> for SshAgentIdentity {
7777
impl SshAgentIdentity {
7878
/// Check if the provided public key matches the identity
7979
///
80-
/// If `All` is provided, this method will always return `true`
80+
/// If [`SshAgentIdentity::All`] is provided, this method will always return `true`
8181
pub(crate) fn pubkey_matches(&self, blob: &[u8]) -> bool {
8282
match self {
8383
SshAgentIdentity::All => true,
@@ -94,7 +94,7 @@ impl SshAgentIdentity {
9494
/// You may specify some options that can be in conflict (e.g. `port` and `Port` parameter in ssh configuration).
9595
/// In these cases, the resolution is performed in this order (from highest, to lower priority):
9696
///
97-
/// 1. SshOpts attribute (e.g. `port` or `username`)
97+
/// 1. [`SshOpts`] attribute (e.g. `port` or `username`)
9898
/// 2. Ssh configuration
9999
///
100100
/// This applies also to ciphers and key exchange methods.
@@ -123,7 +123,7 @@ pub struct SshOpts {
123123
}
124124

125125
impl SshOpts {
126-
/// Initialize SshOpts.
126+
/// Initialize [`SshOpts`].
127127
/// You must define the host you want to connect to.
128128
/// Host may be resolved by ssh configuration, if specified.
129129
///

src/ssh/scp.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,27 @@ mod test {
14471447
.is_err());
14481448
}
14491449

1450+
fn is_send<T: Send>(_send: T) {}
1451+
1452+
fn is_sync<T: Sync>(_sync: T) {}
1453+
1454+
#[test]
1455+
fn test_should_be_sync() {
1456+
let client = ScpFs::new(
1457+
SshOpts::new("sftp").key_storage(Box::new(ssh_mock::MockSshKeyStorage::default())),
1458+
);
1459+
1460+
is_sync(client);
1461+
}
1462+
1463+
#[test]
1464+
fn test_should_be_send() {
1465+
let client = ScpFs::new(
1466+
SshOpts::new("sftp").key_storage(Box::new(ssh_mock::MockSshKeyStorage::default())),
1467+
);
1468+
is_send(client);
1469+
}
1470+
14501471
// -- test utils
14511472

14521473
#[cfg(feature = "with-containers")]

src/ssh/sftp.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,27 @@ mod test {
12341234
.is_err());
12351235
}
12361236

1237+
fn is_send<T: Send>(_send: T) {}
1238+
1239+
fn is_sync<T: Sync>(_sync: T) {}
1240+
1241+
#[test]
1242+
fn test_should_be_sync() {
1243+
let client = SftpFs::new(
1244+
SshOpts::new("sftp").key_storage(Box::new(ssh_mock::MockSshKeyStorage::default())),
1245+
);
1246+
1247+
is_sync(client);
1248+
}
1249+
1250+
#[test]
1251+
fn test_should_be_send() {
1252+
let client = SftpFs::new(
1253+
SshOpts::new("sftp").key_storage(Box::new(ssh_mock::MockSshKeyStorage::default())),
1254+
);
1255+
is_send(client);
1256+
}
1257+
12371258
// -- test utils
12381259

12391260
#[cfg(feature = "with-containers")]

0 commit comments

Comments
 (0)