Skip to content

Commit

Permalink
Add test for docker auth
Browse files Browse the repository at this point in the history
  • Loading branch information
jssblck committed Feb 26, 2025
1 parent d71a3aa commit f8f4bb5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/check-dynamic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ jobs:
- uses: Swatinem/[email protected]
with:
key: test_${{ matrix.settings.host }}_${{ matrix.settings.target }}
- uses: docker/login-action@v3
with:
registry: quay.io
username: fossa+sparkle
password: ${{ secrets.QUAY_API_KEY }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- run: cargo nextest run --all-targets
- run: cargo test --doc

Expand Down
30 changes: 30 additions & 0 deletions lib/tests/it/docker.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use async_tempfile::TempDir;
use circe_lib::{registry::Registry, Authentication, Reference};
use color_eyre::Result;
use simple_test_case::test_case;

// These tests require that your local docker instance is authenticated with the servers.
// This is performed before tests are run in CI, but you may need to `docker login` locally.
#[test_case("quay.io/fossa/hubble-api:latest"; "quay.io/fossa/hubble-api:latest")]
#[test_case("ghcr.io/fossas/sherlock/server:latest"; "ghcr.io/fossas/sherlock/server:latest")]
#[test_log::test(tokio::test)]
async fn pull_authed(image: &str) -> Result<()> {
let reference = image.parse::<Reference>()?;
let auth = Authentication::docker(&reference).await?;
let registry = Registry::builder()
.auth(auth)
.reference(reference)
.build()
.await?;

let layers = registry.layers().await?;
assert!(!layers.is_empty(), "image should have at least one layer");

let tmp = TempDir::new().await?;
for layer in layers {
let path = tmp.dir_path().join(layer.digest.as_hex());
registry.apply_layer(&layer, &path).await?;
}

Ok(())
}
1 change: 1 addition & 0 deletions lib/tests/it/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod docker;
mod platform;
mod reference;
mod registry;
Expand Down

0 comments on commit f8f4bb5

Please sign in to comment.