2012-04-10 18:01:53 +09:30
|
|
|
#!/bin/bash
|
|
|
|
|
2012-06-05 11:05:56 +09:30
|
|
|
# Tests for Serval rhizome operations.
|
2012-04-10 18:01:53 +09:30
|
|
|
#
|
2013-02-06 18:55:31 +10:30
|
|
|
# Copyright 2012 Serval Project, Inc.
|
2012-04-10 18:01:53 +09:30
|
|
|
#
|
|
|
|
# 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 11:05:56 +09:30
|
|
|
#
|
2012-04-10 18:01:53 +09:30
|
|
|
# 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 11:05:56 +09:30
|
|
|
#
|
2012-04-10 18:01:53 +09:30
|
|
|
# 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-07-06 13:32:21 +09:30
|
|
|
source "${0%/*}/../testdefs_rhizome.sh"
|
2012-04-10 18:01:53 +09:30
|
|
|
|
2012-06-12 11:48:15 +09:30
|
|
|
shopt -s extglob
|
|
|
|
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_rhizome() {
|
2012-06-22 15:56:28 +09:30
|
|
|
set_instance +A
|
2013-07-05 16:24:50 +09:30
|
|
|
executeOk_servald config \
|
|
|
|
set debug.rhizome on \
|
|
|
|
set debug.verbose on \
|
|
|
|
set log.console.level debug
|
2013-02-20 14:44:29 +10:30
|
|
|
create_single_identity
|
2012-06-22 15:56:28 +09:30
|
|
|
set_instance +B
|
2013-07-05 16:24:50 +09:30
|
|
|
executeOk_servald config \
|
|
|
|
set debug.rhizome on \
|
|
|
|
set debug.verbose on \
|
|
|
|
set log.console.level debug
|
2012-09-14 15:04:05 +09:30
|
|
|
create_identities 4
|
2012-07-06 13:32:21 +09:30
|
|
|
assert [ $SIDB1 != $SIDA1 ]
|
|
|
|
assert [ $SIDB2 != $SIDA1 ]
|
|
|
|
assert [ $SIDB3 != $SIDA1 ]
|
|
|
|
assert [ $SIDB4 != $SIDA1 ]
|
2012-05-25 14:29:55 +09:30
|
|
|
}
|
|
|
|
|
2012-04-13 17:59:40 +09:30
|
|
|
doc_InitialEmptyList="Initial list is empty"
|
2012-04-10 18:01:53 +09:30
|
|
|
setup_InitialEmptyList() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-04-10 18:01:53 +09:30
|
|
|
}
|
|
|
|
test_InitialEmptyList() {
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-04-13 17:47:20 +09:30
|
|
|
assert_rhizome_list
|
|
|
|
}
|
|
|
|
|
2012-05-17 12:00:03 +09:30
|
|
|
doc_AddNoAuthorNoManifest="Add with no author and no manifest file"
|
|
|
|
setup_AddNoAuthorNoManifest() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-05-17 12:00:03 +09:30
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
|
|
|
}
|
|
|
|
test_AddNoAuthorNoManifest() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file1
|
2012-05-17 12:00:03 +09:30
|
|
|
assert_stdout_add_file file1
|
|
|
|
}
|
|
|
|
|
2012-04-13 17:59:40 +09:30
|
|
|
doc_AddNoManifest="Add with no manifest file"
|
2012-04-13 17:47:20 +09:30
|
|
|
setup_AddNoManifest() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-04-13 17:47:20 +09:30
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
|
|
|
}
|
|
|
|
test_AddNoManifest() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1
|
2012-05-04 15:31:03 +09:30
|
|
|
assert_stdout_add_file file1
|
2012-04-13 17:47:20 +09:30
|
|
|
}
|
|
|
|
|
2012-06-05 13:58:59 +09:30
|
|
|
doc_AddNoAuthor="Add with no author makes manifest without BK"
|
|
|
|
setup_AddNoAuthor() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-06-05 13:58:59 +09:30
|
|
|
echo "A test file" >file1
|
|
|
|
}
|
|
|
|
test_AddNoAuthor() {
|
2013-03-15 15:58:17 +10:30
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2012-06-05 13:58:59 +09:30
|
|
|
assert_stdout_add_file file1
|
|
|
|
assertGrep --matches=0 file1.manifest '^BK='
|
|
|
|
}
|
|
|
|
|
2013-03-15 15:58:17 +10:30
|
|
|
doc_AddInvalidAuthor="Add with invalid author fails"
|
|
|
|
setup_AddInvalidAuthor() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "A test file" >file1
|
|
|
|
}
|
|
|
|
test_AddInvalidAuthor() {
|
|
|
|
execute $servald rhizome add file 'not_a_valid_SID' file1
|
|
|
|
assertExitStatus '==' 255
|
|
|
|
assertStderrGrep '^ERROR:.*[Ii]nvalid .*[Ss][Ii][Dd]'
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddNoAuthorEncrypted="Add encrypted payload with no author"
|
|
|
|
setup_AddNoAuthorEncrypted() {
|
2013-01-04 10:44:07 +10:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "A test file" >file1
|
|
|
|
echo "crypt=1" >file1.manifest
|
|
|
|
}
|
2013-03-15 15:58:17 +10:30
|
|
|
test_AddNoAuthorEncrypted() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2013-01-04 10:44:07 +10:30
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1
|
|
|
|
extract_stdout_secret file1_secret
|
|
|
|
assertGrep --matches=0 file1.manifest '^BK='
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome extract file $re_manifestid file1x $file1_secret
|
2013-01-04 10:44:07 +10:30
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert diff file1 file1x
|
|
|
|
}
|
|
|
|
|
2012-04-13 17:59:40 +09:30
|
|
|
doc_AddNonExistManifest="Add with non-existent manifest file"
|
2012-04-13 17:47:20 +09:30
|
|
|
setup_AddNonExistManifest() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-04-13 17:47:20 +09:30
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
|
|
|
}
|
|
|
|
test_AddNonExistManifest() {
|
|
|
|
assert --error-on-fail [ ! -e file1.manifest ]
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-05-04 15:31:03 +09:30
|
|
|
assert_stdout_add_file file1
|
2012-04-13 17:47:20 +09:30
|
|
|
assert [ -r file1.manifest ]
|
2012-06-08 18:25:43 +09:30
|
|
|
assert_manifest_complete file1.manifest
|
2012-05-17 16:09:57 +09:30
|
|
|
assertGrep file1.manifest '^service=file$'
|
2012-04-13 17:47:20 +09:30
|
|
|
assertGrep file1.manifest '^name=file1$'
|
2012-04-10 18:01:53 +09:30
|
|
|
}
|
|
|
|
|
2012-04-13 17:59:40 +09:30
|
|
|
doc_AddManifest="Add with minimal manifest file"
|
2012-04-10 18:01:53 +09:30
|
|
|
setup_AddManifest() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-04-13 17:47:20 +09:30
|
|
|
assert_rhizome_list
|
2012-04-10 18:01:53 +09:30
|
|
|
echo "A test file" >file1
|
2012-04-13 17:47:20 +09:30
|
|
|
echo -e 'name=wah\ndate=12345' >file1.manifest
|
2012-04-10 18:01:53 +09:30
|
|
|
}
|
|
|
|
test_AddManifest() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-05-04 15:31:03 +09:30
|
|
|
tfw_cat --stdout --stderr -v file1.manifest
|
2012-06-12 11:48:15 +09:30
|
|
|
assert_stdout_add_file file1 name=wah
|
2012-06-08 18:25:43 +09:30
|
|
|
assert_manifest_complete file1.manifest
|
2012-05-17 16:09:57 +09:30
|
|
|
assertGrep file1.manifest '^service=file$'
|
2012-04-10 18:09:52 +09:30
|
|
|
assertGrep file1.manifest '^name=wah$'
|
2012-05-02 16:03:09 +09:30
|
|
|
assertGrep file1.manifest '^date=12345$'
|
2012-04-10 18:01:53 +09:30
|
|
|
}
|
|
|
|
|
2012-06-05 15:45:53 +09:30
|
|
|
doc_AddEmpty="Add with empty payload"
|
|
|
|
setup_AddEmpty() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-06-05 15:45:53 +09:30
|
|
|
assert_rhizome_list
|
|
|
|
}
|
|
|
|
test_AddEmpty() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 '' .manifest
|
2012-06-05 15:45:53 +09:30
|
|
|
tfw_cat --stdout --stderr -v .manifest
|
|
|
|
assert_stdout_add_file ''
|
2012-06-12 11:48:15 +09:30
|
|
|
assert_manifest_complete .manifest
|
2012-06-05 15:45:53 +09:30
|
|
|
assertGrep .manifest '^service=file$'
|
|
|
|
assertGrep .manifest '^name=$'
|
|
|
|
assertGrep .manifest '^filesize=0$'
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 ''
|
2012-06-05 15:45:53 +09:30
|
|
|
}
|
|
|
|
|
2012-04-13 17:59:40 +09:30
|
|
|
doc_AddThenList="List contains one file after one add"
|
2012-04-10 18:01:53 +09:30
|
|
|
setup_AddThenList() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-04-13 17:47:20 +09:30
|
|
|
assert_rhizome_list
|
2012-04-10 18:01:53 +09:30
|
|
|
echo "A test file" >file1
|
|
|
|
echo "Another test file" >file2
|
|
|
|
}
|
|
|
|
test_AddThenList() {
|
|
|
|
# Add first file
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1
|
2012-04-10 18:01:53 +09:30
|
|
|
# Add second file
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file2 file2.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-10 18:01:53 +09:30
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_ExtractManifestAfterAdd="Export manifest after one add"
|
2012-10-15 16:41:38 +10:30
|
|
|
setup_ExtractManifestAfterAdd() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 16:03:09 +09:30
|
|
|
echo "A test file" >file1
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1
|
2012-05-02 16:03:09 +09:30
|
|
|
extract_manifest_id manifestid file1.manifest
|
2012-05-02 16:08:27 +09:30
|
|
|
extract_manifest_version version file1.manifest
|
2012-05-03 12:16:32 +09:30
|
|
|
extract_manifest_filehash filehash file1.manifest
|
2012-05-02 16:03:09 +09:30
|
|
|
}
|
2012-10-15 16:41:38 +10:30
|
|
|
test_ExtractManifestAfterAdd() {
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export manifest $manifestid file1x.manifest
|
2013-01-11 11:55:17 +10:30
|
|
|
tfw_cat --stdout --stderr
|
2012-10-15 16:41:38 +10:30
|
|
|
assertStdoutLineCount '==' 8
|
2012-05-03 12:16:32 +09:30
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
2012-05-17 16:09:57 +09:30
|
|
|
assertStdoutGrep --matches=1 "^service:file$"
|
2012-10-09 17:43:34 +10:30
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
2012-10-15 16:41:38 +10:30
|
|
|
assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
2012-10-09 17:43:34 +10:30
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
2012-10-15 16:41:38 +10:30
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
2013-01-11 11:55:17 +10:30
|
|
|
assert [ -e file1x.manifest ]
|
|
|
|
assert diff file1.manifest file1x.manifest
|
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_ExtractManifestFileAfterAdd="Export bundle after one add"
|
2013-01-11 11:55:17 +10:30
|
|
|
setup_ExtractManifestFileAfterAdd() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "A test file" >file1
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2013-01-11 11:55:17 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1
|
|
|
|
extract_manifest_id manifestid file1.manifest
|
|
|
|
extract_manifest_version version file1.manifest
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
|
|
|
}
|
|
|
|
test_ExtractManifestFileAfterAdd() {
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export bundle $manifestid file1x.manifest file1x
|
2013-01-11 11:55:17 +10:30
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assertStdoutLineCount '==' 8
|
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --matches=1 "^service:file$"
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
|
|
|
assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
|
|
|
assert [ -e file1x.manifest ]
|
|
|
|
assert diff file1.manifest file1x.manifest
|
|
|
|
assert [ -e file1x ]
|
|
|
|
assert diff file1 file1x
|
2012-11-07 20:29:12 +10:30
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_ExtractManifestFileFromExtBlob="Export bundle from external blob"
|
2013-02-16 20:25:26 +10:30
|
|
|
setup_ExtractManifestFileFromExtBlob() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-02-18 15:09:03 +10:30
|
|
|
executeOk_servald config set rhizome.external_blobs 1
|
2013-02-16 20:25:26 +10:30
|
|
|
echo "A test file" >file1
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-02-22 13:34:53 +10:30
|
|
|
executeOk_servald config set rhizome.external_blobs 0
|
|
|
|
echo "Another test file" >file2
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file2 file2.manifest
|
2013-02-16 20:25:26 +10:30
|
|
|
executeOk_servald rhizome list
|
2013-02-22 13:34:53 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
|
|
|
extract_manifest_id manifestid1 file1.manifest
|
|
|
|
extract_manifest_version version1 file1.manifest
|
|
|
|
extract_manifest_filehash filehash1 file1.manifest
|
|
|
|
extract_manifest_id manifestid2 file2.manifest
|
|
|
|
extract_manifest_version version2 file2.manifest
|
|
|
|
extract_manifest_filehash filehash2 file2.manifest
|
2013-02-16 20:25:26 +10:30
|
|
|
}
|
|
|
|
test_ExtractManifestFileFromExtBlob() {
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export bundle $manifestid1 file1x.manifest file1x
|
2013-02-16 20:25:26 +10:30
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assertStdoutLineCount '==' 8
|
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --matches=1 "^service:file$"
|
2013-02-22 13:34:53 +10:30
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version1\$"
|
2013-02-16 20:25:26 +10:30
|
|
|
assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$"
|
2013-02-22 13:34:53 +10:30
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash1\$"
|
2013-02-16 20:25:26 +10:30
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
|
|
|
assert [ -e file1x.manifest ]
|
|
|
|
assert diff file1.manifest file1x.manifest
|
|
|
|
assert [ -e file1x ]
|
|
|
|
assert diff file1 file1x
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export bundle $manifestid2 file2x.manifest file2x
|
2013-02-22 13:34:53 +10:30
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assertStdoutLineCount '==' 8
|
|
|
|
local size=$(( $(cat file2 | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --matches=1 "^service:file$"
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid2\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version2\$"
|
|
|
|
assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash2\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
|
|
|
assert [ -e file2x.manifest ]
|
|
|
|
assert diff file2.manifest file2x.manifest
|
|
|
|
assert [ -e file2x ]
|
|
|
|
assert diff file2 file2x
|
2013-02-16 20:25:26 +10:30
|
|
|
}
|
|
|
|
|
2013-08-21 15:45:18 +09:30
|
|
|
doc_CorruptExternalBlob="A corrupted payload should fail to export"
|
|
|
|
setup_CorruptExternalBlob() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
executeOk_servald config set rhizome.external_blobs 1
|
|
|
|
echo "A test file" >file1
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
|
|
|
extract_manifest_id manifestid file1.manifest
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
|
|
|
echo "Replacement" >$SERVALINSTANCE_PATH/$filehash
|
|
|
|
}
|
|
|
|
test_CorruptExternalBlob() {
|
|
|
|
execute --exit-status=255 $servald rhizome extract file $manifestid file1a
|
|
|
|
tfw_cat --stderr
|
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_ExtractManifestToStdout="Export manifest to output field"
|
2012-11-07 20:29:12 +10:30
|
|
|
setup_ExtractManifestToStdout() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "A test file" >file1
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-11-07 20:29:12 +10:30
|
|
|
extract_manifest_id manifestid file1.manifest
|
|
|
|
extract_manifest_version version file1.manifest
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
|
|
|
}
|
|
|
|
test_ExtractManifestToStdout() {
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export manifest $manifestid -
|
2012-11-07 20:29:12 +10:30
|
|
|
assertStdoutLineCount '>=' 9
|
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --line=..8 --matches=1 "^service:file$"
|
|
|
|
assertStdoutGrep --line=..8 --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --line=..8 --matches=1 "^version:$version\$"
|
|
|
|
assertStdoutGrep --line=..8 --matches=1 "^inserttime:$rexp_date\$"
|
|
|
|
assertStdoutGrep --line=..8 --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --line=..8 --matches=1 "^filesize:$size\$"
|
|
|
|
assertStdoutGrep --line=..8 --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --line=..8 --matches=1 "^\.readonly:0\$"
|
|
|
|
assertStdoutGrep --line=9 --matches=1 "^manifest:"
|
|
|
|
replayStdout | $SED -n '9s/^manifest://p' >file1x.manifest
|
|
|
|
replayStdout | $SED -n '10,$p' >>file1x.manifest
|
|
|
|
cat file1.manifest >file1n.manifest
|
|
|
|
echo >>file1n.manifest
|
|
|
|
tfw_cat file1n.manifest file1x.manifest
|
2013-01-11 11:55:17 +10:30
|
|
|
assert diff file1n.manifest file1x.manifest
|
2012-10-15 16:41:38 +10:30
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_ExtractManifestAfterAddNoAuthor="Export manifest after one add with no author"
|
2012-10-15 16:41:38 +10:30
|
|
|
setup_ExtractManifestAfterAddNoAuthor() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "A test file" >file1
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=0 file1
|
2012-10-15 16:41:38 +10:30
|
|
|
extract_manifest_id manifestid file1.manifest
|
|
|
|
extract_manifest_version version file1.manifest
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
|
|
|
}
|
|
|
|
test_ExtractManifestAfterAddNoAuthor() {
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export manifest $manifestid file1x.manifest
|
2013-01-11 11:55:17 +10:30
|
|
|
assert diff file1.manifest file1x.manifest
|
2012-10-15 16:41:38 +10:30
|
|
|
assertStdoutLineCount '==' 7
|
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --matches=1 "^service:file$"
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
|
|
|
assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$"
|
2012-10-09 17:43:34 +10:30
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
2012-10-15 16:41:38 +10:30
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:1\$"
|
2012-05-02 16:03:09 +09:30
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_ExtractManifestNonExistent="Export non-existent manifest"
|
2012-10-15 16:41:38 +10:30
|
|
|
setup_ExtractManifestNonExistent() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 16:24:27 +09:30
|
|
|
manifestid=0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
|
|
|
|
}
|
2012-10-15 16:41:38 +10:30
|
|
|
test_ExtractManifestNonExistent() {
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=1 $servald rhizome export manifest $manifestid foo.manifest
|
2012-05-02 16:24:27 +09:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_ExtractManifestInvalidID="Export manifest using invalid ID"
|
2012-05-02 16:24:27 +09:30
|
|
|
setup_ExtractManifestInvalidID() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 16:24:27 +09:30
|
|
|
}
|
|
|
|
test_ExtractManifestInvalidID() {
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=255 $servald rhizome export manifest 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEx foo.manifest
|
2012-05-02 16:24:27 +09:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=255 $servald rhizome export manifest 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDE foo.manifest
|
2012-05-02 16:24:27 +09:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=255 $servald rhizome export manifest foo.manifest
|
2012-05-02 16:24:27 +09:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
|
|
|
}
|
|
|
|
|
2012-10-15 16:41:38 +10:30
|
|
|
doc_ExtractFileAfterAdd="Extract file after one add"
|
|
|
|
setup_ExtractFileAfterAdd() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 17:57:35 +09:30
|
|
|
echo "A test file" >file1
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-05-25 19:42:45 +09:30
|
|
|
tfw_cat --stderr
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1
|
2013-01-11 11:55:17 +10:30
|
|
|
extract_manifest_id manifestid file1.manifest
|
|
|
|
extract_manifest_version version file1.manifest
|
2013-01-04 11:02:24 +10:30
|
|
|
extract_manifest_filehash filehash file1.manifest
|
2012-05-02 17:57:35 +09:30
|
|
|
}
|
2012-10-15 16:41:38 +10:30
|
|
|
test_ExtractFileAfterAdd() {
|
2013-01-11 11:55:17 +10:30
|
|
|
executeOk_servald rhizome extract file $manifestid file1x
|
2013-01-02 12:53:00 +10:30
|
|
|
tfw_cat --stderr
|
2013-01-11 11:55:17 +10:30
|
|
|
assert diff file1 file1x
|
2012-05-02 17:57:35 +09:30
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
2013-01-11 11:55:17 +10:30
|
|
|
assertStdoutLineCount '==' 8
|
|
|
|
assertStdoutGrep --matches=1 "^service:file$"
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
|
|
|
assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
2012-05-02 17:57:35 +09:30
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_ExtractFileMissing="Extract and export non-existent file"
|
2012-10-15 16:41:38 +10:30
|
|
|
setup_ExtractFileMissing() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-02 12:53:00 +10:30
|
|
|
BID=0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
|
2012-05-02 17:57:35 +09:30
|
|
|
filehash=0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
|
|
|
|
}
|
2012-10-15 16:41:38 +10:30
|
|
|
test_ExtractFileMissing() {
|
2013-01-02 12:53:00 +10:30
|
|
|
execute --exit-status=1 $servald rhizome extract file $BID foo
|
|
|
|
tfw_cat --stderr
|
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=1 $servald rhizome export file $filehash foo
|
2013-01-02 12:53:00 +10:30
|
|
|
tfw_cat --stderr
|
2012-05-02 17:57:35 +09:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_ExtractFileInvalidID="Extract and export file using invalid ID"
|
2012-05-02 17:57:35 +09:30
|
|
|
setup_ExtractFileInvalidID() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 17:57:35 +09:30
|
|
|
}
|
|
|
|
test_ExtractFileInvalidID() {
|
2013-01-02 12:53:00 +10:30
|
|
|
execute --exit-status=255 $servald rhizome extract file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEx foo
|
2012-05-02 17:57:35 +09:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-01-02 12:53:00 +10:30
|
|
|
execute --exit-status=255 $servald rhizome extract file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDE foo
|
2012-05-02 17:57:35 +09:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-13 16:49:52 +10:30
|
|
|
execute --exit-status=255 $servald rhizome extract file foo
|
2012-05-02 17:57:35 +09:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=255 $servald rhizome export file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEx foo
|
2013-01-02 12:53:00 +10:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=255 $servald rhizome export file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDE foo
|
2013-01-02 12:53:00 +10:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=255 $servald rhizome export file foo
|
2013-01-02 12:53:00 +10:30
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2012-05-02 17:57:35 +09:30
|
|
|
}
|
|
|
|
|
2012-04-16 11:46:58 +09:30
|
|
|
doc_AddDuplicate="Add same manifest detects duplicate"
|
2012-04-10 18:01:53 +09:30
|
|
|
setup_AddDuplicate() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-04-13 17:47:20 +09:30
|
|
|
assert_rhizome_list
|
2012-04-10 18:01:53 +09:30
|
|
|
echo "A test file" >file1
|
|
|
|
echo "Another test file" >file2
|
2012-04-13 17:47:20 +09:30
|
|
|
echo "A test file, second version" >file1_2
|
2012-04-10 18:01:53 +09:30
|
|
|
# Add first file
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-06-05 13:58:59 +09:30
|
|
|
extract_stdout_secret file1_secret
|
2012-04-10 18:01:53 +09:30
|
|
|
# Add second file
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file2 file2.manifest
|
2012-06-05 13:58:59 +09:30
|
|
|
extract_stdout_secret file2_secret
|
2012-04-10 18:01:53 +09:30
|
|
|
# Make sure they are both in the list.
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-10 18:01:53 +09:30
|
|
|
}
|
|
|
|
test_AddDuplicate() {
|
2012-04-13 17:47:20 +09:30
|
|
|
# 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).
|
2013-02-13 16:49:52 +10:30
|
|
|
execute --exit-status=2 $servald rhizome add file $SIDB1 file1 file1.manifestA
|
2012-04-13 17:47:20 +09:30
|
|
|
assert [ -s file1.manifestA ]
|
2012-05-04 15:59:58 +09:30
|
|
|
assert_stdout_add_file file1
|
2012-12-17 16:09:22 +10:30
|
|
|
extract_stdout_secret file1_dup_secret
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-13 17:47:20 +09:30
|
|
|
strip_signatures file1.manifest file1.manifestA
|
|
|
|
assert diff file1.manifest file1.manifestA
|
|
|
|
# Repeat for second file.
|
2013-02-13 16:49:52 +10:30
|
|
|
execute --exit-status=2 $servald rhizome add file $SIDB1 file2 file2.manifestA
|
2012-04-13 17:47:20 +09:30
|
|
|
assert [ -s file2.manifestA ]
|
2012-05-04 15:59:58 +09:30
|
|
|
assert_stdout_add_file file2
|
2012-12-17 16:09:22 +10:30
|
|
|
extract_stdout_secret file2_dup_secret
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-13 17:47:20 +09:30
|
|
|
strip_signatures file2.manifest file2.manifestA
|
|
|
|
assert diff file2.manifest file2.manifestA
|
2012-12-20 15:18:59 +10:30
|
|
|
assert [ $file1_secret = $file1_dup_secret ]
|
|
|
|
assert [ $file2_secret = $file2_dup_secret ]
|
2012-04-13 17:47:20 +09:30
|
|
|
}
|
|
|
|
|
2012-04-13 17:59:40 +09:30
|
|
|
doc_AddMismatched="Add mismatched manifest/payload fails"
|
2012-04-13 17:47:20 +09:30
|
|
|
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
|
2013-02-13 16:49:52 +10:30
|
|
|
execute $servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
2012-04-13 17:47:20 +09:30
|
|
|
assertExitStatus '!=' 0
|
2013-01-11 11:55:17 +10:30
|
|
|
assert diff file1.manifest file1_2.manifest
|
2012-04-13 17:47:20 +09:30
|
|
|
# And rhizome store should be unchanged.
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-13 17:47:20 +09:30
|
|
|
}
|
|
|
|
|
2012-05-21 13:18:12 +09:30
|
|
|
doc_AddUpdateSameVersion="Add new payload to existing manifest with same version fails"
|
2012-04-16 11:46:58 +09:30
|
|
|
setup_AddUpdateSameVersion() {
|
2012-04-13 17:47:20 +09:30
|
|
|
setup_AddDuplicate
|
|
|
|
cp file1.manifest file1_2.manifest
|
|
|
|
strip_signatures file1_2.manifest
|
2012-09-13 14:08:52 +09:30
|
|
|
$SED -i -e '/^date=/d;/^filehash=/d;/^filesize=/d' file1_2.manifest
|
2012-04-17 16:54:39 +09:30
|
|
|
tfw_cat -v file1_2.manifest
|
2012-04-13 17:59:40 +09:30
|
|
|
assertGrep --matches=0 file1_2.manifest '^filehash='
|
2012-04-16 11:46:58 +09:30
|
|
|
extract_manifest_version '' file1_2.manifest # asserts has version= line
|
|
|
|
assertGrep file1_2.manifest '^id='
|
2012-04-13 17:59:40 +09:30
|
|
|
cp file1_2.manifest file1_2.manifest.orig
|
|
|
|
}
|
2012-04-16 11:46:58 +09:30
|
|
|
test_AddUpdateSameVersion() {
|
|
|
|
tfw_cat -v file1_2.manifest
|
2013-02-13 16:49:52 +10:30
|
|
|
execute $servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
2012-04-16 11:46:58 +09:30
|
|
|
assertExitStatus --stderr '!=' 0
|
|
|
|
tfw_cat -v file1_2.manifest
|
2012-04-13 17:59:40 +09:30
|
|
|
assert cmp file1_2.manifest file1_2.manifest.orig
|
|
|
|
# And rhizome store should be unchanged.
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-13 17:59:40 +09:30
|
|
|
}
|
|
|
|
|
2012-04-16 11:46:58 +09:30
|
|
|
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 17:59:40 +09:30
|
|
|
let version=version+1
|
2012-09-13 14:08:52 +09:30
|
|
|
$SED -i -e "/^version=/s/=.*/=$version/" file1_2.manifest
|
2012-04-13 17:59:40 +09:30
|
|
|
assertGrep --matches=1 file1_2.manifest "^version=$version$"
|
|
|
|
}
|
2012-04-16 11:46:58 +09:30
|
|
|
test_AddUpdateNewVersion() {
|
2012-04-17 16:54:39 +09:30
|
|
|
tfw_cat -v file1_2.manifest
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
2012-10-09 17:43:34 +10:30
|
|
|
tfw_cat --stderr
|
2012-06-12 11:48:15 +09:30
|
|
|
assert_stdout_add_file file1_2 name=file1
|
2012-04-16 11:46:58 +09:30
|
|
|
assert_manifest_newer file1.manifest file1_2.manifest
|
|
|
|
# Rhizome store contents reflect new payload.
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1_2 file2
|
2012-06-05 13:58:59 +09:30
|
|
|
}
|
|
|
|
|
2012-10-11 17:58:24 +10:30
|
|
|
doc_AddUpdateDiscoverAuthor="Add new payload to manifest with author discovery"
|
|
|
|
setup_AddUpdateDiscoverAuthor() {
|
|
|
|
setup_AddUpdateNewVersion
|
|
|
|
}
|
|
|
|
test_AddUpdateDiscoverAuthor() {
|
|
|
|
tfw_cat -v file1_2.manifest
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file1_2 file1_2.manifest
|
2012-10-11 17:58:24 +10:30
|
|
|
tfw_cat --stderr
|
|
|
|
# Rhizome store contents have new payload.
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1_2 file2
|
2012-10-11 17:58:24 +10:30
|
|
|
}
|
|
|
|
|
2012-06-05 13:58:59 +09:30
|
|
|
doc_AddUpdateNoAuthor="Cannot add new payload to authorless manifest"
|
|
|
|
setup_AddUpdateNoAuthor() {
|
|
|
|
setup_AddUpdateNewVersion
|
2012-09-13 14:08:52 +09:30
|
|
|
$SED -i -e '/^BK=/d' file1_2.manifest
|
2012-06-05 13:58:59 +09:30
|
|
|
}
|
|
|
|
test_AddUpdateNoAuthor() {
|
|
|
|
tfw_cat -v file1_2.manifest
|
2013-02-13 16:49:52 +10:30
|
|
|
execute $servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
2012-06-05 13:58:59 +09:30
|
|
|
tfw_cat --stderr
|
|
|
|
assertExitStatus '!=' 0
|
|
|
|
# Rhizome store contents have old payload.
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-06-05 13:58:59 +09:30
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddUpdateNoAuthorWithSecret="Add new payload to authorless manifest with bundle secret"
|
|
|
|
setup_AddUpdateNoAuthorWithSecret() {
|
|
|
|
setup_AddUpdateNoAuthor
|
|
|
|
}
|
|
|
|
test_AddUpdateNoAuthorWithSecret() {
|
|
|
|
tfw_cat -v file1_2.manifest
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1_2 file1_2.manifest "$file1_secret"
|
2012-06-05 13:58:59 +09:30
|
|
|
tfw_cat --stderr
|
|
|
|
# Rhizome store contents have new payload.
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1_2 file2
|
2012-04-16 11:46:58 +09:30
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddUpdateAutoVersion="Add new payload to existing manifest with automatic version"
|
|
|
|
setup_AddUpdateAutoVersion() {
|
|
|
|
setup_AddUpdateSameVersion
|
2012-09-13 14:08:52 +09:30
|
|
|
$SED -i -e '/^version=/d' file1_2.manifest
|
2012-04-16 11:46:58 +09:30
|
|
|
assertGrep --matches=0 file1_2.manifest '^version='
|
|
|
|
}
|
|
|
|
test_AddUpdateAutoVersion() {
|
2012-04-17 16:54:39 +09:30
|
|
|
tfw_cat -v file1_2.manifest
|
2012-04-16 11:46:58 +09:30
|
|
|
sleep 0.001 # Ensure that at least one millisecond has elapsed
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
2012-04-16 11:46:58 +09:30
|
|
|
assert_manifest_newer file1.manifest file1_2.manifest
|
2012-04-13 17:47:20 +09:30
|
|
|
# Rhizome store contents reflect new payload.
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1_2 file2
|
2012-05-21 13:18:12 +09:30
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddUnsupportedService="Add with unsupported service fails"
|
|
|
|
setup_AddUnsupportedService() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 13:18:12 +09:30
|
|
|
echo "Message1" >file1
|
|
|
|
echo -e 'service=Fubar' >file1.manifest
|
|
|
|
}
|
|
|
|
test_AddUnsupportedService() {
|
2013-02-13 16:49:52 +10:30
|
|
|
execute $servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-05-21 13:18:12 +09:30
|
|
|
assertExitStatus '!=' 0
|
|
|
|
}
|
|
|
|
|
2013-02-27 11:39:23 +10:30
|
|
|
doc_EncryptedPayload="Add and extract an encrypted payload"
|
2013-01-03 16:12:24 +10:30
|
|
|
setup_EncryptedPayload() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "Clear Text" >file1
|
|
|
|
echo -e "service=file\nname=private\ncrypt=1" >file1.manifest
|
|
|
|
}
|
|
|
|
test_EncryptedPayload() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-01-03 16:12:24 +10:30
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2013-01-03 16:12:24 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1
|
|
|
|
extract_manifest_id BID file1.manifest
|
|
|
|
executeOk_servald rhizome extract file $BID file1x
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert diff file1 file1x
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export file $filehash file1y
|
2013-01-03 16:12:24 +10:30
|
|
|
assert ! diff file1 file1y
|
|
|
|
}
|
|
|
|
|
2013-07-19 10:28:15 +09:30
|
|
|
doc_RecipientIsEncrypted="Sender & recipient triggers encryption by default"
|
|
|
|
setup_RecipientIsEncrypted() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "Clear Text" >file1
|
|
|
|
echo -e "service=file\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
|
|
|
}
|
|
|
|
test_RecipientIsEncrypted() {
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list --fromhere=1 file1
|
|
|
|
extract_manifest_id BID file1.manifest
|
|
|
|
executeOk_servald rhizome extract file $BID file1x
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert diff file1 file1x
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
|
|
|
executeOk_servald rhizome export file $filehash file1y
|
|
|
|
assert ! diff file1 file1y
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_BroadcastNotEncrypted="Broadcast recipients are not encrypted by default"
|
|
|
|
setup_BroadcastNotEncrypted() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "Clear Text" >file1
|
|
|
|
echo -e "service=file\nsender=$SIDB1\nrecipient=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" >file1.manifest
|
|
|
|
}
|
|
|
|
test_BroadcastNotEncrypted() {
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list --fromhere=1 file1
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
|
|
|
executeOk_servald rhizome export file $filehash file1y
|
|
|
|
assert diff file1 file1y
|
|
|
|
}
|
|
|
|
|
2013-07-05 16:24:50 +09:30
|
|
|
doc_JournalAdd="Create and append to a journal"
|
|
|
|
setup_JournalAdd() {
|
2013-07-08 14:57:47 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "Part One" > file1
|
|
|
|
echo "Part Two" > file2
|
|
|
|
cat file1 file2 > file
|
2013-07-05 16:24:50 +09:30
|
|
|
}
|
|
|
|
test_JournalAdd() {
|
|
|
|
executeOk_servald rhizome journal append $SIDB1 "" file1
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1
|
|
|
|
extract_stdout_keyvalue BID 'manifestid' '[0-9A-F]\+'
|
|
|
|
executeOk_servald rhizome journal append $SIDB1 $BID file2
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
executeOk_servald rhizome extract file $BID filex
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert diff file filex
|
|
|
|
}
|
|
|
|
|
2013-07-08 14:57:47 +09:30
|
|
|
doc_AppendFile="Attempting to append to a non-journal fails"
|
|
|
|
setup_AppendFile() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "Part One" > file1
|
|
|
|
echo "Part Two" > file2
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1
|
|
|
|
extract_stdout_keyvalue BID 'manifestid' '[0-9A-F]\+'
|
|
|
|
}
|
|
|
|
test_AppendFile() {
|
|
|
|
execute --exit-status=255 $servald rhizome journal append $SIDB1 $BID file2
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
}
|
|
|
|
|
2012-06-12 11:48:15 +09:30
|
|
|
doc_MeshMSAddCreate="First add MeshMS creates manifest"
|
|
|
|
setup_MeshMSAddCreate() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 13:18:12 +09:30
|
|
|
echo "Message1" >file1
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 13:18:12 +09:30
|
|
|
}
|
2012-06-12 11:48:15 +09:30
|
|
|
test_MeshMSAddCreate() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-06-12 11:48:15 +09:30
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2013-01-03 16:12:24 +10:30
|
|
|
extract_manifest_crypt crypt file1.manifest
|
|
|
|
assert [ $crypt = 1 ]
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2013-01-02 12:53:00 +10:30
|
|
|
extract_manifest_id BID file1.manifest
|
|
|
|
executeOk_servald rhizome extract file $BID file1x
|
2012-05-21 13:18:12 +09:30
|
|
|
assert diff file1 file1x
|
|
|
|
}
|
|
|
|
|
2012-06-12 11:48:15 +09:30
|
|
|
doc_MeshMSAddGrow="Subsequent add MeshMS updates manifest and removes old payload"
|
|
|
|
setup_MeshMSAddGrow() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 13:18:12 +09:30
|
|
|
echo "Message1" >file1
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 13:18:12 +09:30
|
|
|
}
|
2012-06-12 11:48:15 +09:30
|
|
|
test_MeshMSAddGrow() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-06-12 11:48:15 +09:30
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2012-05-25 14:29:55 +09:30
|
|
|
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")
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "id=$id\nBK=$bk\nservice=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-25 14:29:55 +09:30
|
|
|
echo "Message$m" >>file1
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2012-05-25 14:29:55 +09:30
|
|
|
extract_manifest_id idx file1.manifest
|
|
|
|
extract_manifest_filehash filehashx file1.manifest
|
|
|
|
extract_manifest_BK bkx file1.manifest
|
|
|
|
assert --message="manifest ID remains the same" [ "$idx" = "$id" ]
|
|
|
|
assert --message="manifest BK remains the same" [ "$bkx" = "$bk" ]
|
2013-01-02 12:53:00 +10:30
|
|
|
assert --message="filehash is for new file" [ "$filehash" != "$filehashx" ]
|
|
|
|
executeOk_servald rhizome extract file "$id" file1x
|
2012-05-25 14:29:55 +09:30
|
|
|
assert --message="extracted payload is correct" diff file1 file1x
|
|
|
|
for ofilehash in "${ofilehashes[@]}"; do
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=1 --stderr $servald rhizome export file "$ofilehash"
|
2012-05-25 14:29:55 +09:30
|
|
|
done
|
|
|
|
done
|
2012-05-21 13:18:12 +09:30
|
|
|
}
|
|
|
|
|
2012-06-12 11:48:15 +09:30
|
|
|
doc_MeshMSAddMissingSender="Add MeshMS without sender fails"
|
|
|
|
setup_MeshMSAddMissingSender() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 13:18:12 +09:30
|
|
|
echo "Message1" >file1
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "service=MeshMS1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 13:18:12 +09:30
|
|
|
}
|
2012-06-12 11:48:15 +09:30
|
|
|
test_MeshMSAddMissingSender() {
|
2013-02-13 16:49:52 +10:30
|
|
|
execute $servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-05-21 13:18:12 +09:30
|
|
|
assertExitStatus '!=' 0
|
|
|
|
}
|
|
|
|
|
2012-06-12 11:48:15 +09:30
|
|
|
doc_MeshMSAddMissingRecipient="Add MeshMS without recipient fails"
|
|
|
|
setup_MeshMSAddMissingRecipient() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-05-21 13:18:12 +09:30
|
|
|
assert_rhizome_list
|
|
|
|
echo "Message1" >file1
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1" >file1.manifest
|
2012-05-21 13:18:12 +09:30
|
|
|
}
|
2012-06-12 11:48:15 +09:30
|
|
|
test_MeshMSAddMissingRecipient() {
|
2013-02-13 16:49:52 +10:30
|
|
|
execute $servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-05-21 13:18:12 +09:30
|
|
|
assertExitStatus '!=' 0
|
|
|
|
}
|
|
|
|
|
2012-06-12 11:48:15 +09:30
|
|
|
doc_MeshMSAddMissingAuthor="Add MeshMS without author uses sender"
|
|
|
|
setup_MeshMSAddMissingAuthor() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 13:18:12 +09:30
|
|
|
echo "Message1" >file1
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 13:18:12 +09:30
|
|
|
}
|
2012-06-12 11:48:15 +09:30
|
|
|
test_MeshMSAddMissingAuthor() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2012-06-08 18:25:43 +09:30
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2012-05-21 14:41:22 +09:30
|
|
|
}
|
|
|
|
|
2013-01-17 11:43:31 +10:30
|
|
|
doc_ListFilter="List manifests by filter"
|
|
|
|
setup_ListFilter() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "File1" > file1
|
|
|
|
echo "File2" > file2
|
|
|
|
echo "File3" > file3
|
|
|
|
echo "File4" > file4
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
assert_stdout_add_file file1
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file2 file2.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
assert_stdout_add_file file2
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file3 file3.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
assert_stdout_add_file file3
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file4 file4.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
assert_stdout_add_file file4
|
|
|
|
}
|
|
|
|
test_ListFilter() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list file
|
2013-01-17 11:43:31 +10:30
|
|
|
assert_rhizome_list file1 file2 file3 file4
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list file 'file%'
|
2013-01-17 11:43:31 +10:30
|
|
|
assert_rhizome_list file1 file2 file3 file4
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' 'file2'
|
2013-01-17 11:43:31 +10:30
|
|
|
assert_rhizome_list file2
|
|
|
|
}
|
|
|
|
|
2012-06-12 11:48:15 +09:30
|
|
|
doc_MeshMSListFilter="List MeshMS manifests by filter"
|
|
|
|
setup_MeshMSListFilter() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 14:41:22 +09:30
|
|
|
echo "Message1" >file1
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 14:41:22 +09:30
|
|
|
echo "Message2" >file2
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB3" >file2.manifest
|
2012-05-21 14:41:22 +09:30
|
|
|
echo "Message3" >file3
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB4" >file3.manifest
|
2012-05-21 14:41:22 +09:30
|
|
|
echo "Message3" >file4
|
2012-07-06 13:32:21 +09:30
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB2\nrecipient=$SIDB3" >file4.manifest
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2012-06-12 11:48:15 +09:30
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file2 file2.manifest
|
2012-06-12 11:48:15 +09:30
|
|
|
assert_stdout_add_file file2
|
|
|
|
assert_manifest_complete file2.manifest
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file3 file3.manifest
|
2012-06-12 11:48:15 +09:30
|
|
|
assert_stdout_add_file file3
|
|
|
|
assert_manifest_complete file3.manifest
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file '' file4 file4.manifest
|
2012-06-12 11:48:15 +09:30
|
|
|
assert_stdout_add_file file4
|
|
|
|
assert_manifest_complete file4.manifest
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1 file2 file3 file4
|
2012-05-21 14:41:22 +09:30
|
|
|
}
|
2012-06-12 11:48:15 +09:30
|
|
|
test_MeshMSListFilter() {
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list file
|
2012-05-21 14:41:22 +09:30
|
|
|
assert_rhizome_list
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list MeshMS1
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1 file2 file3 file4
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' $SIDB1
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1 file2 file3
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' $SIDB2
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file4
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' $SIDB3
|
2012-05-21 14:41:22 +09:30
|
|
|
assert_rhizome_list
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' $SIDB4
|
2012-05-21 14:41:22 +09:30
|
|
|
assert_rhizome_list
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' '' $SIDB1
|
2012-05-21 14:41:22 +09:30
|
|
|
assert_rhizome_list
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' '' $SIDB2
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' '' $SIDB3
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file2 file4
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list file '' '' $SIDB3
|
2012-05-21 14:41:22 +09:30
|
|
|
assert_rhizome_list
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' '' $SIDB4
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file3
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' $SIDB1 $SIDB4
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file3
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' $SIDB2 $SIDB4
|
2012-05-21 14:41:22 +09:30
|
|
|
assert_rhizome_list
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome list '' '' $SIDB2 $SIDB3
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 file4
|
2012-04-10 18:01:53 +09:30
|
|
|
}
|
|
|
|
|
2012-06-08 18:25:43 +09:30
|
|
|
doc_ImportForeignBundle="Can import a bundle created by another instance"
|
|
|
|
setup_ImportForeignBundle() {
|
2012-07-06 13:32:21 +09:30
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-06-22 15:56:28 +09:30
|
|
|
set_instance +A
|
2012-06-08 18:25:43 +09:30
|
|
|
echo "Hello from A" >fileA
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDA1 fileA fileA.manifest
|
2012-06-08 18:25:43 +09:30
|
|
|
assert_stdout_add_file fileA
|
2012-06-22 15:56:28 +09:30
|
|
|
set_instance +B
|
2012-06-08 18:25:43 +09:30
|
|
|
}
|
|
|
|
test_ImportForeignBundle() {
|
|
|
|
executeOk_servald rhizome import bundle fileA fileA.manifest
|
|
|
|
assert_stdout_import_bundle fileA
|
2013-01-15 10:32:48 +10:30
|
|
|
execute --exit-status=2 --stdout --stderr $servald rhizome import bundle fileA fileA.manifest
|
|
|
|
assert_stdout_import_bundle fileA
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=0 fileA
|
2012-06-08 18:25:43 +09:30
|
|
|
}
|
|
|
|
|
2012-10-15 16:41:38 +10:30
|
|
|
doc_ImportOwnBundle="Can import a bundle created by same instance"
|
|
|
|
setup_ImportOwnBundle() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "Hello from B" >fileB
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDB2 fileB fileB.manifest
|
2012-10-15 16:41:38 +10:30
|
|
|
assert_stdout_add_file fileB
|
|
|
|
extract_manifest_id manifestid fileB.manifest
|
|
|
|
extract_manifest_version version fileB.manifest
|
|
|
|
extract_manifest_filehash filehash fileB.manifest
|
|
|
|
rm -f $SERVALINSTANCE_PATH/rhizome.db
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-15 16:41:38 +10:30
|
|
|
assert_rhizome_list
|
|
|
|
}
|
|
|
|
test_ImportOwnBundle() {
|
|
|
|
executeOk_servald rhizome import bundle fileB fileB.manifest
|
|
|
|
assert_stdout_import_bundle fileB
|
|
|
|
# Bundle author and sender are unknown, so appears not to be from here
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=0 fileB
|
2012-10-15 16:41:38 +10:30
|
|
|
# Extracting the manifest discovers that it is ours.
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome extract bundle $manifestid fileBx.manifest fileBx
|
2012-10-15 16:41:38 +10:30
|
|
|
tfw_cat --stderr
|
|
|
|
assert cmp fileB.manifest fileBx.manifest
|
2013-02-27 11:39:23 +10:30
|
|
|
assert cmp fileB fileBx
|
2012-10-15 16:41:38 +10:30
|
|
|
assertStdoutLineCount '==' 8
|
|
|
|
local size=$(( $(cat fileB | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --matches=1 "^service:file$"
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
|
|
|
assertStdoutGrep --matches=1 "^inserttime:$rexp_date\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB2\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
2013-02-27 11:39:23 +10:30
|
|
|
# Now bundle author should be known, so appears to be from here
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2012-10-17 18:10:39 +10:30
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB2 fileB
|
2012-10-15 16:41:38 +10:30
|
|
|
}
|
|
|
|
|
2013-02-20 14:44:29 +10:30
|
|
|
doc_ImportCombinedBundle="Create and import combined bundle"
|
2013-01-11 14:19:26 +10:30
|
|
|
setup_ImportCombinedBundle() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
set_instance +A
|
|
|
|
echo "Hello from A" >fileA
|
2013-02-13 16:49:52 +10:30
|
|
|
executeOk_servald rhizome add file $SIDA1 fileA fileA.manifest
|
2013-01-11 14:19:26 +10:30
|
|
|
assert_stdout_add_file fileA
|
|
|
|
extract_manifest_id manifestid fileA.manifest
|
|
|
|
extract_manifest_filehash filehash fileA.manifest
|
|
|
|
extract_manifest_filesize filesize fileA.manifest
|
|
|
|
}
|
|
|
|
test_ImportCombinedBundle() {
|
|
|
|
executeOk_servald rhizome append manifest fileA fileA.manifest
|
|
|
|
set_instance +B
|
|
|
|
executeOk_servald rhizome import bundle fileA fileA
|
|
|
|
assertStdoutGrep --matches=1 "^service:file$"
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$filesize\$"
|
2013-01-17 11:43:31 +10:30
|
|
|
executeOk_servald rhizome list
|
2013-01-11 14:19:26 +10:30
|
|
|
assert_rhizome_list --fromhere=0 fileA
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export bundle $manifestid fileAx fileAx
|
2013-01-11 14:19:26 +10:30
|
|
|
assert diff fileA fileAx
|
|
|
|
}
|
|
|
|
|
2013-02-20 14:44:29 +10:30
|
|
|
setup_delete() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
set_instance +A
|
|
|
|
executeOk_servald config set rhizome.clean_on_open off
|
|
|
|
rhizome_add_files file{1..4}
|
|
|
|
for i in {1..4}; do
|
|
|
|
extract_manifest_id BID$i file$i.manifest
|
|
|
|
extract_manifest_filehash HASH$i file$i.manifest
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_DeleteManifest="Delete a manifest from store"
|
|
|
|
setup_DeleteManifest() {
|
|
|
|
setup_delete
|
|
|
|
}
|
|
|
|
test_DeleteManifest() {
|
|
|
|
executeOk_servald rhizome delete manifest "$BID2"
|
|
|
|
tfw_cat --stderr
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list file{1,3,4}
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=1 --stderr $servald rhizome export manifest "$BID2"
|
|
|
|
executeOk_servald rhizome export file "$HASH2" file2x
|
2013-02-20 14:44:29 +10:30
|
|
|
assert diff file2 file2x
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_DeletePayload="Delete a payload from store"
|
|
|
|
setup_DeletePayload() {
|
|
|
|
setup_delete
|
|
|
|
}
|
|
|
|
test_DeletePayload() {
|
|
|
|
executeOk_servald rhizome delete payload "$BID3"
|
|
|
|
tfw_cat --stderr
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list file{1..4}
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export manifest "$BID3"
|
|
|
|
execute --exit-status=1 --stderr $servald rhizome export file "$HASH3" file3x
|
2013-02-20 14:44:29 +10:30
|
|
|
}
|
|
|
|
|
|
|
|
doc_DeleteBundle="Delete a bundle from store"
|
|
|
|
setup_DeleteBundle() {
|
|
|
|
setup_delete
|
|
|
|
}
|
|
|
|
test_DeleteBundle() {
|
|
|
|
executeOk_servald rhizome delete bundle "$BID4"
|
|
|
|
tfw_cat --stderr
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list file{1..3}
|
2013-02-27 11:39:23 +10:30
|
|
|
execute --exit-status=1 --stderr $servald rhizome export manifest "$BID4"
|
|
|
|
execute --exit-status=1 --stderr $servald rhizome export file "$HASH4" file4x
|
2013-02-20 14:44:29 +10:30
|
|
|
}
|
|
|
|
|
|
|
|
doc_DeleteFile="Delete a file from store"
|
|
|
|
setup_DeleteFile() {
|
|
|
|
setup_delete
|
|
|
|
}
|
|
|
|
test_DeleteFile() {
|
|
|
|
executeOk_servald rhizome delete file "$HASH1"
|
|
|
|
tfw_cat --stderr
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list file{1..4}
|
2013-02-27 11:39:23 +10:30
|
|
|
executeOk_servald rhizome export manifest "$BID1"
|
|
|
|
execute --exit-status=1 --stderr $servald rhizome export file "$HASH1" file1x
|
2013-02-20 14:44:29 +10:30
|
|
|
}
|
|
|
|
|
2012-04-10 18:01:53 +09:30
|
|
|
runTests "$@"
|