diff --git a/.github/workflows/compat.yml b/.github/workflows/compat.yml index 25bf668..dfbeb63 100644 --- a/.github/workflows/compat.yml +++ b/.github/workflows/compat.yml @@ -20,12 +20,12 @@ concurrency: cancel-in-progress: true env: - RESTIC_REPOSITORY: rest:http://127.0.0.1:8000/test + RESTIC_REPOSITORY: rest:http://restic:restic@127.0.0.1:8000/ci_repo RESTIC_PASSWORD: restic jobs: - test: - name: Test + test-restic: + name: Test server with restic runs-on: ${{ matrix.job.os }} strategy: matrix: @@ -54,21 +54,67 @@ jobs: with: toolchain: stable - - name: Create fixtures + - name: Run server in background + run: cargo run -- serve -c tests/fixtures/test_data/rustic_server.toml -v & + + - name: Run restic shell: bash run: | restic init + restic backup tests/fixtures/test_data/test_repo_source + restic backup tests/fixtures/test_data/test_repo_source + restic check + restic forget --keep-last 1 --prune - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2 - - name: Run Cargo Test - run: cargo test -r --test repositories --features ${{ matrix.feature }} -- test_restic_latest_repo_with_rustic_passes --exact --show-output --ignored + # test-hurl: + # name: Test server with hurl + # runs-on: ${{ matrix.job.os }} + # strategy: + # matrix: + # rust: [stable] + # job: + # - os: macos-latest + # - os: ubuntu-latest + # - os: windows-latest + # steps: + # - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + # if: github.event_name != 'pull_request' + # with: + # fetch-depth: 0 + + # - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + # if: github.event_name == 'pull_request' + # with: + # ref: ${{ github.event.pull_request.head.sha }} + # fetch-depth: 0 + + # - name: Install Rust toolchain + # uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1 + # with: + # toolchain: stable + + # - name: Install hurl + # uses: taiki-e/install-action@c6dc131d2c4291552cafb840290190a53b2cd937 # v2 + # with: + # tool: hurl + # - name: Run server in background + # run: cargo run -- serve -c tests/fixtures/test_data/rustic_server.toml -v & + + # - name: Run hurl + # shell: bash + # run: | + # hurl -i tests/fixtures/hurl/endpoints.hurl + + # - uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2 + result: name: Result (Compat) runs-on: ubuntu-latest needs: - - test + - test-restic steps: - name: Mark the job as successful run: exit 0 diff --git a/maskfile.md b/maskfile.md index 3c3a75f..b488d28 100644 --- a/maskfile.md +++ b/maskfile.md @@ -363,8 +363,8 @@ PowerShell: ```powershell [Diagnostics.Process]::Start("cargo", "run -- serve -c tests/fixtures/test_data/rustic_server.toml -v").WaitForExit() - ``` + ## test-restic-server diff --git a/src/commands/serve.rs b/src/commands/serve.rs index e92d4d6..9995fa2 100644 --- a/src/commands/serve.rs +++ b/src/commands/serve.rs @@ -1,6 +1,5 @@ //! `serve` subcommand - use abscissa_core::{ config::Override, status_err, diff --git a/tests/fixtures/hurl/endpoints.hurl b/tests/fixtures/hurl/endpoints.hurl index 27a59da..63241a2 100644 --- a/tests/fixtures/hurl/endpoints.hurl +++ b/tests/fixtures/hurl/endpoints.hurl @@ -2,7 +2,19 @@ HEAD http://127.0.0.1:8000/ci_repo/config HTTP 403 -# Login +# Access a new repository +HEAD http://127.0.0.1:8000/ci_repo/ +[BasicAuth] +hurl: hurl +HTTP 405 + +# Create a new repository +POST http://127.0.0.1:8000/ci_repo/?create=true +[BasicAuth] +hurl: hurl +HTTP 200 + + HEAD http://127.0.0.1:8000/ci_repo/config [BasicAuth] hurl: hurl @@ -15,17 +27,17 @@ hurl: hurl HTTP 200 Content-Type: application/vnd.x.restic.rest.v1 -GET http://127.0.0.1:8000/ci_repo/keys/92c489eaca950f3a9d860da1bef0af845dd8c74a9a34c860bd8e6a54bd2326d2 +GET http://127.0.0.1:8000/ci_repo/keys/eb7e523a1916c2cc1c750dc89cd6024f5dd319814c417a3f9081578f8c2c4a76 RANGE: bytes=0-230 [BasicAuth] hurl: hurl HTTP 206 content-length: 231 -GET http://127.0.0.1:8000/ci_repo/keys/92c489eaca950f3a9d860da1bef0af845dd8c74a9a34c860bd8e6a54bd2326d2 -[BasicAuth] -hurl: hurl -HTTP 200 +# GET http://127.0.0.1:8000/ci_repo/keys/eb7e523a1916c2cc1c750dc89cd6024f5dd319814c417a3f9081578f8c2c4a76 +# [BasicAuth] +# hurl: hurl +# HTTP 200 GET http://127.0.0.1:8000/ci_repo/config [BasicAuth] @@ -37,10 +49,10 @@ GET http://127.0.0.1:8000/ci_repo/locks/ hurl: hurl HTTP 200 -POST http://127.0.0.1:8000/ci_repo/locks/ac4ff62472b009cf71c81199f4fc635152639909cb1143911150db467ca86544 -[BasicAuth] -hurl: hurl -HTTP 200 +# POST http://127.0.0.1:8000/ci_repo/locks/ac4ff62472b009cf71c81199f4fc635152639909cb1143911150db467ca86544 +# [BasicAuth] +# hurl: hurl +# HTTP 200 GET http://127.0.0.1:8000/ci_repo/locks/ [BasicAuth] @@ -57,27 +69,27 @@ GET http://127.0.0.1:8000/ci_repo/index/ hurl: hurl HTTP 200 -POST http://127.0.0.1:8000/ci_repo/data/3b013253cd72fa7e98f9dcd6106f9565933556f1c80a720e1e44dbf3b57af446 -[BasicAuth] -hurl: hurl -HTTP 200 +# POST http://127.0.0.1:8000/ci_repo/data/3b013253cd72fa7e98f9dcd6106f9565933556f1c80a720e1e44dbf3b57af446 +# [BasicAuth] +# hurl: hurl +# HTTP 200 -POST http://127.0.0.1:8000/ci_repo/data/89923722810777f3026a7cf9b246eb9613c7e3f64e77e6ccecb4001774c38acf -[BasicAuth] -hurl: hurl -HTTP 200 +# POST http://127.0.0.1:8000/ci_repo/data/89923722810777f3026a7cf9b246eb9613c7e3f64e77e6ccecb4001774c38acf +# [BasicAuth] +# hurl: hurl +# HTTP 200 -POST http://127.0.0.1:8000/ci_repo/index/004ebe81e7927131b6dde40bd4595ebf95a355bf26509de83fb9d12b4ab280b4 -[BasicAuth] -hurl: hurl -HTTP 200 +# POST http://127.0.0.1:8000/ci_repo/index/004ebe81e7927131b6dde40bd4595ebf95a355bf26509de83fb9d12b4ab280b4 +# [BasicAuth] +# hurl: hurl +# HTTP 200 -POST http://127.0.0.1:8000/ci_repo/snapshots/ddd75013f2d2470d910adadf728c5c8cd6e91cb591bdfbf1cfd7f3af7e32c7eb -[BasicAuth] -hurl: hurl -HTTP 200 +# POST http://127.0.0.1:8000/ci_repo/snapshots/ddd75013f2d2470d910adadf728c5c8cd6e91cb591bdfbf1cfd7f3af7e32c7eb +# [BasicAuth] +# hurl: hurl +# HTTP 200 -DELETE http://127.0.0.1:8000/ci_repo/locks/ac4ff62472b009cf71c81199f4fc635152639909cb1143911150db467ca86544 -[BasicAuth] -hurl: hurl -HTTP 200 +# DELETE http://127.0.0.1:8000/ci_repo/locks/ac4ff62472b009cf71c81199f4fc635152639909cb1143911150db467ca86544 +# [BasicAuth] +# hurl: hurl +# HTTP 200 diff --git a/tests/integration.rs b/tests/integration.rs deleted file mode 100644 index dbdbc8b..0000000 --- a/tests/integration.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! Integration tests for the rustic_server -// -// # Notes -// -// * https://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html#rest-server -// * https://restic.readthedocs.io/en/latest/100_references.html#rest-backend -// * https://github.com/restic/rest-server -// -// use anyhow::Result; -// use assert_cmd::Command; -// use predicates::prelude::{predicate, PredicateBooleanExt}; -// use dircmp::Comparison; - -// To test: -// -// - [ ] -// - -// pub fn server_runner() -> Result { -// let password = "test"; -// let repo_dir = temp_dir.path().join("repo"); - -// let mut runner = Command::new(env!("CARGO_BIN_EXE_rustic-server")); - -// runner -// .arg(""); - -// Ok(runner) -// }