Skip to content
Snippets Groups Projects
Commit d7775155 authored by Aaron Dewes's avatar Aaron Dewes
Browse files

Merge branch 'main' of gitlab.torproject.org:tpo/core/arti into publish-unparsed-key

parents 7241f4d4 041ef9b3
No related branches found
Tags tor-0.2.2.5-alpha
No related merge requests found
Pipeline #190090 failed
Showing
with 363 additions and 0 deletions
......@@ -20,3 +20,11 @@ insert_final_newline = unset
trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset
[crates/arti/tests/testcases/**/local/state/*]
charset = unset
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset
......@@ -458,6 +458,10 @@ every-crate:
- maint/common/apt-install python3-toml python-is-python3
- ./maint/every-crate
# TODO: we should rename this to matrix_check for clarity,
# and introduce a new matrix_test script that runs cargo test.
# That way, we could use matrix_test to run the tests gated behind
# specific feature combinations, such as the cli_tests.
matrix-test:
stage: test
image: $RECENT_RUST_IMAGE
......@@ -472,12 +476,28 @@ matrix-test-cfg:
script:
- ./maint/matrix_test_cfg
# TODO: consider removing this in favor of cli-test
cli-help:
stage: test
image: $RECENT_RUST_IMAGE
script:
- ./maint/check-cli-help
# TODO: this should be folded in one of the other test jobs.
#
# Since this is testing an additional combination of features,
# ideally it would be handled by the matrix_test script,
# but matrix_test runs cargo check, and we would like to cargo *test*.
cli-test:
stage: test
image: $RECENT_RUST_IMAGE
script:
# The rust-latest job runs the CLI tests with all features enabled.
# This job runs the CLI tests with various feature combinations that aren't
# covered by the other tests
- cargo test --verbose --target x86_64-unknown-linux-gnu -p arti cli_tests
- cargo test --verbose --target x86_64-unknown-linux-gnu -p arti --features experimental cli_tests
coverage-aggregated:
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
......
......@@ -220,6 +220,7 @@ dependencies = [
"serde_json",
"signal-hook",
"signal-hook-async-std",
"tempfile",
"thiserror",
"time",
"tokio",
......@@ -236,6 +237,7 @@ dependencies = [
"tracing-appender",
"tracing-journald",
"tracing-subscriber",
"trycmd",
"visibility",
"winapi",
]
......@@ -707,6 +709,17 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "automod"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edf3ee19dbc0a46d740f6f0926bde8c50f02bdbc7b536842da28f6ac56513a8b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.68",
]
[[package]]
name = "axum"
version = "0.6.20"
......@@ -1034,6 +1047,15 @@ version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
[[package]]
name = "content_inspector"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38"
dependencies = [
"memchr",
]
[[package]]
name = "convert_case"
version = "0.4.0"
......@@ -1083,6 +1105,25 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.11"
......@@ -1466,6 +1507,12 @@ dependencies = [
"zeroize",
]
[[package]]
name = "dunce"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
[[package]]
name = "dyn-clone"
version = "1.0.17"
......@@ -2083,6 +2130,12 @@ version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "glob-match"
version = "0.2.1"
......@@ -2908,6 +2961,12 @@ dependencies = [
"libc",
]
[[package]]
name = "normalize-line-endings"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
[[package]]
name = "notify"
version = "6.1.1"
......@@ -3152,6 +3211,16 @@ dependencies = [
"num-traits",
]
[[package]]
name = "os_pipe"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29d73ba8daf8fac13b0501d1abeddcfe21ba7401ada61a819144b6c2a4f32209"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "overload"
version = "0.1.1"
......@@ -3588,6 +3657,26 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
[[package]]
name = "rayon"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
]
[[package]]
name = "redox_syscall"
version = "0.4.1"
......@@ -4219,6 +4308,12 @@ dependencies = [
"dirs",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook"
version = "0.3.17"
......@@ -4273,6 +4368,12 @@ dependencies = [
"wide",
]
[[package]]
name = "similar"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640"
[[package]]
name = "simple_asn1"
version = "0.6.2"
......@@ -4315,6 +4416,37 @@ version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "snapbox"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d656960fa127e80ade23c321d8c573bb9ba462c3a69e62ede635fc180ffc6cc"
dependencies = [
"anstream",
"anstyle",
"content_inspector",
"dunce",
"filetime",
"libc",
"normalize-line-endings",
"os_pipe",
"similar",
"snapbox-macros",
"tempfile",
"wait-timeout",
"walkdir",
"windows-sys 0.52.0",
]
[[package]]
name = "snapbox-macros"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f4c14672714436c09254801c934b203196a51182a5107fb76591c7cc56424d"
dependencies = [
"anstream",
]
[[package]]
name = "socket2"
version = "0.4.10"
......@@ -5941,6 +6073,23 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "trycmd"
version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59709bd8eccada6a3fded26d22a7f2dcee406c18d3bd7ad2605ca3eeb8f6f6ec"
dependencies = [
"automod",
"glob",
"humantime",
"humantime-serde",
"rayon",
"serde",
"shlex",
"snapbox",
"toml_edit 0.22.14",
]
[[package]]
name = "typed-index-collections"
version = "3.1.0"
......@@ -6102,6 +6251,15 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "wait-timeout"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
dependencies = [
"libc",
]
[[package]]
name = "waker-fn"
version = "1.2.0"
......
......@@ -140,6 +140,8 @@ derive_more = "0.99.3"
itertools = "0.13.0"
regex = { version = "1", default-features = false, features = ["std"] }
serde_json = "1.0.50"
tempfile = "3"
trycmd = "0.15.4"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.8", features = ["winerror"] }
......
# Arti CLI tests
This is a [`trycmd`]-based test suite for the arti CLI.
Each testable subcommand has a corresponding directory in `testdata`:
```
tests
├── cli_tests.rs # The test runner
├── README.md
└── testcases
├── hsc
│ ├── help.stderr # expected stderr for the "help" test
│ ├── help.stdout # expected stdout for the "help" test
│ ├── help.toml # hsc "help" test
│ ├── hsc.in # test inputs and CWD
│ └── hsc.md # multiple hsc tests
├── hss # hss subcommand tests
│ ├── hss.in # test inputs and CWD
│ └── hss.md # multiple hss tests
└── ...
```
Each feature-dependent subcommand has a corresponding `<subcmd>-feature-missing`
test case, which tests that we output a hint about recompiling arti with the
necessary features (the feature-dependent tests are currently all skipped,
because we don't yet print helpful messages in such cases. See #1487).
The tests can be written as [`*.trycmd`/`*.md` files], or in [`toml` format].
The `*md`-based tests can double as documentation, so they are often preferable
over the `toml` ones.
See the [`trycmd`] docs for more information.
### Debugging
You can pass `-F trycmd/debug` to `cargo test` to debug `trycmd`'s behavior.`
[`trycmd`]: https://docs.rs/trycmd/latest/trycmd/
[`*.trycmd`/`*.md` files]: https://docs.rs/trycmd/latest/trycmd/#trycmd
[`toml` format]: https://docs.rs/trycmd/latest/trycmd/#toml
#![doc = include_str!("../README.md")]
#[test]
fn cli_tests() {
let t = trycmd::TestCases::new();
let dir = tempfile::TempDir::new().unwrap();
t.env("HOME", dir.path().to_str().unwrap());
cfg_if::cfg_if! {
if #[cfg(feature = "onion-service-service")] {
t.case("tests/testcases/hss/*.toml");
t.case("tests/testcases/hss/*.md");
} else {
// This is not yet implemented, see #1487
t.skip("tests/testcases/hss-feature-missing/*.toml");
t.skip("tests/testcases/hss-feature-missing/*.md");
}
}
cfg_if::cfg_if! {
if #[cfg(all(feature = "onion-service-client", feature = "experimental-api", feature = "keymgr"))] {
// TODO: Skipped because running creating multiple TorClient at the same time
// is not supported.
//
// Re-enable these when #1497 is closed.
t.skip("tests/testcases/hsc/*.toml");
t.skip("tests/testcases/hsc/*.md");
} else {
// This is not yet implemented, see #1487
t.skip("tests/testcases/hsc-feature-missing/*.toml");
t.skip("tests/testcases/hsc-feature-missing/*.md");
}
}
t.case("README.md");
// Run the tests.
//
// Note: the TestCases must be dropped *before* the tempdir
// (otherwise HOME will get cleaned up before the tests have had a chance to run!)
drop(t);
}
[application]
allow_running_as_root = true
[storage]
state_dir = "./local"
[storage.permissions]
dangerously_trust_everyone = true
[logging]
console = "warn"
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAQgAAABp4MjU1MT
lAc3BlYy50b3Jwcm9qZWN0Lm9yZwAAACCNrKwy3SXHTOiSGMXywSI3ouBHfF3bKdyyx5LI
Os0dWwAAAHj5tlsh+bZbIQAAABp4MjU1MTlAc3BlYy50b3Jwcm9qZWN0Lm9yZwAAACCNrK
wy3SXHTOiSGMXywSI3ouBHfF3bKdyyx5LIOs0dWwAAACAO5qh4FRo41KE2Q7D5VACR8Rnu
3zdBIVgjwDVRX7ByegAAAAABAgMEBQY=
-----END OPENSSH PRIVATE KEY-----
{
"version": 1,
"histogram": [],
"current_timeout": 60000
}
\ No newline at end of file
{
"default": {
"guards": [],
"confirmed": []
},
"restricted": {
"guards": [],
"confirmed": []
},
"bridges": {
"guards": [],
"confirmed": []
}
}
\ No newline at end of file
# `arti hsc`
`arti hsc` is only supported in builds that have the `onion-service-client`,
`keymgr`, and `experimental-api` features enabled:
```console
$ arti hsc --help
error: unrecognized subcommand 'hsc' (hint: recompile with the onion-service-client, keymgr, experimental-api features)
```
[application]
allow_running_as_root = true
[storage]
state_dir = "./tests/testcases/hsc/hsc.in/local"
[storage.permissions]
dangerously_trust_everyone = true
[logging]
console = "warn"
[..]error: Service discovery key not found. Rerun with --generate=if-needed to generate a new service discovery keypair
bin.name = "arti"
args = "-c ./tests/testcases/hsc/conf/hsc.toml hsc get-key --key-type=service-discovery --onion-name fpqqmiwzqiv63jczrshh4qcmlxw6gujcai3arobq23wikt7hk7ojadid.onion --generate=no --output -"
status.code = 127
Run state management commands for an Arti hidden service client
Usage: arti hsc [OPTIONS] <COMMAND>
Commands:
get-key Prepare a service discovery key for connecting to a service running in restricted
discovery mode
help Print this message or the help of the given subcommand(s)
Options:
-c, --config <FILE> Specify which config file(s) to read. Defaults to
[File("[..]"),
Dir("[..]")]
-o <KEY=VALUE> Override config file parameters, using TOML-like syntax.
-l, --log-level <LEVEL> Override the log level (usually one of 'trace', 'debug',
'info', 'warn', 'error').
--disable-fs-permission-checks Don't check permissions on the files we use.
-h, --help Print help
bin.name = "arti"
args = "hsc --help"
status.code = 0
[application]
allow_running_as_root = true
[storage]
state_dir = "./local"
[storage.permissions]
dangerously_trust_everyone = true
[logging]
console = "warn"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment