2014-01-17 07:14:30 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
export PYTHON_BUILD_SKIP_MIRROR=
|
|
|
|
export PYTHON_BUILD_CACHE_PATH=
|
|
|
|
export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com
|
|
|
|
|
|
|
|
|
|
|
|
@test "package URL without checksum bypasses mirror" {
|
2014-06-02 22:41:47 -04:00
|
|
|
stub shasum true
|
2014-04-09 08:23:46 -04:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
install_fixture definitions/without-checksum
|
|
|
|
echo "$output" >&2
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
|
|
|
|
unstub curl
|
2014-06-02 22:41:47 -04:00
|
|
|
unstub shasum
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-02 22:41:47 -04:00
|
|
|
@test "package URL with checksum but no shasum support bypasses mirror" {
|
|
|
|
stub shasum false
|
2014-04-09 08:23:46 -04:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
|
|
|
|
unstub curl
|
2014-06-02 22:41:47 -04:00
|
|
|
unstub shasum
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "package URL with checksum hits mirror first" {
|
2014-06-02 22:41:47 -04:00
|
|
|
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2014-01-17 07:14:30 -05:00
|
|
|
local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum"
|
|
|
|
|
2014-06-02 22:41:47 -04:00
|
|
|
stub shasum true "echo $checksum"
|
2014-01-17 07:14:30 -05:00
|
|
|
stub curl "-*I* $mirror_url : true" \
|
2014-04-09 08:23:46 -04:00
|
|
|
"-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
|
|
|
|
unstub curl
|
2014-06-02 22:41:47 -04:00
|
|
|
unstub shasum
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "package is fetched from original URL if mirror download fails" {
|
2014-06-02 22:41:47 -04:00
|
|
|
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2014-01-17 07:14:30 -05:00
|
|
|
local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum"
|
|
|
|
|
2014-06-02 22:41:47 -04:00
|
|
|
stub shasum true "echo $checksum"
|
2014-01-17 07:14:30 -05:00
|
|
|
stub curl "-*I* $mirror_url : false" \
|
2014-04-09 08:23:46 -04:00
|
|
|
"-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
|
|
|
|
unstub curl
|
2014-06-02 22:41:47 -04:00
|
|
|
unstub shasum
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "package is fetched from original URL if mirror download checksum is invalid" {
|
2014-06-02 22:41:47 -04:00
|
|
|
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2014-01-17 07:14:30 -05:00
|
|
|
local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum"
|
|
|
|
|
2014-06-02 22:41:47 -04:00
|
|
|
stub shasum true "echo invalid" "echo $checksum"
|
2014-01-17 07:14:30 -05:00
|
|
|
stub curl "-*I* $mirror_url : true" \
|
2014-04-09 08:23:46 -04:00
|
|
|
"-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \
|
|
|
|
"-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
|
|
|
echo "$output" >&2
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
|
|
|
|
unstub curl
|
2014-06-02 22:41:47 -04:00
|
|
|
unstub shasum
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "default mirror URL" {
|
|
|
|
export PYTHON_BUILD_MIRROR_URL=
|
2014-06-02 22:41:47 -04:00
|
|
|
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
2014-06-02 22:41:47 -04:00
|
|
|
stub shasum true "echo $checksum"
|
2014-01-17 07:14:30 -05:00
|
|
|
stub curl "-*I* : true" \
|
2014-10-28 11:02:49 -04:00
|
|
|
"-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
|
|
|
|
unstub curl
|
2014-06-02 22:41:47 -04:00
|
|
|
unstub shasum
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|