Skip to content

Commit

Permalink
Merge pull request #107 from stormshield-gt/switch_to_testcontainers
Browse files Browse the repository at this point in the history
Switch to testcontainers
  • Loading branch information
stormshield-gt authored Nov 19, 2024
2 parents d12c6cf + 65ef402 commit 27b18db
Show file tree
Hide file tree
Showing 41 changed files with 1,694 additions and 2,029 deletions.
139 changes: 31 additions & 108 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,125 +16,48 @@ env:
TOOLCHAIN_PROFILE: minimal

jobs:
lint-vaultrs:
name: Run cargo fmt and cargo clippy for vaultrs
fmt:
runs-on: ubuntu-latest
name: stable / fmt
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
components: rustfmt, clippy
- name: Use cache
uses: Swatinem/rust-cache@v1
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
lint-vaultrs-login:
name: Run cargo fmt and cargo clippy for vaultrs-login
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
components: rustfmt, clippy
- name: Use cache
uses: Swatinem/rust-cache@v1
with:
working-directory: vaultrs-login/
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all --package vaultr-login -- --check
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --package vaultrs-login -- -D warnings
test-vaultrs:
name: Run cargo test for vaultrs
- uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: cargo fmt
run: cargo fmt --check
clippy:
runs-on: ubuntu-latest
name: stable / clippy
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Use cache
uses: Swatinem/rust-cache@v1
- name: Run cargo test with -no-run (compile tests)
uses: actions-rs/cargo@v1
with:
command: test
args: --no-run
- name: Run cargo test --all-features
uses: actions-rs/cargo@v1
env:
RUST_TEST_THREADS: 1
with:
command: test
args: --all-features
- name: Run cargo test
uses: actions-rs/cargo@v1
env:
RUST_TEST_THREADS: 1
with:
command: test
test-vaultrs-login:
name: Run cargo test for vaultrs-login
- uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: cargo clippy
run: cargo clippy --all-targets --all-features --workspace -- -D warnings
test:
runs-on: ubuntu-latest
name: stable / test
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Use cache
uses: Swatinem/rust-cache@v1
with:
working-directory: vaultrs-login/
- name: Run cargo test with -no-run (compile tests)
uses: actions-rs/cargo@v1
with:
command: test
args: --package vaultrs-login --all-features --no-run
- name: Run cargo test
uses: actions-rs/cargo@v1
env:
RUST_TEST_THREADS: 1
with:
command: test
args: --package vaultrs-login --all-features
- uses: actions/checkout@v4
- name: Install stable
uses: dtolnay/rust-toolchain@stable
- name: cargo test
run: cargo test --all-targets --all-features --workspace
# https://github.com/rust-lang/cargo/issues/6669
- name: cargo test --doc
run: cargo test --all-features --workspace --doc

publish:
name: Publish to crates.io
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags/v')
needs: [lint-vaultrs, lint-vaultrs-login, test-vaultrs, test-vaultrs-login]
needs: [fmt, clippy, test]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
Expand Down
25 changes: 5 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ license = "MIT"
readme = "README.md"
repository = "https://github.com/jmgilman/vaultrs"
keywords = ["Vault", "API", "Client", "Hashicorp"]
edition = "2018"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[workspace]
members = [
"vaultrs-login",
members = [
"vaultrs-login", "vaultrs-tests", "."
]

default-members = ["vaultrs-login", "vaultrs-tests", "."]

[features]
default = [ "rustls" ]
rustls = [ "reqwest/rustls-tls", "rustify/rustls-tls" ]
Expand All @@ -36,20 +38,3 @@ thiserror = "1.0.40"
url = "2.3.1"
tracing = { version = "0.1.37", features = ["log"] }

[dev-dependencies]
base64 = "0.21"
chrono = "0.4.38"
data-encoding = "2.3.3"
tokio-test = "0.4.2"
tracing-subscriber = { version = "0.3.16", default-features = false, features = ["env-filter", "fmt"] }
tracing-test = "0.2.4"
test-log = { version = "0.2.11", features = ["trace"] }
env_logger = "0.10.0"
dockertest = "0.3.0"
dockertest-server = { version = "0.1.7", features = ["hashi", "database", "webserver", "cloud"] }
jwt = "0.16.0"
sha2 = "0.10.6"
hmac = "0.12.1"
serial_test = "1.0.0"
rcgen = "0.12.1"
tempfile = "3.10.1"
4 changes: 4 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ impl VaultClient {
/// Creates a new [VaultClient] using the given [VaultClientSettings].
#[instrument(skip(settings), err)]
pub fn new(settings: VaultClientSettings) -> Result<VaultClient, ClientError> {
#[cfg(not(feature = "rustls"))]
let mut http_client = reqwest::ClientBuilder::new();

#[cfg(feature = "rustls")]
let mut http_client = reqwest::ClientBuilder::new().use_rustls_tls();

// Optionally set timeout on client
http_client = if let Some(timeout) = settings.timeout {
http_client.timeout(timeout)
Expand Down
Loading

0 comments on commit 27b18db

Please sign in to comment.