github.com/containers/podman/v5@v5.1.0-rc1/test/system/750-trust.bats (about)

     1  #!/usr/bin/env bats   -*- bats -*-
     2  #
     3  # tests for podman image trust
     4  #
     5  
     6  load helpers
     7  
     8  @test "podman image trust set" {
     9        skip_if_remote "trust only works locally"
    10        policypath=$PODMAN_TMPDIR/policy.json
    11        run_podman 125 image trust set --policypath=$policypath --type=bogus default
    12        is "$output" "Error: invalid choice: bogus.*" "error from --type=bogus"
    13  
    14        run_podman image trust set --policypath=$policypath --type=accept default
    15        run_podman image trust show --policypath=$policypath
    16        is "$output" ".*all  *default  *accept" "default policy should be accept"
    17  
    18        run_podman image trust set --policypath=$policypath --type=reject default
    19        run_podman image trust show --policypath=$policypath
    20        is "$output" ".*all  *default  *reject" "default policy should be reject"
    21  
    22        run_podman image trust set --policypath=$policypath --type=reject docker.io
    23        run_podman image trust show --policypath=$policypath
    24        is "$output" ".*all  *default  *reject" "default policy should still be reject"
    25        is "$output" ".*repository  *docker.io  *reject" "docker.io should also be reject"
    26  
    27        run_podman image trust show --policypath=$policypath --json
    28        subset=$(jq -r '.[0] | .repo_name, .type' <<<"$output" | fmt)
    29        is "$subset" "default reject" "--json also shows default"
    30        subset=$(jq -r '.[1] | .repo_name, .type' <<<"$output" | fmt)
    31        is "$subset" "docker.io reject" "--json also shows docker.io"
    32  
    33        run_podman image trust set --policypath=$policypath --type=accept docker.io
    34        run_podman image trust show --policypath=$policypath --json
    35        subset=$(jq -r '.[0] | .repo_name, .type' <<<"$output" | fmt)
    36        is "$subset" "default reject" "--json, default is still reject"
    37        subset=$(jq -r '.[1] | .repo_name, .type' <<<"$output" | fmt)
    38        is "$subset" "docker.io accept" "--json, docker.io should now be accept"
    39  
    40        policy="$(< $policypath)"
    41        run_podman image trust show --policypath=$policypath --raw
    42        is "$output" "$policy" "output should show match content of policy.json"
    43  }
    44  
    45  # vim: filetype=sh