|
| 1 | +import pytest |
| 2 | +import subprocess |
| 3 | +import hashlib |
| 4 | + |
| 5 | +# This test is designed to verify the accessibility of the XOA deployment script |
| 6 | +# |
| 7 | +# Requirements: |
| 8 | +# - an XCP-ng host with xcp-ng-release >= 8.3.0.29 |
| 9 | + |
| 10 | +@pytest.mark.parametrize("command_id", ["curl", "wget"]) |
| 11 | +@pytest.mark.parametrize("url_id", [ |
| 12 | + "xoa", |
| 13 | + "xcp-ng", |
| 14 | + "vates" |
| 15 | +]) |
| 16 | +def test_access_links(host, command_id, url_id): |
| 17 | + """ |
| 18 | + Verifies that the specified URL responds correctly via the specified command |
| 19 | + and compares the checksum of the downloaded content between local and remote. |
| 20 | + """ |
| 21 | + command = {"curl": "curl -fsSL", |
| 22 | + "wget": "wget -qO-"}[command_id] |
| 23 | + url = { |
| 24 | + "xoa": "https://xoa.io/deploy", |
| 25 | + "xcpng": "https://updates.xcp-ng.org/trace", |
| 26 | + "vates": "https://repo.vates.tech/README.txt" |
| 27 | + }[url_id] |
| 28 | + COMMAND = f"{command} '{url}'" |
| 29 | + |
| 30 | + # Download from remote host |
| 31 | + remote_result = host.ssh(COMMAND) |
| 32 | + |
| 33 | + # Verify the download worked by comparing with local download |
| 34 | + # This ensures the content is accessible and identical from both locations |
| 35 | + local_result = host.local_cmd(COMMAND) |
| 36 | + |
| 37 | + assert local_result.returncode == 0, ( |
| 38 | + f"Failed to fetch URL locally: {local_result.stderr}" |
| 39 | + ) |
| 40 | + |
| 41 | + # Extract checksums |
| 42 | + local_checksum = hashlib.sha256(local_result.stdout.split()[0].encode('utf-8')).hexdigest() |
| 43 | + remote_checksum = hashlib.sha256(remote_result.split()[0].encode('utf-8')).hexdigest() |
| 44 | + |
| 45 | + assert local_checksum == remote_checksum, ( |
| 46 | + f"Checksum mismatch: local ({local_checksum}) != remote ({remote_checksum})" |
| 47 | + ) |
0 commit comments