|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Scenario: invalid_version |
| 4 | +# Verifies that the install script's version validation correctly rejects |
| 5 | +# a non-existent version. Since the container must build successfully to |
| 6 | +# run tests, sbom-tool is installed with "latest" and we then exercise the |
| 7 | +# validation logic manually. |
| 8 | + |
| 9 | +set -e |
| 10 | + |
| 11 | +source dev-container-features-test-lib |
| 12 | + |
| 13 | +# sbom-tool should be installed (the scenario uses "latest") |
| 14 | +check "sbom-tool is installed" bash -c "which sbom-tool" |
| 15 | + |
| 16 | +# Verify that a completely fake version does NOT appear in the releases list |
| 17 | +check "fake version not in releases" bash -c \ |
| 18 | + "! curl -sL https://api.github.com/repos/microsoft/sbom-tool/releases | jq -r '.[].tag_name' | grep -qx 'v99.99.99'" |
| 19 | + |
| 20 | +# Simulate the install script's validation: attempt to match a non-existent |
| 21 | +# version against the release list and confirm it fails |
| 22 | +check "validation rejects non-existent version" bash -c ' |
| 23 | + version_list=$(curl -sL https://api.github.com/repos/microsoft/sbom-tool/releases | jq -r ".[].tag_name") |
| 24 | + if echo "${version_list}" | grep -qx "v99.99.99"; then |
| 25 | + echo "ERROR: fake version was found in release list" |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | + echo "Correctly rejected non-existent version v99.99.99" |
| 29 | +' |
| 30 | + |
| 31 | +# Also verify that a valid version IS accepted by the same logic |
| 32 | +check "validation accepts a real version" bash -c ' |
| 33 | + version_list=$(curl -sL https://api.github.com/repos/microsoft/sbom-tool/releases | jq -r ".[].tag_name") |
| 34 | + if ! echo "${version_list}" | grep -q "0.3.3"; then |
| 35 | + echo "ERROR: valid version 0.3.3 was not found in release list" |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | + echo "Correctly accepted valid version 0.3.3" |
| 39 | +' |
| 40 | + |
| 41 | +reportResults |
0 commit comments