Skip to content

Commit

Permalink
Change: toggle smoketest
Browse files Browse the repository at this point in the history
Instead of having to run a smoke test for each cargo test we just run it
when explicitely set. This is done by introducing a feature called
`smoketest` that is toggling if the `smoketest/tests/tests.rs` is run.

To run the smoke tests execute:

```
cargo test --features=smoketest
```

this is also reflected within the Makefile.
  • Loading branch information
nichtsfrei committed Jan 17, 2024
1 parent 3af2609 commit e2a5c9d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/rustification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ jobs:
- uses: actions/checkout@v4
- run: sudo apt update && sudo apt-get install -y libpcap-dev
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} || rustup default ${{ matrix.toolchain }}
# Run unittests and integration test, but excludes the smoketest since it depends on a running openvasd server.
- run: cargo test --lib --tests --workspace --exclude smoketest
- run: cargo test --lib --tests --workspace
clippy:
runs-on: ubuntu-latest
defaults:
Expand Down Expand Up @@ -94,7 +93,7 @@ jobs:
needs: [rs-build-binaries]
container:
# maybe better to use builder, build openvas to have
# the version of this checkout rather than a dataed official one?
# the version of this checkout rather than a dated official one?
image: greenbone/openvas-scanner:unstable
options: --privileged
services:
Expand Down
1 change: 1 addition & 0 deletions rust/smoketest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ serde_json = "1"
[features]
default = ["serde_support"]
serde_support = ["serde"]
smoketest = []

[dev-dependencies]
serde_json = "1"
2 changes: 1 addition & 1 deletion rust/smoketest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ build: prepare-scan
${CARGO} build

run:
cargo test --tests
${CARGO} test --tests --features=smoketest

prepare-scan:
sed -i 's|<username>|'$(TARGET_USERNAME)'|' configs/simple_scan_ssh_only.json
Expand Down
2 changes: 0 additions & 2 deletions rust/smoketest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Usage of api-key is optional. For details on how to configure it, see the [openv

In case of running the test against a mTLS enabled `openvasd`, you need to configure the client key and cert as well in the smoke test environment. For details on how to configure it, see the [openvasd documentation](../openvasd/README.md).

WARNING: Don't use the provided key/cert pair for production. This smoketest includes client cert/key example files which work with the provided one in the helm charts.

For creation of the key/cert pair for mTLS authentication, see the tls section in the [openvasd documentation](../openvasd/README.md). Also, you find certificate generators in the [examples](../examples/tls)

For authenticated scans, you can set a custom target (default is 127.0.0.1), username and password.
Expand Down
1 change: 1 addition & 0 deletions rust/smoketest/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later

#[cfg(feature = "smoketest")]
pub mod tests {
use models::Phase;
use smoketest::*;
Expand Down

0 comments on commit e2a5c9d

Please sign in to comment.