mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-08 03:24:13 +00:00
Test RESTful Rhizome journal append with shared payload
When an append produces a payload that is already in the store, the append must succeed, and the returned status codes should indicate that the payload already existed
This commit is contained in:
parent
53e4e5be5f
commit
0f8141af95
@ -1039,6 +1039,40 @@ test_JournalAppend() {
|
||||
assert diff file filex
|
||||
}
|
||||
|
||||
doc_JournalAppendSharedPayload="Journal append produces a shared payload"
|
||||
setup_JournalAppendSharedPayload() {
|
||||
setup_servald
|
||||
setup_rhizome
|
||||
executeOk_servald config set rhizome.max_blob_size 0
|
||||
create_file file1 101
|
||||
>manifest1
|
||||
create_file file2 102
|
||||
>manifest2
|
||||
cat file1 file2 >file12
|
||||
executeOk_servald rhizome add file '' file1
|
||||
extract_stdout_filehash HASH1
|
||||
assert cmp file1 "$SERVALINSTANCE_PATH/blob/$HASH1"
|
||||
executeOk_servald rhizome add file '' file12
|
||||
extract_stdout_filehash HASH12
|
||||
assert cmp file12 "$SERVALINSTANCE_PATH/blob/$HASH12"
|
||||
assert [ $(ls "$SERVALINSTANCE_PATH/blob" | wc -l) -eq 2 ]
|
||||
}
|
||||
test_JournalAppendSharedPayload() {
|
||||
executeOk_servald rhizome journal append $SIDA "" file1
|
||||
tfw_cat --stdout --stderr
|
||||
assert_stdout_add_file file1
|
||||
extract_stdout_filehash addedhash
|
||||
assert [ $addedhash = $HASH1 ]
|
||||
assert [ $(ls "$SERVALINSTANCE_PATH/blob" | wc -l) -eq 2 ]
|
||||
extract_stdout_manifestid BID
|
||||
executeOk_servald rhizome journal append $SIDA $BID file2
|
||||
tfw_cat --stdout --stderr
|
||||
assert_stdout_add_file file12 !name
|
||||
extract_stdout_filehash addedhash
|
||||
assert [ $addedhash = $HASH12 ]
|
||||
assert [ $(ls "$SERVALINSTANCE_PATH/blob" | wc -l) -eq 2 ]
|
||||
}
|
||||
|
||||
doc_JournalAddCreate="Cannot create a journal using file add"
|
||||
setup_JournalAddCreate() {
|
||||
setup_servald
|
||||
|
@ -1250,6 +1250,66 @@ test_RhizomeJournalAppend() {
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Payload-Status-Code: 1$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Payload-Status-Message: .*payload new to store.*$CR\$"
|
||||
}
|
||||
|
||||
doc_RhizomeJournalAppendSharedPayload="HTTP RESTful Rhizome journal append with shared payload"
|
||||
setup_RhizomeJournalAppendSharedPayload() {
|
||||
set_extra_config() {
|
||||
executeOk_servald config set rhizome.max_blob_size 0
|
||||
}
|
||||
setup
|
||||
echo 'File one' >file1
|
||||
>manifest1
|
||||
echo 'File two two' >file2
|
||||
>manifest2
|
||||
cat file1 file2 >file12
|
||||
executeOk_servald rhizome add file '' file1
|
||||
extract_stdout_filehash HASH1
|
||||
assert cmp file1 "$SERVALINSTANCE_PATH/blob/$HASH1"
|
||||
executeOk_servald rhizome add file '' file12
|
||||
extract_stdout_filehash HASH12
|
||||
assert cmp file12 "$SERVALINSTANCE_PATH/blob/$HASH12"
|
||||
assert [ $(ls "$SERVALINSTANCE_PATH/blob" | wc -l) -eq 2 ]
|
||||
}
|
||||
test_RhizomeJournalAppendSharedPayload() {
|
||||
execute curl \
|
||||
--silent --show-error --write-out '%{http_code}' \
|
||||
--output file1.manifest \
|
||||
--dump-header http.header \
|
||||
--basic --user harry:potter \
|
||||
--form "bundle-author=$SIDA" \
|
||||
--form "manifest=@manifest1;type=rhizome/manifest;format=\"text+binarysig\"" \
|
||||
--form "payload=@file1" \
|
||||
"http://$addr_localhost:$PORTA/restful/rhizome/append"
|
||||
tfw_cat http.header file1.manifest
|
||||
assertExitStatus == 0
|
||||
assertStdoutIs 201
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Bundle-Filehash: $HASH1$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Bundle-Status-Code: 0$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Bundle-Status-Message: .*bundle new to store.*$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Payload-Status-Code: 2$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Payload-Status-Message: .*payload already in store.*$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Payload-Status-Message: .*payload already in store.*$CR\$"
|
||||
assert [ $(ls "$SERVALINSTANCE_PATH/blob" | wc -l) -eq 2 ]
|
||||
extract_http_header BID http.header Serval-Rhizome-Bundle-Id "$rexp_manifestid"
|
||||
execute curl \
|
||||
--silent --show-error --write-out '%{http_code}' \
|
||||
--output file2.manifest \
|
||||
--dump-header http.header \
|
||||
--basic --user harry:potter \
|
||||
--form "bundle-id=$BID" \
|
||||
--form "manifest=@manifest2;type=rhizome/manifest;format=\"text+binarysig\"" \
|
||||
--form "payload=@file2" \
|
||||
"http://$addr_localhost:$PORTA/restful/rhizome/append"
|
||||
tfw_cat http.header file2.manifest
|
||||
assertExitStatus == 0
|
||||
assertStdoutIs 201
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Bundle-Filehash: $HASH12$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Bundle-Status-Code: 0$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Bundle-Status-Message: .*bundle new to store.*$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Payload-Status-Code: 2$CR\$"
|
||||
assertGrep --matches=1 --ignore-case http.header "^Serval-Rhizome-Result-Payload-Status-Message: .*payload already in store.*$CR\$"
|
||||
assert [ $(ls "$SERVALINSTANCE_PATH/blob" | wc -l) -eq 2 ]
|
||||
}
|
||||
}
|
||||
|
||||
runTests "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user