Files
swupd-client/test/functional/mirror/mirror-allow-http.bats
Otavio Pontes 0696de4435 curl: Initialize curl as needed
Instead of initializing curl library on start, initialize it only when needed.
The advantage of this approach is that we can run some commands offline, if
there's no file to download.

Fixes #801
Fixes #895
Fixes #277

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00

94 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bats
# Author: Otavio Pontes
# Email: otavio.pontes@intel.com
load "../testlib"
global_setup() {
create_test_environment "$TEST_NAME"
}
test_setup() {
# do nothing
return
}
test_teardown() {
sudo rm -rf "$TARGETDIR"/etc/swupd
}
global_teardown() {
destroy_test_environment "$TEST_NAME"
}
@test "MIR007: Trying to set a http mirror" {
run sudo sh -c "$SWUPD mirror -s http://example.com/swupd-file $SWUPD_OPTS"
assert_status_is "$SWUPD_INVALID_OPTION"
expected_output=$(cat <<-EOM
Error: This is an insecure connection
Use the --allow-insecure-http flag to proceed
EOM
)
assert_in_output "$expected_output"
}
@test "MIR008: Forcing a http mirror ang checking if the mirror works" {
run sudo sh -c "$SWUPD mirror -s http://example.com/swupd-file --allow-insecure-http $SWUPD_OPTS"
assert_status_is 0
expected_output=$(cat <<-EOM
Warning: This is an insecure connection
The --allow-insecure-http flag was used, be aware that this poses a threat to the system
Warning: The mirror was set up using HTTP. In order for autoupdate to continue working you will need to set allow_insecure_http=true in the swupd configuration file. Alternatively you can set the mirror using HTTPS (recommended)
Mirror url set
Distribution: Swupd Test Distro
Installed version: 10
Version URL: http://example.com/swupd-file
Content URL: http://example.com/swupd-file
EOM
)
assert_is_output "$expected_output"
assert_equal "http://example.com/swupd-file" "$(<"$TARGETDIR"/etc/swupd/mirror_contenturl)"
assert_equal "http://example.com/swupd-file" "$(<"$TARGETDIR"/etc/swupd/mirror_versionurl)"
}
@test "MIR009: swupd operations when http mirror is used without allow-insecure-http" {
run sudo sh -c "$SWUPD diagnose $SWUPD_OPTS -u http://cdn.download.clearlinux.org/update"
assert_status_is "$SWUPD_INIT_GLOBALS_FAILED"
expected_output=$(cat <<-EOM
Error: This is an insecure connection
Use the --allow-insecure-http flag to proceed
EOM
)
assert_in_output "$expected_output"
}
@test "MIR010: swupd operations when http mirror is used without allow-insecure-http" {
run sudo sh -c "$SWUPD diagnose $SWUPD_OPTS --allow-insecure-http -u http://cdn.download.clearlinux.org/update"
# Error is because server doesn't respond to this manifest, but connection was created
assert_status_is_not "$SWUPD_OK"
expected_output=$(cat <<-EOM
Warning: This is an insecure connection
The --allow-insecure-http flag was used, be aware that this poses a threat to the system
EOM
)
assert_in_output "$expected_output"
}