Skip to content

Commit 32c12a9

Browse files
committed
CI: change the endpoint from localhost to the IP of the running samba service
1 parent ee95150 commit 32c12a9

File tree

4 files changed

+43
-13
lines changed

4 files changed

+43
-13
lines changed
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Rust
1+
name: Build
22

33
on:
44
push:
@@ -12,9 +12,12 @@ env:
1212
CARGO_TERM_COLOR: always
1313

1414
jobs:
15-
build_and_test:
15+
test:
1616

1717
runs-on: ubuntu-latest
18+
container:
19+
image: rust:latest
20+
1821
strategy:
1922
matrix:
2023
compile_features: [ async, multi_threaded, single_threaded ]
@@ -31,10 +34,24 @@ jobs:
3134
credentials:
3235
username: ${{ github.actor }}
3336
password: ${{ secrets.ACCESS_TOKEN }}
37+
options: --name samba --privileged --cap-add NET_ADMIN
3438

3539
steps:
3640
- uses: actions/checkout@v4
41+
- name: check
42+
run: |
43+
apt update
44+
apt install -y iputils-ping net-tools netcat-traditional samba smbclient tcpdump
45+
ping -c 4 samba
46+
nc -zv samba 445
47+
find / -name smbclient
48+
echo "ls" | smbclient --user=LocalAdmin --password=123456 "\\\\samba\\MyShare"
3749
- name: Build/${{ matrix.compile_features }}
3850
run: cargo build --verbose --no-default-features --features "${{ matrix.compile_features }},sign,encrypt,compress"
3951
- name: Tests/${{ matrix.compile_features }}
40-
run: cargo test --verbose --no-default-features --features "${{ matrix.compile_features }},sign,encrypt,compress"
52+
run: |
53+
export SMB_RUST_TESTS_SERVER=samba:445
54+
echo "ls" | smbclient --debuglevel=10 --user=LocalAdmin --password=123456 "\\\\samba\\MyShare"
55+
# run tcpdump in background to capture SMB traffic, log to stdout
56+
tcpdump -i any -w - -s 0 -nn -vv -X -c 100 'port 445' &
57+
cargo test --verbose --no-default-features --features "${{ matrix.compile_features }},sign,encrypt,compress" -- --nocapture

smb/tests/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Integration tests
2+
## Running the tests
3+
The tests below are intended to test the library's integration with the SMB protocol, by starting up a samba container and running the tests against it.
4+
To start the container, run the following command:
5+
```bash
6+
docker compose up [-d]
7+
```
8+
9+
Then, you can run the tests as usual, using `cargo test`.
10+
11+
> [!IMPORTANT]
12+
> The tests bind to port 445 by default, so make sure it is available on your machine.
13+
> On many windows machines, this port is already in use by the system; Modify docker-compose.yml to use a different port if necessary,
14+
> and use the `SMB_RUST_TESTS_SERVER=HOST:PORT` environment variable to specify the new port. The same goes for the IP address, if necessary.
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ pub async fn test_smb_integration_basic() -> Result<(), Box<dyn std::error::Erro
1313

1414
let mut smb = Connection::new();
1515
// Default to localhost, LocalAdmin, 123456
16-
let server = var("SMB_SERVER").unwrap_or("127.0.0.1:445".to_string());
17-
let user = var("SMB_USER").unwrap_or("LocalAdmin".to_string());
18-
let password = var("SMB_PASSWORD").unwrap_or("123456".to_string());
16+
let server = var("SMB_RUST_TESTS_SERVER").unwrap_or("127.0.0.1:445".to_string());
17+
let user = var("SMB_RUST_TESTS_USER_NAME").unwrap_or("LocalAdmin".to_string());
18+
let password = var("SMB_RUST_TESTS_PASSWORD").unwrap_or("123456".to_string());
19+
20+
println!("Connecting to {} as {}", server, user);
21+
1922
// Connect & Authenticate
2023
smb.connect(&server).await?;
24+
print!("Connected, authenticating...");
2125
let mut session = smb.authenticate(&user, password).await?;
26+
println!("Authenticated!");
2227
let mut tree = session.tree_connect("MyShare").await?;
28+
print!("Connected to share, start test basic");
2329

2430
// Hello, World! > test.txt
2531
{

smb/tests/start.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)