mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-08 03:24:13 +00:00
Unify output manifest fields from CLI rhizome commands
This commit is contained in:
parent
6361bfd757
commit
b53cabaae5
181
commandline.c
181
commandline.c
@ -527,6 +527,65 @@ void cli_flush(struct cli_context *context)
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void cli_put_manifest(struct cli_context *context, const rhizome_manifest *m)
|
||||
{
|
||||
assert(m->filesize != RHIZOME_SIZE_UNSET);
|
||||
cli_field_name(context, "manifestid", ":"); // TODO rename to "bundleid" or "bid"
|
||||
cli_put_string(context, alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), "\n");
|
||||
cli_field_name(context, "version", ":");
|
||||
cli_put_long(context, m->version, "\n");
|
||||
cli_field_name(context, "filesize", ":");
|
||||
cli_put_long(context, m->filesize, "\n");
|
||||
if (m->filesize != 0) {
|
||||
cli_field_name(context, "filehash", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_filehash_t(m->filehash), "\n");
|
||||
}
|
||||
if (m->has_bundle_key) {
|
||||
cli_field_name(context, "BK", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_bk_t(m->bundle_key), "\n");
|
||||
}
|
||||
if (m->has_date) {
|
||||
cli_field_name(context, "date", ":");
|
||||
cli_put_long(context, m->date, "\n");
|
||||
}
|
||||
switch (m->payloadEncryption) {
|
||||
case PAYLOAD_CRYPT_UNKNOWN:
|
||||
break;
|
||||
case PAYLOAD_CLEAR:
|
||||
cli_field_name(context, "crypt", ":");
|
||||
cli_put_long(context, 0, "\n");
|
||||
break;
|
||||
case PAYLOAD_ENCRYPTED:
|
||||
cli_field_name(context, "crypt", ":");
|
||||
cli_put_long(context, 1, "\n");
|
||||
break;
|
||||
}
|
||||
if (m->service) {
|
||||
cli_field_name(context, "service", ":");
|
||||
cli_put_string(context, m->service, "\n");
|
||||
}
|
||||
if (m->name) {
|
||||
cli_field_name(context, "name", ":");
|
||||
cli_put_string(context, m->name, "\n");
|
||||
}
|
||||
cli_field_name(context, ".readonly", ":");
|
||||
cli_put_long(context, m->haveSecret ? 0 : 1, "\n");
|
||||
if (m->haveSecret) {
|
||||
char secret[RHIZOME_BUNDLE_KEY_STRLEN + 1];
|
||||
rhizome_bytes_to_hex_upper(m->cryptoSignSecret, secret, RHIZOME_BUNDLE_KEY_BYTES);
|
||||
cli_field_name(context, ".secret", ":");
|
||||
cli_put_string(context, secret, "\n");
|
||||
}
|
||||
if (m->authorship == AUTHOR_AUTHENTIC) {
|
||||
cli_field_name(context, ".author", ":");
|
||||
cli_put_string(context, alloca_tohex_sid_t(m->author), "\n");
|
||||
}
|
||||
cli_field_name(context, ".rowid", ":");
|
||||
cli_put_long(context, m->rowid, "\n");
|
||||
cli_field_name(context, ".inserttime", ":");
|
||||
cli_put_long(context, m->inserttime, "\n");
|
||||
}
|
||||
|
||||
int app_echo(const struct cli_parsed *parsed, struct cli_context *context)
|
||||
{
|
||||
if (config.debug.verbose)
|
||||
@ -1479,54 +1538,15 @@ int app_rhizome_add_file(const struct cli_parsed *parsed, struct cli_context *co
|
||||
keyring_free(keyring);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (manifestpath && *manifestpath
|
||||
&& rhizome_write_manifest_file(mout, manifestpath, 0) == -1)
|
||||
ret = WHY("Could not overwrite manifest file.");
|
||||
if (mout->service) {
|
||||
cli_field_name(context, "service", ":");
|
||||
cli_put_string(context, mout->service, "\n");
|
||||
}
|
||||
{
|
||||
cli_field_name(context, "manifestid", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_bid_t(mout->cryptoSignPublic), "\n");
|
||||
}
|
||||
|
||||
assert(m->haveSecret);
|
||||
{
|
||||
char secret[RHIZOME_BUNDLE_KEY_STRLEN + 1];
|
||||
rhizome_bytes_to_hex_upper(mout->cryptoSignSecret, secret, RHIZOME_BUNDLE_KEY_BYTES);
|
||||
cli_field_name(context, ".secret", ":");
|
||||
cli_put_string(context, secret, "\n");
|
||||
}
|
||||
assert(mout->authorship != AUTHOR_LOCAL);
|
||||
if (mout->authorship == AUTHOR_AUTHENTIC) {
|
||||
cli_field_name(context, ".author", ":");
|
||||
cli_put_string(context, alloca_tohex_sid_t(mout->author), "\n");
|
||||
}
|
||||
cli_field_name(context, ".rowid", ":");
|
||||
cli_put_long(context, m->rowid, "\n");
|
||||
cli_field_name(context, ".inserttime", ":");
|
||||
cli_put_long(context, m->inserttime, "\n");
|
||||
if (mout->has_bundle_key) {
|
||||
cli_field_name(context, "BK", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_bk_t(mout->bundle_key), "\n");
|
||||
}
|
||||
if (mout->has_date) {
|
||||
cli_field_name(context, "date", ":");
|
||||
cli_put_long(context, mout->date, "\n");
|
||||
}
|
||||
cli_field_name(context, "version", ":");
|
||||
cli_put_long(context, mout->version, "\n");
|
||||
cli_field_name(context, "filesize", ":");
|
||||
cli_put_long(context, mout->filesize, "\n");
|
||||
if (mout->filesize != 0) {
|
||||
cli_field_name(context, "filehash", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_filehash_t(mout->filehash), "\n");
|
||||
}
|
||||
if (mout->name) {
|
||||
cli_field_name(context, "name", ":");
|
||||
cli_put_string(context, mout->name, "\n");
|
||||
}
|
||||
cli_put_manifest(context, mout);
|
||||
|
||||
if (mout != m)
|
||||
rhizome_manifest_free(mout);
|
||||
rhizome_manifest_free(m);
|
||||
@ -1595,44 +1615,7 @@ int app_rhizome_import_bundle(const struct cli_parsed *parsed, struct cli_contex
|
||||
if (status<0)
|
||||
goto cleanup;
|
||||
|
||||
// TODO generalise the way we dump manifest details from add, import & export
|
||||
// so callers can also generalise their parsing
|
||||
|
||||
if (m->service) {
|
||||
cli_field_name(context, "service", ":");
|
||||
cli_put_string(context, m->service, "\n");
|
||||
}
|
||||
{
|
||||
cli_field_name(context, "manifestid", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_bid_t(m->cryptoSignPublic), "\n");
|
||||
}
|
||||
{
|
||||
char secret[RHIZOME_BUNDLE_KEY_STRLEN + 1];
|
||||
rhizome_bytes_to_hex_upper(m->cryptoSignSecret, secret, RHIZOME_BUNDLE_KEY_BYTES);
|
||||
cli_field_name(context, ".secret", ":");
|
||||
cli_put_string(context, secret, "\n");
|
||||
}
|
||||
if (m->has_bundle_key) {
|
||||
cli_field_name(context, "BK", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_bk_t(m->bundle_key), "\n");
|
||||
}
|
||||
cli_field_name(context, "version", ":");
|
||||
cli_put_long(context, m->version, "\n");
|
||||
if (m->has_date) {
|
||||
cli_field_name(context, "date", ":");
|
||||
cli_put_long(context, m->date, "\n");
|
||||
}
|
||||
cli_field_name(context, "filesize", ":");
|
||||
cli_put_long(context, m->filesize, "\n");
|
||||
assert(m->filesize != RHIZOME_SIZE_UNSET);
|
||||
if (m->filesize != 0) {
|
||||
cli_field_name(context, "filehash", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_filehash_t(m->filehash), "\n");
|
||||
}
|
||||
if (m->name) {
|
||||
cli_field_name(context, "name", ":");
|
||||
cli_put_string(context, m->name, "\n");
|
||||
}
|
||||
cli_put_manifest(context, m);
|
||||
|
||||
cleanup:
|
||||
rhizome_manifest_free(m);
|
||||
@ -1787,42 +1770,8 @@ int app_rhizome_extract(const struct cli_parsed *parsed, struct cli_context *con
|
||||
rhizome_apply_bundle_secret(m, &bsk);
|
||||
rhizome_authenticate_author(m);
|
||||
|
||||
if (m->service) {
|
||||
cli_field_name(context, "service", ":");
|
||||
cli_put_string(context, m->service, "\n");
|
||||
}
|
||||
cli_field_name(context, "manifestid", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_bid_t(bid), "\n");
|
||||
cli_field_name(context, "version", ":");
|
||||
cli_put_long(context, m->version, "\n");
|
||||
if (m->has_date) {
|
||||
cli_field_name(context, "date", ":");
|
||||
cli_put_long(context, m->date, "\n");
|
||||
}
|
||||
cli_field_name(context, "filesize", ":");
|
||||
cli_put_long(context, m->filesize, "\n");
|
||||
assert(m->filesize != RHIZOME_SIZE_UNSET);
|
||||
if (m->filesize != 0) {
|
||||
cli_field_name(context, "filehash", ":");
|
||||
cli_put_string(context, alloca_tohex_rhizome_filehash_t(m->filehash), "\n");
|
||||
}
|
||||
if (m->haveSecret) {
|
||||
char secret[RHIZOME_BUNDLE_KEY_STRLEN + 1];
|
||||
rhizome_bytes_to_hex_upper(m->cryptoSignSecret, secret, RHIZOME_BUNDLE_KEY_BYTES);
|
||||
cli_field_name(context, ".secret", ":");
|
||||
cli_put_string(context, secret, "\n");
|
||||
}
|
||||
assert(m->authorship != AUTHOR_LOCAL);
|
||||
if (m->authorship == AUTHOR_AUTHENTIC) {
|
||||
cli_field_name(context, ".author", ":");
|
||||
cli_put_string(context, alloca_tohex_sid_t(m->author), "\n");
|
||||
}
|
||||
cli_field_name(context, ".rowid", ":");
|
||||
cli_put_long(context, m->rowid, "\n");
|
||||
cli_field_name(context, ".inserttime", ":");
|
||||
cli_put_long(context, m->inserttime, "\n");
|
||||
cli_field_name(context, ".readonly", ":");
|
||||
cli_put_long(context, m->haveSecret?0:1, "\n");
|
||||
cli_put_manifest(context, m);
|
||||
}
|
||||
|
||||
int retfile=0;
|
||||
|
160
tests/rhizomeops
160
tests/rhizomeops
@ -214,24 +214,27 @@ setup_ExtractManifestAfterAdd() {
|
||||
extract_manifest_id manifestid file1.manifest
|
||||
extract_manifest_version version file1.manifest
|
||||
extract_manifest_filehash filehash file1.manifest
|
||||
extract_manifest_BK BK file1.manifest
|
||||
extract_manifest_date date file1.manifest
|
||||
}
|
||||
test_ExtractManifestAfterAdd() {
|
||||
executeOk_servald rhizome export manifest $manifestid file1x.manifest
|
||||
tfw_cat --stdout --stderr
|
||||
assertStdoutLineCount '==' 11
|
||||
assertStdoutLineCount '==' 13
|
||||
local size=$(( $(cat file1 | wc -c) + 0 ))
|
||||
assertStdoutGrep --matches=1 "^service:file$"
|
||||
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
||||
assertStdoutGrep --matches=1 "^version:$version\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^BK:$BK\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^service:file\$"
|
||||
assertStdoutGrep --matches=1 "^name:file1\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
||||
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assert [ -e file1x.manifest ]
|
||||
assert diff file1.manifest file1x.manifest
|
||||
}
|
||||
@ -248,24 +251,27 @@ setup_ExtractManifestFileAfterAdd() {
|
||||
extract_manifest_id manifestid file1.manifest
|
||||
extract_manifest_version version file1.manifest
|
||||
extract_manifest_filehash filehash file1.manifest
|
||||
extract_manifest_BK BK file1.manifest
|
||||
extract_manifest_date date file1.manifest
|
||||
}
|
||||
test_ExtractManifestFileAfterAdd() {
|
||||
executeOk_servald rhizome export bundle $manifestid file1x.manifest file1x
|
||||
tfw_cat --stdout --stderr
|
||||
assertStdoutLineCount '==' 11
|
||||
assertStdoutLineCount '==' 13
|
||||
local size=$(( $(cat file1 | wc -c) + 0 ))
|
||||
assertStdoutGrep --matches=1 "^service:file$"
|
||||
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
||||
assertStdoutGrep --matches=1 "^version:$version\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^BK:$BK\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^service:file\$"
|
||||
assertStdoutGrep --matches=1 "^name:file1\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
||||
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assert [ -e file1x.manifest ]
|
||||
assert diff file1.manifest file1x.manifest
|
||||
assert [ -e file1x ]
|
||||
@ -289,47 +295,53 @@ setup_ExtractManifestFileFromExtBlob() {
|
||||
extract_manifest_id manifestid1 file1.manifest
|
||||
extract_manifest_version version1 file1.manifest
|
||||
extract_manifest_filehash filehash1 file1.manifest
|
||||
extract_manifest_BK BK1 file1.manifest
|
||||
extract_manifest_date date1 file1.manifest
|
||||
extract_manifest_id manifestid2 file2.manifest
|
||||
extract_manifest_version version2 file2.manifest
|
||||
extract_manifest_filehash filehash2 file2.manifest
|
||||
extract_manifest_BK BK2 file2.manifest
|
||||
extract_manifest_date date2 file2.manifest
|
||||
}
|
||||
test_ExtractManifestFileFromExtBlob() {
|
||||
executeOk_servald rhizome export bundle $manifestid1 file1x.manifest file1x
|
||||
tfw_cat --stdout --stderr
|
||||
assertStdoutLineCount '==' 11
|
||||
assertStdoutLineCount '==' 13
|
||||
local size=$(( $(cat file1 | wc -c) + 0 ))
|
||||
assertStdoutGrep --matches=1 "^service:file$"
|
||||
assertStdoutGrep --matches=1 "^manifestid:$manifestid1\$"
|
||||
assertStdoutGrep --matches=1 "^version:$version1\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash1\$"
|
||||
assertStdoutGrep --matches=1 "^BK:$BK1\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date1\$"
|
||||
assertStdoutGrep --matches=1 "^service:file\$"
|
||||
assertStdoutGrep --matches=1 "^name:file1\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.rowid:$rowid1\$"
|
||||
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash1\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date1\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assert [ -e file1x.manifest ]
|
||||
assert diff file1.manifest file1x.manifest
|
||||
assert [ -e file1x ]
|
||||
assert diff file1 file1x
|
||||
executeOk_servald rhizome export bundle $manifestid2 file2x.manifest file2x
|
||||
tfw_cat --stdout --stderr
|
||||
assertStdoutLineCount '==' 11
|
||||
assertStdoutLineCount '==' 13
|
||||
local size=$(( $(cat file2 | wc -c) + 0 ))
|
||||
assertStdoutGrep --matches=1 "^service:file$"
|
||||
assertStdoutGrep --matches=1 "^manifestid:$manifestid2\$"
|
||||
assertStdoutGrep --matches=1 "^version:$version2\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash2\$"
|
||||
assertStdoutGrep --matches=1 "^BK:$BK2\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date2\$"
|
||||
assertStdoutGrep --matches=1 "^service:file\$"
|
||||
assertStdoutGrep --matches=1 "^name:file2\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.rowid:$rowid2\$"
|
||||
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash2\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date2\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assert [ -e file2x.manifest ]
|
||||
assert diff file2.manifest file2x.manifest
|
||||
assert [ -e file2x ]
|
||||
@ -362,26 +374,29 @@ setup_ExtractManifestToStdout() {
|
||||
extract_manifest_id manifestid file1.manifest
|
||||
extract_manifest_version version file1.manifest
|
||||
extract_manifest_filehash filehash file1.manifest
|
||||
extract_manifest_BK BK file1.manifest
|
||||
extract_manifest_date date file1.manifest
|
||||
}
|
||||
test_ExtractManifestToStdout() {
|
||||
executeOk_servald rhizome export manifest $manifestid -
|
||||
assertStdoutLineCount '>=' 11
|
||||
assertStdoutLineCount '>=' 14
|
||||
local size=$(( $(cat file1 | wc -c) + 0 ))
|
||||
assertStdoutGrep --line=..11 --matches=1 "^service:file$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^manifestid:$manifestid\$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^version:$version\$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^\.rowid:$rowid\$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^\.inserttime:$rexp_date\$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --line=..11 --matches=1 "^\.readonly:0\$"
|
||||
assertStdoutGrep --line=12 --matches=1 "^manifest:"
|
||||
replayStdout | $SED -n '12s/^manifest://p' >file1x.manifest
|
||||
replayStdout | $SED -n '13,$p' >>file1x.manifest
|
||||
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
|
||||
cat file1.manifest >file1n.manifest
|
||||
echo >>file1n.manifest
|
||||
tfw_cat file1n.manifest file1x.manifest
|
||||
@ -405,17 +420,18 @@ setup_ExtractManifestAfterAddNoAuthor() {
|
||||
test_ExtractManifestAfterAddNoAuthor() {
|
||||
executeOk_servald rhizome export manifest $manifestid file1x.manifest
|
||||
assert diff file1.manifest file1x.manifest
|
||||
assertStdoutLineCount '==' 9
|
||||
assertStdoutLineCount '==' 10
|
||||
local size=$(( $(cat file1 | wc -c) + 0 ))
|
||||
assertStdoutGrep --matches=1 "^service:file$"
|
||||
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
||||
assertStdoutGrep --matches=1 "^version:$version\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^service:file\$"
|
||||
assertStdoutGrep --matches=1 "^name:file1\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:1\$"
|
||||
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
||||
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:1\$"
|
||||
}
|
||||
|
||||
doc_ExtractManifestNonExistent="Export non-existent manifest"
|
||||
@ -460,6 +476,7 @@ setup_ExtractFileAfterAdd() {
|
||||
extract_manifest_id manifestid file1.manifest
|
||||
extract_manifest_version version file1.manifest
|
||||
extract_manifest_filehash filehash file1.manifest
|
||||
extract_manifest_BK BK file1.manifest
|
||||
extract_manifest_date date file1.manifest
|
||||
}
|
||||
test_ExtractFileAfterAdd() {
|
||||
@ -467,18 +484,20 @@ test_ExtractFileAfterAdd() {
|
||||
tfw_cat --stderr
|
||||
assert diff file1 file1x
|
||||
local size=$(( $(cat file1 | wc -c) + 0 ))
|
||||
assertStdoutLineCount '==' 11
|
||||
assertStdoutGrep --matches=1 "^service:file$"
|
||||
assertStdoutLineCount '==' 13
|
||||
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
||||
assertStdoutGrep --matches=1 "^version:$version\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^BK:$BK\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^service:file\$"
|
||||
assertStdoutGrep --matches=1 "^name:file1\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
||||
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB1\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
}
|
||||
|
||||
doc_ExtractFileMissing="Extract and export non-existent file"
|
||||
@ -1056,6 +1075,7 @@ setup_ImportOwnBundle() {
|
||||
extract_manifest_id manifestid fileB.manifest
|
||||
extract_manifest_version version fileB.manifest
|
||||
extract_manifest_filehash filehash fileB.manifest
|
||||
extract_manifest_BK BK fileB.manifest
|
||||
extract_manifest_date date fileB.manifest
|
||||
rm -f $SERVALINSTANCE_PATH/rhizome.db
|
||||
executeOk_servald rhizome list
|
||||
@ -1072,19 +1092,21 @@ test_ImportOwnBundle() {
|
||||
tfw_cat --stderr
|
||||
assert cmp fileB.manifest fileBx.manifest
|
||||
assert cmp fileB fileBx
|
||||
assertStdoutLineCount '==' 11
|
||||
assertStdoutLineCount '==' 13
|
||||
local size=$(( $(cat fileB | wc -c) + 0 ))
|
||||
assertStdoutGrep --matches=1 "^service:file$"
|
||||
assertStdoutGrep --matches=1 "^manifestid:$manifestid\$"
|
||||
assertStdoutGrep --matches=1 "^version:$version\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^BK:$BK\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^service:file\$"
|
||||
assertStdoutGrep --matches=1 "^name:fileB\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB2\$"
|
||||
assertStdoutGrep --matches=1 "^\.rowid:$rowid\$"
|
||||
assertStdoutGrep --matches=1 "^\.inserttime:$rexp_date\$"
|
||||
assertStdoutGrep --matches=1 "^filehash:$filehash\$"
|
||||
assertStdoutGrep --matches=1 "^filesize:$size\$"
|
||||
assertStdoutGrep --matches=1 "^date:$date\$"
|
||||
assertStdoutGrep --matches=1 "^\.author:$SIDB2\$"
|
||||
assertStdoutGrep --matches=1 "^\.secret:$rexp_bundlesecret\$"
|
||||
assertStdoutGrep --matches=1 "^\.readonly:0\$"
|
||||
# Now bundle author should be known, so appears to be from here
|
||||
executeOk_servald rhizome list
|
||||
assert_rhizome_list --fromhere=1 --author=$SIDB2 fileB
|
||||
|
Loading…
x
Reference in New Issue
Block a user