2012-04-10 08:31:53 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-06-05 01:35:56 +00:00
|
|
|
# Tests for Serval rhizome operations.
|
2012-04-10 08:31:53 +00:00
|
|
|
#
|
|
|
|
# Copyright 2012 Paul Gardner-Stephen
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2012-06-05 01:35:56 +00:00
|
|
|
#
|
2012-04-10 08:31:53 +00:00
|
|
|
# This program 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 General Public License for more details.
|
2012-06-05 01:35:56 +00:00
|
|
|
#
|
2012-04-10 08:31:53 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
source "${0%/*}/../testframework.sh"
|
|
|
|
source "${0%/*}/../testdefs.sh"
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
shopt -s extglob
|
|
|
|
|
2012-06-05 04:28:59 +00:00
|
|
|
# Some useful regular expressions. These must work for grep(1) (as basic
|
|
|
|
# expressions) and also in sed(1).
|
|
|
|
rexp_service='[A-Za-z0-9_]\+'
|
|
|
|
rexp_manifestid='[0-9a-fA-F]\{64\}'
|
|
|
|
rexp_bundlekey='[0-9a-fA-F]\{128\}'
|
|
|
|
rexp_bundlesecret="$rexp_bundlekey"
|
|
|
|
rexp_filehash='[0-9a-fA-F]\{128\}'
|
2012-06-12 02:18:15 +00:00
|
|
|
rexp_filesize='[0-9]\{1,\}'
|
2012-06-05 04:28:59 +00:00
|
|
|
rexp_version='[0-9]\{1,\}'
|
|
|
|
rexp_date='[0-9]\{1,\}'
|
|
|
|
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome() {
|
2012-06-05 01:35:56 +00:00
|
|
|
setup_servald
|
2012-06-08 08:55:43 +00:00
|
|
|
set_instance A
|
|
|
|
executeOk_servald config set debug.rhizome on
|
|
|
|
executeOk_servald keyring add
|
|
|
|
executeOk_servald keyring list
|
|
|
|
tfw_cat --stdout
|
|
|
|
othersid=$(replayStdout | sed -ne "1s/^\($rexp_sid\):.*\$/\1/p")
|
|
|
|
assert --message='other identity known' [ -n "$othersid" ]
|
2012-06-05 01:35:56 +00:00
|
|
|
set_instance
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald config set debug.rhizome on
|
|
|
|
executeOk_servald keyring add
|
|
|
|
executeOk_servald keyring add
|
|
|
|
executeOk_servald keyring add
|
|
|
|
executeOk_servald keyring add
|
|
|
|
executeOk_servald keyring list
|
2012-06-05 04:28:59 +00:00
|
|
|
tfw_cat --stdout
|
|
|
|
sid=$(replayStdout | sed -ne "1s/^\($rexp_sid\):.*\$/\1/p")
|
|
|
|
sid1=$(replayStdout | sed -ne "2s/^\($rexp_sid\):.*\$/\1/p")
|
|
|
|
sid2=$(replayStdout | sed -ne "3s/^\($rexp_sid\):.*\$/\1/p")
|
|
|
|
sid3=$(replayStdout | sed -ne "4s/^\($rexp_sid\):.*\$/\1/p")
|
2012-05-21 05:11:22 +00:00
|
|
|
assert --message='main identity known' [ -n "$sid" ]
|
|
|
|
assert --message='identity 1 known' [ -n "$sid1" ]
|
|
|
|
assert --message='identity 2 known' [ -n "$sid2" ]
|
|
|
|
assert --message='identity 3 known' [ -n "$sid3" ]
|
2012-06-08 08:55:43 +00:00
|
|
|
assert [ $sid != $othersid ]
|
|
|
|
assert [ $sid1 != $othersid ]
|
|
|
|
assert [ $sid2 != $othersid ]
|
|
|
|
assert [ $sid3 != $othersid ]
|
2012-06-05 04:28:59 +00:00
|
|
|
assert [ $sid != $sid1 ]
|
|
|
|
assert [ $sid != $sid2 ]
|
|
|
|
assert [ $sid != $sid3 ]
|
|
|
|
assert [ $sid1 != $sid2 ]
|
|
|
|
assert [ $sid1 != $sid3 ]
|
|
|
|
assert [ $sid2 != $sid3 ]
|
2012-04-12 08:58:34 +00:00
|
|
|
}
|
|
|
|
|
2012-06-08 08:55:43 +00:00
|
|
|
assert_manifest_complete() {
|
|
|
|
local manifest="$1"
|
|
|
|
tfw_cat -v "$manifest"
|
|
|
|
assertGrep "$manifest" "^service=$rexp_service\$"
|
|
|
|
assertGrep "$manifest" "^id=$rexp_manifestid\$"
|
|
|
|
assertGrep "$manifest" "^BK=$rexp_bundlekey\$"
|
|
|
|
assertGrep "$manifest" "^date=$rexp_date\$"
|
|
|
|
assertGrep "$manifest" "^version=$rexp_version\$"
|
|
|
|
assertGrep "$manifest" "^filehash=$rexp_filehash\$"
|
|
|
|
assertGrep "$manifest" "^filesize=$rexp_filesize\$"
|
|
|
|
if grep -q '^service=file$' "$manifest"; then
|
|
|
|
assertGrep "$manifest" "^name="
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list() {
|
2012-06-05 04:28:59 +00:00
|
|
|
assertStdoutLineCount '==' $(($# + 2))
|
2012-06-12 08:43:21 +00:00
|
|
|
assertStdoutIs --stderr --line=1 -e '11\n'
|
2012-06-13 08:41:14 +00:00
|
|
|
assertStdoutIs --stderr --line=2 -e 'service:id:version:date:.inserttime:.selfsigned:filesize:filehash:sender:recipient:name\n'
|
2012-04-13 08:17:20 +00:00
|
|
|
local filename
|
|
|
|
for filename; do
|
2012-06-12 02:18:15 +00:00
|
|
|
re__selfsigned=1
|
|
|
|
case "$filename" in
|
|
|
|
*!) filename="${filename%!}"; re__selfsigned=0;;
|
|
|
|
esac
|
2012-05-04 06:01:03 +00:00
|
|
|
unpack_manifest_for_grep "$filename"
|
2012-06-12 02:18:15 +00:00
|
|
|
assertStdoutGrep --stderr --matches=1 "^$re_service:$re_manifestid:.*:$re__selfsigned:$re_filesize:$re_filehash:$re_sender:$re_recipient:$re_name\$"
|
2012-04-13 08:17:20 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2012-05-04 06:01:03 +00:00
|
|
|
assert_stdout_add_file() {
|
2012-06-05 06:15:53 +00:00
|
|
|
[ $# -ge 1 ] || error "missing filename arg"
|
|
|
|
local filename="${1}"
|
2012-06-12 02:18:15 +00:00
|
|
|
shift
|
2012-05-04 06:01:03 +00:00
|
|
|
unpack_manifest_for_grep "$filename"
|
2012-06-12 02:18:15 +00:00
|
|
|
opt_name=false
|
|
|
|
if replayStdout | grep -q '^service:file$'; then
|
|
|
|
opt_name=true
|
2012-06-08 08:55:43 +00:00
|
|
|
fi
|
2012-06-12 02:18:15 +00:00
|
|
|
fieldnames='service|manifestid|secret|filehash|filesize|name'
|
|
|
|
for arg; do
|
|
|
|
case "$arg" in
|
|
|
|
!+($fieldnames))
|
|
|
|
fieldname="${arg#!}"
|
|
|
|
eval opt_$fieldname=false
|
|
|
|
;;
|
|
|
|
+($fieldnames)=*)
|
|
|
|
value="${arg#*=}"
|
|
|
|
fieldname="${arg%%=*}"
|
|
|
|
assertStdoutGrep --matches=1 "^$fieldname:$value\$"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
error "unsupported argument: $arg"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
${opt_service:-true} && assertStdoutGrep --matches=1 "^service:$re_service\$"
|
|
|
|
${opt_manifestid:-true} && assertStdoutGrep --matches=1 "^manifestid:$re_manifestid\$"
|
|
|
|
${opt_secret:-true} && assertStdoutGrep --matches=1 "^secret:$re_secret\$"
|
|
|
|
${opt_filehash:-true} && assertStdoutGrep --matches=1 "^filehash:$re_filehash\$"
|
|
|
|
${opt_filesize:-true} && assertStdoutGrep --matches=1 "^filesize:$re_filesize\$"
|
2012-06-08 08:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_stdout_import_bundle() {
|
2012-06-12 02:18:15 +00:00
|
|
|
# Output of "import bundle" is the same as "add file" but without the secret.
|
|
|
|
assert_stdout_add_file "$@" '!secret'
|
2012-05-04 06:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unpack_manifest_for_grep() {
|
|
|
|
local filename="$1"
|
2012-06-05 04:28:59 +00:00
|
|
|
re_service="$rexp_service"
|
2012-06-05 06:15:53 +00:00
|
|
|
if [ -n "$filename" ]; then
|
2012-06-08 05:57:15 +00:00
|
|
|
re_filesize=$(( $(cat "$filename" | wc -c) + 0 ))
|
2012-06-05 06:15:53 +00:00
|
|
|
else
|
2012-06-08 05:57:15 +00:00
|
|
|
re_filesize=0
|
2012-06-05 06:15:53 +00:00
|
|
|
fi
|
2012-05-25 04:59:55 +00:00
|
|
|
compute_filehash re_filehash "$filename"
|
2012-06-05 04:28:59 +00:00
|
|
|
re_manifestid="$rexp_manifestid"
|
2012-06-08 05:57:15 +00:00
|
|
|
re_version="$rexp_version"
|
2012-06-05 04:28:59 +00:00
|
|
|
re_secret="$rexp_bundlesecret"
|
2012-06-05 01:35:56 +00:00
|
|
|
re_name=$(escape_grep_basic "${filename##*/}")
|
2012-05-04 06:01:03 +00:00
|
|
|
# If there is a manifest file that looks like it matches this payload
|
2012-06-08 08:55:43 +00:00
|
|
|
# file, then use its file hash to check the rhizome list '' output.
|
2012-05-21 03:48:12 +00:00
|
|
|
local filehash=$(sed -n -e '/^filehash=/s///p' "$filename.manifest" 2>/dev/null)
|
|
|
|
if [ "$filehash" = "$re_filehash" ]; then
|
|
|
|
re_manifestid=$(sed -n -e '/^id=/s///p' "$filename.manifest")
|
2012-06-08 05:57:15 +00:00
|
|
|
re_version=$(sed -n -e '/^version=/s///p' "$filename.manifest")
|
2012-05-21 03:48:12 +00:00
|
|
|
re_service=$(sed -n -e '/^service=/s///p' "$filename.manifest")
|
2012-06-05 01:35:56 +00:00
|
|
|
re_service=$(escape_grep_basic "$re_service")
|
2012-05-27 12:54:56 +00:00
|
|
|
re_sender=$(sed -n -e '/^sender=/s///p' "$filename.manifest")
|
|
|
|
re_recipient=$(sed -n -e '/^recipient=/s///p' "$filename.manifest")
|
2012-05-21 03:48:12 +00:00
|
|
|
case "$re_service" in
|
|
|
|
file)
|
|
|
|
re_name=$(sed -n -e '/^name=/s///p' "$filename.manifest")
|
2012-06-05 01:35:56 +00:00
|
|
|
re_name=$(escape_grep_basic "$re_name")
|
2012-05-21 03:48:12 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
re_name=
|
|
|
|
;;
|
|
|
|
esac
|
2012-05-04 06:01:03 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-04-16 02:16:58 +00:00
|
|
|
assert_manifest_newer() {
|
|
|
|
local manifest1="$1"
|
|
|
|
local manifest2="$2"
|
|
|
|
# The new manifest must have a higher version than the original.
|
|
|
|
extract_manifest_version oldversion "$manifest1"
|
|
|
|
extract_manifest_version newversion "$manifest2"
|
|
|
|
assert [ $newversion -gt $oldversion ]
|
|
|
|
# The new manifest must have a different filehash from the original.
|
|
|
|
extract_manifest_filehash oldfilehash "$manifest1"
|
|
|
|
extract_manifest_filehash newfilehash "$manifest2"
|
|
|
|
assert [ $oldfilehash != $newfilehash ]
|
|
|
|
}
|
|
|
|
|
2012-04-13 08:17:20 +00:00
|
|
|
strip_signatures() {
|
|
|
|
for file; do
|
|
|
|
cat -v "$file" | sed -e '/^^@/,$d' >"tmp.$file" && mv -f "tmp.$file" "$file"
|
|
|
|
done
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
|
2012-06-05 04:28:59 +00:00
|
|
|
extract_stdout_keyvalue() {
|
|
|
|
local _var="$1"
|
|
|
|
local _label="$2"
|
|
|
|
local _rexp="$3"
|
|
|
|
local _value=$(replayStdout | sed -n -e "/^$_label:$_rexp\$/s/^$_label://p")
|
|
|
|
assert --message="stdout contains valid '$_label:' line" --stdout [ -n "$_value" ]
|
|
|
|
[ -n "$_var" ] && eval $_var=$_value
|
|
|
|
}
|
|
|
|
|
|
|
|
extract_stdout_secret() {
|
|
|
|
extract_stdout_keyvalue "$1" secret "$rexp_bundlesecret"
|
|
|
|
}
|
|
|
|
|
|
|
|
extract_stdout_BK() {
|
|
|
|
extract_stdout_keyvalue "$1" BK "$rexp_bundlekey"
|
|
|
|
}
|
|
|
|
|
2012-05-02 08:27:35 +00:00
|
|
|
extract_manifest() {
|
2012-05-02 06:33:09 +00:00
|
|
|
local _var="$1"
|
|
|
|
local _manifestfile="$2"
|
2012-05-02 08:27:35 +00:00
|
|
|
local _label="$3"
|
|
|
|
local _rexp="$4"
|
|
|
|
local _value=$(sed -n -e "/^$_label=$_rexp\$/s/^$_label=//p" "$_manifestfile")
|
|
|
|
assert --message="$_manifestfile contains valid '$_label=' line" \
|
|
|
|
--dump-on-fail="$_manifestfile" \
|
|
|
|
[ -n "$_value" ]
|
|
|
|
[ -n "$_var" ] && eval $_var=$_value
|
2012-05-02 06:33:09 +00:00
|
|
|
}
|
|
|
|
|
2012-05-17 06:39:57 +00:00
|
|
|
extract_manifest_service() {
|
2012-06-05 04:28:59 +00:00
|
|
|
extract_manifest "$1" "$2" service "$rexp_service"
|
2012-05-17 06:39:57 +00:00
|
|
|
}
|
|
|
|
|
2012-05-02 08:27:35 +00:00
|
|
|
extract_manifest_id() {
|
2012-06-05 04:28:59 +00:00
|
|
|
extract_manifest "$1" "$2" id "$rexp_manifestid"
|
2012-04-16 02:16:58 +00:00
|
|
|
}
|
|
|
|
|
2012-05-21 03:48:12 +00:00
|
|
|
extract_manifest_BK() {
|
2012-06-05 04:28:59 +00:00
|
|
|
extract_manifest "$1" "$2" BK "$rexp_bundlekey"
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
|
|
|
|
2012-04-16 02:16:58 +00:00
|
|
|
extract_manifest_filehash() {
|
2012-06-05 04:28:59 +00:00
|
|
|
extract_manifest "$1" "$2" filehash "$rexp_filehash"
|
2012-05-02 08:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_manifest_version() {
|
2012-06-05 04:28:59 +00:00
|
|
|
extract_manifest "$1" "$2" version "$rexp_version"
|
2012-04-16 02:16:58 +00:00
|
|
|
}
|
|
|
|
|
2012-05-25 04:59:55 +00:00
|
|
|
compute_filehash() {
|
|
|
|
local _var="$1"
|
|
|
|
local _file="$2"
|
|
|
|
local _hash=$($servald rhizome hash file "$_file") || error "$servald failed to compute file hash"
|
|
|
|
[ -z "${_hash//[0-9a-fA-F]/}" ] || error "file hash contains non-hex: $_hash"
|
|
|
|
[ "${#_hash}" -eq 128 ] || error "file hash incorrect length: $_hash"
|
|
|
|
[ -n "$_var" ] && eval $_var=$_hash
|
|
|
|
}
|
|
|
|
|
2012-04-13 08:29:40 +00:00
|
|
|
doc_InitialEmptyList="Initial list is empty"
|
2012-04-10 08:31:53 +00:00
|
|
|
setup_InitialEmptyList() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
test_InitialEmptyList() {
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
}
|
|
|
|
|
2012-05-17 02:30:03 +00:00
|
|
|
doc_AddNoAuthorNoManifest="Add with no author and no manifest file"
|
|
|
|
setup_AddNoAuthorNoManifest() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-17 02:30:03 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
|
|
|
echo "Another test file" >file2
|
|
|
|
}
|
|
|
|
test_AddNoAuthorNoManifest() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file '' '' file1
|
2012-05-17 02:30:03 +00:00
|
|
|
assert_stdout_add_file file1
|
|
|
|
}
|
|
|
|
|
2012-04-13 08:29:40 +00:00
|
|
|
doc_AddNoManifest="Add with no manifest file"
|
2012-04-13 08:17:20 +00:00
|
|
|
setup_AddNoManifest() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
|
|
|
}
|
|
|
|
test_AddNoManifest() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1
|
2012-05-04 06:01:03 +00:00
|
|
|
assert_stdout_add_file file1
|
2012-04-13 08:17:20 +00:00
|
|
|
}
|
|
|
|
|
2012-06-05 04:28:59 +00:00
|
|
|
doc_AddNoAuthor="Add with no author makes manifest without BK"
|
|
|
|
setup_AddNoAuthor() {
|
|
|
|
setup_servald_rhizome
|
|
|
|
echo "A test file" >file1
|
|
|
|
}
|
|
|
|
test_AddNoAuthor() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file '' '' file1 file1.manifest
|
2012-06-05 04:28:59 +00:00
|
|
|
assert_stdout_add_file file1
|
|
|
|
assertGrep --matches=0 file1.manifest '^BK='
|
|
|
|
}
|
|
|
|
|
2012-04-13 08:29:40 +00:00
|
|
|
doc_AddNonExistManifest="Add with non-existent manifest file"
|
2012-04-13 08:17:20 +00:00
|
|
|
setup_AddNonExistManifest() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
|
|
|
echo "Another test file" >file2
|
|
|
|
}
|
|
|
|
test_AddNonExistManifest() {
|
|
|
|
assert --error-on-fail [ ! -e file1.manifest ]
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1 file1.manifest
|
2012-05-04 06:01:03 +00:00
|
|
|
assert_stdout_add_file file1
|
2012-04-13 08:17:20 +00:00
|
|
|
assert [ -r file1.manifest ]
|
2012-06-08 08:55:43 +00:00
|
|
|
assert_manifest_complete file1.manifest
|
2012-05-17 06:39:57 +00:00
|
|
|
assertGrep file1.manifest '^service=file$'
|
2012-04-13 08:17:20 +00:00
|
|
|
assertGrep file1.manifest '^name=file1$'
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
|
2012-04-13 08:29:40 +00:00
|
|
|
doc_AddManifest="Add with minimal manifest file"
|
2012-04-10 08:31:53 +00:00
|
|
|
setup_AddManifest() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list
|
2012-04-10 08:31:53 +00:00
|
|
|
echo "A test file" >file1
|
2012-04-13 08:17:20 +00:00
|
|
|
echo -e 'name=wah\ndate=12345' >file1.manifest
|
2012-04-10 08:31:53 +00:00
|
|
|
echo "Another test file" >file2
|
|
|
|
}
|
|
|
|
test_AddManifest() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1 file1.manifest
|
2012-05-04 06:01:03 +00:00
|
|
|
tfw_cat --stdout --stderr -v file1.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file1 name=wah
|
2012-06-08 08:55:43 +00:00
|
|
|
assert_manifest_complete file1.manifest
|
2012-05-17 06:39:57 +00:00
|
|
|
assertGrep file1.manifest '^service=file$'
|
2012-04-10 08:39:52 +00:00
|
|
|
assertGrep file1.manifest '^name=wah$'
|
2012-05-02 06:33:09 +00:00
|
|
|
assertGrep file1.manifest '^date=12345$'
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
|
2012-06-05 06:15:53 +00:00
|
|
|
doc_AddEmpty="Add with empty payload"
|
|
|
|
setup_AddEmpty() {
|
|
|
|
setup_servald_rhizome
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-06-05 06:15:53 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
}
|
|
|
|
test_AddEmpty() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' '' .manifest
|
2012-06-05 06:15:53 +00:00
|
|
|
tfw_cat --stdout --stderr -v .manifest
|
|
|
|
assert_stdout_add_file ''
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_manifest_complete .manifest
|
2012-06-05 06:15:53 +00:00
|
|
|
assertGrep .manifest '^service=file$'
|
|
|
|
assertGrep .manifest '^name=$'
|
|
|
|
assertGrep .manifest '^filesize=0$'
|
|
|
|
}
|
|
|
|
|
2012-04-13 08:29:40 +00:00
|
|
|
doc_AddThenList="List contains one file after one add"
|
2012-04-10 08:31:53 +00:00
|
|
|
setup_AddThenList() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list
|
2012-04-10 08:31:53 +00:00
|
|
|
echo "A test file" >file1
|
|
|
|
echo "Another test file" >file2
|
|
|
|
}
|
|
|
|
test_AddThenList() {
|
|
|
|
# Add first file
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1 file1.manifest
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list file1
|
2012-04-10 08:31:53 +00:00
|
|
|
# Add second file
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file2 file2.manifest
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list file1 file2
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
|
2012-05-02 06:38:27 +00:00
|
|
|
doc_AddThenExtractManifest="Extract manifest after one add"
|
|
|
|
setup_AddThenExtractManifest() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-05-02 06:33:09 +00:00
|
|
|
echo "A test file" >file1
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1 file1.manifest
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-02 06:33:09 +00:00
|
|
|
assert_rhizome_list file1
|
|
|
|
extract_manifest_id manifestid file1.manifest
|
2012-05-02 06:38:27 +00:00
|
|
|
extract_manifest_version version file1.manifest
|
2012-05-03 02:46:32 +00:00
|
|
|
extract_manifest_filehash filehash file1.manifest
|
2012-05-02 06:33:09 +00:00
|
|
|
}
|
2012-05-02 06:38:27 +00:00
|
|
|
test_AddThenExtractManifest() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome extract manifest $manifestid file1x.manifest
|
2012-05-02 06:33:09 +00:00
|
|
|
assert cmp file1.manifest file1x.manifest
|
2012-05-17 06:39:57 +00:00
|
|
|
assertStdoutLineCount '==' 6
|
2012-05-03 02:46:32 +00:00
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
2012-05-17 06:39:57 +00:00
|
|
|
assertStdoutGrep --matches=1 "^service:file$"
|
2012-05-02 06:38:27 +00:00
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version$"
|
|
|
|
assertStdoutGrep --matches=1 "^inserttime:[0-9]\+$"
|
2012-05-03 02:46:32 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size$"
|
2012-05-02 06:33:09 +00:00
|
|
|
}
|
|
|
|
|
2012-05-02 06:54:27 +00:00
|
|
|
doc_ExtractMissingManifest="Extract non-existent manifest"
|
|
|
|
setup_ExtractMissingManifest() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-05-02 06:54:27 +00:00
|
|
|
manifestid=0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
|
|
|
|
}
|
|
|
|
test_ExtractMissingManifest() {
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=1 $servald rhizome extract manifest $manifestid foo.manifest
|
2012-05-02 06:54:27 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_ExtractManifestInvalidID="Extract manifest using invalid ID"
|
|
|
|
setup_ExtractManifestInvalidID() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-05-02 06:54:27 +00:00
|
|
|
}
|
|
|
|
test_ExtractManifestInvalidID() {
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=255 $servald rhizome extract manifest 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEx foo.manifest
|
2012-05-02 06:54:27 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=255 $servald rhizome extract manifest 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDE foo.manifest
|
2012-05-02 06:54:27 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=255 $servald rhizome extract manifest '' foo.manifest
|
2012-05-02 06:54:27 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
|
|
|
}
|
|
|
|
|
2012-05-02 08:27:35 +00:00
|
|
|
doc_AddThenExtractFile="Extract file after one add"
|
|
|
|
setup_AddThenExtractFile() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-05-02 08:27:35 +00:00
|
|
|
echo "A test file" >file1
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1 file1.manifest
|
2012-05-25 10:12:45 +00:00
|
|
|
tfw_cat --stderr
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-02 08:27:35 +00:00
|
|
|
assert_rhizome_list file1
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
|
|
|
}
|
|
|
|
test_AddThenExtractFile() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome extract file $filehash file1x
|
2012-05-02 08:27:35 +00:00
|
|
|
assert cmp file1 file1x
|
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
|
|
|
assertStdoutLineCount '==' 2
|
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash$"
|
2012-05-03 02:46:32 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size$"
|
2012-05-02 08:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
doc_ExtractMissingFile="Extract non-existent file"
|
|
|
|
setup_ExtractMissingFile() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-05-02 08:27:35 +00:00
|
|
|
filehash=0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
|
|
|
|
}
|
|
|
|
test_ExtractMissingFile() {
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=1 $servald rhizome extract file $filehash foo
|
2012-05-02 08:27:35 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_ExtractFileInvalidID="Extract file using invalid ID"
|
|
|
|
setup_ExtractFileInvalidID() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-05-02 08:27:35 +00:00
|
|
|
}
|
|
|
|
test_ExtractFileInvalidID() {
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=255 $servald rhizome extract file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEx foo
|
2012-05-02 08:27:35 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=255 $servald rhizome extract file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDE foo
|
2012-05-02 08:27:35 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=255 $servald rhizome extract file '' foo
|
2012-05-02 08:27:35 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
|
|
|
}
|
|
|
|
|
2012-04-16 02:16:58 +00:00
|
|
|
doc_AddDuplicate="Add same manifest detects duplicate"
|
2012-04-10 08:31:53 +00:00
|
|
|
setup_AddDuplicate() {
|
2012-05-20 04:18:02 +00:00
|
|
|
setup_servald_rhizome
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list
|
2012-04-10 08:31:53 +00:00
|
|
|
echo "A test file" >file1
|
|
|
|
echo "Another test file" >file2
|
2012-04-13 08:17:20 +00:00
|
|
|
echo "A test file, second version" >file1_2
|
2012-04-10 08:31:53 +00:00
|
|
|
# Add first file
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1 file1.manifest
|
2012-06-05 04:28:59 +00:00
|
|
|
extract_stdout_secret file1_secret
|
2012-04-10 08:31:53 +00:00
|
|
|
# Add second file
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file2 file2.manifest
|
2012-06-05 04:28:59 +00:00
|
|
|
extract_stdout_secret file2_secret
|
2012-04-10 08:31:53 +00:00
|
|
|
# Make sure they are both in the list.
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list file1 file2
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
test_AddDuplicate() {
|
2012-04-13 08:17:20 +00:00
|
|
|
# Add first file again - nothing should change in its manifests, and it
|
|
|
|
# should appear that the add command succeeded (with perhaps some grumbling
|
|
|
|
# on stderr).
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=2 $servald rhizome add file $sid '' file1 file1.manifestA
|
2012-04-13 08:17:20 +00:00
|
|
|
assert [ -s file1.manifestA ]
|
2012-05-04 06:29:58 +00:00
|
|
|
assert_stdout_add_file file1
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list file1 file2
|
|
|
|
strip_signatures file1.manifest file1.manifestA
|
|
|
|
assert diff file1.manifest file1.manifestA
|
|
|
|
# Repeat for second file.
|
2012-05-20 04:18:02 +00:00
|
|
|
execute --exit-status=2 $servald rhizome add file $sid '' file2 file2.manifestA
|
2012-04-13 08:17:20 +00:00
|
|
|
assert [ -s file2.manifestA ]
|
2012-05-04 06:29:58 +00:00
|
|
|
assert_stdout_add_file file2
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list file1 file2
|
|
|
|
strip_signatures file2.manifest file2.manifestA
|
|
|
|
assert diff file2.manifest file2.manifestA
|
|
|
|
}
|
|
|
|
|
2012-04-13 08:29:40 +00:00
|
|
|
doc_AddMismatched="Add mismatched manifest/payload fails"
|
2012-04-13 08:17:20 +00:00
|
|
|
setup_AddMismatched() {
|
|
|
|
setup_AddDuplicate
|
|
|
|
}
|
|
|
|
test_AddMismatched() {
|
|
|
|
# Try to add another file using an existing manifest, should fail and leave
|
|
|
|
# the manifest file unchanged.
|
|
|
|
cp file1.manifest file1_2.manifest
|
2012-05-20 04:18:02 +00:00
|
|
|
execute $servald rhizome add file $sid '' file1_2 file1_2.manifest
|
2012-04-13 08:17:20 +00:00
|
|
|
assertExitStatus '!=' 0
|
|
|
|
assert cmp file1.manifest file1_2.manifest
|
|
|
|
# And rhizome store should be unchanged.
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list file1 file2
|
|
|
|
}
|
|
|
|
|
2012-05-21 03:48:12 +00:00
|
|
|
doc_AddUpdateSameVersion="Add new payload to existing manifest with same version fails"
|
2012-04-16 02:16:58 +00:00
|
|
|
setup_AddUpdateSameVersion() {
|
2012-04-13 08:17:20 +00:00
|
|
|
setup_AddDuplicate
|
|
|
|
cp file1.manifest file1_2.manifest
|
|
|
|
strip_signatures file1_2.manifest
|
2012-04-17 07:24:39 +00:00
|
|
|
sed -i -e '/^date=/d;/^filehash=/d;/^filesize=/d' file1_2.manifest
|
|
|
|
tfw_cat -v file1_2.manifest
|
2012-04-13 08:29:40 +00:00
|
|
|
assertGrep --matches=0 file1_2.manifest '^filehash='
|
2012-04-16 02:16:58 +00:00
|
|
|
extract_manifest_version '' file1_2.manifest # asserts has version= line
|
|
|
|
assertGrep file1_2.manifest '^id='
|
2012-04-13 08:29:40 +00:00
|
|
|
cp file1_2.manifest file1_2.manifest.orig
|
|
|
|
}
|
2012-04-16 02:16:58 +00:00
|
|
|
test_AddUpdateSameVersion() {
|
|
|
|
tfw_cat -v file1_2.manifest
|
2012-05-20 04:18:02 +00:00
|
|
|
execute $servald rhizome add file $sid '' file1_2 file1_2.manifest
|
2012-04-16 02:16:58 +00:00
|
|
|
assertExitStatus --stderr '!=' 0
|
|
|
|
tfw_cat -v file1_2.manifest
|
2012-04-13 08:29:40 +00:00
|
|
|
assert cmp file1_2.manifest file1_2.manifest.orig
|
|
|
|
# And rhizome store should be unchanged.
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-04-13 08:29:40 +00:00
|
|
|
assert_rhizome_list file1 file2
|
|
|
|
}
|
|
|
|
|
2012-04-16 02:16:58 +00:00
|
|
|
doc_AddUpdateNewVersion="Add new payload to existing manifest with new version"
|
|
|
|
setup_AddUpdateNewVersion() {
|
|
|
|
setup_AddUpdateSameVersion
|
|
|
|
extract_manifest_version version file1_2.manifest
|
2012-04-13 08:29:40 +00:00
|
|
|
let version=version+1
|
|
|
|
sed -i -e "/^version=/s/=.*/=$version/" file1_2.manifest
|
|
|
|
assertGrep --matches=1 file1_2.manifest "^version=$version$"
|
|
|
|
}
|
2012-04-16 02:16:58 +00:00
|
|
|
test_AddUpdateNewVersion() {
|
2012-04-17 07:24:39 +00:00
|
|
|
tfw_cat -v file1_2.manifest
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1_2 file1_2.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file1_2 name=file1
|
2012-04-16 02:16:58 +00:00
|
|
|
assert_manifest_newer file1.manifest file1_2.manifest
|
|
|
|
# Rhizome store contents reflect new payload.
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-21 03:48:12 +00:00
|
|
|
assert_rhizome_list file1_2 file2
|
2012-06-05 04:28:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddUpdateNoAuthor="Cannot add new payload to authorless manifest"
|
|
|
|
setup_AddUpdateNoAuthor() {
|
|
|
|
setup_AddUpdateNewVersion
|
|
|
|
sed -i -e '/^BK=/d' file1_2.manifest
|
|
|
|
}
|
|
|
|
test_AddUpdateNoAuthor() {
|
|
|
|
tfw_cat -v file1_2.manifest
|
|
|
|
execute $servald rhizome add file $sid '' file1_2 file1_2.manifest
|
|
|
|
tfw_cat --stderr
|
|
|
|
assertExitStatus '!=' 0
|
|
|
|
# Rhizome store contents have old payload.
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-06-05 04:28:59 +00:00
|
|
|
assert_rhizome_list file1 file2
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddUpdateNoAuthorWithSecret="Add new payload to authorless manifest with bundle secret"
|
|
|
|
setup_AddUpdateNoAuthorWithSecret() {
|
|
|
|
setup_AddUpdateNoAuthor
|
|
|
|
}
|
|
|
|
test_AddUpdateNoAuthorWithSecret() {
|
|
|
|
tfw_cat -v file1_2.manifest
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1_2 file1_2.manifest "$file1_secret"
|
2012-06-05 04:28:59 +00:00
|
|
|
tfw_cat --stderr
|
|
|
|
# Rhizome store contents have new payload.
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_rhizome_list file1_2! file2
|
2012-04-16 02:16:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddUpdateAutoVersion="Add new payload to existing manifest with automatic version"
|
|
|
|
setup_AddUpdateAutoVersion() {
|
|
|
|
setup_AddUpdateSameVersion
|
|
|
|
sed -i -e '/^version=/d' file1_2.manifest
|
|
|
|
assertGrep --matches=0 file1_2.manifest '^version='
|
|
|
|
}
|
|
|
|
test_AddUpdateAutoVersion() {
|
2012-04-17 07:24:39 +00:00
|
|
|
tfw_cat -v file1_2.manifest
|
2012-04-16 02:16:58 +00:00
|
|
|
sleep 0.001 # Ensure that at least one millisecond has elapsed
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1_2 file1_2.manifest
|
2012-04-16 02:16:58 +00:00
|
|
|
assert_manifest_newer file1.manifest file1_2.manifest
|
2012-04-13 08:17:20 +00:00
|
|
|
# Rhizome store contents reflect new payload.
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-21 03:48:12 +00:00
|
|
|
assert_rhizome_list file1_2 file2
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddUnsupportedService="Add with unsupported service fails"
|
|
|
|
setup_AddUnsupportedService() {
|
|
|
|
setup_servald_rhizome
|
|
|
|
echo "Message1" >file1
|
|
|
|
echo -e 'service=Fubar' >file1.manifest
|
|
|
|
}
|
|
|
|
test_AddUnsupportedService() {
|
|
|
|
execute $servald rhizome add file $sid '' file1 file1.manifest
|
|
|
|
assertExitStatus '!=' 0
|
|
|
|
}
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
doc_MeshMSAddCreate="First add MeshMS creates manifest"
|
|
|
|
setup_MeshMSAddCreate() {
|
2012-05-21 03:48:12 +00:00
|
|
|
setup_servald_rhizome
|
|
|
|
echo "Message1" >file1
|
2012-05-21 05:11:22 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$sid\nrecipient=$sid1" >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddCreate() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1 file1.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-21 03:48:12 +00:00
|
|
|
assert_rhizome_list file1
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome extract file $filehash file1x
|
2012-05-21 03:48:12 +00:00
|
|
|
assert diff file1 file1x
|
|
|
|
}
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
doc_MeshMSAddGrow="Subsequent add MeshMS updates manifest and removes old payload"
|
|
|
|
setup_MeshMSAddGrow() {
|
2012-05-21 03:48:12 +00:00
|
|
|
setup_servald_rhizome
|
|
|
|
echo "Message1" >file1
|
2012-05-21 05:11:22 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$sid\nrecipient=$sid1" >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddGrow() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1 file1.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-25 04:59:55 +00:00
|
|
|
assert_rhizome_list file1
|
|
|
|
extract_manifest_id id file1.manifest
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
|
|
|
extract_manifest_BK bk file1.manifest
|
|
|
|
local -a ofilehashes=()
|
|
|
|
for m in 2 3 4 5; do
|
|
|
|
ofilehashes+=("$filehash")
|
|
|
|
echo -e "id=$id\nBK=$bk\nservice=MeshMS1\nsender=$sid\nrecipient=$sid1" >file1.manifest
|
|
|
|
echo "Message$m" >>file1
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file $sid '' file1 file1.manifest
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-25 04:59:55 +00:00
|
|
|
assert_rhizome_list file1
|
|
|
|
extract_manifest_id idx file1.manifest
|
|
|
|
extract_manifest_filehash filehashx file1.manifest
|
|
|
|
extract_manifest_BK bkx file1.manifest
|
|
|
|
compute_filehash filehash file1
|
|
|
|
assert --message="manifest ID remains the same" [ "$idx" = "$id" ]
|
|
|
|
assert --message="manifest BK remains the same" [ "$bkx" = "$bk" ]
|
|
|
|
assert --message="filehash is for new file" [ "$filehash" = "$filehashx" ]
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome extract file "$filehash" file1x
|
2012-05-25 04:59:55 +00:00
|
|
|
assert --message="extracted payload is correct" diff file1 file1x
|
|
|
|
for ofilehash in "${ofilehashes[@]}"; do
|
|
|
|
execute --exit-status=1 --stderr $servald rhizome extract file "$ofilehash"
|
|
|
|
done
|
|
|
|
done
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
doc_MeshMSAddMissingSender="Add MeshMS without sender fails"
|
|
|
|
setup_MeshMSAddMissingSender() {
|
2012-05-21 03:48:12 +00:00
|
|
|
setup_servald_rhizome
|
|
|
|
echo "Message1" >file1
|
2012-05-21 05:11:22 +00:00
|
|
|
echo -e "service=MeshMS1\nrecipient=$sid1" >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddMissingSender() {
|
2012-05-21 03:48:12 +00:00
|
|
|
execute $servald rhizome add file $sid '' file1 file1.manifest
|
|
|
|
assertExitStatus '!=' 0
|
|
|
|
}
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
doc_MeshMSAddMissingRecipient="Add MeshMS without recipient fails"
|
|
|
|
setup_MeshMSAddMissingRecipient() {
|
2012-05-21 03:48:12 +00:00
|
|
|
setup_servald_rhizome
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-21 03:48:12 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
echo "Message1" >file1
|
|
|
|
echo -e "service=MeshMS1\nsender=$sid" >file1.manifest
|
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddMissingRecipient() {
|
2012-05-21 03:48:12 +00:00
|
|
|
execute $servald rhizome add file $sid '' file1 file1.manifest
|
|
|
|
assertExitStatus '!=' 0
|
|
|
|
}
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
doc_MeshMSAddMissingAuthor="Add MeshMS without author uses sender"
|
|
|
|
setup_MeshMSAddMissingAuthor() {
|
2012-05-21 03:48:12 +00:00
|
|
|
setup_servald_rhizome
|
|
|
|
echo "Message1" >file1
|
2012-05-21 05:11:22 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$sid\nrecipient=$sid1" >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddMissingAuthor() {
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file '' '' file1 file1.manifest
|
2012-06-08 08:55:43 +00:00
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
|
|
|
executeOk_servald rhizome list ''
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list file1
|
|
|
|
}
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
doc_MeshMSListFilter="List MeshMS manifests by filter"
|
|
|
|
setup_MeshMSListFilter() {
|
2012-05-21 05:11:22 +00:00
|
|
|
setup_servald_rhizome
|
|
|
|
echo "Message1" >file1
|
|
|
|
echo -e "service=MeshMS1\nsender=$sid\nrecipient=$sid1" >file1.manifest
|
|
|
|
echo "Message2" >file2
|
|
|
|
echo -e "service=MeshMS1\nsender=$sid\nrecipient=$sid2" >file2.manifest
|
|
|
|
echo "Message3" >file3
|
|
|
|
echo -e "service=MeshMS1\nsender=$sid\nrecipient=$sid3" >file3.manifest
|
|
|
|
echo "Message3" >file4
|
|
|
|
echo -e "service=MeshMS1\nsender=$sid1\nrecipient=$sid2" >file4.manifest
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file '' '' file1 file1.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file '' '' file2 file2.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file2
|
|
|
|
assert_manifest_complete file2.manifest
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file '' '' file3 file3.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file3
|
|
|
|
assert_manifest_complete file3.manifest
|
2012-06-08 03:43:26 +00:00
|
|
|
executeOk_servald rhizome add file '' '' file4 file4.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file4
|
|
|
|
assert_manifest_complete file4.manifest
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list ''
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list file1 file2 file3 file4
|
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSListFilter() {
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' file
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' MeshMS1
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list file1 file2 file3 file4
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' $sid
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list file1 file2 file3
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' $sid1
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list file4
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' $sid2
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' $sid3
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' '' $sid
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' '' $sid1
|
2012-05-21 03:48:12 +00:00
|
|
|
assert_rhizome_list file1
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' '' $sid2
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list file2 file4
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' file '' $sid2
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' '' $sid3
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list file3
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' $sid $sid3
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list file3
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' $sid1 $sid3
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2012-06-08 08:55:43 +00:00
|
|
|
executeOk_servald rhizome list '' '' $sid1 $sid2
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list file4
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
|
2012-06-08 08:55:43 +00:00
|
|
|
doc_ImportForeignBundle="Can import a bundle created by another instance"
|
|
|
|
setup_ImportForeignBundle() {
|
|
|
|
setup_servald_rhizome
|
|
|
|
set_instance A
|
|
|
|
echo "Hello from A" >fileA
|
|
|
|
executeOk_servald rhizome add file $othersid '' fileA fileA.manifest
|
|
|
|
assert_stdout_add_file fileA
|
|
|
|
set_instance
|
|
|
|
}
|
|
|
|
test_ImportForeignBundle() {
|
|
|
|
executeOk_servald rhizome import bundle fileA fileA.manifest
|
|
|
|
assert_stdout_import_bundle fileA
|
|
|
|
executeOk_servald rhizome list ''
|
2012-06-15 08:40:10 +00:00
|
|
|
assert_rhizome_list fileA!
|
2012-06-08 08:55:43 +00:00
|
|
|
}
|
|
|
|
|
2012-04-10 08:31:53 +00:00
|
|
|
runTests "$@"
|