2011-10-28 18:25:36 +04:00
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
2018-01-30 22:26:26 +03:00
# SPDX-License-Identifier: LGPL-2.0+
#
2011-11-10 22:17:04 +04: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.
2011-10-28 18:25:36 +04:00
#
2011-11-10 22:17:04 +04:00
# This library is distributed in the hope that it will be useful,
2011-10-28 18:25:36 +04:00
# but WITHOUT ANY WARRANTY; without even the implied warranty of
2011-11-10 22:17:04 +04:00
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
2011-10-28 18:25:36 +04:00
#
2011-11-10 22:17:04 +04:00
# 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/>.
2011-10-28 18:25:36 +04:00
2016-01-27 19:44:10 +03:00
set -euo pipefail
2011-10-28 18:25:36 +04:00
2013-05-01 23:26:21 +04:00
. $( dirname $0 ) /libtest.sh
2011-10-28 18:25:36 +04:00
2017-09-13 01:05:08 +03:00
echo '1..16'
2011-10-28 18:25:36 +04:00
2012-09-15 20:44:57 +04:00
setup_test_repository "bare"
2011-11-04 07:08:28 +04:00
$OSTREE remote add origin http://example.com/ostree/gnome
2014-12-16 00:21:15 +03:00
$OSTREE remote show-url origin >/dev/null
2011-10-28 18:25:36 +04:00
echo "ok config"
2013-12-25 23:17:36 +04:00
2019-11-17 21:01:13 +03:00
$OSTREE remote add --no-sign-verify another http://another.com/repo
2014-12-16 00:21:15 +03:00
$OSTREE remote show-url another >/dev/null
2013-12-25 23:17:36 +04:00
echo "ok remote no gpg-verify"
2014-10-17 19:47:01 +04:00
2019-11-17 21:01:13 +03:00
if $OSTREE remote add --no-sign-verify another http://another.example.com/anotherrepo 2>err.txt; then
2014-12-16 00:21:15 +03:00
assert_not_reached "Adding duplicate remote unexpectedly succeeded"
fi
echo "ok"
2019-11-17 21:01:13 +03:00
$OSTREE remote add --if-not-exists --no-sign-verify another http://another.example.com/anotherrepo
2014-12-16 00:21:15 +03:00
$OSTREE remote show-url another >/dev/null
echo "ok"
2019-11-17 21:01:13 +03:00
$OSTREE remote add --if-not-exists --no-sign-verify another-noexist http://another-noexist.example.com/anotherrepo
2014-12-16 00:21:15 +03:00
$OSTREE remote show-url another-noexist >/dev/null
echo "ok"
2014-12-16 18:41:34 +03:00
$OSTREE remote list > list.txt
assert_file_has_content list.txt "origin"
assert_file_has_content list.txt "another"
assert_file_has_content list.txt "another-noexist"
2019-04-02 05:01:49 +03:00
assert_not_file_has_content list.txt "http://example\.com/ostree/gnome"
assert_not_file_has_content list.txt "http://another\.com/repo"
assert_not_file_has_content list.txt "http://another-noexist\.example\.com/anotherrepo"
2014-12-16 18:41:34 +03:00
echo "ok remote list"
$OSTREE remote list --show-urls > list.txt
assert_file_has_content list.txt "origin"
assert_file_has_content list.txt "another"
assert_file_has_content list.txt "another-noexist"
2019-04-02 05:01:49 +03:00
assert_file_has_content list.txt "http://example\.com/ostree/gnome"
assert_file_has_content list.txt "http://another\.com/repo"
assert_file_has_content list.txt "http://another-noexist\.example\.com/anotherrepo"
2014-12-16 18:41:34 +03:00
echo "ok remote list with urls"
2017-12-05 23:57:46 +03:00
cd ${ test_tmpdir }
rm -rf parent-repo
ostree_repo_init parent-repo
$OSTREE config set core.parent ${ test_tmpdir } /parent-repo
2019-11-17 21:01:13 +03:00
${ CMD_PREFIX } ostree --repo= parent-repo remote add --no-sign-verify parent-remote http://parent-remote.example.com/parent-remote
2017-12-05 23:57:46 +03:00
$OSTREE remote list > list.txt
assert_file_has_content list.txt "origin"
assert_file_has_content list.txt "another"
assert_file_has_content list.txt "another-noexist"
assert_file_has_content list.txt "parent-remote"
echo "ok remote list with parent repo remotes"
2014-10-17 19:47:01 +04:00
$OSTREE remote delete another
echo "ok remote delete"
if $OSTREE remote delete nosuchremote 2>err.txt; then
assert_not_reached "Deleting remote unexpectedly succeeded"
fi
assert_file_has_content err.txt "error: "
2014-12-16 00:21:15 +03:00
$OSTREE remote delete --if-exists nosuchremote
echo "ok"
2014-10-17 19:47:01 +04:00
2014-12-16 00:21:15 +03:00
if $OSTREE remote show-url nosuchremote 2>/dev/null; then
assert_not_reached "Deleting remote unexpectedly failed"
fi
echo "ok"
$OSTREE remote delete --if-exists origin
echo "ok"
if $OSTREE remote show-url origin 2>/dev/null; then
assert_not_reached "Deleting remote unexpectedly failed"
fi
echo "ok"
2014-12-16 18:41:34 +03:00
$OSTREE remote list > list.txt
assert_not_file_has_content list.txt "origin"
# Can't grep for 'another' because of 'another-noexist'
assert_file_has_content list.txt "another-noexist"
echo "ok remote list remaining"
2017-09-13 01:05:08 +03:00
# Both --if-not-exists and --force cannot be used
if $OSTREE remote add --if-not-exists --force yetanother http://yetanother.com/repo 2>/dev/null; then
assert_not_reached "Adding remote with --if-not-exists and --force unexpectedly succeeded"
fi
echo "ok remote add fail --if-not-exists and --force"
# Overwrite with --force
$OSTREE remote add --force another http://another.example.com/anotherrepo
$OSTREE remote list --show-urls > list.txt
2019-04-02 05:01:49 +03:00
assert_file_has_content list.txt " ^another \+http://another\.example\.com/anotherrepo $"
2017-09-13 01:05:08 +03:00
echo "ok remote add --force"