- }
- assert_response :success
- assert_not_nil assigns(:object)
- resp = JSON.parse(@response.body)
- assert_equal manifest_uuid, resp['uuid']
- assert_equal 48, resp['data_size']
- # All of the locators in the output must be signed.
- resp['manifest_text'].lines.each do |entry|
- m = /([[:xdigit:]]{32}\+\S+)/.match(entry)
- if m
- assert Blob.verify_signature m[0], signing_opts
+ signed_locators = locators.collect do |x|
+ Blob.sign_locator x, signing_opts
+ end
+ if permit_unsigned
+ # Leave a non-empty blob unsigned.
+ signed_locators[1] = locators[1]
+ else
+ # Leave the empty blob unsigned. This should still be allowed.
+ signed_locators[0] = locators[0]
+ end
+ signed_manifest =
+ ". " + signed_locators[0] + " 0:0:foo.txt\n" +
+ ". " + signed_locators[1] + " 0:0:foo.txt\n" +
+ ". " + signed_locators[2] + " 0:0:foo.txt\n"
+
+ post :create, {
+ collection: {
+ manifest_text: signed_manifest,
+ uuid: manifest_uuid,
+ }
+ }
+ assert_response :success
+ assert_not_nil assigns(:object)
+ resp = JSON.parse(@response.body)
+ assert_equal manifest_uuid, resp['uuid']
+ assert_equal 48, resp['data_size']
+ # All of the locators in the output must be signed.
+ resp['manifest_text'].lines.each do |entry|
+ m = /([[:xdigit:]]{32}\+\S+)/.match(entry)
+ if m
+ assert Blob.verify_signature m[0], signing_opts
+ end