mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-30 16:13:51 +00:00
Test and fix rhizome clean verify
This commit is contained in:
parent
f06d9bb574
commit
2f60b8417f
@ -469,7 +469,7 @@ static int app_rhizome_delete(const struct cli_parsed *parsed, struct cli_contex
|
|||||||
|
|
||||||
DEFINE_CMD(app_rhizome_clean, 0,
|
DEFINE_CMD(app_rhizome_clean, 0,
|
||||||
"Remove stale and orphaned content from the Rhizome store",
|
"Remove stale and orphaned content from the Rhizome store",
|
||||||
"rhizome","clean","[verify]");
|
"rhizome","clean","[verify]" KEYRING_PIN_OPTIONS);
|
||||||
static int app_rhizome_clean(const struct cli_parsed *parsed, struct cli_context *context)
|
static int app_rhizome_clean(const struct cli_parsed *parsed, struct cli_context *context)
|
||||||
{
|
{
|
||||||
DEBUG_cli_parsed(verbose, parsed);
|
DEBUG_cli_parsed(verbose, parsed);
|
||||||
@ -481,8 +481,10 @@ static int app_rhizome_clean(const struct cli_parsed *parsed, struct cli_context
|
|||||||
if (rhizome_opendb() == -1)
|
if (rhizome_opendb() == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (verify)
|
if (verify){
|
||||||
|
keyring = keyring_open_instance_cli(parsed);
|
||||||
verify_bundles();
|
verify_bundles();
|
||||||
|
}
|
||||||
struct rhizome_cleanup_report report;
|
struct rhizome_cleanup_report report;
|
||||||
if (rhizome_cleanup(&report) == -1)
|
if (rhizome_cleanup(&report) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -156,11 +156,12 @@ static enum rhizome_bundle_authorship set_authentic(rhizome_manifest *m, const k
|
|||||||
* and finally update the database with the result.
|
* and finally update the database with the result.
|
||||||
*/
|
*/
|
||||||
static enum rhizome_bundle_authorship try_author(rhizome_manifest *m, const keyring_identity *id, const sid_t *sid){
|
static enum rhizome_bundle_authorship try_author(rhizome_manifest *m, const keyring_identity *id, const sid_t *sid){
|
||||||
assert(keyring != NULL);
|
|
||||||
if (!sid)
|
if (!sid)
|
||||||
return AUTHOR_UNKNOWN;
|
return AUTHOR_UNKNOWN;
|
||||||
|
|
||||||
if (!id){
|
if (!id){
|
||||||
|
if (!keyring)
|
||||||
|
return AUTHOR_UNKNOWN;
|
||||||
id = keyring_find_identity_sid(keyring, sid);
|
id = keyring_find_identity_sid(keyring, sid);
|
||||||
if (!id)
|
if (!id)
|
||||||
return AUTHOR_UNKNOWN;
|
return AUTHOR_UNKNOWN;
|
||||||
@ -230,7 +231,6 @@ static enum rhizome_bundle_authorship try_author(rhizome_manifest *m, const keyr
|
|||||||
void rhizome_authenticate_author(rhizome_manifest *m)
|
void rhizome_authenticate_author(rhizome_manifest *m)
|
||||||
{
|
{
|
||||||
IN();
|
IN();
|
||||||
assert(keyring != NULL);
|
|
||||||
DEBUGF(rhizome, "authenticate author for bid=%s", m->has_id ? alloca_tohex_rhizome_bid_t(m->keypair.public_key) : "(none)");
|
DEBUGF(rhizome, "authenticate author for bid=%s", m->has_id ? alloca_tohex_rhizome_bid_t(m->keypair.public_key) : "(none)");
|
||||||
switch (m->authorship) {
|
switch (m->authorship) {
|
||||||
case ANONYMOUS:
|
case ANONYMOUS:
|
||||||
@ -242,8 +242,8 @@ void rhizome_authenticate_author(rhizome_manifest *m)
|
|||||||
if (crypto_sign_to_sid(&m->keypair.public_key, &test_sid)==0){
|
if (crypto_sign_to_sid(&m->keypair.public_key, &test_sid)==0){
|
||||||
if (cmp_sid_t(&test_sid, &m->sender)==0){
|
if (cmp_sid_t(&test_sid, &m->sender)==0){
|
||||||
// self signed bundle, is it ours?
|
// self signed bundle, is it ours?
|
||||||
keyring_identity *id = keyring_find_identity(keyring, &m->keypair.public_key);
|
keyring_identity *id;
|
||||||
if (id){
|
if (keyring && (id = keyring_find_identity(keyring, &m->keypair.public_key))){
|
||||||
set_authentic(m, id, &m->sender);
|
set_authentic(m, id, &m->sender);
|
||||||
RETURNVOID;
|
RETURNVOID;
|
||||||
}else{
|
}else{
|
||||||
@ -259,6 +259,7 @@ void rhizome_authenticate_author(rhizome_manifest *m)
|
|||||||
if (m->has_sender && try_author(m, NULL, &m->sender) == AUTHOR_AUTHENTIC)
|
if (m->has_sender && try_author(m, NULL, &m->sender) == AUTHOR_AUTHENTIC)
|
||||||
RETURNVOID;
|
RETURNVOID;
|
||||||
|
|
||||||
|
if (keyring){
|
||||||
keyring_iterator it;
|
keyring_iterator it;
|
||||||
keyring_iterator_start(keyring, &it);
|
keyring_iterator_start(keyring, &it);
|
||||||
keyring_identity *id;
|
keyring_identity *id;
|
||||||
@ -269,6 +270,7 @@ void rhizome_authenticate_author(rhizome_manifest *m)
|
|||||||
if (try_author(m, id, id->box_pk) == AUTHOR_AUTHENTIC)
|
if (try_author(m, id, id->box_pk) == AUTHOR_AUTHENTIC)
|
||||||
RETURNVOID;
|
RETURNVOID;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RETURNVOID;
|
RETURNVOID;
|
||||||
|
|
||||||
|
@ -285,6 +285,32 @@ test_AddThenList() {
|
|||||||
assert_rhizome_list --fromhere=1 --author=$SIDA file1 file2
|
assert_rhizome_list --fromhere=1 --author=$SIDA file1 file2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doc_CleanVerify="Verify all bundles"
|
||||||
|
setup_CleanVerify() {
|
||||||
|
setup_servald
|
||||||
|
setup_rhizome
|
||||||
|
echo "File1" > file1
|
||||||
|
echo "File2" > file2
|
||||||
|
echo "File3" > file3
|
||||||
|
echo "File4" > file4
|
||||||
|
executeOk_servald rhizome add file '' file1 file1.manifest
|
||||||
|
assert_stdout_add_file file1 !.author !BK
|
||||||
|
executeOk_servald rhizome add file '' file2 file2.manifest
|
||||||
|
assert_stdout_add_file file2 !.author !BK
|
||||||
|
executeOk_servald rhizome add file '' file3 file3.manifest
|
||||||
|
assert_stdout_add_file file3 !.author !BK
|
||||||
|
executeOk_servald rhizome add file '' file4 file4.manifest
|
||||||
|
assert_stdout_add_file file4 !.author !BK
|
||||||
|
executeOk_servald rhizome list file
|
||||||
|
assert_rhizome_list file1 file2 file3 file4
|
||||||
|
}
|
||||||
|
test_CleanVerify() {
|
||||||
|
executeOk_servald rhizome clean verify
|
||||||
|
tfw_cat --stdout --stderr
|
||||||
|
executeOk_servald rhizome list file
|
||||||
|
assert_rhizome_list file1 file2 file3 file4
|
||||||
|
}
|
||||||
|
|
||||||
doc_ExtractManifestAfterAdd="Export manifest after one add"
|
doc_ExtractManifestAfterAdd="Export manifest after one add"
|
||||||
setup_ExtractManifestAfterAdd() {
|
setup_ExtractManifestAfterAdd() {
|
||||||
setup_servald
|
setup_servald
|
||||||
|
Loading…
x
Reference in New Issue
Block a user