Add <bsk> optional arg to "rhizome add file"

Improve regular expressions for common data types in test scripts

Revert column count field delimiter in "rhizome list" from ":" to "\n"

Add a few more test cases
This commit is contained in:
Andrew Bettison 2012-06-05 13:58:59 +09:30
parent c857aea237
commit a9ad1b6afc
6 changed files with 212 additions and 88 deletions

@ -1114,11 +1114,6 @@ int app_config_get(int argc, const char *const *argv, struct command_line_option
return 0;
}
int cli_optional_sid(const char *arg)
{
return !arg[0] || validateSid(arg);
}
int app_rhizome_hash_file(int argc, const char *const *argv, struct command_line_option *o)
{
/* compute hash of file. We do this without a manifest, so it will necessarily
@ -1133,13 +1128,29 @@ int app_rhizome_hash_file(int argc, const char *const *argv, struct command_line
return 0;
}
int cli_optional_sid(const char *arg)
{
return !arg[0] || validateSid(arg);
}
int cli_optional_bundle_key(const char *arg)
{
return !arg[0] || rhizome_str_is_bundle_key(arg);
}
int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_option *o)
{
const char *filepath, *manifestpath, *authorSid, *pin;
const char *filepath, *manifestpath, *authorSid, *pin, *bskhex;
cli_arg(argc, argv, o, "filepath", &filepath, NULL, "");
cli_arg(argc, argv, o, "author_sid", &authorSid, cli_optional_sid, "");
if (cli_arg(argc, argv, o, "author_sid", &authorSid, cli_optional_sid, "") == -1)
return -1;
cli_arg(argc, argv, o, "pin", &pin, NULL, "");
cli_arg(argc, argv, o, "manifestpath", &manifestpath, NULL, "");
if (cli_arg(argc, argv, o, "bsk", &bskhex, cli_optional_bundle_key, "") == -1)
return -1;
unsigned char bsk[RHIZOME_BUNDLE_KEY_STRLEN + 1];
if (bskhex[0] && stowBytes(bsk, bskhex, RHIZOME_BUNDLE_KEY_BYTES) == -1)
return -1;
if (create_serval_instance_dir() == -1)
return -1;
if (!(keyring = keyring_open_with_pins((char *)pin)))
@ -1193,23 +1204,29 @@ int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_
}
}
/* bind an ID for the manifest, and also bind the file.
Then finalise the manifest.
/* Bind an ID to the manifest, and also bind the file. Then finalise the manifest.
But if the manifest already contains an ID, don't override it. */
if (rhizome_manifest_get(m, "id", NULL, 0)==NULL) {
if (rhizome_manifest_bind_id(m,authorSid)) {
rhizome_manifest_free(m); m=NULL;
if (rhizome_manifest_bind_id(m, authorSid)) {
rhizome_manifest_free(m);
m = NULL;
return WHY("Could not bind manifest to an ID");
}
} else if (bskhex[0]) {
memcpy(m->cryptoSignSecret, bsk, RHIZOME_BUNDLE_KEY_BYTES);
if (rhizome_verify_bundle_privatekey(m) == -1) {
rhizome_manifest_free(m);
m = NULL;
return WHY("Incorrect BID secret key.");
}
} else {
/* User supplied manifest has a BID, so see if we can extract the
private key from a BK entry */
if (rhizome_extract_privatekey(m,authorSid))
{
rhizome_manifest_free(m); m=NULL;
return WHY("Could not extract BID secret key. Does the manifest have a BK, did you supply the correct author SID?");
}
if (rhizome_extract_privatekey(m,authorSid) == -1) {
rhizome_manifest_free(m);
m = NULL;
return WHY("Could not extract BID secret key. Does the manifest have a BK, did you supply the correct author SID?");
}
}
#warning need to sanely determine whether to encrypt a file
#warning payload encryption disabled for now
@ -1252,10 +1269,16 @@ int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_
if (service) {
cli_puts("service"); cli_delim(":"); cli_puts(service); cli_delim("\n");
}
char bid[RHIZOME_MANIFEST_ID_STRLEN + 1];
rhizome_bytes_to_hex_upper(mwritten->cryptoSignPublic, bid,
RHIZOME_MANIFEST_ID_BYTES);
cli_puts("manifestid"); cli_delim(":"); cli_puts(bid); cli_delim("\n");
{
char bid[RHIZOME_MANIFEST_ID_STRLEN + 1];
rhizome_bytes_to_hex_upper(mwritten->cryptoSignPublic, bid, RHIZOME_MANIFEST_ID_BYTES);
cli_puts("manifestid"); cli_delim(":"); cli_puts(bid); cli_delim("\n");
}
{
char secret[RHIZOME_BUNDLE_KEY_STRLEN + 1];
rhizome_bytes_to_hex_upper(mwritten->cryptoSignSecret, secret, RHIZOME_BUNDLE_KEY_BYTES);
cli_puts("secret"); cli_delim(":"); cli_puts(secret); cli_delim("\n");
}
cli_puts("filehash"); cli_delim(":"); cli_puts(mwritten->fileHexHash); cli_delim("\n");
cli_puts("filesize"); cli_delim(":"); cli_printf("%lld", mwritten->fileLength); cli_delim("\n");
const char *name = rhizome_manifest_get(mwritten, "name", NULL, 0);
@ -1313,20 +1336,20 @@ int cli_fileid(const char *arg)
return rhizome_str_is_file_hash(arg);
}
int cli_bundlekey(const char *arg)
int cli_optional_bundle_crypt_key(const char *arg)
{
return rhizome_str_is_bundle_crypt_key(arg);
return !arg[0] || rhizome_str_is_bundle_crypt_key(arg);
}
int app_rhizome_extract_file(int argc, const char *const *argv, struct command_line_option *o)
{
const char *fileid, *filepath, *keyhex;
unsigned char key[RHIZOME_CRYPT_KEY_STRLEN + 1];
if (cli_arg(argc, argv, o, "fileid", &fileid, cli_fileid, NULL)
|| cli_arg(argc, argv, o, "filepath", &filepath, NULL, "") == -1)
return -1;
cli_arg(argc, argv, o, "key", &keyhex, cli_bundlekey, NULL);
if (keyhex && stowBytes(key, keyhex, RHIZOME_CRYPT_KEY_BYTES) == -1)
cli_arg(argc, argv, o, "key", &keyhex, cli_optional_bundle_crypt_key, "");
unsigned char key[RHIZOME_CRYPT_KEY_STRLEN + 1];
if (keyhex[0] && stowBytes(key, keyhex, RHIZOME_CRYPT_KEY_BYTES) == -1)
return -1;
/* Ensure the Rhizome database exists and is open */
if (create_serval_instance_dir() == -1)
@ -1337,7 +1360,7 @@ int app_rhizome_extract_file(int argc, const char *const *argv, struct command_l
We don't provide a decryption key here, because we don't know it.
(We probably should allow the user to provide one).
*/
int ret = rhizome_retrieve_file(fileid, filepath, keyhex ? key : NULL);
int ret = rhizome_retrieve_file(fileid, filepath, keyhex[0] ? key : NULL);
switch (ret) {
case 0: ret = 1; break;
case 1: ret = 0; break;
@ -1696,7 +1719,7 @@ command_line_option command_line_options[]={
"Get specified configuration variable."},
{app_rhizome_hash_file,{"rhizome","hash","file","<filepath>",NULL},CLIFLAG_STANDALONE,
"Compute the Rhizome hash of a file"},
{app_rhizome_add_file,{"rhizome","add","file","<author_sid>","<pin>","<filepath>","[<manifestpath>]",NULL},CLIFLAG_STANDALONE,
{app_rhizome_add_file,{"rhizome","add","file","<author_sid>","<pin>","<filepath>","[<manifestpath>]","[<bsk>]",NULL},CLIFLAG_STANDALONE,
"Add a file to Rhizome and optionally write its manifest to the given path"},
{app_rhizome_list,{"rhizome","list","[<service>]","[<sender_sid>]","[<recipient_sid>]","[<offset>]","[<limit>]",NULL},CLIFLAG_STANDALONE,
"List all manifests and files in Rhizome"},

@ -198,6 +198,8 @@ int rhizome_opendb();
int rhizome_manifest_createid(rhizome_manifest *m);
int rhizome_strn_is_manifest_id(const char *text);
int rhizome_str_is_manifest_id(const char *text);
int rhizome_strn_is_bundle_key(const char *text);
int rhizome_str_is_bundle_key(const char *text);
int rhizome_strn_is_bundle_crypt_key(const char *text);
int rhizome_str_is_bundle_crypt_key(const char *text);
int rhizome_strn_is_file_hash(const char *text);
@ -279,6 +281,7 @@ int rhizome_bk_xor(const char *author,
unsigned char bkout[crypto_sign_edwards25519sha512batch_SECRETKEYBYTES]);
unsigned char *rhizome_bundle_shared_secret(rhizome_manifest *m);
int rhizome_extract_privatekey(rhizome_manifest *m,const char *authorHex);
int rhizome_verify_bundle_privatekey(rhizome_manifest *m);
int rhizome_queue_ignore_manifest(rhizome_manifest *m,
struct sockaddr_in *peerip,int timeout);
int rhizome_ignore_manifest_check(rhizome_manifest *m,

@ -56,14 +56,24 @@ int rhizome_str_is_manifest_id(const char *id)
return _is_xstring(id, RHIZOME_MANIFEST_ID_STRLEN);
}
int rhizome_strn_is_bundle_key(const char *key)
{
return _is_xsubstring(key, RHIZOME_BUNDLE_KEY_STRLEN);
}
int rhizome_str_is_bundle_key(const char *key)
{
return _is_xstring(key, RHIZOME_BUNDLE_KEY_STRLEN);
}
int rhizome_strn_is_bundle_crypt_key(const char *key)
{
return _is_xstring(key, RHIZOME_CRYPT_KEY_STRLEN);
return _is_xsubstring(key, RHIZOME_CRYPT_KEY_STRLEN);
}
int rhizome_str_is_bundle_crypt_key(const char *key)
{
return _is_xsubstring(key, RHIZOME_CRYPT_KEY_STRLEN);
return _is_xstring(key, RHIZOME_CRYPT_KEY_STRLEN);
}
int rhizome_manifest_createid(rhizome_manifest *m)
@ -162,7 +172,7 @@ int rhizome_bk_xor(const char *author,
the supplied SID is correct.
*/
int rhizome_extract_privatekey(rhizome_manifest *m,const char *authorHex)
int rhizome_extract_privatekey(rhizome_manifest *m, const char *authorHex)
{
if (!authorHex) return -1; // WHY("No author SID supplied");
char *bk = rhizome_manifest_get(m, "BK", NULL, 0);
@ -177,11 +187,16 @@ int rhizome_extract_privatekey(rhizome_manifest *m,const char *authorHex)
bkBytes,
m->cryptoSignSecret))
return WHY("rhizome_bk_xor() failed");
return rhizome_verify_bundle_privatekey(m);
/* Verify validity of key.
XXX This is a pretty ugly way to do it, but NaCl offers no API to
do this cleanly. */
{
}
/* Verify the validity of the manifest's sccret key.
XXX This is a pretty ugly way to do it, but NaCl offers no API to
do this cleanly.
*/
int rhizome_verify_bundle_privatekey(rhizome_manifest *m)
{
#ifdef HAVE_CRYPTO_SIGN_NACL_GE25519_H
# include "crypto_sign_edwards25519sha512batch_ref/ge25519.h"
#else
@ -190,34 +205,35 @@ int rhizome_extract_privatekey(rhizome_manifest *m,const char *authorHex)
# endif
#endif
#ifdef ge25519
unsigned char *sk=m->cryptoSignSecret;
unsigned char pk[crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES];
sc25519 scsk;
ge25519 gepk;
sc25519_from32bytes(&scsk,sk);
ge25519_scalarmult_base(&gepk, &scsk);
ge25519_pack(pk, &gepk);
bzero(&scsk,sizeof(scsk));
if (memcmp(pk, m->cryptoSignPublic, crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)) {
if (1) {
char hex[17];
rhizome_bytes_to_hex_upper(m->cryptoSignPublic, hex, 8);
WHYF(" stored public key = %s*", hex);
rhizome_bytes_to_hex_upper(pk, hex, 8);
WHYF("computed public key = %s*", hex);
}
return WHY("BID secret key decoded from BK was not valid");
} else {
m->haveSecret=1;
return 0;
unsigned char *sk=m->cryptoSignSecret;
unsigned char pk[crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES];
sc25519 scsk;
ge25519 gepk;
sc25519_from32bytes(&scsk,sk);
ge25519_scalarmult_base(&gepk, &scsk);
ge25519_pack(pk, &gepk);
bzero(&scsk,sizeof(scsk));
if (memcmp(pk, m->cryptoSignPublic, crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)) {
m->haveSecret=0;
if (1) {
char hex[17];
rhizome_bytes_to_hex_upper(m->cryptoSignPublic, hex, 8);
WHYF(" stored public key = %s*", hex);
rhizome_bytes_to_hex_upper(pk, hex, 8);
WHYF("computed public key = %s*", hex);
}
#else //!ge25519
/* XXX Need to test key by signing and testing signature validity. */
/* For the time being barf so that the caller does not think we have a validated BK
when in fact we do not. */
return WHY("ge25519 function not available");
#endif //!ge25519
return WHY("BID secret key decoded from BK was not valid");
} else {
m->haveSecret=1;
return 0;
}
#else //!ge25519
/* XXX Need to test key by signing and testing signature validity. */
/* For the time being barf so that the caller does not think we have a validated BK
when in fact we do not. */
m->haveSecret=0;
return WHY("ge25519 function not available");
#endif //!ge25519
}
rhizome_signature *rhizome_sign_hash(rhizome_manifest *m,const char *author)

@ -629,7 +629,7 @@ int rhizome_list_manifests(const char *service, const char *sender_sid, const ch
ret = WHY(sqlite3_errmsg(rhizome_db));
} else {
size_t rows = 0;
cli_puts("10"); cli_delim(":"); // number of columns
cli_puts("10"); cli_delim("\n"); // number of columns
cli_puts("service"); cli_delim(":");
cli_puts("id"); cli_delim(":");
cli_puts("version"); cli_delim(":");
@ -637,9 +637,9 @@ int rhizome_list_manifests(const char *service, const char *sender_sid, const ch
cli_puts("_inserttime"); cli_delim(":");
cli_puts("filesize"); cli_delim(":");
cli_puts("filehash"); cli_delim(":");
cli_puts("name"); cli_delim(":");
cli_puts("sender"); cli_delim(":");
cli_puts("recipient"); cli_delim("\n");
cli_puts("recipient"); cli_delim(":");
cli_puts("name"); cli_delim("\n"); // should be last, because name may contain ':'
while (sqlite3_step(statement) == SQLITE_ROW) {
++rows;
if (!( sqlite3_column_count(statement) == 4
@ -697,9 +697,9 @@ int rhizome_list_manifests(const char *service, const char *sender_sid, const ch
cli_printf("%lld", q_inserttime); cli_delim(":");
cli_printf("%lld", blob_filesize); cli_delim(":");
cli_puts(blob_filehash ? blob_filehash : ""); cli_delim(":");
cli_puts(blob_name ? blob_name : ""); cli_delim(":");
cli_puts(blob_sender ? blob_sender : ""); cli_delim(":");
cli_puts(blob_recipient ? blob_recipient : ""); cli_delim("\n");
cli_puts(blob_recipient ? blob_recipient : ""); cli_delim(":");
cli_puts(blob_name ? blob_name : ""); cli_delim("\n");
}
}
if (m) rhizome_manifest_free(m);

@ -4,6 +4,10 @@ testdefs_sh=$(abspath "${BASH_SOURCE[0]}")
servald_source_root="${testdefs_sh%/*}"
servald_build_root="$servald_source_root"
# Some useful regular expressions. These must work in grep(1) as basic
# expressions, and also in sed(1).
rexp_sid='[0-9a-fA-F]\{64\}'
# Utility function for creating DNA fixtures:
# - Create a temporary directory to contain all servald-related files
# - set $servald variable (executable under test)
@ -27,7 +31,7 @@ set_instance() {
*) set_instance_vars "default"; return 1;;
esac
}
# Utility function:
# - set all the instance variables and environment variables and create the
# instance directory for the given instance name
@ -37,7 +41,7 @@ set_instance_vars() {
mkdir -p "$instance_dir"
export instance_servald_log="$instance_dir/servald.log"
export SERVALINSTANCE_PATH="$instance_dir/servald"
export instance_servald_pidfile="$SERVALINSTANCE_PATH/servald.pid"
export instance_servald_pidfile="$SERVALINSTANCE_PATH/servald.pid"
}
# Utility function for setting up DNA JNI fixtures:

@ -21,6 +21,16 @@
source "${0%/*}/../testframework.sh"
source "${0%/*}/../testdefs.sh"
# Some useful regular expressions. These must work for grep(1) (as basic
# expressions) and also in sed(1).
rexp_service='[A-Za-z0-9_]\+'
rexp_manifestid='[0-9a-fA-F]\{64\}'
rexp_bundlekey='[0-9a-fA-F]\{128\}'
rexp_bundlesecret="$rexp_bundlekey"
rexp_filehash='[0-9a-fA-F]\{128\}'
rexp_version='[0-9]\{1,\}'
rexp_date='[0-9]\{1,\}'
setup_servald_rhizome() {
setup_servald
set_instance
@ -30,43 +40,53 @@ setup_servald_rhizome() {
executeOk $servald keyring add
executeOk $servald keyring add
executeOk $servald keyring list
sid=$(replayStdout | sed -ne '1s/^\([0-9a-fA-F]\{64\}\):.*$/\1/p')
sid1=$(replayStdout | sed -ne '2s/^\([0-9a-fA-F]\{64\}\):.*$/\1/p')
sid2=$(replayStdout | sed -ne '3s/^\([0-9a-fA-F]\{64\}\):.*$/\1/p')
sid3=$(replayStdout | sed -ne '4s/^\([0-9a-fA-F]\{64\}\):.*$/\1/p')
tfw_cat --stdout
sid=$(replayStdout | sed -ne "1s/^\($rexp_sid\):.*\$/\1/p")
sid1=$(replayStdout | sed -ne "2s/^\($rexp_sid\):.*\$/\1/p")
sid2=$(replayStdout | sed -ne "3s/^\($rexp_sid\):.*\$/\1/p")
sid3=$(replayStdout | sed -ne "4s/^\($rexp_sid\):.*\$/\1/p")
assert --message='main identity known' [ -n "$sid" ]
assert --message='identity 1 known' [ -n "$sid1" ]
assert --message='identity 2 known' [ -n "$sid2" ]
assert --message='identity 3 known' [ -n "$sid3" ]
assert [ $sid != $sid1 ]
assert [ $sid != $sid2 ]
assert [ $sid != $sid3 ]
assert [ $sid1 != $sid2 ]
assert [ $sid1 != $sid3 ]
assert [ $sid2 != $sid3 ]
}
assert_rhizome_list() {
assertStdoutLineCount '==' $(($# + 1))
assertStdoutIs --line=1 -e '10:service:id:version:date:_inserttime:filesize:filehash:name:sender:recipient\n'
assertStdoutLineCount '==' $(($# + 2))
assertStdoutIs --line=1 -e '10\n'
assertStdoutIs --line=2 -e 'service:id:version:date:_inserttime:filesize:filehash:sender:recipient:name\n'
local filename
for filename; do
unpack_manifest_for_grep "$filename"
assertStdoutGrep --matches=1 "^$re_service:$re_manifestid:.*:$re_filehash:$re_name:$re_sender:$re_recipient\$"
assertStdoutGrep --matches=1 "^$re_service:$re_manifestid:.*:$re_filehash:$re_sender:$re_recipient:$re_name\$"
done
}
assert_stdout_add_file() {
local filename="$1"
unpack_manifest_for_grep "$filename"
assertStdoutLineCount '==' 5
assertStdoutLineCount '==' 6
assertStdoutGrep --matches=1 "^service:$re_service\$"
assertStdoutGrep --matches=1 "^name:${2:-$re_name}\$"
assertStdoutGrep --matches=1 "^manifestid:$re_manifestid\$"
assertStdoutGrep --matches=1 "^secret:$re_secret\$"
assertStdoutGrep --matches=1 "^filehash:$re_filehash\$"
assertStdoutGrep --matches=1 "^filesize:$re_size\$"
}
unpack_manifest_for_grep() {
local filename="$1"
re_service='[A-Za-z0-9_]\+'
re_service="$rexp_service"
re_size=$(( $(cat "$filename" | wc -c) + 0 ))
compute_filehash re_filehash "$filename"
re_manifestid='[0-9a-fA-F]\{64\}'
re_manifestid="$rexp_manifestid"
re_secret="$rexp_bundlesecret"
re_name=$(escape_grep_basic "${filename##*/}")
# If there is a manifest file that looks like it matches this payload
# file, then use its file hash to check the rhizome list output.
@ -108,6 +128,23 @@ strip_signatures() {
done
}
extract_stdout_keyvalue() {
local _var="$1"
local _label="$2"
local _rexp="$3"
local _value=$(replayStdout | sed -n -e "/^$_label:$_rexp\$/s/^$_label://p")
assert --message="stdout contains valid '$_label:' line" --stdout [ -n "$_value" ]
[ -n "$_var" ] && eval $_var=$_value
}
extract_stdout_secret() {
extract_stdout_keyvalue "$1" secret "$rexp_bundlesecret"
}
extract_stdout_BK() {
extract_stdout_keyvalue "$1" BK "$rexp_bundlekey"
}
extract_manifest() {
local _var="$1"
local _manifestfile="$2"
@ -121,23 +158,23 @@ extract_manifest() {
}
extract_manifest_service() {
extract_manifest "$1" "$2" service '[0-9a-zA-Z]\+'
extract_manifest "$1" "$2" service "$rexp_service"
}
extract_manifest_id() {
extract_manifest "$1" "$2" id '[0-9a-fA-F]\{64\}'
extract_manifest "$1" "$2" id "$rexp_manifestid"
}
extract_manifest_BK() {
extract_manifest "$1" "$2" BK '[0-9a-fA-F]\{128\}'
extract_manifest "$1" "$2" BK "$rexp_bundlekey"
}
extract_manifest_filehash() {
extract_manifest "$1" "$2" filehash '[0-9a-fA-F]\{128\}'
extract_manifest "$1" "$2" filehash "$rexp_filehash"
}
extract_manifest_version() {
extract_manifest "$1" "$2" version '[0-9]\{1,\}'
extract_manifest "$1" "$2" version "$rexp_version"
}
compute_filehash() {
@ -184,6 +221,17 @@ test_AddNoManifest() {
assert_stdout_add_file file1
}
doc_AddNoAuthor="Add with no author makes manifest without BK"
setup_AddNoAuthor() {
setup_servald_rhizome
echo "A test file" >file1
}
test_AddNoAuthor() {
executeOk $servald rhizome add file '' '' file1 file1.manifest
assert_stdout_add_file file1
assertGrep --matches=0 file1.manifest '^BK='
}
doc_AddNonExistManifest="Add with non-existent manifest file"
setup_AddNonExistManifest() {
setup_servald_rhizome
@ -199,10 +247,10 @@ test_AddNonExistManifest() {
assert [ -r file1.manifest ]
tfw_cat -v file1.manifest
assertGrep file1.manifest '^service=file$'
assertGrep file1.manifest '^BK=[0-9a-fA-F]\+$'
assertGrep file1.manifest "^BK=$rexp_bundlekey\$"
assertGrep file1.manifest '^name=file1$'
assertGrep file1.manifest '^date=[0-9]\+$'
assertGrep file1.manifest '^version=[0-9]\+$'
assertGrep file1.manifest "^date=$rexp_date\$"
assertGrep file1.manifest "^version=$rexp_version\$"
assertGrep file1.manifest "^id=$re_manifestid\$"
assertGrep file1.manifest "^filehash=$re_filehash\$"
assertGrep file1.manifest "^filesize=$re_size\$"
@ -222,9 +270,9 @@ test_AddManifest() {
tfw_cat --stdout --stderr -v file1.manifest
assert_stdout_add_file file1 wah
assertGrep file1.manifest '^service=file$'
assertGrep file1.manifest '^BK=[0-9a-fA-F]\+$'
assertGrep file1.manifest "^BK=$rexp_bundlekey\$"
assertGrep file1.manifest '^name=wah$'
assertGrep file1.manifest '^version=[0-9]\+$'
assertGrep file1.manifest "^version=$rexp_version\$"
assertGrep file1.manifest '^date=12345$'
assertGrep file1.manifest "^id=$re_manifestid\$"
assertGrep file1.manifest "^filehash=$re_filehash\$"
@ -357,8 +405,10 @@ setup_AddDuplicate() {
echo "A test file, second version" >file1_2
# Add first file
executeOk $servald rhizome add file $sid '' file1 file1.manifest
extract_stdout_secret file1_secret
# Add second file
executeOk $servald rhizome add file $sid '' file2 file2.manifest
extract_stdout_secret file2_secret
# Make sure they are both in the list.
executeOk $servald rhizome list
assert_rhizome_list file1 file2
@ -441,6 +491,34 @@ test_AddUpdateNewVersion() {
assert_rhizome_list file1_2 file2
}
doc_AddUpdateNoAuthor="Cannot add new payload to authorless manifest"
setup_AddUpdateNoAuthor() {
setup_AddUpdateNewVersion
sed -i -e '/^BK=/d' file1_2.manifest
}
test_AddUpdateNoAuthor() {
tfw_cat -v file1_2.manifest
execute $servald rhizome add file $sid '' file1_2 file1_2.manifest
tfw_cat --stderr
assertExitStatus '!=' 0
# Rhizome store contents have old payload.
executeOk $servald rhizome list
assert_rhizome_list file1 file2
}
doc_AddUpdateNoAuthorWithSecret="Add new payload to authorless manifest with bundle secret"
setup_AddUpdateNoAuthorWithSecret() {
setup_AddUpdateNoAuthor
}
test_AddUpdateNoAuthorWithSecret() {
tfw_cat -v file1_2.manifest
executeOk $servald rhizome add file $sid '' file1_2 file1_2.manifest "$file1_secret"
tfw_cat --stderr
# Rhizome store contents have new payload.
executeOk $servald rhizome list
assert_rhizome_list file1_2 file2
}
doc_AddUpdateAutoVersion="Add new payload to existing manifest with automatic version"
setup_AddUpdateAutoVersion() {
setup_AddUpdateSameVersion