2016-11-16 05:03:26 +03:00
#!/bin/bash
#
# Copyright (C) 2016 Red Hat, Inc.
#
2018-01-30 22:26:26 +03:00
# SPDX-License-Identifier: LGPL-2.0+
#
2016-11-16 05:03:26 +03:00
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
2021-12-07 04:20:55 +03:00
# License along with this library. If not, see <https://www.gnu.org/licenses/>.
2016-11-16 05:03:26 +03:00
set -euo pipefail
echo '1..2'
. $( dirname $0 ) /libtest.sh
2018-03-14 17:36:48 +03:00
V = $( $CMD_PREFIX ostree --version | \
python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin)["libostree"]["Version"])' )
2016-11-16 05:03:26 +03:00
setup_fake_remote_repo1 "archive" "" \
2018-03-14 17:36:48 +03:00
--expected-header foo = bar \
--expected-header baz = badger \
--expected-header " User-Agent=libostree/ $V dodo/2.15 "
2016-11-16 05:03:26 +03:00
cd ${ test_tmpdir }
rm repo -rf
mkdir repo
2017-03-24 17:35:59 +03:00
ostree_repo_init repo
2016-11-16 05:03:26 +03:00
${ CMD_PREFIX } ostree --repo= repo remote add --set= gpg-verify= false origin $( cat httpd-address) /ostree/gnomerepo
# Sanity check the setup, without headers the pull should fail
assert_fail ${ CMD_PREFIX } ostree --repo= repo pull origin main
2018-03-14 17:36:48 +03:00
# without proper User-Agent, the pull should fail
assert_fail ${ CMD_PREFIX } ostree --repo= repo pull origin main \
--http-header foo = bar \
--http-header baz = badger
assert_fail ${ CMD_PREFIX } ostree --repo= repo pull origin main \
--http-header foo = bar \
--http-header baz = badger \
--append-user-agent bar/1.2
2017-05-17 18:41:54 +03:00
echo "ok setup done"
2016-11-16 05:03:26 +03:00
# Now pull should succeed now
2018-03-14 17:36:48 +03:00
${ CMD_PREFIX } ostree --repo= repo pull \
--http-header foo = bar \
--http-header baz = badger \
--append-user-agent dodo/2.15 \
origin main
2016-11-16 05:03:26 +03:00
2017-05-17 18:41:54 +03:00
echo "ok pull succeeded"