change diaspora_id to author

see #29
This commit is contained in:
Benjamin Neff 2016-02-10 03:17:10 +01:00
parent 1c2e2f560d
commit 5ebda543a1
71 changed files with 209 additions and 273 deletions

View file

@ -47,7 +47,6 @@ module DiasporaFederation
# @!attribute [r] nickname
# the first part of the diaspora ID
# @see Entities::Person#diaspora_id
# @return [String] nickname
property :nickname

View file

@ -4,11 +4,11 @@ module DiasporaFederation
#
# @see Validators::AccountDeletionValidator
class AccountDeletion < Entity
# @!attribute [r] diaspora_id
# @!attribute [r] author
# The diaspora ID of the deleted account
# @see Person#diaspora_id
# @see Person#author
# @return [String] diaspora ID
property :diaspora_id, xml_name: :diaspora_handle
property :author, xml_name: :diaspora_handle
end
end
end

View file

@ -6,7 +6,7 @@ module DiasporaFederation
class Comment < Entity
# old signature order
# @deprecated
LEGACY_SIGNATURE_ORDER = %i(guid parent_guid text diaspora_id).freeze
LEGACY_SIGNATURE_ORDER = %i(guid parent_guid text author).freeze
include Relayable

View file

@ -22,17 +22,16 @@ module DiasporaFederation
# @return [[Entities::Message]] Messages of this conversation
entity :messages, [Entities::Message]
# @!attribute [r] diaspora_id
# @!attribute [r] author
# The diaspora ID of the person initiated the conversation.
# @see Person#diaspora_id
# @see Person#author
# @return [String] diaspora ID
property :diaspora_id, xml_name: :diaspora_handle
property :author, xml_name: :diaspora_handle
# @!attribute [r] participant_ids
# @!attribute [r] participants
# The diaspora IDs of the persons participating the conversation separated by ";".
# @see Person#diaspora_id
# @return [String] participants diaspora IDs
property :participant_ids, xml_name: :participant_handles
property :participants, xml_name: :participant_handles
end
end
end

View file

@ -6,7 +6,7 @@ module DiasporaFederation
class Like < Entity
# old signature order
# @deprecated
LEGACY_SIGNATURE_ORDER = %i(positive guid parent_type parent_guid diaspora_id).freeze
LEGACY_SIGNATURE_ORDER = %i(positive guid parent_type parent_guid author).freeze
include Relayable

View file

@ -6,7 +6,7 @@ module DiasporaFederation
class Message < Entity
# old signature order
# @deprecated
LEGACY_SIGNATURE_ORDER = %i(guid parent_guid text created_at diaspora_id conversation_guid).freeze
LEGACY_SIGNATURE_ORDER = %i(guid parent_guid text created_at author conversation_guid).freeze
include Relayable

View file

@ -6,7 +6,7 @@ module DiasporaFederation
class Participation < Entity
# old signature order
# @deprecated
LEGACY_SIGNATURE_ORDER = %i(guid parent_type parent_guid diaspora_id).freeze
LEGACY_SIGNATURE_ORDER = %i(guid parent_type parent_guid author).freeze
include Relayable

View file

@ -11,11 +11,11 @@ module DiasporaFederation
# @return [String] guid
property :guid
# @!attribute [r] diaspora_id
# @!attribute [r] author
# The diaspora ID of the person
# @see Validation::Rule::DiasporaId
# @return [String] diaspora ID
property :diaspora_id, xml_name: :diaspora_handle
property :author, xml_name: :diaspora_handle
# @!attribute [r] url
# @see Discovery::WebFinger#seed_url

View file

@ -10,11 +10,11 @@ module DiasporaFederation
# @return [String] guid
property :guid
# @!attribute [r] diaspora_id
# @!attribute [r] author
# The diaspora ID of the person who uploaded the photo
# @see Person#diaspora_id
# @see Person#author
# @return [String] author diaspora ID
property :diaspora_id, xml_name: :diaspora_handle
property :author, xml_name: :diaspora_handle
# @!attribute [r] public
# Points if the photo is visible to everyone or only to some aspects

View file

@ -6,7 +6,7 @@ module DiasporaFederation
class PollParticipation < Entity
# old signature order
# @deprecated
LEGACY_SIGNATURE_ORDER = %i(guid parent_guid diaspora_id poll_answer_guid).freeze
LEGACY_SIGNATURE_ORDER = %i(guid parent_guid author poll_answer_guid).freeze
include Relayable

View file

@ -4,11 +4,11 @@ module DiasporaFederation
#
# @see Validators::ProfileValidator
class Profile < Entity
# @!attribute [r] diaspora_id
# @!attribute [r] author
# The diaspora ID of the person
# @see Person#diaspora_id
# @see Person#author
# @return [String] diaspora ID
property :diaspora_id, xml_name: :diaspora_handle
property :author, xml_name: :diaspora_handle
# @!attribute [r] first_name
# @deprecated We decided to only use one name field, these should be removed

View file

@ -12,9 +12,9 @@ module DiasporaFederation
# on inclusion of this module the required properties for a relayable are added to the object that includes it
#
# @!attribute [r] diaspora_id
# @!attribute [r] author
# The diaspora ID of the author.
# @see Person#diaspora_id
# @see Person#author
# @return [String] diaspora ID
#
# @!attribute [r] guid
@ -43,7 +43,7 @@ module DiasporaFederation
# @param [Entity] entity the entity in which it is included
def self.included(entity)
entity.class_eval do
property :diaspora_id, xml_name: :diaspora_handle
property :author, xml_name: :diaspora_handle
property :guid
property :parent_guid
property :author_signature, default: nil
@ -59,10 +59,10 @@ module DiasporaFederation
def to_signed_h
to_h.tap do |hash|
if author_signature.nil?
privkey = DiasporaFederation.callbacks.trigger(:fetch_private_key_by_diaspora_id, diaspora_id)
raise AuthorPrivateKeyNotFound, "author=#{diaspora_id} guid=#{guid}" if privkey.nil?
privkey = DiasporaFederation.callbacks.trigger(:fetch_private_key_by_diaspora_id, author)
raise AuthorPrivateKeyNotFound, "author=#{author} guid=#{guid}" if privkey.nil?
hash[:author_signature] = sign_with_key(privkey, hash)
logger.info "event=sign status=complete signature=author_signature author=#{diaspora_id} guid=#{guid}"
logger.info "event=sign status=complete signature=author_signature author=#{author} guid=#{guid}"
end
try_sign_with_parent_author(hash) if parent_author_signature.nil?
@ -85,8 +85,8 @@ module DiasporaFederation
# verifies the signatures (+author_signature+ and +parent_author_signature+ if needed)
# @raise [SignatureVerificationFailed] if the signature is not valid or no public key is found
def verify_signatures
pubkey = DiasporaFederation.callbacks.trigger(:fetch_public_key_by_diaspora_id, diaspora_id)
raise PublicKeyNotFound, "author_signature author=#{diaspora_id} guid=#{guid}" if pubkey.nil?
pubkey = DiasporaFederation.callbacks.trigger(:fetch_public_key_by_diaspora_id, author)
raise PublicKeyNotFound, "author_signature author=#{author} guid=#{guid}" if pubkey.nil?
raise SignatureVerificationFailed, "wrong author_signature" unless verify_signature(pubkey, author_signature)
parent_author_local = DiasporaFederation.callbacks.trigger(:entity_author_is_local?, parent_type, parent_guid)

View file

@ -38,11 +38,11 @@ module DiasporaFederation
# @return [String] target type
property :target_type
# @!attribute [r] diaspora_id
# @!attribute [r] author
# The diaspora ID of the person who deletes a relayable
# @see Person#diaspora_id
# @see Person#author
# @return [String] diaspora ID
property :diaspora_id, xml_name: :sender_handle
property :author, xml_name: :sender_handle
# @!attribute [r] target_author_signature
# Contains a signature of the entity using the private key of the
@ -71,7 +71,7 @@ module DiasporaFederation
# @return [Hash] entity data hash with updated signatures
def to_h
target_author = DiasporaFederation.callbacks.trigger(:fetch_entity_author_id_by_guid, target_type, target_guid)
privkey = DiasporaFederation.callbacks.trigger(:fetch_private_key_by_diaspora_id, diaspora_id)
privkey = DiasporaFederation.callbacks.trigger(:fetch_private_key_by_diaspora_id, author)
super.tap do |hash|
fill_required_signature(target_author, privkey, hash) unless privkey.nil?
@ -81,7 +81,7 @@ module DiasporaFederation
# use only {Retraction} for receive
# @return [Retraction] instance as normal retraction
def to_retraction
Retraction.new(diaspora_id: diaspora_id, target_guid: target_guid, target_type: target_type)
Retraction.new(author: author, target_guid: target_guid, target_type: target_type)
end
private
@ -90,9 +90,9 @@ module DiasporaFederation
# @param [OpenSSL::PKey::RSA] privkey private key of sender
# @param [Hash] hash hash given for a signing
def fill_required_signature(target_author, privkey, hash)
if target_author == diaspora_id && target_author_signature.nil?
if target_author == author && target_author_signature.nil?
hash[:target_author_signature] = SignedRetraction.sign_with_key(privkey, self)
elsif target_author != diaspora_id && parent_author_signature.nil?
elsif target_author != author && parent_author_signature.nil?
hash[:parent_author_signature] = SignedRetraction.sign_with_key(privkey, self)
end
end

View file

@ -5,17 +5,17 @@ module DiasporaFederation
#
# @see Validators::RequestValidator
class Request < Entity
# @!attribute [r] diaspora_id
# @!attribute [r] author
# The diaspora ID of the person who shares his profile
# @see Person#diaspora_id
# @see Person#author
# @return [String] sender ID
property :diaspora_id, xml_name: :sender_handle
property :author, xml_name: :sender_handle
# @!attribute [r] recipient_id
# @!attribute [r] recipient
# The diaspora ID of the person who will be shared with
# @see Person#diaspora_id
# @see Validation::Rule::DiasporaId
# @return [String] recipient ID
property :recipient_id, xml_name: :recipient_handle
property :recipient, xml_name: :recipient_handle
end
end
end

View file

@ -4,11 +4,11 @@ module DiasporaFederation
#
# @see Validators::ReshareValidator
class Reshare < Entity
# @!attribute [r] diaspora_id
# @!attribute [r] root_author
# The diaspora ID of the person who posted the original post
# @see Person#diaspora_id
# @see Person#author
# @return [String] diaspora ID
property :root_diaspora_id # inconsistent, everywhere else it's "handle"
property :root_author, xml_name: :root_diaspora_id
# @!attribute [r] root_guid
# guid of the original post
@ -16,6 +16,12 @@ module DiasporaFederation
# @return [String] root guid
property :root_guid
# @!attribute [r] author
# The diaspora ID of the person who reshares a post
# @see Person#author
# @return [String] diaspora ID
property :author, xml_name: :diaspora_handle
# @!attribute [r] guid
# a random string of at least 16 chars.
# @see Validation::Rule::Guid
@ -23,12 +29,6 @@ module DiasporaFederation
# @return [String] guid
property :guid
# @!attribute [r] diaspora_id
# The diaspora ID of the person who reshares a post
# @see Person#diaspora_id
# @return [String] diaspora ID
property :diaspora_id, xml_name: :diaspora_handle
# @!attribute [r] public
# has no meaning at the moment
# @return [Boolean] public

View file

@ -4,17 +4,17 @@ module DiasporaFederation
#
# @see Validators::RetractionValidator
class Retraction < Entity
# @!attribute [r] author
# The diaspora ID of the person who deletes the entity
# @see Person#author
# @return [String] diaspora ID
property :author, xml_name: :diaspora_handle
# @!attribute [r] target_guid
# guid of the entity to be deleted
# @return [String] target guid
property :target_guid, xml_name: :post_guid
# @!attribute [r] diaspora_id
# The diaspora ID of the person who deletes the entity
# @see Person#diaspora_id
# @return [String] diaspora ID
property :diaspora_id, xml_name: :diaspora_handle
# @!attribute [r] target_type
# A string describing the type of the target.
# @return [String] target type

View file

@ -18,11 +18,11 @@ module DiasporaFederation
# @return [String] target type
property :target_type
# @!attribute [r] diaspora_id
# @!attribute [r] author
# The diaspora ID of the person who deletes a post
# @see Person#diaspora_id
# @see Person#author
# @return [String] diaspora ID
property :diaspora_id, xml_name: :sender_handle
property :author, xml_name: :sender_handle
# @!attribute [r] author_signature
# Contains a signature of the entity using the private key of the author of a post
@ -47,7 +47,7 @@ module DiasporaFederation
def to_h
super.tap do |hash|
if target_author_signature.nil?
privkey = DiasporaFederation.callbacks.trigger(:fetch_private_key_by_diaspora_id, diaspora_id)
privkey = DiasporaFederation.callbacks.trigger(:fetch_private_key_by_diaspora_id, author)
hash[:target_author_signature] = SignedRetraction.sign_with_key(privkey, self) unless privkey.nil?
end
end
@ -56,7 +56,7 @@ module DiasporaFederation
# use only {Retraction} for receive
# @return [Retraction] instance as normal retraction
def to_retraction
Retraction.new(diaspora_id: diaspora_id, target_guid: target_guid, target_type: target_type)
Retraction.new(author: author, target_guid: target_guid, target_type: target_type)
end
# Create signature for a retraction

View file

@ -4,6 +4,18 @@ module DiasporaFederation
#
# @see Validators::StatusMessageValidator
class StatusMessage < Entity
# @!attribute [r] author
# The diaspora ID of the person who posts the status message
# @see Person#author
# @return [String] diaspora ID
property :author, xml_name: :diaspora_handle
# @!attribute [r] guid
# a random string of at least 16 chars.
# @see Validation::Rule::Guid
# @return [String] status message guid
property :guid
# @!attribute [r] raw_message
# text of the status message composed by the user
# @return [String] text of the status message
@ -24,18 +36,6 @@ module DiasporaFederation
# @return [Entities::Poll] poll
entity :poll, Entities::Poll, default: nil
# @!attribute [r] guid
# a random string of at least 16 chars.
# @see Validation::Rule::Guid
# @return [String] status message guid
property :guid
# @!attribute [r] diaspora_id
# The diaspora ID of the person who posts the status message
# @see Person#diaspora_id
# @return [String] diaspora ID
property :diaspora_id, xml_name: :diaspora_handle
# @!attribute [r] public
# shows whether the status message is visible to everyone or only to some aspects
# @return [Boolean] is it public

View file

@ -42,16 +42,16 @@ module DiasporaFederation
factory :person_entity, class: DiasporaFederation::Entities::Person do
guid
diaspora_id
author { generate(:diaspora_id) }
url "http://localhost:3000/"
exported_key { generate(:public_key) }
profile {
FactoryGirl.build(:profile_entity, diaspora_id: diaspora_id)
FactoryGirl.build(:profile_entity, author: author)
}
end
factory :profile_entity, class: DiasporaFederation::Entities::Profile do
diaspora_id
author { generate(:diaspora_id) }
first_name "my name"
last_name nil
image_url "/assets/user/default.png"
@ -74,7 +74,7 @@ module DiasporaFederation
factory :photo_entity, class: DiasporaFederation::Entities::Photo do
guid
diaspora_id
author { generate(:diaspora_id) }
public(true)
created_at { Time.now.utc }
remote_photo_path "https://diaspora.example.tld/uploads/images/"
@ -91,84 +91,84 @@ module DiasporaFederation
factory :participation_entity,
class: DiasporaFederation::Entities::Participation, parent: :relayable_entity do
author { generate(:diaspora_id) }
guid
parent_type "Post"
diaspora_id
end
factory :status_message_entity, class: DiasporaFederation::Entities::StatusMessage do
raw_message "i am a very interesting status update"
author { generate(:diaspora_id) }
guid
diaspora_id
public(true)
created_at { Time.now.utc }
end
factory :request_entity, class: DiasporaFederation::Entities::Request do
diaspora_id
recipient_id { generate(:diaspora_id) }
author { generate(:diaspora_id) }
recipient { generate(:diaspora_id) }
end
factory :comment_entity, class: DiasporaFederation::Entities::Comment, parent: :relayable_entity do
author { generate(:diaspora_id) }
guid
text "this is a very informative comment"
diaspora_id
end
factory :like_entity, class: DiasporaFederation::Entities::Like, parent: :relayable_entity do
positive true
author { generate(:diaspora_id) }
guid
parent_type "Post"
diaspora_id
end
factory :account_deletion_entity, class: DiasporaFederation::Entities::AccountDeletion do
diaspora_id
author { generate(:diaspora_id) }
end
factory :conversation_entity, class: DiasporaFederation::Entities::Conversation do
author { generate(:diaspora_id) }
guid
subject "this is a very informative subject"
created_at { Time.now.utc }
messages []
diaspora_id
participant_ids { Array.new(3) { generate(:diaspora_id) }.join(";") }
participants { Array.new(3) { generate(:diaspora_id) }.join(";") }
end
factory :message_entity, class: DiasporaFederation::Entities::Message, parent: :relayable_entity do
guid
author { generate(:diaspora_id) }
text "this is a very informative text"
created_at { Time.now.utc }
diaspora_id
conversation_guid { generate(:guid) }
end
factory :relayable_retraction_entity, class: DiasporaFederation::Entities::RelayableRetraction do
author { generate(:diaspora_id) }
target_guid { generate(:guid) }
target_type "Comment"
diaspora_id
end
factory :reshare_entity, class: DiasporaFederation::Entities::Reshare do
root_diaspora_id { generate(:diaspora_id) }
root_author { generate(:diaspora_id) }
root_guid { generate(:guid) }
guid
diaspora_id
author { generate(:diaspora_id) }
public(true)
created_at { Time.now.utc }
provider_display_name { "the testsuite" }
end
factory :retraction_entity, class: DiasporaFederation::Entities::Retraction do
author { generate(:diaspora_id) }
target_guid { generate(:guid) }
diaspora_id
target_type "Post"
end
factory :signed_retraction_entity, class: DiasporaFederation::Entities::SignedRetraction do
author { generate(:diaspora_id) }
target_guid { generate(:guid) }
target_type "Post"
diaspora_id
end
factory :poll_answer_entity, class: DiasporaFederation::Entities::PollAnswer do
@ -184,8 +184,8 @@ module DiasporaFederation
factory :poll_participation_entity,
class: DiasporaFederation::Entities::PollParticipation, parent: :relayable_entity do
author { generate(:diaspora_id) }
guid
diaspora_id
poll_answer_guid { generate(:guid) }
end
end

View file

@ -4,7 +4,7 @@ module DiasporaFederation
class AccountDeletionValidator < Validation::Validator
include Validation
rule :diaspora_id, %i(not_empty diaspora_id)
rule :author, %i(not_empty diaspora_id)
end
end
end

View file

@ -4,14 +4,10 @@ module DiasporaFederation
class CommentValidator < Validation::Validator
include Validation
rule :guid, :guid
include RelayableValidator
rule :text, [:not_empty,
length: {maximum: 65_535}]
rule :diaspora_id, %i(not_empty diaspora_id)
end
end
end

View file

@ -6,9 +6,9 @@ module DiasporaFederation
rule :guid, :guid
rule :diaspora_id, %i(not_empty diaspora_id)
rule :author, %i(not_empty diaspora_id)
rule :participant_ids, diaspora_id_count: {maximum: 20}
rule :participants, diaspora_id_count: {maximum: 20}
end
end
end

View file

@ -4,13 +4,9 @@ module DiasporaFederation
class LikeValidator < Validation::Validator
include Validation
rule :guid, :guid
rule :parent_type, [:not_empty, regular_expression: {regex: /\A(Post|Comment)\z/}]
include RelayableValidator
rule :diaspora_id, %i(not_empty diaspora_id)
rule :parent_type, [:not_empty, regular_expression: {regex: /\A(Post|Comment)\z/}]
end
end
end

View file

@ -4,12 +4,8 @@ module DiasporaFederation
class MessageValidator < Validation::Validator
include Validation
rule :guid, :guid
include RelayableValidator
rule :diaspora_id, %i(not_empty diaspora_id)
rule :conversation_guid, :guid
end
end

View file

@ -4,13 +4,9 @@ module DiasporaFederation
class ParticipationValidator < Validation::Validator
include Validation
rule :guid, :guid
rule :parent_type, [:not_empty, regular_expression: {regex: /\APost\z/}]
include RelayableValidator
rule :diaspora_id, %i(not_empty diaspora_id)
rule :parent_type, [:not_empty, regular_expression: {regex: /\APost\z/}]
end
end
end

View file

@ -6,7 +6,7 @@ module DiasporaFederation
rule :guid, :guid
rule :diaspora_id, %i(not_empty diaspora_id)
rule :author, %i(not_empty diaspora_id)
rule :url, %i(not_nil URI)

View file

@ -6,7 +6,7 @@ module DiasporaFederation
rule :guid, :guid
rule :diaspora_id, %i(not_empty diaspora_id)
rule :author, %i(not_empty diaspora_id)
rule :public, :boolean

View file

@ -4,12 +4,8 @@ module DiasporaFederation
class PollParticipationValidator < Validation::Validator
include Validation
rule :guid, :guid
include RelayableValidator
rule :diaspora_id, %i(not_empty diaspora_id)
rule :poll_answer_guid, :guid
end
end

View file

@ -4,7 +4,7 @@ module DiasporaFederation
class ProfileValidator < Validation::Validator
include Validation
rule :diaspora_id, :diaspora_id
rule :author, :diaspora_id
# the name must not contain a semicolon because of mentions
# @{<full_name> ; <diaspora_id>}

View file

@ -9,7 +9,7 @@ module DiasporaFederation
rule :target_type, :not_empty
rule :diaspora_id, %i(not_empty diaspora_id)
rule :author, %i(not_empty diaspora_id)
end
end
end

View file

@ -6,6 +6,8 @@ module DiasporaFederation
# @param [Validation::Validator] validator the validator in which it is included
def self.included(validator)
validator.class_eval do
rule :author, %i(not_empty diaspora_id)
rule :guid, :guid
rule :parent_guid, :guid
end
end

View file

@ -4,8 +4,8 @@ module DiasporaFederation
class RequestValidator < Validation::Validator
include Validation
rule :diaspora_id, %i(not_empty diaspora_id)
rule :recipient_id, %i(not_empty diaspora_id)
rule :author, %i(not_empty diaspora_id)
rule :recipient, %i(not_empty diaspora_id)
end
end
end

View file

@ -4,13 +4,13 @@ module DiasporaFederation
class ReshareValidator < Validation::Validator
include Validation
rule :root_diaspora_id, %i(not_empty diaspora_id)
rule :root_author, %i(not_empty diaspora_id)
rule :root_guid, :guid
rule :guid, :guid
rule :author, %i(not_empty diaspora_id)
rule :diaspora_id, %i(not_empty diaspora_id)
rule :guid, :guid
rule :public, :boolean
end

View file

@ -4,9 +4,9 @@ module DiasporaFederation
class RetractionValidator < Validation::Validator
include Validation
rule :target_guid, :guid
rule :author, %i(not_empty diaspora_id)
rule :diaspora_id, %i(not_empty diaspora_id)
rule :target_guid, :guid
rule :target_type, :not_empty
end

View file

@ -9,7 +9,7 @@ module DiasporaFederation
rule :target_type, :not_empty
rule :diaspora_id, %i(not_empty diaspora_id)
rule :author, %i(not_empty diaspora_id)
end
end
end

View file

@ -4,9 +4,9 @@ module DiasporaFederation
class StatusMessageValidator < Validation::Validator
include Validation
rule :guid, :guid
rule :author, %i(not_empty diaspora_id)
rule :diaspora_id, %i(not_empty diaspora_id)
rule :guid, :guid
rule :public, :boolean
end

View file

@ -5,7 +5,7 @@ module DiasporaFederation
let(:xml) {
<<-XML
<account_deletion>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<diaspora_handle>#{data[:author]}</diaspora_handle>
</account_deletion>
XML
}

View file

@ -1,14 +1,12 @@
module DiasporaFederation
describe Entities::Comment do
let(:parent) { FactoryGirl.create(:post, author: bob) }
let(:data) {
FactoryGirl.build(:comment_entity, diaspora_id: alice.diaspora_id, parent_guid: parent.guid).to_signed_h
}
let(:data) { FactoryGirl.build(:comment_entity, author: alice.diaspora_id, parent_guid: parent.guid).to_signed_h }
let(:xml) {
<<-XML
<comment>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{data[:guid]}</guid>
<parent_guid>#{parent.guid}</parent_guid>
<author_signature>#{data[:author_signature]}</author_signature>

View file

@ -2,19 +2,19 @@ module DiasporaFederation
describe Entities::Conversation do
let(:parent) { FactoryGirl.create(:conversation, author: bob) }
let(:signed_msg1) {
msg = FactoryGirl.build(:message_entity, diaspora_id: alice.diaspora_id, parent_guid: parent.guid).to_signed_h
msg = FactoryGirl.build(:message_entity, author: alice.diaspora_id, parent_guid: parent.guid).to_signed_h
Entities::Message.new(msg)
}
let(:signed_msg2) {
msg = FactoryGirl.build(:message_entity, diaspora_id: alice.diaspora_id, parent_guid: parent.guid).to_signed_h
msg = FactoryGirl.build(:message_entity, author: alice.diaspora_id, parent_guid: parent.guid).to_signed_h
Entities::Message.new(msg)
}
let(:data) {
FactoryGirl.attributes_for(:conversation_entity).merge!(
messages: [signed_msg1, signed_msg2],
diaspora_id: bob.diaspora_id,
guid: parent.guid,
participant_ids: "#{bob.diaspora_id};#{FactoryGirl.generate(:diaspora_id)}"
messages: [signed_msg1, signed_msg2],
author: bob.diaspora_id,
guid: parent.guid,
participants: "#{bob.diaspora_id};#{FactoryGirl.generate(:diaspora_id)}"
)
}
@ -25,8 +25,8 @@ module DiasporaFederation
<subject>#{data[:subject]}</subject>
<created_at>#{data[:created_at]}</created_at>
#{data[:messages].map {|a| a.to_xml.to_s.indent(2) }.join("\n")}
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<participant_handles>#{data[:participant_ids]}</participant_handles>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<participant_handles>#{data[:participants]}</participant_handles>
</conversation>
XML
}

View file

@ -4,7 +4,7 @@ module DiasporaFederation
let(:data) {
FactoryGirl.build(
:like_entity,
diaspora_id: alice.diaspora_id,
author: alice.diaspora_id,
parent_guid: parent.guid,
parent_type: parent.entity_type
).to_signed_h
@ -13,7 +13,7 @@ module DiasporaFederation
let(:xml) {
<<-XML
<like>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{data[:guid]}</guid>
<parent_guid>#{parent.guid}</parent_guid>
<author_signature>#{data[:author_signature]}</author_signature>

View file

@ -1,14 +1,12 @@
module DiasporaFederation
describe Entities::Message do
let(:parent) { FactoryGirl.create(:conversation, author: bob) }
let(:data) {
FactoryGirl.build(:message_entity, diaspora_id: alice.diaspora_id, parent_guid: parent.guid).to_signed_h
}
let(:data) { FactoryGirl.build(:message_entity, author: alice.diaspora_id, parent_guid: parent.guid).to_signed_h }
let(:xml) {
<<-XML
<message>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{data[:guid]}</guid>
<parent_guid>#{parent.guid}</parent_guid>
<author_signature>#{data[:author_signature]}</author_signature>

View file

@ -4,7 +4,7 @@ module DiasporaFederation
let(:data) {
FactoryGirl.build(
:participation_entity,
diaspora_id: alice.diaspora_id,
author: alice.diaspora_id,
parent_guid: parent.guid,
parent_type: parent.entity_type
).to_signed_h
@ -13,7 +13,7 @@ module DiasporaFederation
let(:xml) {
<<-XML
<participation>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{data[:guid]}</guid>
<parent_guid>#{parent.guid}</parent_guid>
<author_signature>#{data[:author_signature]}</author_signature>

View file

@ -6,10 +6,10 @@ module DiasporaFederation
<<-XML
<person>
<guid>#{data[:guid]}</guid>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<url>#{data[:url]}</url>
<profile>
<diaspora_handle>#{data[:profile].diaspora_id}</diaspora_handle>
<diaspora_handle>#{data[:profile].author}</diaspora_handle>
<first_name>#{data[:profile].first_name}</first_name>
<last_name/>
<image_url>#{data[:profile].image_url}</image_url>

View file

@ -6,7 +6,7 @@ module DiasporaFederation
<<-XML
<photo>
<guid>#{data[:guid]}</guid>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<public>#{data[:public]}</public>
<created_at>#{data[:created_at]}</created_at>
<remote_photo_path>#{data[:remote_photo_path]}</remote_photo_path>

View file

@ -2,17 +2,13 @@ module DiasporaFederation
describe Entities::PollParticipation do
let(:parent) { FactoryGirl.create(:poll, author: bob) }
let(:data) {
FactoryGirl.build(
:poll_participation_entity,
diaspora_id: alice.diaspora_id,
parent_guid: parent.guid
).to_signed_h
FactoryGirl.build(:poll_participation_entity, author: alice.diaspora_id, parent_guid: parent.guid).to_signed_h
}
let(:xml) {
<<-XML
<poll_participation>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{data[:guid]}</guid>
<parent_guid>#{parent.guid}</parent_guid>
<author_signature>#{data[:author_signature]}</author_signature>

View file

@ -5,7 +5,7 @@ module DiasporaFederation
let(:xml) {
<<-XML
<profile>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<first_name>#{data[:first_name]}</first_name>
<last_name/>
<image_url>#{data[:image_url]}</image_url>

View file

@ -1,6 +1,6 @@
module DiasporaFederation
describe Entities::RelayableRetraction do
let(:data) { FactoryGirl.build(:relayable_retraction_entity, diaspora_id: alice.diaspora_id).to_h }
let(:data) { FactoryGirl.build(:relayable_retraction_entity, author: alice.diaspora_id).to_h }
let(:xml) {
<<-XML
@ -8,7 +8,7 @@ module DiasporaFederation
<parent_author_signature>#{data[:parent_author_signature]}</parent_author_signature>
<target_guid>#{data[:target_guid]}</target_guid>
<target_type>#{data[:target_type]}</target_type>
<sender_handle>#{data[:diaspora_id]}</sender_handle>
<sender_handle>#{data[:author]}</sender_handle>
<target_author_signature/>
</relayable_retraction>
XML
@ -25,10 +25,10 @@ XML
it "updates author signature when it was nil and key was supplied" do
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_entity_author_id_by_guid, hash[:target_type], hash[:target_guid]
).and_return(hash[:diaspora_id])
).and_return(hash[:author])
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_private_key_by_diaspora_id, hash[:diaspora_id]
:fetch_private_key_by_diaspora_id, hash[:author]
).and_return(author_pkey)
signed_string = "#{hash[:target_guid]};#{hash[:target_type]}"
@ -45,7 +45,7 @@ XML
).and_return(FactoryGirl.generate(:diaspora_id))
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_private_key_by_diaspora_id, hash[:diaspora_id]
:fetch_private_key_by_diaspora_id, hash[:author]
).and_return(author_pkey)
signed_string = "#{hash[:target_guid]};#{hash[:target_type]}"
@ -64,12 +64,12 @@ XML
it "doesn't change signatures if keys weren't supplied" do
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_private_key_by_diaspora_id, hash[:diaspora_id]
:fetch_private_key_by_diaspora_id, hash[:author]
).and_return(nil)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_entity_author_id_by_guid, "Comment", hash[:target_guid]
).and_return(hash[:diaspora_id])
).and_return(hash[:author])
signed_hash = Entities::RelayableRetraction.new(hash).to_h
expect(signed_hash[:target_author_signature]).to eq(nil)
@ -82,7 +82,7 @@ XML
retraction = relayable_retraction.to_retraction
expect(retraction).to be_a(Entities::Retraction)
expect(retraction.diaspora_id).to eq(relayable_retraction.diaspora_id)
expect(retraction.author).to eq(relayable_retraction.author)
expect(retraction.target_guid).to eq(relayable_retraction.target_guid)
expect(retraction.target_type).to eq(relayable_retraction.target_type)
end

View file

@ -5,17 +5,17 @@ module DiasporaFederation
let(:guid) { FactoryGirl.generate(:guid) }
let(:parent_guid) { FactoryGirl.generate(:guid) }
let(:diaspora_id) { FactoryGirl.generate(:diaspora_id) }
let(:author) { FactoryGirl.generate(:diaspora_id) }
let(:property) { "hello" }
let(:new_property) { "some text" }
let(:hash) { {guid: guid, diaspora_id: diaspora_id, parent_guid: parent_guid, property: property} }
let(:hash) { {guid: guid, author: author, parent_guid: parent_guid, property: property} }
let(:signature_data) { "#{diaspora_id};#{guid};#{parent_guid};#{property}" }
let(:signature_data_with_new_property) { "#{diaspora_id};#{guid};#{new_property};#{parent_guid};#{property}" }
let(:legacy_signature_data) { "#{guid};#{diaspora_id};#{property};#{parent_guid}" }
let(:signature_data) { "#{author};#{guid};#{parent_guid};#{property}" }
let(:signature_data_with_new_property) { "#{author};#{guid};#{new_property};#{parent_guid};#{property}" }
let(:legacy_signature_data) { "#{guid};#{author};#{property};#{parent_guid}" }
class SomeRelayable < Entity
LEGACY_SIGNATURE_ORDER = %i(guid diaspora_id property parent_guid).freeze
LEGACY_SIGNATURE_ORDER = %i(guid author property parent_guid).freeze
include Entities::Relayable
@ -41,7 +41,7 @@ module DiasporaFederation
signed_hash[:parent_author_signature] = sign_with_key(parent_pkey, legacy_signature_data)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_public_key_by_diaspora_id, diaspora_id
:fetch_public_key_by_diaspora_id, author
).and_return(author_pkey.public_key)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
@ -69,7 +69,7 @@ module DiasporaFederation
hash[:author_signature] = nil
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_public_key_by_diaspora_id, diaspora_id
:fetch_public_key_by_diaspora_id, author
).and_return(author_pkey.public_key)
expect {
@ -81,7 +81,7 @@ module DiasporaFederation
hash[:author_signature] = sign_with_key(author_pkey, legacy_signature_data)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_public_key_by_diaspora_id, diaspora_id
:fetch_public_key_by_diaspora_id, author
).and_return(author_pkey.public_key)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
@ -102,7 +102,7 @@ module DiasporaFederation
hash[:parent_author_signature] = nil
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_public_key_by_diaspora_id, diaspora_id
:fetch_public_key_by_diaspora_id, author
).and_return(author_pkey.public_key)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
@ -123,7 +123,7 @@ module DiasporaFederation
hash[:parent_author_signature] = nil
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_public_key_by_diaspora_id, diaspora_id
:fetch_public_key_by_diaspora_id, author
).and_return(author_pkey.public_key)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
@ -140,7 +140,7 @@ module DiasporaFederation
signed_hash[:parent_author_signature] = sign_with_key(parent_pkey, signature_data)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_public_key_by_diaspora_id, diaspora_id
:fetch_public_key_by_diaspora_id, author
).and_return(author_pkey.public_key)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
@ -160,7 +160,7 @@ module DiasporaFederation
signed_hash[:parent_author_signature] = sign_with_key(parent_pkey, signature_data_with_new_property)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_public_key_by_diaspora_id, diaspora_id
:fetch_public_key_by_diaspora_id, author
).and_return(author_pkey.public_key)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
@ -179,7 +179,7 @@ module DiasporaFederation
signed_hash[:author_signature] = sign_with_key(author_pkey, legacy_signature_data)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_public_key_by_diaspora_id, diaspora_id
:fetch_public_key_by_diaspora_id, author
).and_return(author_pkey.public_key)
expect {
@ -192,7 +192,7 @@ module DiasporaFederation
describe "#to_signed_h" do
it "updates signatures when they were nil and keys were supplied" do
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_private_key_by_diaspora_id, diaspora_id
:fetch_private_key_by_diaspora_id, author
).and_return(author_pkey)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
@ -213,7 +213,7 @@ module DiasporaFederation
it "raises when author_signature not set and key isn't supplied" do
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_private_key_by_diaspora_id, diaspora_id
:fetch_private_key_by_diaspora_id, author
).and_return(nil)
expect {
@ -223,7 +223,7 @@ module DiasporaFederation
it "doesn't set parent_author_signature if key isn't supplied" do
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_private_key_by_diaspora_id, diaspora_id
:fetch_private_key_by_diaspora_id, author
).and_return(author_pkey)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
@ -259,7 +259,7 @@ module DiasporaFederation
expected_xml = <<-XML
<some_relayable>
<diaspora_handle>#{diaspora_id}</diaspora_handle>
<diaspora_handle>#{author}</diaspora_handle>
<guid>#{guid}</guid>
<parent_guid>#{parent_guid}</parent_guid>
<author_signature>aa</author_signature>
@ -274,7 +274,7 @@ XML
it "computes correct signatures for the entity" do
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_private_key_by_diaspora_id, diaspora_id
:fetch_private_key_by_diaspora_id, author
).and_return(author_pkey)
expect(DiasporaFederation.callbacks).to receive(:trigger).with(

View file

@ -5,8 +5,8 @@ module DiasporaFederation
let(:xml) {
<<-XML
<request>
<sender_handle>#{data[:diaspora_id]}</sender_handle>
<recipient_handle>#{data[:recipient_id]}</recipient_handle>
<sender_handle>#{data[:author]}</sender_handle>
<recipient_handle>#{data[:recipient]}</recipient_handle>
</request>
XML
}

View file

@ -5,10 +5,10 @@ module DiasporaFederation
let(:xml) {
<<-XML
<reshare>
<root_diaspora_id>#{data[:root_diaspora_id]}</root_diaspora_id>
<root_diaspora_id>#{data[:root_author]}</root_diaspora_id>
<root_guid>#{data[:root_guid]}</root_guid>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{data[:guid]}</guid>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<public>#{data[:public]}</public>
<created_at>#{data[:created_at]}</created_at>
<provider_display_name>#{data[:provider_display_name]}</provider_display_name>

View file

@ -5,8 +5,8 @@ module DiasporaFederation
let(:xml) {
<<-XML
<retraction>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<post_guid>#{data[:target_guid]}</post_guid>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<type>#{data[:target_type]}</type>
</retraction>
XML

View file

@ -1,13 +1,13 @@
module DiasporaFederation
describe Entities::SignedRetraction do
let(:data) { FactoryGirl.build(:signed_retraction_entity, diaspora_id: alice.diaspora_id).to_h }
let(:data) { FactoryGirl.build(:signed_retraction_entity, author: alice.diaspora_id).to_h }
let(:xml) {
<<-XML
<signed_retraction>
<target_guid>#{data[:target_guid]}</target_guid>
<target_type>#{data[:target_type]}</target_type>
<sender_handle>#{data[:diaspora_id]}</sender_handle>
<sender_handle>#{data[:author]}</sender_handle>
<target_author_signature>#{data[:target_author_signature]}</target_author_signature>
</signed_retraction>
XML
@ -23,7 +23,7 @@ XML
it "updates author signature when it was nil and key was supplied" do
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_private_key_by_diaspora_id, hash[:diaspora_id]
:fetch_private_key_by_diaspora_id, hash[:author]
).and_return(author_pkey)
signed_string = "#{hash[:target_guid]};#{hash[:target_type]}"
@ -44,7 +44,7 @@ XML
it "doesn't change signature if a key wasn't supplied" do
expect(DiasporaFederation.callbacks).to receive(:trigger).with(
:fetch_private_key_by_diaspora_id, hash[:diaspora_id]
:fetch_private_key_by_diaspora_id, hash[:author]
).and_return(nil)
signed_hash = Entities::SignedRetraction.new(hash).to_h
@ -58,7 +58,7 @@ XML
retraction = signed_retraction.to_retraction
expect(retraction).to be_a(Entities::Retraction)
expect(retraction.diaspora_id).to eq(signed_retraction.diaspora_id)
expect(retraction.author).to eq(signed_retraction.author)
expect(retraction.target_guid).to eq(signed_retraction.target_guid)
expect(retraction.target_type).to eq(signed_retraction.target_type)
end

View file

@ -15,10 +15,12 @@ module DiasporaFederation
let(:xml) {
<<-XML
<status_message>
<diaspora_handle>#{data[:author]}</diaspora_handle>
<guid>#{data[:guid]}</guid>
<raw_message>#{data[:raw_message]}</raw_message>
<photo>
<guid>#{photo1.guid}</guid>
<diaspora_handle>#{photo1.diaspora_id}</diaspora_handle>
<diaspora_handle>#{photo1.author}</diaspora_handle>
<public>#{photo1.public}</public>
<created_at>#{photo1.created_at}</created_at>
<remote_photo_path>#{photo1.remote_photo_path}</remote_photo_path>
@ -30,7 +32,7 @@ module DiasporaFederation
</photo>
<photo>
<guid>#{photo2.guid}</guid>
<diaspora_handle>#{photo2.diaspora_id}</diaspora_handle>
<diaspora_handle>#{photo2.author}</diaspora_handle>
<public>#{photo2.public}</public>
<created_at>#{photo2.created_at}</created_at>
<remote_photo_path>#{photo2.remote_photo_path}</remote_photo_path>
@ -45,8 +47,6 @@ module DiasporaFederation
<lat>#{location.lat}</lat>
<lng>#{location.lng}</lng>
</location>
<guid>#{data[:guid]}</guid>
<diaspora_handle>#{data[:diaspora_id]}</diaspora_handle>
<public>#{data[:public]}</public>
<created_at>#{data[:created_at]}</created_at>
<provider_display_name>#{data[:provider_display_name]}</provider_display_name>

View file

@ -182,7 +182,7 @@ XML
context "relayable signature verification feature support" do
it "calls signatures verification on relayable unpack" do
entity = FactoryGirl.build(:comment_entity, diaspora_id: alice.diaspora_id)
entity = FactoryGirl.build(:comment_entity, author: alice.diaspora_id)
payload = Salmon::XmlPayload.pack(entity)
payload.at_xpath("post/*[1]/author_signature").content = nil

View file

@ -5,7 +5,7 @@ module DiasporaFederation
it_behaves_like "a common validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:property) { :author }
let(:mandatory) { true }
end
end

View file

@ -6,17 +6,6 @@ module DiasporaFederation
it_behaves_like "a relayable validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:mandatory) { true }
end
describe "#guid" do
it_behaves_like "a guid validator" do
let(:property) { :guid }
end
end
describe "#text" do
it_behaves_like "a property with a value validation/restriction" do
let(:property) { :text }

View file

@ -5,7 +5,7 @@ module DiasporaFederation
it_behaves_like "a common validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:property) { :author }
let(:mandatory) { true }
end
@ -16,7 +16,7 @@ module DiasporaFederation
describe "participant_ids" do
# must not contain more than 20 participant handles
it_behaves_like "a property with a value validation/restriction" do
let(:property) { :participant_ids }
let(:property) { :participants }
let(:wrong_values) { [Array.new(21) { FactoryGirl.generate(:diaspora_id) }.join(";")] }
let(:correct_values) { [Array.new(20) { FactoryGirl.generate(:diaspora_id) }.join(";")] }
end

View file

@ -5,17 +5,6 @@ module DiasporaFederation
it_behaves_like "a relayable validator"
describe "#guid" do
it_behaves_like "a guid validator" do
let(:property) { :guid }
end
end
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:mandatory) { true }
end
describe "#parent_type" do
it_behaves_like "a property with a value validation/restriction" do
let(:property) { :parent_type }

View file

@ -5,16 +5,9 @@ module DiasporaFederation
it_behaves_like "a relayable validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:mandatory) { true }
end
%i(guid conversation_guid).each do |prop|
describe "##{prop}" do
it_behaves_like "a guid validator" do
let(:property) { prop }
end
describe "#conversation_guid" do
it_behaves_like "a guid validator" do
let(:property) { :conversation_guid }
end
end
end

View file

@ -6,17 +6,6 @@ module DiasporaFederation
it_behaves_like "a relayable validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:mandatory) { true }
end
describe "#guid" do
it_behaves_like "a guid validator" do
let(:property) { :guid }
end
end
describe "#parent_type" do
it_behaves_like "a property with a value validation/restriction" do
let(:property) { :parent_type }

View file

@ -5,7 +5,7 @@ module DiasporaFederation
it_behaves_like "a common validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:property) { :author }
let(:mandatory) { true }
end

View file

@ -5,7 +5,7 @@ module DiasporaFederation
it_behaves_like "a common validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:property) { :author }
let(:mandatory) { true }
end

View file

@ -6,16 +6,9 @@ module DiasporaFederation
it_behaves_like "a relayable validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:mandatory) { true }
end
%i(guid poll_answer_guid).each do |prop|
describe "##{prop}" do
it_behaves_like "a guid validator" do
let(:property) { prop }
end
describe "#poll_answer_guid" do
it_behaves_like "a guid validator" do
let(:property) { :poll_answer_guid }
end
end
end

View file

@ -5,7 +5,7 @@ module DiasporaFederation
it_behaves_like "a common validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:property) { :author }
let(:mandatory) { false }
end

View file

@ -4,7 +4,7 @@ module DiasporaFederation
it_behaves_like "a common validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:property) { :author }
let(:mandatory) { true }
end

View file

@ -4,7 +4,7 @@ module DiasporaFederation
it_behaves_like "a common validator"
%i(diaspora_id recipient_id).each do |prop|
%i(author recipient).each do |prop|
describe "##{prop}" do
it_behaves_like "a diaspora id validator" do
let(:property) { prop }

View file

@ -3,7 +3,7 @@ module DiasporaFederation
let(:entity) { :reshare_entity }
it_behaves_like "a common validator"
%i(root_diaspora_id diaspora_id).each do |prop|
%i(root_author author).each do |prop|
describe "##{prop}" do
it_behaves_like "a diaspora id validator" do
let(:property) { prop }

View file

@ -8,7 +8,7 @@ module DiasporaFederation
end
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:property) { :author }
let(:mandatory) { true }
end

View file

@ -4,7 +4,7 @@ module DiasporaFederation
it_behaves_like "a common validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:property) { :author }
let(:mandatory) { true }
end

View file

@ -5,7 +5,7 @@ module DiasporaFederation
it_behaves_like "a common validator"
it_behaves_like "a diaspora id validator" do
let(:property) { :diaspora_id }
let(:property) { :author }
let(:mandatory) { true }
end

View file

@ -17,6 +17,17 @@ shared_examples "a common validator" do
end
shared_examples "a relayable validator" do
it_behaves_like "a diaspora id validator" do
let(:property) { :author }
let(:mandatory) { true }
end
describe "#guid" do
it_behaves_like "a guid validator" do
let(:property) { :guid }
end
end
describe "#parent_guid" do
it_behaves_like "a guid validator" do
let(:property) { :parent_guid }