2014-01-17 12:14:30 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
export PYTHON_BUILD_SKIP_MIRROR=1
|
|
|
|
export PYTHON_BUILD_CACHE_PATH=
|
2016-08-15 04:42:50 +00:00
|
|
|
|
2014-01-17 12:14:30 +00:00
|
|
|
|
|
|
|
@test "package URL without checksum" {
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-01-17 12:14:30 +00:00
|
|
|
|
|
|
|
install_fixture definitions/without-checksum
|
2016-02-08 00:01:02 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
2014-01-17 12:14:30 +00:00
|
|
|
|
2016-06-21 00:31:19 +00:00
|
|
|
unstub curl
|
2014-01-17 12:14:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "package URL with valid checksum" {
|
2014-06-03 02:41:47 +00:00
|
|
|
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-01-17 12:14:30 +00:00
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
2016-02-08 00:01:02 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
2014-01-17 12:14:30 +00:00
|
|
|
|
2016-06-21 00:31:19 +00:00
|
|
|
unstub curl
|
2014-06-03 02:41:47 +00:00
|
|
|
unstub shasum
|
2014-01-17 12:14:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "package URL with invalid checksum" {
|
2014-06-03 02:41:47 +00:00
|
|
|
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-01-17 12:14:30 +00:00
|
|
|
|
|
|
|
install_fixture definitions/with-invalid-checksum
|
2016-02-08 00:01:02 +00:00
|
|
|
|
|
|
|
assert_failure
|
|
|
|
refute [ -f "${INSTALL_ROOT}/bin/package" ]
|
2014-01-17 12:14:30 +00:00
|
|
|
|
2016-06-21 00:31:19 +00:00
|
|
|
unstub curl
|
2014-06-03 02:41:47 +00:00
|
|
|
unstub shasum
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "package URL with checksum but no shasum support" {
|
|
|
|
stub shasum false
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-06-03 02:41:47 +00:00
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
2016-02-08 00:01:02 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
2014-06-03 02:41:47 +00:00
|
|
|
|
2016-06-21 00:31:19 +00:00
|
|
|
unstub curl
|
2014-06-03 02:41:47 +00:00
|
|
|
unstub shasum
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "package URL with valid md5 checksum" {
|
|
|
|
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-06-03 02:41:47 +00:00
|
|
|
|
|
|
|
install_fixture definitions/with-md5-checksum
|
2016-02-08 00:01:02 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
2014-06-03 02:41:47 +00:00
|
|
|
|
2016-06-21 00:31:19 +00:00
|
|
|
unstub curl
|
2014-01-17 12:14:30 +00:00
|
|
|
unstub md5
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-03 02:41:47 +00:00
|
|
|
@test "package URL with md5 checksum but no md5 support" {
|
2014-01-17 12:14:30 +00:00
|
|
|
stub md5 false
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-01-17 12:14:30 +00:00
|
|
|
|
2014-06-03 02:41:47 +00:00
|
|
|
install_fixture definitions/with-md5-checksum
|
2016-02-08 00:01:02 +00:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
2014-01-17 12:14:30 +00:00
|
|
|
|
2016-06-21 00:31:19 +00:00
|
|
|
unstub curl
|
2014-01-17 12:14:30 +00:00
|
|
|
unstub md5
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "package with invalid checksum" {
|
2014-06-03 02:41:47 +00:00
|
|
|
stub shasum true "echo invalid"
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-01-17 12:14:30 +00:00
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
2016-02-08 00:01:02 +00:00
|
|
|
|
|
|
|
assert_failure
|
|
|
|
refute [ -f "${INSTALL_ROOT}/bin/package" ]
|
2014-01-17 12:14:30 +00:00
|
|
|
|
2016-06-21 00:31:19 +00:00
|
|
|
unstub curl
|
2014-06-03 02:41:47 +00:00
|
|
|
unstub shasum
|
2014-01-17 12:14:30 +00:00
|
|
|
}
|
2014-04-09 12:23:46 +00:00
|
|
|
|
|
|
|
@test "existing tarball in build location is reused" {
|
2014-06-03 02:41:47 +00:00
|
|
|
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl false
|
2014-04-09 12:23:46 +00:00
|
|
|
stub curl false
|
|
|
|
stub wget false
|
|
|
|
|
|
|
|
export -n PYTHON_BUILD_CACHE_PATH
|
|
|
|
export PYTHON_BUILD_BUILD_PATH="${TMP}/build"
|
|
|
|
|
|
|
|
mkdir -p "$PYTHON_BUILD_BUILD_PATH"
|
|
|
|
ln -s "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_BUILD_PATH"
|
|
|
|
|
|
|
|
run_inline_definition <<DEF
|
2014-06-03 02:41:47 +00:00
|
|
|
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
|
2014-04-09 12:23:46 +00:00
|
|
|
DEF
|
|
|
|
|
|
|
|
assert_success
|
2016-02-08 00:01:02 +00:00
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
2014-04-09 12:23:46 +00:00
|
|
|
|
2014-06-03 02:41:47 +00:00
|
|
|
unstub shasum
|
2014-04-09 12:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "existing tarball in build location is discarded if not matching checksum" {
|
2014-06-03 02:41:47 +00:00
|
|
|
stub shasum true \
|
2014-04-09 12:23:46 +00:00
|
|
|
"echo invalid" \
|
2014-06-03 02:41:47 +00:00
|
|
|
"echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2014-04-09 12:23:46 +00:00
|
|
|
|
|
|
|
export -n PYTHON_BUILD_CACHE_PATH
|
|
|
|
export PYTHON_BUILD_BUILD_PATH="${TMP}/build"
|
|
|
|
|
|
|
|
mkdir -p "$PYTHON_BUILD_BUILD_PATH"
|
|
|
|
touch "${PYTHON_BUILD_BUILD_PATH}/package-1.0.0.tar.gz"
|
|
|
|
|
|
|
|
run_inline_definition <<DEF
|
2014-06-03 02:41:47 +00:00
|
|
|
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
|
2014-04-09 12:23:46 +00:00
|
|
|
DEF
|
|
|
|
|
|
|
|
assert_success
|
2016-02-08 00:01:02 +00:00
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
2014-04-09 12:23:46 +00:00
|
|
|
|
2014-06-03 02:41:47 +00:00
|
|
|
unstub shasum
|
2014-04-09 12:23:46 +00:00
|
|
|
}
|
2016-02-08 00:01:02 +00:00
|
|
|
|
|
|
|
@test "package URL with checksum of unexpected length" {
|
2016-06-21 00:31:19 +00:00
|
|
|
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
2016-02-08 00:01:02 +00:00
|
|
|
|
|
|
|
run_inline_definition <<DEF
|
|
|
|
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#checksum_of_unexpected_length" copy
|
|
|
|
DEF
|
|
|
|
|
|
|
|
assert_failure
|
|
|
|
refute [ -f "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
assert_output_contains "unexpected checksum length: 29 (checksum_of_unexpected_length)"
|
|
|
|
assert_output_contains "expected 0 (no checksum), 32 (MD5), or 64 (SHA2-256)"
|
|
|
|
}
|