2012-04-10 08:31:53 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-11-19 02:56:50 +00:00
|
|
|
# Tests for Serval rhizome command-line operations.
|
2012-04-10 08:31:53 +00:00
|
|
|
#
|
2014-11-19 02:56:50 +00:00
|
|
|
# Copyright 2012-2014 Serval Project, Inc.
|
2012-04-10 08:31:53 +00:00
|
|
|
#
|
|
|
|
# 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-07-06 04:02:21 +00:00
|
|
|
source "${0%/*}/../testdefs_rhizome.sh"
|
2012-04-10 08:31:53 +00:00
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
shopt -s extglob
|
|
|
|
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_rhizome() {
|
2012-06-22 06:26:28 +00:00
|
|
|
set_instance +A
|
2013-10-14 06:19:06 +00:00
|
|
|
set_rhizome_config
|
2013-02-20 04:14:29 +00:00
|
|
|
create_single_identity
|
2013-10-14 06:19:06 +00:00
|
|
|
echo "$SIDA1" >sids
|
2012-06-22 06:26:28 +00:00
|
|
|
set_instance +B
|
2013-10-14 06:19:06 +00:00
|
|
|
set_rhizome_config
|
|
|
|
create_identities 4
|
|
|
|
echo "$SIDB1" >>sids
|
|
|
|
echo "$SIDB2" >>sids
|
|
|
|
echo "$SIDB3" >>sids
|
|
|
|
echo "$SIDB4" >>sids
|
|
|
|
assert [ $(sort sids | uniq | wc -l) -eq 5 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
set_rhizome_config() {
|
2013-07-05 06:54:50 +00:00
|
|
|
executeOk_servald config \
|
|
|
|
set debug.rhizome on \
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
set debug.rhizome_manifest on \
|
2013-07-05 06:54:50 +00:00
|
|
|
set debug.verbose on \
|
|
|
|
set log.console.level debug
|
2012-05-25 04:59:55 +00:00
|
|
|
}
|
|
|
|
|
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-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
test_InitialEmptyList() {
|
2013-01-17 01:13:31 +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-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-05-17 02:30:03 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
2014-03-12 03:52:38 +00:00
|
|
|
echo "Another test file" >file2
|
2012-05-17 02:30:03 +00:00
|
|
|
}
|
|
|
|
test_AddNoAuthorNoManifest() {
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file1
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file1 !.author !BK
|
2014-03-12 03:52:38 +00:00
|
|
|
executeOk_servald rhizome add file '' "$PWD/file2"
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file2 !.author !BK
|
2012-05-17 02:30:03 +00:00
|
|
|
}
|
|
|
|
|
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-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
2014-03-12 03:52:38 +00:00
|
|
|
echo "Another test file" >file2
|
2012-04-13 08:17:20 +00:00
|
|
|
}
|
|
|
|
test_AddNoManifest() {
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1
|
2012-05-04 06:01:03 +00:00
|
|
|
assert_stdout_add_file file1
|
2014-03-12 03:52:38 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 "$PWD/file2"
|
|
|
|
assert_stdout_add_file file2
|
2012-04-13 08:17:20 +00:00
|
|
|
}
|
|
|
|
|
2014-11-17 13:11:03 +00:00
|
|
|
doc_AddManifestFieldUnsupported="Add with unsupported manifest field"
|
|
|
|
setup_AddManifestFieldUnsupported() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
|
|
|
echo "Another test file" >file2
|
|
|
|
echo "bogus=one" >file1.manifest
|
|
|
|
}
|
|
|
|
test_AddManifestFieldUnsupported() {
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
|
|
|
assert_stdout_add_file file1
|
|
|
|
tfw_cat -v file1.manifest
|
|
|
|
assert_manifest_complete file1.manifest
|
|
|
|
assert_manifest_fields file1.manifest bogus=one
|
|
|
|
}
|
|
|
|
|
2014-11-19 02:56:50 +00:00
|
|
|
doc_AddManifestFieldUnsupportedArgs="Add with unsupported manifest field argument"
|
|
|
|
setup_AddManifestFieldUnsupportedArgs() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
|
|
|
echo "Another test file" >file2
|
|
|
|
}
|
|
|
|
test_AddManifestFieldUnsupportedArgs() {
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest '' bogus=two
|
|
|
|
assert_stdout_add_file file1
|
|
|
|
tfw_cat -v file1.manifest
|
|
|
|
assert_manifest_complete file1.manifest
|
|
|
|
assert_manifest_fields file1.manifest bogus=two
|
|
|
|
}
|
|
|
|
|
2012-06-05 04:28:59 +00:00
|
|
|
doc_AddNoAuthor="Add with no author makes manifest without BK"
|
|
|
|
setup_AddNoAuthor() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-06-05 04:28:59 +00:00
|
|
|
echo "A test file" >file1
|
|
|
|
}
|
|
|
|
test_AddNoAuthor() {
|
2013-03-15 05:28:17 +00:00
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2014-03-12 03:52:38 +00:00
|
|
|
assert_manifest_fields file1.manifest !BK
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file1 !.author !BK
|
2012-06-05 04:28:59 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 05:28:17 +00:00
|
|
|
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 00:14:07 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "A test file" >file1
|
|
|
|
echo "crypt=1" >file1.manifest
|
|
|
|
}
|
2013-03-15 05:28:17 +00:00
|
|
|
test_AddNoAuthorEncrypted() {
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2014-11-18 08:12:43 +00:00
|
|
|
tfw_cat --stdout --stderr -v file1.manifest
|
2014-03-12 03:52:38 +00:00
|
|
|
assert_manifest_fields file1.manifest !BK
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file1 !.author !BK
|
2013-01-04 00:14:07 +00:00
|
|
|
extract_stdout_secret file1_secret
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome extract file $re_manifestid file1x $file1_secret
|
2013-01-04 00:14:07 +00:00
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert diff file1 file1x
|
|
|
|
}
|
|
|
|
|
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-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-04-13 08:17:20 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
2014-03-12 03:52:38 +00:00
|
|
|
echo "Another test file" >file2
|
2012-04-13 08:17:20 +00:00
|
|
|
}
|
|
|
|
test_AddNonExistManifest() {
|
|
|
|
assert --error-on-fail [ ! -e file1.manifest ]
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 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
|
2014-03-12 03:52:38 +00:00
|
|
|
assert_manifest_fields file1.manifest service=file name=file1
|
|
|
|
assert --error-on-fail [ ! -e file2.manifest ]
|
|
|
|
executeOk_servald rhizome add file $SIDB1 "$PWD/file2" file2.manifest
|
|
|
|
assert_stdout_add_file file2
|
|
|
|
assert [ -r file2.manifest ]
|
|
|
|
assert_manifest_complete file2.manifest
|
|
|
|
assert_manifest_fields file2.manifest service=file name=file2
|
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-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 01:13:31 +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
|
|
|
}
|
|
|
|
test_AddManifest() {
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 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
|
2014-03-12 03:52:38 +00:00
|
|
|
assert_manifest_fields file1.manifest service=file name=wah date=12345
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
|
2014-11-19 02:56:50 +00:00
|
|
|
doc_AddManifestArgs="Add with minimal manifest from arguments"
|
|
|
|
setup_AddManifestArgs() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list
|
|
|
|
echo "A test file" >file1
|
|
|
|
}
|
|
|
|
test_AddManifestArgs() {
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest '' name=wah date=12345
|
|
|
|
tfw_cat --stdout --stderr -v file1.manifest
|
|
|
|
assert_stdout_add_file file1 name=wah
|
|
|
|
assert_manifest_complete file1.manifest
|
|
|
|
assert_manifest_fields file1.manifest service=file name=wah date=12345
|
|
|
|
}
|
|
|
|
|
2012-06-05 06:15:53 +00:00
|
|
|
doc_AddEmpty="Add with empty payload"
|
|
|
|
setup_AddEmpty() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-06-05 06:15:53 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
}
|
|
|
|
test_AddEmpty() {
|
2013-09-30 07:09:58 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 '' empty.manifest
|
|
|
|
tfw_cat --stdout --stderr -v empty.manifest
|
|
|
|
assert_stdout_add_file --manifest=empty.manifest ''
|
|
|
|
assert_manifest_complete empty.manifest
|
2014-03-12 03:52:38 +00:00
|
|
|
assert_manifest_fields empty.manifest service=file name= filesize=0
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2013-09-30 07:09:58 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 --manifest=empty.manifest ''
|
2012-06-05 06:15:53 +00:00
|
|
|
}
|
|
|
|
|
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-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 01:13:31 +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
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1
|
2012-04-10 08:31:53 +00:00
|
|
|
# Add second file
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file2 file2.manifest
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
|
2013-02-27 01:09:23 +00:00
|
|
|
doc_ExtractManifestAfterAdd="Export manifest after one add"
|
2012-10-15 06:11:38 +00:00
|
|
|
setup_ExtractManifestAfterAdd() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 06:33:09 +00:00
|
|
|
echo "A test file" >file1
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_stdout_rowid rowid
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1
|
2012-05-02 06:33:09 +00:00
|
|
|
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
|
2013-12-13 06:54:59 +00:00
|
|
|
extract_manifest_BK BK file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_manifest_date date file1.manifest
|
2012-05-02 06:33:09 +00:00
|
|
|
}
|
2012-10-15 06:11:38 +00:00
|
|
|
test_ExtractManifestAfterAdd() {
|
2013-02-27 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export manifest $manifestid file1x.manifest
|
2013-01-11 01:25:17 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutLineCount '==' 13
|
2012-05-03 02:46:32 +00:00
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
2012-10-09 07:13:34 +00:00
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
2012-10-15 06:11:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^BK:$BK\$"
|
2013-11-11 07:43:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^date:$date\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^service:file\$"
|
|
|
|
assertStdoutGrep --matches=1 "^name:file1\$"
|
2012-10-15 06:11:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
2013-01-11 01:25:17 +00:00
|
|
|
assert [ -e file1x.manifest ]
|
|
|
|
assert diff file1.manifest file1x.manifest
|
|
|
|
}
|
|
|
|
|
2013-02-27 01:09:23 +00:00
|
|
|
doc_ExtractManifestFileAfterAdd="Export bundle after one add"
|
2013-01-11 01:25:17 +00:00
|
|
|
setup_ExtractManifestFileAfterAdd() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "A test file" >file1
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_stdout_rowid rowid
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2013-01-11 01:25:17 +00:00
|
|
|
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
|
2013-12-13 06:54:59 +00:00
|
|
|
extract_manifest_BK BK file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_manifest_date date file1.manifest
|
2013-01-11 01:25:17 +00:00
|
|
|
}
|
|
|
|
test_ExtractManifestFileAfterAdd() {
|
2013-02-27 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export bundle $manifestid file1x.manifest file1x
|
2013-01-11 01:25:17 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutLineCount '==' 13
|
2013-01-11 01:25:17 +00:00
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^BK:$BK\$"
|
2013-11-11 07:43:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^date:$date\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^service:file\$"
|
|
|
|
assertStdoutGrep --matches=1 "^name:file1\$"
|
2013-01-11 01:25:17 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
2013-01-11 01:25:17 +00:00
|
|
|
assert [ -e file1x.manifest ]
|
|
|
|
assert diff file1.manifest file1x.manifest
|
|
|
|
assert [ -e file1x ]
|
|
|
|
assert diff file1 file1x
|
2012-11-07 09:59:12 +00:00
|
|
|
}
|
|
|
|
|
2013-02-27 01:09:23 +00:00
|
|
|
doc_ExtractManifestFileFromExtBlob="Export bundle from external blob"
|
2013-02-16 09:55:26 +00:00
|
|
|
setup_ExtractManifestFileFromExtBlob() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-12-30 04:21:20 +00:00
|
|
|
executeOk_servald config set rhizome.max_blob_size 0
|
2013-02-16 09:55:26 +00:00
|
|
|
echo "A test file" >file1
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_stdout_rowid rowid1
|
2013-12-30 04:21:20 +00:00
|
|
|
executeOk_servald config set rhizome.max_blob_size 1000
|
2013-02-22 03:04:53 +00:00
|
|
|
echo "Another test file" >file2
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file2 file2.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_stdout_rowid rowid2
|
2013-02-16 09:55:26 +00:00
|
|
|
executeOk_servald rhizome list
|
2013-02-22 03:04:53 +00:00
|
|
|
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
|
2013-12-13 06:54:59 +00:00
|
|
|
extract_manifest_BK BK1 file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_manifest_date date1 file1.manifest
|
2013-02-22 03:04:53 +00:00
|
|
|
extract_manifest_id manifestid2 file2.manifest
|
|
|
|
extract_manifest_version version2 file2.manifest
|
|
|
|
extract_manifest_filehash filehash2 file2.manifest
|
2013-12-13 06:54:59 +00:00
|
|
|
extract_manifest_BK BK2 file2.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_manifest_date date2 file2.manifest
|
2013-02-16 09:55:26 +00:00
|
|
|
}
|
|
|
|
test_ExtractManifestFileFromExtBlob() {
|
2013-02-27 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export bundle $manifestid1 file1x.manifest file1x
|
2013-02-16 09:55:26 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutLineCount '==' 13
|
2013-02-16 09:55:26 +00:00
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
2013-02-22 03:04:53 +00:00
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version1\$"
|
2013-02-16 09:55:26 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^BK:$BK1\$"
|
2013-11-11 07:43:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^date:$date1\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^service:file\$"
|
|
|
|
assertStdoutGrep --matches=1 "^name:file1\$"
|
2013-02-16 09:55:26 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.rowid:$rowid1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
2013-02-16 09:55:26 +00:00
|
|
|
assert [ -e file1x.manifest ]
|
|
|
|
assert diff file1.manifest file1x.manifest
|
|
|
|
assert [ -e file1x ]
|
|
|
|
assert diff file1 file1x
|
2013-02-27 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export bundle $manifestid2 file2x.manifest file2x
|
2013-02-22 03:04:53 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutLineCount '==' 13
|
2013-02-22 03:04:53 +00:00
|
|
|
local size=$(( $(cat file2 | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid2\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version2\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash2\$"
|
|
|
|
assertStdoutGrep --matches=1 "^BK:$BK2\$"
|
2013-11-11 07:43:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^date:$date2\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^service:file\$"
|
|
|
|
assertStdoutGrep --matches=1 "^name:file2\$"
|
2013-02-22 03:04:53 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.rowid:$rowid2\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
2013-02-22 03:04:53 +00:00
|
|
|
assert [ -e file2x.manifest ]
|
|
|
|
assert diff file2.manifest file2x.manifest
|
|
|
|
assert [ -e file2x ]
|
|
|
|
assert diff file2 file2x
|
2013-02-16 09:55:26 +00:00
|
|
|
}
|
|
|
|
|
2014-06-04 07:23:41 +00:00
|
|
|
doc_LargePayload="Export huge bundle after one add"
|
|
|
|
setup_LargePayload() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
set_instance +A
|
|
|
|
executeOk_servald config set debug.rhizome_store on
|
|
|
|
}
|
|
|
|
test_LargePayload() {
|
|
|
|
rhizome_add_file file1 100000
|
|
|
|
executeOk_servald rhizome export bundle $BID file1x.manifest file1x
|
|
|
|
assert [ -e file1x.manifest ]
|
|
|
|
assert diff file1.manifest file1x.manifest
|
|
|
|
assert [ -e file1x ]
|
|
|
|
assert diff file1 file1x
|
|
|
|
}
|
|
|
|
|
2014-11-19 02:56:50 +00:00
|
|
|
doc_CorruptExternalBlob="Corrupted payload fails to export"
|
2013-08-21 06:15:18 +00:00
|
|
|
setup_CorruptExternalBlob() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-12-30 04:21:20 +00:00
|
|
|
executeOk_servald config set rhizome.max_blob_size 0
|
2013-08-21 06:15:18 +00:00
|
|
|
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
|
2014-03-07 06:25:38 +00:00
|
|
|
assert cmp file1 "$SERVALINSTANCE_PATH/blob/$filehash"
|
|
|
|
echo "Replacement" >"$SERVALINSTANCE_PATH/blob/$filehash"
|
2013-08-21 06:15:18 +00:00
|
|
|
}
|
|
|
|
test_CorruptExternalBlob() {
|
|
|
|
execute --exit-status=255 $servald rhizome extract file $manifestid file1a
|
|
|
|
tfw_cat --stderr
|
|
|
|
}
|
|
|
|
|
2014-11-17 13:11:03 +00:00
|
|
|
doc_ExtractManifestToStdout="Export manifest to standard output"
|
2012-11-07 09:59:12 +00:00
|
|
|
setup_ExtractManifestToStdout() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "A test file" >file1
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_stdout_rowid rowid
|
2012-11-07 09:59:12 +00:00
|
|
|
extract_manifest_id manifestid file1.manifest
|
|
|
|
extract_manifest_version version file1.manifest
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
2013-12-13 06:54:59 +00:00
|
|
|
extract_manifest_BK BK file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_manifest_date date file1.manifest
|
2012-11-07 09:59:12 +00:00
|
|
|
}
|
|
|
|
test_ExtractManifestToStdout() {
|
2013-02-27 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export manifest $manifestid -
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutLineCount '>=' 14
|
2012-11-07 09:59:12 +00:00
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^version:$version\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^filesize:$size\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^BK:$BK\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^date:$date\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^service:file\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^name:file1\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^\.readonly:0\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^\.rowid:$rowid\$"
|
|
|
|
assertStdoutGrep --line=..13 --matches=1 "^\.inserttime:$rexp_date\$"
|
|
|
|
assertStdoutGrep --line=14 --matches=1 "^manifest:"
|
|
|
|
replayStdout | $SED -n '14s/^manifest://p' >file1x.manifest
|
|
|
|
replayStdout | $SED -n '15,$p' >>file1x.manifest
|
2012-11-07 09:59:12 +00:00
|
|
|
cat file1.manifest >file1n.manifest
|
|
|
|
echo >>file1n.manifest
|
|
|
|
tfw_cat file1n.manifest file1x.manifest
|
2013-01-11 01:25:17 +00:00
|
|
|
assert diff file1n.manifest file1x.manifest
|
2012-10-15 06:11:38 +00:00
|
|
|
}
|
|
|
|
|
2013-02-27 01:09:23 +00:00
|
|
|
doc_ExtractManifestAfterAddNoAuthor="Export manifest after one add with no author"
|
2012-10-15 06:11:38 +00:00
|
|
|
setup_ExtractManifestAfterAddNoAuthor() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "A test file" >file1
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_stdout_rowid rowid
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=0 file1
|
2012-10-15 06:11:38 +00:00
|
|
|
extract_manifest_id manifestid file1.manifest
|
|
|
|
extract_manifest_version version file1.manifest
|
|
|
|
extract_manifest_filehash filehash file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_manifest_date date file1.manifest
|
2012-10-15 06:11:38 +00:00
|
|
|
}
|
|
|
|
test_ExtractManifestAfterAddNoAuthor() {
|
2013-02-27 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export manifest $manifestid file1x.manifest
|
2013-01-11 01:25:17 +00:00
|
|
|
assert diff file1.manifest file1x.manifest
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutLineCount '==' 10
|
2012-10-15 06:11:38 +00:00
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
2012-10-09 07:13:34 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
2013-11-11 07:43:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^date:$date\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^service:file\$"
|
|
|
|
assertStdoutGrep --matches=1 "^name:file1\$"
|
2012-10-15 06:11:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:1\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
2012-05-02 06:33:09 +00:00
|
|
|
}
|
|
|
|
|
2013-02-27 01:09:23 +00:00
|
|
|
doc_ExtractManifestNonExistent="Export non-existent manifest"
|
2012-10-15 06:11:38 +00:00
|
|
|
setup_ExtractManifestNonExistent() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 06:54:27 +00:00
|
|
|
manifestid=0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
|
|
|
|
}
|
2012-10-15 06:11:38 +00:00
|
|
|
test_ExtractManifestNonExistent() {
|
2013-02-27 01:09:23 +00:00
|
|
|
execute --exit-status=1 $servald rhizome export manifest $manifestid foo.manifest
|
2012-05-02 06:54:27 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
|
|
|
}
|
|
|
|
|
2013-02-27 01:09:23 +00:00
|
|
|
doc_ExtractManifestInvalidID="Export manifest using invalid ID"
|
2012-05-02 06:54:27 +00:00
|
|
|
setup_ExtractManifestInvalidID() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 06:54:27 +00:00
|
|
|
}
|
|
|
|
test_ExtractManifestInvalidID() {
|
2013-02-27 01:09:23 +00:00
|
|
|
execute --exit-status=255 $servald rhizome export manifest 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEx foo.manifest
|
2012-05-02 06:54:27 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
2013-02-27 01:09:23 +00:00
|
|
|
execute --exit-status=255 $servald rhizome export manifest 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDE foo.manifest
|
2012-05-02 06:54:27 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
2013-02-27 01:09:23 +00:00
|
|
|
execute --exit-status=255 $servald rhizome export manifest foo.manifest
|
2012-05-02 06:54:27 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo.manifest ]
|
|
|
|
}
|
|
|
|
|
2012-10-15 06:11:38 +00:00
|
|
|
doc_ExtractFileAfterAdd="Extract file after one add"
|
|
|
|
setup_ExtractFileAfterAdd() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 08:27:35 +00:00
|
|
|
echo "A test file" >file1
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-05-25 10:12:45 +00:00
|
|
|
tfw_cat --stderr
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_stdout_rowid rowid
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1
|
2013-01-11 01:25:17 +00:00
|
|
|
extract_manifest_id manifestid file1.manifest
|
|
|
|
extract_manifest_version version file1.manifest
|
2013-01-04 00:32:24 +00:00
|
|
|
extract_manifest_filehash filehash file1.manifest
|
2013-12-13 06:54:59 +00:00
|
|
|
extract_manifest_BK BK file1.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_manifest_date date file1.manifest
|
2012-05-02 08:27:35 +00:00
|
|
|
}
|
2012-10-15 06:11:38 +00:00
|
|
|
test_ExtractFileAfterAdd() {
|
2013-01-11 01:25:17 +00:00
|
|
|
executeOk_servald rhizome extract file $manifestid file1x
|
2013-01-02 02:23:00 +00:00
|
|
|
tfw_cat --stderr
|
2013-01-11 01:25:17 +00:00
|
|
|
assert diff file1 file1x
|
2012-05-02 08:27:35 +00:00
|
|
|
local size=$(( $(cat file1 | wc -c) + 0 ))
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutLineCount '==' 13
|
2013-01-11 01:25:17 +00:00
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^BK:$BK\$"
|
2013-11-11 07:43:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^date:$date\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^service:file\$"
|
|
|
|
assertStdoutGrep --matches=1 "^name:file1\$"
|
2013-01-11 01:25:17 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
2012-05-02 08:27:35 +00:00
|
|
|
}
|
|
|
|
|
2013-02-27 01:09:23 +00:00
|
|
|
doc_ExtractFileMissing="Extract and export non-existent file"
|
2012-10-15 06:11:38 +00:00
|
|
|
setup_ExtractFileMissing() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-02 02:23:00 +00:00
|
|
|
BID=0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
|
2012-05-02 08:27:35 +00:00
|
|
|
filehash=0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
|
|
|
|
}
|
2012-10-15 06:11:38 +00:00
|
|
|
test_ExtractFileMissing() {
|
2013-01-02 02:23:00 +00:00
|
|
|
execute --exit-status=1 $servald rhizome extract file $BID foo
|
|
|
|
tfw_cat --stderr
|
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-27 01:09:23 +00:00
|
|
|
execute --exit-status=1 $servald rhizome export file $filehash foo
|
2013-01-02 02:23:00 +00:00
|
|
|
tfw_cat --stderr
|
2012-05-02 08:27:35 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
|
|
|
}
|
|
|
|
|
2013-02-27 01:09:23 +00:00
|
|
|
doc_ExtractFileInvalidID="Extract and export file using invalid ID"
|
2012-05-02 08:27:35 +00:00
|
|
|
setup_ExtractFileInvalidID() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-02 08:27:35 +00:00
|
|
|
}
|
|
|
|
test_ExtractFileInvalidID() {
|
2013-01-02 02:23:00 +00:00
|
|
|
execute --exit-status=255 $servald rhizome extract file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEx foo
|
2012-05-02 08:27:35 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-01-02 02:23:00 +00:00
|
|
|
execute --exit-status=255 $servald rhizome extract file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDE foo
|
2012-05-02 08:27:35 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-13 06:19:52 +00:00
|
|
|
execute --exit-status=255 $servald rhizome extract file foo
|
2012-05-02 08:27:35 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-27 01:09:23 +00:00
|
|
|
execute --exit-status=255 $servald rhizome export file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEx foo
|
2013-01-02 02:23:00 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-27 01:09:23 +00:00
|
|
|
execute --exit-status=255 $servald rhizome export file 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDE foo
|
2013-01-02 02:23:00 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2013-02-27 01:09:23 +00:00
|
|
|
execute --exit-status=255 $servald rhizome export file foo
|
2013-01-02 02:23:00 +00:00
|
|
|
assertStdoutLineCount '==' 0
|
|
|
|
assert [ ! -e foo ]
|
2012-05-02 08:27:35 +00:00
|
|
|
}
|
|
|
|
|
2013-09-30 07:12:25 +00:00
|
|
|
doc_AddDeDuplicate="Add duplicate file does not create new bundle by default"
|
2013-09-30 07:04:17 +00:00
|
|
|
setup_AddDeDuplicate() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 01:13:31 +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
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 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
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 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.
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
2013-09-30 07:04:17 +00:00
|
|
|
test_AddDeDuplicate() {
|
2013-11-28 07:14:37 +00:00
|
|
|
# Add first file again - should return a "duplicate" status code and nothing
|
|
|
|
# should change in its manifests.
|
2013-12-19 08:43:39 +00:00
|
|
|
execute --exit-status=2 --stderr --core-backtrace $servald rhizome add file $SIDB1 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-12-17 05:39:22 +00:00
|
|
|
extract_stdout_secret file1_dup_secret
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-13 08:17:20 +00:00
|
|
|
strip_signatures file1.manifest file1.manifestA
|
|
|
|
assert diff file1.manifest file1.manifestA
|
2013-09-30 07:12:25 +00:00
|
|
|
assert [ $file1_secret = $file1_dup_secret ]
|
2012-04-13 08:17:20 +00:00
|
|
|
# Repeat for second file.
|
2013-11-28 07:14:37 +00:00
|
|
|
execute --exit-status=2 --stderr $servald rhizome add file $SIDB1 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-12-17 05:39:22 +00:00
|
|
|
extract_stdout_secret file2_dup_secret
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-13 08:17:20 +00:00
|
|
|
strip_signatures file2.manifest file2.manifestA
|
|
|
|
assert diff file2.manifest file2.manifestA
|
2012-12-20 04:48:59 +00:00
|
|
|
assert [ $file2_secret = $file2_dup_secret ]
|
2012-04-13 08:17:20 +00:00
|
|
|
}
|
|
|
|
|
2013-09-30 07:12:25 +00:00
|
|
|
doc_AddForceDuplicate="Add duplicate file with --force-new option"
|
|
|
|
setup_AddForceDuplicate() {
|
|
|
|
setup_AddDeDuplicate
|
|
|
|
}
|
|
|
|
test_AddForceDuplicate() {
|
|
|
|
# Add first file again with the --force-new option. A new manifest
|
|
|
|
# should be created with a new ID.
|
|
|
|
executeOk_servald rhizome add file --force-new $SIDB1 file1 file1.manifestA
|
|
|
|
assert [ -s file1.manifestA ]
|
|
|
|
assert_stdout_add_file --manifest=file1.manifestA file1
|
|
|
|
extract_stdout_secret file1_dup_secret
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2 --manifest=file1.manifestA file1
|
|
|
|
strip_signatures file1.manifest file1.manifestA
|
|
|
|
assert ! diff file1.manifest file1.manifestA
|
|
|
|
assert [ $file1_secret != $file1_dup_secret ]
|
|
|
|
# Repeat for second file.
|
|
|
|
executeOk_servald rhizome add file --force-new $SIDB1 file2 file2.manifestA
|
|
|
|
assert [ -s file2.manifestA ]
|
|
|
|
assert_stdout_add_file --manifest=file2.manifestA file2
|
|
|
|
extract_stdout_secret file2_dup_secret
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2 --manifest=file1.manifestA file1 --manifest=file2.manifestA file2
|
|
|
|
strip_signatures file2.manifest file2.manifestA
|
|
|
|
assert ! diff file2.manifest file2.manifestA
|
|
|
|
assert [ $file2_secret != $file2_dup_secret ]
|
|
|
|
}
|
|
|
|
|
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() {
|
2013-09-30 07:04:17 +00:00
|
|
|
setup_AddDeDuplicate
|
2012-04-13 08:17:20 +00:00
|
|
|
}
|
|
|
|
test_AddMismatched() {
|
2013-12-19 08:43:39 +00:00
|
|
|
# Try to add another file using an existing manifest, should fail with status
|
|
|
|
# code indicating inconsistency.
|
2012-04-13 08:17:20 +00:00
|
|
|
cp file1.manifest file1_2.manifest
|
2013-12-19 08:43:39 +00:00
|
|
|
# Exit status 6 means manifest and payload do not match (filesize/filehash).
|
|
|
|
execute --exit-status=6 --stderr --core-backtrace $servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
|
|
|
tfw_cat file1.manifest file1_2.manifest
|
|
|
|
# Output manifest should be the same as the re-used manigfest
|
|
|
|
assert --stderr cmp file1.manifest file1_2.manifest
|
2012-04-13 08:17:20 +00:00
|
|
|
# And rhizome store should be unchanged.
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-13 08:17:20 +00:00
|
|
|
}
|
|
|
|
|
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() {
|
2013-10-03 05:43:28 +00:00
|
|
|
setup_AddDeDuplicate
|
2012-04-13 08:17:20 +00:00
|
|
|
cp file1.manifest file1_2.manifest
|
|
|
|
strip_signatures file1_2.manifest
|
2012-09-13 04:38:52 +00:00
|
|
|
$SED -i -e '/^date=/d;/^filehash=/d;/^filesize=/d' file1_2.manifest
|
2012-04-17 07:24:39 +00:00
|
|
|
tfw_cat -v file1_2.manifest
|
2014-03-12 03:52:38 +00:00
|
|
|
assert_manifest_fields file1_2.manifest !date !filehash !filesize version 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() {
|
2013-12-19 08:43:39 +00:00
|
|
|
# Try to add another file using an existing manifest Id and Version, should
|
|
|
|
# fail and update the manifest file to show existing bundle's manifest.
|
2012-04-16 02:16:58 +00:00
|
|
|
tfw_cat -v file1_2.manifest
|
2014-11-14 02:28:49 +00:00
|
|
|
execute $servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
|
|
|
assertExitStatus --stderr '==' 1
|
2013-12-19 08:43:39 +00:00
|
|
|
tfw_cat -v file1_2.manifest file1.manifest
|
|
|
|
assert cmp file1_2.manifest file1.manifest
|
2012-04-13 08:29:40 +00:00
|
|
|
# And rhizome store should be unchanged.
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-04-13 08:29:40 +00:00
|
|
|
}
|
|
|
|
|
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
|
2012-09-13 04:38:52 +00:00
|
|
|
$SED -i -e "/^version=/s/=.*/=$version/" file1_2.manifest
|
2014-03-12 03:52:38 +00:00
|
|
|
assert_manifest_fields file1_2.manifest version="$version"
|
2012-04-13 08:29:40 +00:00
|
|
|
}
|
2012-04-16 02:16:58 +00:00
|
|
|
test_AddUpdateNewVersion() {
|
2012-04-17 07:24:39 +00:00
|
|
|
tfw_cat -v file1_2.manifest
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
2012-10-09 07:13:34 +00:00
|
|
|
tfw_cat --stderr
|
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.
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1_2 file2
|
2012-06-05 04:28:59 +00:00
|
|
|
}
|
|
|
|
|
2012-10-11 07:28:24 +00:00
|
|
|
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 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file1_2 file1_2.manifest
|
2012-10-11 07:28:24 +00:00
|
|
|
tfw_cat --stderr
|
|
|
|
# Rhizome store contents have new payload.
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1_2 file2
|
2012-10-11 07:28:24 +00:00
|
|
|
}
|
|
|
|
|
2012-06-05 04:28:59 +00:00
|
|
|
doc_AddUpdateNoAuthor="Cannot add new payload to authorless manifest"
|
|
|
|
setup_AddUpdateNoAuthor() {
|
|
|
|
setup_AddUpdateNewVersion
|
2012-09-13 04:38:52 +00:00
|
|
|
$SED -i -e '/^BK=/d' file1_2.manifest
|
2012-06-05 04:28:59 +00:00
|
|
|
}
|
|
|
|
test_AddUpdateNoAuthor() {
|
|
|
|
tfw_cat -v file1_2.manifest
|
2013-02-13 06:19:52 +00:00
|
|
|
execute $servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
2012-06-05 04:28:59 +00:00
|
|
|
tfw_cat --stderr
|
|
|
|
assertExitStatus '!=' 0
|
2013-11-05 07:28:03 +00:00
|
|
|
# Rhizome store contents have old payload, with the original author.
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB1 file1 file2
|
2012-06-05 04:28:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1_2 file1_2.manifest "$file1_secret"
|
2012-06-05 04:28:59 +00:00
|
|
|
tfw_cat --stderr
|
2013-11-05 07:28:03 +00:00
|
|
|
# Rhizome store contents have new payload, but it has lost its author (no BK
|
|
|
|
# field any more).
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2013-11-05 07:28:03 +00:00
|
|
|
assert_rhizome_list --fromhere=0 file1_2 --fromhere=1 --author=$SIDB1 file2
|
2012-04-16 02:16:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddUpdateAutoVersion="Add new payload to existing manifest with automatic version"
|
|
|
|
setup_AddUpdateAutoVersion() {
|
|
|
|
setup_AddUpdateSameVersion
|
2012-09-13 04:38:52 +00:00
|
|
|
$SED -i -e '/^version=/d' file1_2.manifest
|
2014-03-12 03:52:38 +00:00
|
|
|
assert_manifest_fields file1_2.manifest !version
|
2012-04-16 02:16:58 +00:00
|
|
|
}
|
|
|
|
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
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1_2 file1_2.manifest
|
2014-11-19 02:56:50 +00:00
|
|
|
assert_manifest_newer file1.manifest file1_2.manifest
|
|
|
|
# Rhizome store contents reflect new payload.
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list --fromhere=1 file1_2 file2
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_AddUpdateArgs="Update existing bundle using manifest args"
|
|
|
|
setup_AddUpdateArgs() {
|
|
|
|
setup_AddDeDuplicate
|
|
|
|
extract_manifest_id BID file1.manifest
|
|
|
|
cp file1.manifest file1_2.manifest
|
|
|
|
}
|
|
|
|
test_AddUpdateArgs() {
|
|
|
|
sleep 0.001 # Ensure that at least one millisecond has elapsed
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1_2 file1_2.manifest '' !version !filesize !filehash !date
|
|
|
|
assert_stdout_add_file file1_2 name=file1
|
|
|
|
assert_manifest_fields file1_2.manifest name=file1
|
|
|
|
extract_manifest_id BID2 file1_2.manifest
|
|
|
|
assert [ $BID = $BID2 ]
|
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.
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file1_2 file2
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
|
|
|
|
2013-11-26 07:16:07 +00:00
|
|
|
doc_AddServiceInvalid="Add with invalid service fails"
|
|
|
|
setup_AddServiceInvalid() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 03:48:12 +00:00
|
|
|
echo "Message1" >file1
|
2013-11-26 07:16:07 +00:00
|
|
|
echo 'service=Fubar!' >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2013-11-26 07:16:07 +00:00
|
|
|
test_AddServiceInvalid() {
|
2013-02-13 06:19:52 +00:00
|
|
|
execute $servald rhizome add file $SIDB1 file1 file1.manifest
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
tfw_cat --stdout --stderr
|
2012-05-21 03:48:12 +00:00
|
|
|
assertExitStatus '!=' 0
|
|
|
|
}
|
|
|
|
|
2013-11-26 07:16:07 +00:00
|
|
|
doc_AddServiceUnsupported="Add with unsupported service succeeds"
|
|
|
|
setup_AddServiceUnsupported() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "Message1" >file1
|
|
|
|
echo 'service=Fubar' >file1.manifest
|
|
|
|
}
|
|
|
|
test_AddServiceUnsupported() {
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
}
|
|
|
|
|
2014-11-13 05:24:20 +00:00
|
|
|
doc_AddUpdateNoAuthorWithPassphrase="Add and update authorless bundle with only secret passphrase"
|
|
|
|
setup_AddUpdateNoAuthorWithPassphrase() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
create_file file1 1k
|
|
|
|
create_file file1_2 2k
|
|
|
|
pass='On the Ning Nang Nong'
|
|
|
|
}
|
|
|
|
test_AddUpdateNoAuthorWithPassphrase() {
|
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest "#$pass"
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1 !.author '!BK'
|
|
|
|
assert_manifest_complete file1.manifest
|
|
|
|
extract_manifest_id BID file1.manifest
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list --fromhere=0 file1
|
|
|
|
executeOk_servald rhizome add file '' file1_2 file1_2.manifest "#$pass"
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1_2 !.author '!BK'
|
|
|
|
assert_manifest_complete file1_2.manifest
|
|
|
|
extract_manifest_id BID2 file1.manifest
|
|
|
|
assert [ "$BID" = "$BID2" ]
|
|
|
|
executeOk_servald rhizome extract file $BID file1x
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert diff file1_2 file1x
|
|
|
|
}
|
|
|
|
|
2014-11-14 02:31:44 +00:00
|
|
|
doc_AddUpdateWithPassphrase="Add and update bundle using secret passphrase"
|
|
|
|
setup_AddUpdateWithPassphrase() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
create_file file1 1k
|
|
|
|
create_file file1_2 2k
|
|
|
|
pass='On the Ning Nang Nong'
|
|
|
|
}
|
|
|
|
test_AddUpdateWithPassphrase() {
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest "#$pass"
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1 .author=$SIDB1
|
|
|
|
assert_manifest_complete file1.manifest
|
|
|
|
extract_manifest_id BID file1.manifest
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list --fromhere=1 file1
|
|
|
|
executeOk_servald rhizome add file $SIDB1 file1_2 file1_2.manifest "#$pass"
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1_2 .author=$SIDB1
|
|
|
|
assert_manifest_complete file1_2.manifest
|
|
|
|
extract_manifest_id BID2 file1.manifest
|
|
|
|
assert [ "$BID" = "$BID2" ]
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list --fromhere=1 file1_2
|
|
|
|
executeOk_servald rhizome extract file $BID file1x
|
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert diff file1_2 file1x
|
|
|
|
}
|
|
|
|
|
2013-02-27 01:09:23 +00:00
|
|
|
doc_EncryptedPayload="Add and extract an encrypted payload"
|
2013-01-03 05:42:24 +00:00
|
|
|
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 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-01-03 05:42:24 +00:00
|
|
|
tfw_cat --stdout --stderr
|
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2013-01-03 05:42:24 +00:00
|
|
|
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 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export file $filehash file1y
|
2013-01-03 05:42:24 +00:00
|
|
|
assert ! diff file1 file1y
|
|
|
|
}
|
|
|
|
|
2013-07-19 00:58:15 +00:00
|
|
|
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
|
Refactor manifest: specific setter functions
Replace generic rhizome_manifest_set() and rhizome_manifest_set_ll()
with per-field setter functions, eg, rhizome_manifest_set_filesize().
Struct rhizome_manifest elements for all known fields, to replace the
use of rhizome_manifest_get() and rhizome_manifest_get_ll() everywhere:
sender, recipient, service, name, date, bundle_key.
Add boolean validity flags for binary blob types, to avoid having to compare
with many bytes of all-zero to detect presence, eg, has_sender, has_recipient,
has_author, has_bundle_key. These maintained by the setter functions.
Rename existing manifest struct elements to be the same as their field
names: fileLength -> filesize, journalTail -> tail.
More use of unsigned int, size_t and uint64_t for payload sizes, offsets, byte
counts, etc. especially in rhizome_store.c and meshms.c. More uniform use of
size_t to dimension memory buffers. Fix some printf(3) style format strings
for 64-bit correctness on 32-bit systems. Use new constant RHIZOME_SIZE_UNSET
instead of -1 to indicate unknown dimension, and explicitly assert its absence
before comparisons and arithmetic, for safety.
Replace some 'int' loop variables with 'unsigned' where appropriate.
Fix bugs discovered in MeshMS bundle private/public key generation and
bundle secret key handling for export/extract commands.
Instrument the first MeshMS test case to aid debugging.
New debug config flag: debug.manifest logs all modifications to all manifest
fields by setter functions.
Rename debug config flag: debug.rhizome_bind -> debug.rhizome_sql_bind.
2013-10-30 12:52:19 +00:00
|
|
|
tfw_cat file1 -v file1y
|
2013-07-19 00:58:15 +00:00
|
|
|
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 06:54:50 +00:00
|
|
|
doc_JournalAdd="Create and append to a journal"
|
|
|
|
setup_JournalAdd() {
|
2013-07-08 05:27:47 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "Part One" > file1
|
|
|
|
echo "Part Two" > file2
|
|
|
|
cat file1 file2 > file
|
2013-07-05 06:54:50 +00:00
|
|
|
}
|
|
|
|
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 05:27:47 +00:00
|
|
|
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 02:18:15 +00:00
|
|
|
doc_MeshMSAddCreate="First add MeshMS creates manifest"
|
|
|
|
setup_MeshMSAddCreate() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 03:48:12 +00:00
|
|
|
echo "Message1" >file1
|
2012-07-06 04:02:21 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddCreate() {
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2013-01-03 05:42:24 +00:00
|
|
|
extract_manifest_crypt crypt file1.manifest
|
|
|
|
assert [ $crypt = 1 ]
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2013-01-02 02:23:00 +00:00
|
|
|
extract_manifest_id BID file1.manifest
|
|
|
|
executeOk_servald rhizome extract file $BID 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-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-08-27 04:12:56 +00:00
|
|
|
executeOk_servald config set rhizome.clean_on_open on
|
2013-10-06 17:12:17 +00:00
|
|
|
export SERVALD_ORPHAN_PAYLOAD_PERSIST_MS=0
|
2012-05-21 03:48:12 +00:00
|
|
|
echo "Message1" >file1
|
2012-07-06 04:02:21 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddGrow() {
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_stdout_add_file file1
|
|
|
|
assert_manifest_complete file1.manifest
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2012-05-25 04:59:55 +00:00
|
|
|
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 04:02:21 +00:00
|
|
|
echo -e "id=$id\nBK=$bk\nservice=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-25 04:59:55 +00:00
|
|
|
echo "Message$m" >>file1
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2012-05-25 04:59:55 +00:00
|
|
|
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 02:23:00 +00:00
|
|
|
assert --message="filehash is for new file" [ "$filehash" != "$filehashx" ]
|
|
|
|
executeOk_servald rhizome extract file "$id" file1x
|
2012-05-25 04:59:55 +00:00
|
|
|
assert --message="extracted payload is correct" diff file1 file1x
|
|
|
|
for ofilehash in "${ofilehashes[@]}"; do
|
2013-02-27 01:09:23 +00:00
|
|
|
execute --exit-status=1 --stderr $servald rhizome export file "$ofilehash"
|
2012-05-25 04:59:55 +00:00
|
|
|
done
|
2014-03-18 05:33:26 +00:00
|
|
|
filehash="$filehashx"
|
2012-05-25 04:59:55 +00:00
|
|
|
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-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 03:48:12 +00:00
|
|
|
echo "Message1" >file1
|
2012-07-06 04:02:21 +00:00
|
|
|
echo -e "service=MeshMS1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddMissingSender() {
|
2013-02-13 06:19:52 +00:00
|
|
|
execute $servald rhizome add file $SIDB1 file1 file1.manifest
|
2013-12-19 08:43:39 +00:00
|
|
|
assertExitStatus --stdout --stderr '!=' 0
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
doc_MeshMSAddMissingRecipient="Add MeshMS without recipient fails"
|
|
|
|
setup_MeshMSAddMissingRecipient() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-05-21 03:48:12 +00:00
|
|
|
assert_rhizome_list
|
|
|
|
echo "Message1" >file1
|
2012-07-06 04:02:21 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1" >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddMissingRecipient() {
|
2013-02-13 06:19:52 +00:00
|
|
|
execute $servald rhizome add file $SIDB1 file1 file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
assertExitStatus '!=' 0
|
|
|
|
}
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
doc_MeshMSAddMissingAuthor="Add MeshMS without author uses sender"
|
|
|
|
setup_MeshMSAddMissingAuthor() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 03:48:12 +00:00
|
|
|
echo "Message1" >file1
|
2012-07-06 04:02:21 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 03:48:12 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSAddMissingAuthor() {
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file1 !.author !BK
|
2012-06-08 08:55:43 +00:00
|
|
|
assert_manifest_complete file1.manifest
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2012-05-21 05:11:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-17 01:13:31 +00:00
|
|
|
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 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file1 !.author !BK
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file2 file2.manifest
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file2 !.author !BK
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file3 file3.manifest
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file3 !.author !BK
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file4 file4.manifest
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file4 !.author !BK
|
2013-01-17 01:13:31 +00:00
|
|
|
}
|
|
|
|
test_ListFilter() {
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list file
|
2013-01-17 01:13:31 +00:00
|
|
|
assert_rhizome_list file1 file2 file3 file4
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list file 'file%'
|
2013-01-17 01:13:31 +00:00
|
|
|
assert_rhizome_list file1 file2 file3 file4
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' 'file2'
|
2013-01-17 01:13:31 +00:00
|
|
|
assert_rhizome_list file2
|
|
|
|
}
|
|
|
|
|
2012-06-12 02:18:15 +00:00
|
|
|
doc_MeshMSListFilter="List MeshMS manifests by filter"
|
|
|
|
setup_MeshMSListFilter() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-05-21 05:11:22 +00:00
|
|
|
echo "Message1" >file1
|
2012-07-06 04:02:21 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB2" >file1.manifest
|
2012-05-21 05:11:22 +00:00
|
|
|
echo "Message2" >file2
|
2012-07-06 04:02:21 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB3" >file2.manifest
|
2012-05-21 05:11:22 +00:00
|
|
|
echo "Message3" >file3
|
2012-07-06 04:02:21 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB1\nrecipient=$SIDB4" >file3.manifest
|
2012-05-21 05:11:22 +00:00
|
|
|
echo "Message3" >file4
|
2012-07-06 04:02:21 +00:00
|
|
|
echo -e "service=MeshMS1\nsender=$SIDB2\nrecipient=$SIDB3" >file4.manifest
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file1 !.author !BK
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_manifest_complete file1.manifest
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file2 file2.manifest
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file2 !.author !BK
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_manifest_complete file2.manifest
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file3 file3.manifest
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file3 !.author !BK
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_manifest_complete file3.manifest
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file '' file4 file4.manifest
|
2014-11-14 02:27:43 +00:00
|
|
|
assert_stdout_add_file file4 !.author !BK
|
2012-06-12 02:18:15 +00:00
|
|
|
assert_manifest_complete file4.manifest
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file1 file2 file3 file4
|
2012-05-21 05:11:22 +00:00
|
|
|
}
|
2012-06-12 02:18:15 +00:00
|
|
|
test_MeshMSListFilter() {
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list file
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list MeshMS1
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file1 file2 file3 file4
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' $SIDB1
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file1 file2 file3
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' $SIDB2
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file4
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' $SIDB3
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' $SIDB4
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' '' $SIDB1
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' '' $SIDB2
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file1
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' '' $SIDB3
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file2 file4
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list file '' '' $SIDB3
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' '' $SIDB4
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file3
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' $SIDB1 $SIDB4
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file3
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' $SIDB2 $SIDB4
|
2012-05-21 05:11:22 +00:00
|
|
|
assert_rhizome_list
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome list '' '' $SIDB2 $SIDB3
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 file4
|
2012-04-10 08:31:53 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 01:43:50 +00:00
|
|
|
doc_ImportForeignBundle="Import a bundle created by another instance"
|
2012-06-08 08:55:43 +00:00
|
|
|
setup_ImportForeignBundle() {
|
2012-07-06 04:02:21 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
2012-06-22 06:26:28 +00:00
|
|
|
set_instance +A
|
2012-06-08 08:55:43 +00:00
|
|
|
echo "Hello from A" >fileA
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDA1 fileA fileA.manifest
|
2012-06-08 08:55:43 +00:00
|
|
|
assert_stdout_add_file fileA
|
2012-06-22 06:26:28 +00:00
|
|
|
set_instance +B
|
2012-06-08 08:55:43 +00:00
|
|
|
}
|
|
|
|
test_ImportForeignBundle() {
|
|
|
|
executeOk_servald rhizome import bundle fileA fileA.manifest
|
|
|
|
assert_stdout_import_bundle fileA
|
2013-12-19 08:43:39 +00:00
|
|
|
# Exit status 1 means bundle is already in store
|
|
|
|
execute --exit-status=1 --stdout --stderr $servald rhizome import bundle fileA fileA.manifest
|
2013-01-15 00:02:48 +00:00
|
|
|
assert_stdout_import_bundle fileA
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=0 fileA
|
2012-06-08 08:55:43 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 01:43:50 +00:00
|
|
|
doc_ImportOwnBundle="Import a bundle created by same instance"
|
2012-10-15 06:11:38 +00:00
|
|
|
setup_ImportOwnBundle() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
echo "Hello from B" >fileB
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDB2 fileB fileB.manifest
|
2012-10-15 06:11:38 +00:00
|
|
|
assert_stdout_add_file fileB
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_stdout_rowid rowid
|
2012-10-15 06:11:38 +00:00
|
|
|
extract_manifest_id manifestid fileB.manifest
|
|
|
|
extract_manifest_version version fileB.manifest
|
|
|
|
extract_manifest_filehash filehash fileB.manifest
|
2013-12-13 06:54:59 +00:00
|
|
|
extract_manifest_BK BK fileB.manifest
|
2013-11-11 07:43:38 +00:00
|
|
|
extract_manifest_date date fileB.manifest
|
2014-03-07 06:25:38 +00:00
|
|
|
assert [ -e "$SERVALINSTANCE_PATH/rhizome.db" ]
|
|
|
|
rm -f "$SERVALINSTANCE_PATH/rhizome.db"
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-15 06:11:38 +00:00
|
|
|
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 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=0 fileB
|
2012-10-15 06:11:38 +00:00
|
|
|
# Extracting the manifest discovers that it is ours.
|
2013-02-27 01:09:23 +00:00
|
|
|
executeOk_servald rhizome extract bundle $manifestid fileBx.manifest fileBx
|
2012-10-15 06:11:38 +00:00
|
|
|
tfw_cat --stderr
|
|
|
|
assert cmp fileB.manifest fileBx.manifest
|
2013-02-27 01:09:23 +00:00
|
|
|
assert cmp fileB fileBx
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutLineCount '==' 13
|
2012-10-15 06:11:38 +00:00
|
|
|
local size=$(( $(cat fileB | wc -c) + 0 ))
|
|
|
|
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^version:$version\$"
|
|
|
|
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
|
|
|
assertStdoutGrep --matches=1 "^BK:$BK\$"
|
2013-11-11 07:43:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^date:$date\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^service:file\$"
|
|
|
|
assertStdoutGrep --matches=1 "^name:fileB\$"
|
2012-10-15 06:11:38 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
2013-12-13 06:54:59 +00:00
|
|
|
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.author:$SIDB2\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
|
|
|
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
2013-02-27 01:09:23 +00:00
|
|
|
# Now bundle author should be known, so appears to be from here
|
2013-01-17 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2012-10-17 07:40:39 +00:00
|
|
|
assert_rhizome_list --fromhere=1 --author=$SIDB2 fileB
|
2012-10-15 06:11:38 +00:00
|
|
|
}
|
|
|
|
|
2013-02-20 04:14:29 +00:00
|
|
|
doc_ImportCombinedBundle="Create and import combined bundle"
|
2013-01-11 03:49:26 +00:00
|
|
|
setup_ImportCombinedBundle() {
|
2015-03-02 01:43:50 +00:00
|
|
|
# A "combined bundle" is a single file consisting of a payload with its
|
|
|
|
# manifest appended to the end.
|
2013-01-11 03:49:26 +00:00
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
set_instance +A
|
|
|
|
echo "Hello from A" >fileA
|
2013-02-13 06:19:52 +00:00
|
|
|
executeOk_servald rhizome add file $SIDA1 fileA fileA.manifest
|
2013-01-11 03:49:26 +00:00
|
|
|
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() {
|
2015-03-02 01:43:50 +00:00
|
|
|
# Create the combined bundle
|
2013-01-11 03:49:26 +00:00
|
|
|
executeOk_servald rhizome append manifest fileA fileA.manifest
|
2015-03-02 01:43:50 +00:00
|
|
|
# Import the combined bundle
|
2013-01-11 03:49:26 +00:00
|
|
|
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 01:13:31 +00:00
|
|
|
executeOk_servald rhizome list
|
2013-01-11 03:49:26 +00:00
|
|
|
assert_rhizome_list --fromhere=0 fileA
|
2013-02-27 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export bundle $manifestid fileAx fileAx
|
2013-01-11 03:49:26 +00:00
|
|
|
assert diff fileA fileAx
|
|
|
|
}
|
|
|
|
|
2013-02-20 04:14:29 +00:00
|
|
|
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
|
|
|
|
}
|
2014-06-16 06:26:31 +00:00
|
|
|
rhizome_clean() {
|
|
|
|
executeOk_servald rhizome clean
|
|
|
|
extract_stdout_keyvalue deleted_files 'deleted_orphan_files' '[0-9]\+'
|
|
|
|
extract_stdout_keyvalue deleted_fileblobs 'deleted_orphan_fileblobs' '[0-9]\+'
|
|
|
|
extract_stdout_keyvalue deleted_manifests 'deleted_orphan_manifests' '[0-9]\+'
|
|
|
|
}
|
2013-02-20 04:14:29 +00:00
|
|
|
|
|
|
|
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 01:09:23 +00:00
|
|
|
execute --exit-status=1 --stderr $servald rhizome export manifest "$BID2"
|
|
|
|
executeOk_servald rhizome export file "$HASH2" file2x
|
2013-02-20 04:14:29 +00:00
|
|
|
assert diff file2 file2x
|
2014-06-16 06:26:31 +00:00
|
|
|
rhizome_clean
|
|
|
|
assert [ $deleted_files = 1 ]
|
2014-06-18 07:55:15 +00:00
|
|
|
assert [ $deleted_fileblobs = 0 ]
|
2014-06-16 06:26:31 +00:00
|
|
|
assert [ $deleted_manifests = 0 ]
|
2013-02-20 04:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export manifest "$BID3"
|
|
|
|
execute --exit-status=1 --stderr $servald rhizome export file "$HASH3" file3x
|
2014-06-16 06:26:31 +00:00
|
|
|
rhizome_clean
|
|
|
|
assert [ $deleted_files = 0 ]
|
|
|
|
assert [ $deleted_fileblobs = 0 ]
|
|
|
|
assert [ $deleted_manifests = 1 ]
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list file{1,2,4}
|
2013-02-20 04:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 01:09:23 +00:00
|
|
|
execute --exit-status=1 --stderr $servald rhizome export manifest "$BID4"
|
|
|
|
execute --exit-status=1 --stderr $servald rhizome export file "$HASH4" file4x
|
2014-06-16 06:26:31 +00:00
|
|
|
rhizome_clean
|
|
|
|
assert [ $deleted_files = 0 ]
|
|
|
|
assert [ $deleted_fileblobs = 0 ]
|
|
|
|
assert [ $deleted_manifests = 0 ]
|
2013-02-20 04:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 01:09:23 +00:00
|
|
|
executeOk_servald rhizome export manifest "$BID1"
|
|
|
|
execute --exit-status=1 --stderr $servald rhizome export file "$HASH1" file1x
|
2014-06-16 06:26:31 +00:00
|
|
|
rhizome_clean
|
|
|
|
assert [ $deleted_files = 0 ]
|
|
|
|
assert [ $deleted_fileblobs = 0 ]
|
|
|
|
assert [ $deleted_manifests = 1 ]
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list file{2..4}
|
2013-02-20 04:14:29 +00:00
|
|
|
}
|
|
|
|
|
2014-06-18 07:55:15 +00:00
|
|
|
doc_payloadTooBig="Fail to insert a payload that is larger than the database"
|
|
|
|
setup_payloadTooBig() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
set_instance +A
|
|
|
|
executeOk_servald config set rhizome.database_size 32K
|
|
|
|
}
|
|
|
|
test_payloadTooBig(){
|
|
|
|
create_file file1 32K
|
|
|
|
execute $servald rhizome add file $SIDA file1 file1.manifest
|
|
|
|
assertExitStatus '==' 7
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_payloadUninteresting="Fail to insert a payload that is uninteresting"
|
|
|
|
setup_payloadUninteresting() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
set_instance +A
|
|
|
|
executeOk_servald config set rhizome.database_size 64K
|
|
|
|
}
|
|
|
|
test_payloadUninteresting(){
|
|
|
|
create_file file1 32K
|
|
|
|
create_file file2 32K
|
|
|
|
executeOk_servald rhizome add file $SIDA file1 file1.manifest
|
|
|
|
execute $servald rhizome add file $SIDA file2 file2.manifest
|
|
|
|
assertExitStatus '==' 7
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_evictUninteresting="Evict a large payload to make room for smaller payloads"
|
|
|
|
setup_evictUninteresting() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
set_instance +A
|
|
|
|
executeOk_servald config set rhizome.database_size 1M
|
2014-06-23 01:38:01 +00:00
|
|
|
create_file file1 512K
|
|
|
|
create_file file2 256K
|
|
|
|
create_file file3 128K
|
|
|
|
create_file file4 128K
|
2014-06-18 07:55:15 +00:00
|
|
|
}
|
|
|
|
test_evictUninteresting(){
|
2014-06-23 01:38:01 +00:00
|
|
|
executeOk_servald rhizome add file $SIDA file1 file1.manifest
|
|
|
|
executeOk_servald rhizome add file $SIDA file2 file2.manifest
|
|
|
|
executeOk_servald rhizome add file $SIDA file3 file3.manifest
|
|
|
|
executeOk_servald rhizome add file $SIDA file4 file4.manifest
|
|
|
|
tfw_cat --stderr
|
|
|
|
rhizome_clean
|
|
|
|
assert [ $deleted_files = 0 ]
|
|
|
|
assert [ $deleted_fileblobs = 0 ]
|
|
|
|
assert [ $deleted_manifests = 1 ]
|
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list file{2,3,4}
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_evictFreeSpace="Reduce database size due to insufficient free space"
|
|
|
|
setup_evictFreeSpace() {
|
|
|
|
setup_servald
|
|
|
|
setup_rhizome
|
|
|
|
set_instance +A
|
2014-06-18 07:55:15 +00:00
|
|
|
create_file file1 512K
|
|
|
|
create_file file2 256K
|
|
|
|
create_file file3 128K
|
|
|
|
create_file file4 128K
|
|
|
|
executeOk_servald rhizome add file $SIDA file1 file1.manifest
|
|
|
|
executeOk_servald rhizome add file $SIDA file2 file2.manifest
|
|
|
|
executeOk_servald rhizome add file $SIDA file3 file3.manifest
|
|
|
|
executeOk_servald rhizome add file $SIDA file4 file4.manifest
|
2014-06-23 01:38:01 +00:00
|
|
|
}
|
|
|
|
test_evictFreeSpace() {
|
|
|
|
executeOk_servald config \
|
|
|
|
set rhizome.min_free_space 1M
|
|
|
|
# only 640K free...
|
|
|
|
export SERVALD_FREE_SPACE=655360
|
2014-06-18 07:55:15 +00:00
|
|
|
rhizome_clean
|
2014-06-23 01:38:01 +00:00
|
|
|
assert [ $deleted_files = 0 ]
|
|
|
|
assert [ $deleted_fileblobs = 0 ]
|
|
|
|
assert [ $deleted_manifests = 1 ]
|
2014-06-18 07:55:15 +00:00
|
|
|
executeOk_servald rhizome list
|
|
|
|
assert_rhizome_list file{2,3,4}
|
|
|
|
}
|
2012-04-10 08:31:53 +00:00
|
|
|
runTests "$@"
|