diaspora_federation-test 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0303f98534c6ab03def50f40594448c758e8b332
4
+ data.tar.gz: 30b809afd2691f629aa30dbc8dbe519247db0ddc
5
+ SHA512:
6
+ metadata.gz: ca2a2c889b84ece782e0a6d15a626a458a5c1ba1713c471784eb137459335b48f6d42c302b75e320671d31273ddc10a14e3e45a30797e73a69a659cb4f267535
7
+ data.tar.gz: b3aaa49256bcf620978acd0144167b01edd96c55a2b8f8d70c0fb187a74143b22b6999b466cc6ea3175779867294e6c902ba78ecaaf4c2f5b1a0385b260f3284
@@ -0,0 +1,54 @@
1
+ require "diaspora_federation/test/factories"
2
+
3
+ module DiasporaFederation
4
+ # This module encapsulates helper functions maybe wanted by a testsuite of a diaspora_federation gem user application
5
+ module Test
6
+ # Sort hash according to an entity class's property sequence.
7
+ # This is used for rspec tests in order to generate correct input hash to
8
+ # compare results with.
9
+ #
10
+ # @param [Hash] data input hash for sorting
11
+ # @param [Entity.Class] klass entity type to sort according to
12
+ # @return [Hash] sorted hash
13
+ def self.sort_hash(data, klass)
14
+ Hash[klass.class_props.map { |prop|
15
+ [prop[:name], data[prop[:name]]] unless data[prop[:name]].nil?
16
+ }.compact]
17
+ end
18
+
19
+ # Generates attributes for entity constructor with correct signatures in it
20
+ #
21
+ # @param [Symbol] factory_name the factory to generate attributes for (normally entity name)
22
+ # @return [Hash] hash with correct signatures
23
+ def self.relayable_attributes_with_signatures(factory_name)
24
+ klass = FactoryGirl.factory_by_name(factory_name).build_class
25
+ sort_hash(FactoryGirl.attributes_for(factory_name), klass).tap do |data|
26
+ DiasporaFederation::Entities::Relayable.update_signatures!(data)
27
+ end
28
+ end
29
+
30
+ # Generates attributes for signed retraction entity constructor with correct signatures in it
31
+ #
32
+ # @return [Hash] hash with correct signatures
33
+ def self.signed_retraction_attributes_with_signatures
34
+ sort_hash(FactoryGirl.attributes_for(:signed_retraction_entity), Entities::SignedRetraction).tap do |data|
35
+ Entities::SignedRetraction.update_signatures!(data)
36
+ end
37
+ end
38
+
39
+ # Generates attributes for relayable retraction entity constructor with correct signatures in it
40
+ #
41
+ # @return [Hash] hash with correct signatures
42
+ def self.relayable_retraction_attributes_with_signatures
43
+ sort_hash(
44
+ FactoryGirl.attributes_for(
45
+ :relayable_retraction_entity,
46
+ target_author_signature: "false sig"
47
+ ),
48
+ Entities::RelayableRetraction
49
+ ).tap do |data|
50
+ Entities::RelayableRetraction.update_signatures!(data)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,183 @@
1
+ require "factory_girl"
2
+
3
+ FactoryGirl.define do
4
+ initialize_with { new(attributes) }
5
+ sequence(:guid) { UUID.generate :compact }
6
+ sequence(:diaspora_id) {|n| "person-#{n}-#{SecureRandom.hex(3)}@localhost:3000" }
7
+ sequence(:public_key) { OpenSSL::PKey::RSA.generate(1024).public_key.export }
8
+
9
+ factory :webfinger, class: DiasporaFederation::Discovery::WebFinger do
10
+ guid
11
+ acct_uri { "acct:#{generate(:diaspora_id)}" }
12
+ alias_url "http://localhost:3000/people/0123456789abcdef"
13
+ hcard_url "http://localhost:3000/hcard/users/user"
14
+ seed_url "http://localhost:3000/"
15
+ profile_url "http://localhost:3000/u/user"
16
+ atom_url "http://localhost:3000/public/user.atom"
17
+ salmon_url "http://localhost:3000/receive/users/0123456789abcdef"
18
+ public_key
19
+ end
20
+
21
+ factory :h_card, class: DiasporaFederation::Discovery::HCard do
22
+ guid
23
+ nickname "some_name"
24
+ full_name "my name"
25
+ first_name "my name"
26
+ last_name nil
27
+ url "http://localhost:3000/"
28
+ public_key
29
+ photo_large_url "/assets/user/default.png"
30
+ photo_medium_url "/assets/user/default.png"
31
+ photo_small_url "/assets/user/default.png"
32
+ searchable true
33
+ end
34
+
35
+ factory :person_entity, class: DiasporaFederation::Entities::Person do
36
+ guid
37
+ diaspora_id
38
+ url "http://localhost:3000/"
39
+ exported_key { generate(:public_key) }
40
+ profile {
41
+ FactoryGirl.build(:profile_entity, diaspora_id: diaspora_id)
42
+ }
43
+ end
44
+
45
+ factory :profile_entity, class: DiasporaFederation::Entities::Profile do
46
+ diaspora_id
47
+ first_name "my name"
48
+ last_name nil
49
+ image_url "/assets/user/default.png"
50
+ image_url_medium "/assets/user/default.png"
51
+ image_url_small "/assets/user/default.png"
52
+ birthday "1988-07-15"
53
+ gender "Male"
54
+ bio "some text about me"
55
+ location "github"
56
+ searchable true
57
+ nsfw false
58
+ tag_string "#i #love #tags"
59
+ end
60
+
61
+ factory :location_entity, class: DiasporaFederation::Entities::Location do
62
+ address "Vienna, Austria"
63
+ lat 48.208174.to_s
64
+ lng 16.373819.to_s
65
+ end
66
+
67
+ factory :photo_entity, class: DiasporaFederation::Entities::Photo do
68
+ guid
69
+ diaspora_id
70
+ public(true)
71
+ created_at { Time.zone.now }
72
+ remote_photo_path "https://diaspora.example.tld/uploads/images/"
73
+ remote_photo_name "f2a41e9d2db4d9a199c8.jpg"
74
+ text "what you see here..."
75
+ status_message_guid { generate(:guid) }
76
+ height 480
77
+ width 800
78
+ end
79
+
80
+ factory :relayable_entity, class: DiasporaFederation::Entities::Relayable do
81
+ parent_guid { generate(:guid) }
82
+ end
83
+
84
+ factory :participation_entity, class: DiasporaFederation::Entities::Participation, parent: :relayable_entity do
85
+ guid
86
+ target_type "Post"
87
+ diaspora_id
88
+ end
89
+
90
+ factory :status_message_entity, class: DiasporaFederation::Entities::StatusMessage do
91
+ raw_message "i am a very interesting status update"
92
+ guid
93
+ diaspora_id
94
+ public(true)
95
+ created_at { Time.zone.now }
96
+ end
97
+
98
+ factory :request_entity, class: DiasporaFederation::Entities::Request do
99
+ sender_id { generate(:diaspora_id) }
100
+ recipient_id { generate(:diaspora_id) }
101
+ end
102
+
103
+ factory :comment_entity, class: DiasporaFederation::Entities::Comment, parent: :relayable_entity do
104
+ guid
105
+ text "this is a very informative comment"
106
+ diaspora_id
107
+ end
108
+
109
+ factory :like_entity, class: DiasporaFederation::Entities::Like, parent: :relayable_entity do
110
+ positive true
111
+ guid
112
+ target_type "Post"
113
+ diaspora_id
114
+ end
115
+
116
+ factory :account_deletion_entity, class: DiasporaFederation::Entities::AccountDeletion do
117
+ diaspora_id
118
+ end
119
+
120
+ factory :conversation_entity, class: DiasporaFederation::Entities::Conversation do
121
+ guid
122
+ subject "this is a very informative subject"
123
+ created_at { DateTime.now.utc }
124
+ messages []
125
+ diaspora_id
126
+ participant_ids { 3.times.map { generate(:diaspora_id) }.join(";") }
127
+ end
128
+
129
+ factory :message_entity, class: DiasporaFederation::Entities::Message, parent: :relayable_entity do
130
+ guid
131
+ text "this is a very informative text"
132
+ created_at { DateTime.now.utc }
133
+ diaspora_id
134
+ conversation_guid { generate(:guid) }
135
+ end
136
+
137
+ factory :relayable_retraction_entity, class: DiasporaFederation::Entities::RelayableRetraction do
138
+ target_guid { generate(:guid) }
139
+ target_type "Comment"
140
+ diaspora_id
141
+ end
142
+
143
+ factory :reshare_entity, class: DiasporaFederation::Entities::Reshare do
144
+ root_diaspora_id { generate(:diaspora_id) }
145
+ root_guid { generate(:guid) }
146
+ guid
147
+ diaspora_id
148
+ public(true)
149
+ created_at { DateTime.now.utc }
150
+ provider_display_name { "the testsuite" }
151
+ end
152
+
153
+ factory :retraction_entity, class: DiasporaFederation::Entities::Retraction do
154
+ target_guid { generate(:guid) }
155
+ diaspora_id
156
+ target_type "Post"
157
+ end
158
+
159
+ factory :signed_retraction_entity, class: DiasporaFederation::Entities::SignedRetraction do
160
+ target_guid { generate(:guid) }
161
+ target_type "Post"
162
+ diaspora_id
163
+ end
164
+
165
+ factory :poll_answer_entity, class: DiasporaFederation::Entities::PollAnswer do
166
+ guid
167
+ answer { "Obama is a bicycle" }
168
+ end
169
+
170
+ factory :poll_entity, class: DiasporaFederation::Entities::Poll do
171
+ guid
172
+ question { "Select an answer" }
173
+ poll_answers { 3.times.map { FactoryGirl.build(:poll_answer_entity) } }
174
+ end
175
+
176
+ factory :poll_participation_entity,
177
+ class: DiasporaFederation::Entities::PollParticipation,
178
+ parent: :relayable_entity do
179
+ guid
180
+ diaspora_id
181
+ poll_answer_guid { generate(:guid) }
182
+ end
183
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: diaspora_federation-test
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin Neff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: diaspora_federation
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.9
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: factory_girl
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 4.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 4.5.0
41
+ description: This gem provides some supplimentary code (factory definitions), thathelps
42
+ to build tests for users of the diaspora_federation gem.
43
+ email:
44
+ - benjamin@coding4.coffee
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - lib/diaspora_federation/test.rb
50
+ - lib/diaspora_federation/test/factories.rb
51
+ homepage: https://github.com/SuperTux88/diaspora_federation
52
+ licenses:
53
+ - AGPL 3.0 - http://www.gnu.org/licenses/agpl-3.0.html
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '2.0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.4.6
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: diaspora* federation test utils
75
+ test_files: []
76
+ has_rdoc: