impermium 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE.txt +20 -0
- data/README.md +118 -0
- data/Rakefile +7 -0
- data/impermium.gemspec +31 -0
- data/lib/faraday/raise_4xx.rb +18 -0
- data/lib/impermium/client.rb +57 -0
- data/lib/impermium/configuration.rb +44 -0
- data/lib/impermium/content/blog_post.rb +38 -0
- data/lib/impermium/content/bookmark.rb +47 -0
- data/lib/impermium/content/comment.rb +38 -0
- data/lib/impermium/content/connection.rb +42 -0
- data/lib/impermium/content/listing.rb +37 -0
- data/lib/impermium/content.rb +15 -0
- data/lib/impermium/errors.rb +25 -0
- data/lib/impermium/user/account.rb +50 -0
- data/lib/impermium/user/profile.rb +35 -0
- data/lib/impermium/user.rb +9 -0
- data/lib/impermium/version.rb +3 -0
- data/lib/impermium.rb +20 -0
- data/spec/.gitignore +1 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_analyst_feedback_method/missing_arguments/missing_blog_post_id.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_blog_post_id.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_blog_post_permalink.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_blog_url.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_content.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_enduser_ip.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_user_id.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/successful_blog_post_request.yml +39 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/missing_blog_post_id.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_analyst_feedback_method/missing_arguments/missing_bookmark_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_bookmark_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_bookmark_url.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_like_value.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/missing_arguments/missing_bookmark_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/missing_arguments/missing_bookmark_url.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/missing_bookmark_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/comment_object/comment_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_analyst_feedback_method/missing_arguments/missing_comment_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_article_permalink.yml +43 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_comment_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_comment_permalink.yml +43 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_content.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_enduser_ip.yml +43 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_user_id.yml +43 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/successful_request.yml +39 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/missing_comment_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/invalid_connection_type_value.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/missing_connection_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/missing_connection_type.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/invalid_connection_type_value.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/invalid_operation_value.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_connection_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_connection_type.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_requester_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_responder_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/successful_follow_connection_request.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/successful_follow_connection_response.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/successful_friend_connection_request.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/successful_friend_connection_response.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/invalid_connection_type_value.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_connection_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_connection_type.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/listing_object/listing_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_analyst_feedback_method/missing_arguments/missing_listing_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_content.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_listing_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_listing_permalink.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/missing_listing_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_analyst_feedback_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_analyst_feedback_method/successful_account_analyst_feedback_method_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_attempt_method/missing_arguments.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_attempt_method/successful_account_attempt_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_login_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_login_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_login_method/successful_account_login_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_method/successful_account_method_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/user_API_section/profile_object/profile_analyst_feedback_method/missing_params/missing_analyst_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_analyst_feedback_method/missing_params/missing_desired_result.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_analyst_feedback_method/missing_params/missing_profile_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/user_API_section/profile_object/profile_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_method/missing_arguments/missing_profile_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_method/successful_request.yml +38 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/missing_profile_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/successful_request.yml +38 -0
- data/spec/configuration.yml.sample +3 -0
- data/spec/impermium/client_spec.rb +67 -0
- data/spec/impermium/content/blog_post_spec.rb +173 -0
- data/spec/impermium/content/bookmark_spec.rb +205 -0
- data/spec/impermium/content/comment_spec.rb +178 -0
- data/spec/impermium/content/connection_spec.rb +257 -0
- data/spec/impermium/content/listing_spec.rb +169 -0
- data/spec/impermium/user/account_spec.rb +184 -0
- data/spec/impermium/user/profile_spec.rb +154 -0
- data/spec/spec_helper.rb +32 -0
- metadata +433 -0
@@ -0,0 +1,257 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
describe "content API section" do
|
5
|
+
describe "connection object" do
|
6
|
+
before(:each) do
|
7
|
+
@connection_id = "u236711u558749c9724392933355478"
|
8
|
+
@requester_user_id = "u236711"
|
9
|
+
@responder_user_id = "u558749"
|
10
|
+
@analyst_id = "4n4l1s7cid"
|
11
|
+
@reporter_user_id = "r3p0rt3rcid"
|
12
|
+
@ip = "3.3.3.3"
|
13
|
+
@desired_result = {:spam_classifier => { :label => "notspam" }}
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "connection method" do
|
17
|
+
describe "missing arguments" do
|
18
|
+
|
19
|
+
context "invalid operation value" do
|
20
|
+
use_vcr_cassette
|
21
|
+
it "should use default value and respond OK" do
|
22
|
+
res= Impermium.connection('invalid', 'friend', @connection_id, @requester_user_id, @responder_user_id, @ip)
|
23
|
+
res.response_id.should be_true
|
24
|
+
res.timestamp.should be_true
|
25
|
+
res.status.should be_nil
|
26
|
+
res.message.should be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "missing connection_type" do
|
31
|
+
use_vcr_cassette
|
32
|
+
it "should raise BadRequest error" do
|
33
|
+
lambda { Impermium.connection('request', nil, @connection_id, @requester_user_id, @responder_user_id, @ip)
|
34
|
+
}.should raise_error(Impermium::BadRequest, /connection_type/)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "invalid connection_type value" do
|
39
|
+
use_vcr_cassette
|
40
|
+
it "should raise BadRequest error" do
|
41
|
+
lambda { Impermium.connection('request', 'no-valid', @connection_id, @requester_user_id, @responder_user_id, @ip)
|
42
|
+
}.should raise_error(Impermium::BadRequest, /connection_type/)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "missing connection_id" do
|
47
|
+
use_vcr_cassette
|
48
|
+
it "should raise BadRequest error" do
|
49
|
+
lambda { Impermium.connection('request', 'friend', nil, @requester_user_id, @responder_user_id, @ip)
|
50
|
+
}.should raise_error(Impermium::BadRequest, /connection_id/)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "missing requester_user_id" do
|
55
|
+
use_vcr_cassette
|
56
|
+
it "should raise BadRequest error" do
|
57
|
+
lambda { Impermium.connection('request', 'friend', @connection_id, nil, @responder_user_id, @ip)
|
58
|
+
}.should raise_error(Impermium::BadRequest, /requester_user_id/)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "missing responder_user_id" do
|
63
|
+
use_vcr_cassette
|
64
|
+
it "should raise BadRequest error" do
|
65
|
+
lambda { Impermium.connection('request', 'friend', @connection_id, @requester_user_id, nil, @ip)
|
66
|
+
}.should raise_error(Impermium::BadRequest, /responder_user_id/)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "missing enduser_ip" do
|
71
|
+
use_vcr_cassette
|
72
|
+
it "should raise BadRequest error" do
|
73
|
+
lambda { Impermium.connection('request', 'follow', @connection_id, @requester_user_id, @responder_user_id, nil)
|
74
|
+
}.should raise_error(Impermium::BadRequest, /enduser_ip/)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "successful friend connection request" do
|
80
|
+
use_vcr_cassette
|
81
|
+
it "should return an OK response" do
|
82
|
+
res = Impermium.connection('request', 'friend', @connection_id, @requester_user_id, @responder_user_id, @ip)
|
83
|
+
res.response_id.should be_true
|
84
|
+
res.timestamp.should be_true
|
85
|
+
res.status.should be_nil
|
86
|
+
res.message.should be_nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "successful friend connection response" do
|
91
|
+
use_vcr_cassette
|
92
|
+
it "should return an OK response" do
|
93
|
+
res = Impermium.connection('response', 'friend', @connection_id, @requester_user_id, @responder_user_id, @ip)
|
94
|
+
res.response_id.should be_true
|
95
|
+
res.timestamp.should be_true
|
96
|
+
res.status.should be_nil
|
97
|
+
res.message.should be_nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "successful follow connection request" do
|
102
|
+
use_vcr_cassette
|
103
|
+
it "should return an OK response" do
|
104
|
+
res = Impermium.connection('request', 'follow', @connection_id, @requester_user_id, @responder_user_id, @ip)
|
105
|
+
res.response_id.should be_true
|
106
|
+
res.timestamp.should be_true
|
107
|
+
res.status.should be_nil
|
108
|
+
res.message.should be_nil
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "successful follow connection response" do
|
113
|
+
use_vcr_cassette
|
114
|
+
it "should return an OK response" do
|
115
|
+
res = Impermium.connection('response', 'follow', @connection_id, @requester_user_id, @responder_user_id, @ip)
|
116
|
+
res.response_id.should be_true
|
117
|
+
res.timestamp.should be_true
|
118
|
+
res.status.should be_nil
|
119
|
+
res.message.should be_nil
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "connection_analyst_feedback method" do
|
125
|
+
describe "missing arguments" do
|
126
|
+
context "missing analyst_id" do
|
127
|
+
use_vcr_cassette
|
128
|
+
it "should raise BadRequest error" do
|
129
|
+
lambda { Impermium.connection_analyst_feedback(nil, 'friend', @connection_id, @desired_result) }.should raise_error(Impermium::BadRequest, /analyst_id/)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "missing connection_type" do
|
134
|
+
use_vcr_cassette
|
135
|
+
it "should raise BadRequest error" do
|
136
|
+
lambda { Impermium.connection_analyst_feedback(@analyst_id, nil, @connection_id, @desired_result)
|
137
|
+
}.should raise_error(Impermium::BadRequest, /connection_type/)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context "invalid connection_type value" do
|
142
|
+
use_vcr_cassette
|
143
|
+
it "should raise BadRequest error" do
|
144
|
+
lambda { Impermium.connection_analyst_feedback(@analyst_id, 'invalid_type', @connection_id, @desired_result)
|
145
|
+
}.should raise_error(Impermium::BadRequest, /connection_type/)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context "missing connection_id" do
|
150
|
+
use_vcr_cassette
|
151
|
+
it "should raise BadRequest error" do
|
152
|
+
lambda { Impermium.connection_analyst_feedback(@analyst_id, 'friend', nil, @desired_result) }.should raise_error(Impermium::BadRequest, /connection_id/)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context "missing desired_result" do
|
157
|
+
use_vcr_cassette
|
158
|
+
it "should raise BadRequest error" do
|
159
|
+
lambda { Impermium.connection_analyst_feedback(@analyst_id, 'friend', @connection_id, nil) }.should raise_error(Impermium::BadRequest, /desired_result/)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "successful request" do
|
165
|
+
use_vcr_cassette
|
166
|
+
it "should return an OK response" do
|
167
|
+
res = Impermium.connection_analyst_feedback(@analyst_id, 'friend', @connection_id, @desired_result)
|
168
|
+
res.response_id.should be_true
|
169
|
+
res.timestamp.should be_true
|
170
|
+
res.status.should be_nil
|
171
|
+
res.message.should be_nil
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "connection_user_feedback method" do
|
177
|
+
describe "missing arguments" do
|
178
|
+
context "missing reporter_user_id" do
|
179
|
+
use_vcr_cassette
|
180
|
+
it "should raise BadRequest error" do
|
181
|
+
lambda { Impermium.connection_user_feedback(nil, "MODERATOR",
|
182
|
+
@ip, 'follow', @connection_id, @desired_result)
|
183
|
+
}.should raise_error(Impermium::BadRequest, /reporter_user_id/)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
context "invalid reporter_user_type" do
|
188
|
+
use_vcr_cassette
|
189
|
+
it "should use default value" do
|
190
|
+
res = Impermium.connection_user_feedback(@reporter_user_id, "NOT VALID", @ip, 'follow', @connection_id, @desired_result)
|
191
|
+
res.response_id.should be
|
192
|
+
res.timestamp.should be
|
193
|
+
res.status.should be_nil
|
194
|
+
res.message.should be_nil
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context "missing reporter_ip" do
|
199
|
+
use_vcr_cassette
|
200
|
+
it "should raise BadRequest error" do
|
201
|
+
lambda { Impermium.connection_user_feedback(@reporter_user_id, "MODERATOR",
|
202
|
+
"", 'follow', @connection_id, @desired_result)
|
203
|
+
}.should raise_error(Impermium::BadRequest, /reporter_ip/)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
context "missing connection_type" do
|
208
|
+
use_vcr_cassette
|
209
|
+
it "should raise BadRequest error" do
|
210
|
+
lambda { Impermium.connection_user_feedback(@reporter_user_id, "MODERATOR",
|
211
|
+
@ip, nil, @connection_id, @desired_result)
|
212
|
+
}.should raise_error(Impermium::BadRequest, /connection_type/)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context "invalid connection_type value" do
|
217
|
+
use_vcr_cassette
|
218
|
+
it "should raise BadRequest error" do
|
219
|
+
lambda { Impermium.connection_user_feedback(@reporter_user_id, "MODERATOR",
|
220
|
+
@ip, 'wrong_type', @connection_id, @desired_result)
|
221
|
+
}.should raise_error(Impermium::BadRequest, /connection_type/)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
context "missing connection_id" do
|
226
|
+
use_vcr_cassette
|
227
|
+
it "should raise BadRequest error" do
|
228
|
+
lambda { Impermium.connection_user_feedback(@reporter_user_id, "MODERATOR",
|
229
|
+
@ip, 'follow', nil, @desired_result)
|
230
|
+
}.should raise_error(Impermium::BadRequest, /connection_id/)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
context "missing desired_result" do
|
235
|
+
use_vcr_cassette
|
236
|
+
it "should raise BadRequest error" do
|
237
|
+
lambda { Impermium.connection_user_feedback(@reporter_user_id, "MODERATOR",
|
238
|
+
@ip, 'follow', @connection_id, nil)
|
239
|
+
}.should raise_error(Impermium::BadRequest, /desired_result/)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
describe "successful request" do
|
245
|
+
use_vcr_cassette
|
246
|
+
it "should return an OK response" do
|
247
|
+
res = Impermium.connection_user_feedback(@reporter_user_id, "ENDUSER", @ip, 'follow', @connection_id, @desired_result)
|
248
|
+
res.response_id.start_with?("CLID").should be_true
|
249
|
+
res.response_id.should be
|
250
|
+
res.timestamp.should be
|
251
|
+
res.status.should be_nil
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
describe "content API section" do
|
5
|
+
describe "listing object" do
|
6
|
+
before(:each) do
|
7
|
+
@user_id = "whi231"
|
8
|
+
@listing_id = "78912li"
|
9
|
+
@listing_permalink = "http://example.com/listings/78912li"
|
10
|
+
@content = "sales ad list"
|
11
|
+
@analyst_id = "4n4l1s7"
|
12
|
+
@reporter_user_id = "r3p0rt3r"
|
13
|
+
@ip = "1.1.1.1"
|
14
|
+
@desired_result = {:spam_classifier => { :label => "notspam" }}
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "listing method" do
|
18
|
+
describe "missing arguments" do
|
19
|
+
|
20
|
+
context "missing user_id" do
|
21
|
+
use_vcr_cassette
|
22
|
+
it "should raise BadRequest error" do
|
23
|
+
lambda { Impermium.listing(nil, @listing_id, @content, @listing_permalink, @ip)
|
24
|
+
}.should raise_error(Impermium::BadRequest, /user_id/)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "missing listing_id" do
|
29
|
+
use_vcr_cassette
|
30
|
+
it "should raise BadRequest error" do
|
31
|
+
lambda { Impermium.listing(@user_id, nil, @content, @listing_permalink, @ip)
|
32
|
+
}.should raise_error(Impermium::BadRequest, /listing_id/)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "missing content" do
|
37
|
+
use_vcr_cassette
|
38
|
+
it "should raise BadRequest error" do
|
39
|
+
lambda { Impermium.listing(@user_id, @listing_id, nil, @listing_permalink, @ip)
|
40
|
+
}.should raise_error(Impermium::BadRequest, /content/)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "missing listing_permalink" do
|
45
|
+
use_vcr_cassette
|
46
|
+
it "should raise BadRequest error" do
|
47
|
+
lambda { Impermium.listing(@user_id, @listing_id, @content, nil, @ip)
|
48
|
+
}.should raise_error(Impermium::BadRequest, /listing_permalink/)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "missing enduser_ip" do
|
53
|
+
use_vcr_cassette
|
54
|
+
it "should raise BadRequest error" do
|
55
|
+
lambda { Impermium.listing(@user_id, @listing_id, @content, @listing_permalink, nil)
|
56
|
+
}.should raise_error(Impermium::BadRequest, /enduser_ip/)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "successful request" do
|
62
|
+
use_vcr_cassette
|
63
|
+
it "should mark listing with 'notspam' label" do
|
64
|
+
res = Impermium.listing(@user_id, @listing_id, @content, @listing_permalink, @ip)
|
65
|
+
res.spam_classifier.label.should == "notspam"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "listing_analyst_feedback method" do
|
71
|
+
describe "missing arguments" do
|
72
|
+
context "missing analyst_id" do
|
73
|
+
use_vcr_cassette
|
74
|
+
it "should raise BadRequest error" do
|
75
|
+
lambda { Impermium.listing_analyst_feedback(nil, @listing_id, @desired_result) }.should raise_error(Impermium::BadRequest, /analyst_id/)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "missing listing_id" do
|
80
|
+
use_vcr_cassette
|
81
|
+
it "should raise BadRequest error" do
|
82
|
+
lambda { Impermium.listing_analyst_feedback(@analyst_id, nil, @desired_result) }.should raise_error(Impermium::BadRequest, /listing_id/)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context "missing desired_result" do
|
87
|
+
use_vcr_cassette
|
88
|
+
it "should raise BadRequest error" do
|
89
|
+
lambda { Impermium.listing_analyst_feedback(@analyst_id, @listing_id, nil) }.should raise_error(Impermium::BadRequest, /desired_result/)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "successful request" do
|
95
|
+
use_vcr_cassette
|
96
|
+
it "should return an OK response" do
|
97
|
+
res = Impermium.listing_analyst_feedback(@analyst_id, @listing_id, @desired_result)
|
98
|
+
res.response_id.should be_true
|
99
|
+
res.timestamp.should be_true
|
100
|
+
res.status.should be_nil
|
101
|
+
res.message.should be_nil
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "listing_user_feedback method" do
|
107
|
+
describe "missing arguments" do
|
108
|
+
context "missing reporter_user_id" do
|
109
|
+
use_vcr_cassette
|
110
|
+
it "should raise BadRequest error" do
|
111
|
+
lambda { Impermium.listing_user_feedback(nil, "MODERATOR",
|
112
|
+
@ip, @listing_id, @desired_result)
|
113
|
+
}.should raise_error(Impermium::BadRequest, /reporter_user_id/)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "invalid reporter_user_type" do
|
118
|
+
use_vcr_cassette
|
119
|
+
it "should use default value" do
|
120
|
+
res = Impermium.listing_user_feedback(@reporter_user_id, "NOT VALID", @ip, @listing_id, @desired_result)
|
121
|
+
res.response_id.should be
|
122
|
+
res.timestamp.should be
|
123
|
+
res.status.should be_nil
|
124
|
+
res.message.should be_nil
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "missing reporter_ip" do
|
129
|
+
use_vcr_cassette
|
130
|
+
it "should raise BadRequest error" do
|
131
|
+
lambda { Impermium.listing_user_feedback(@reporter_user_id, "MODERATOR",
|
132
|
+
"", @listing_id, @desired_result)
|
133
|
+
}.should raise_error(Impermium::BadRequest, /reporter_ip/)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "missing listing_id" do
|
138
|
+
use_vcr_cassette
|
139
|
+
it "should raise BadRequest error" do
|
140
|
+
lambda { Impermium.listing_user_feedback(@reporter_user_id, "MODERATOR",
|
141
|
+
@ip, nil, @desired_result)
|
142
|
+
}.should raise_error(Impermium::BadRequest, /listing_id/)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "missing desired_result" do
|
147
|
+
use_vcr_cassette
|
148
|
+
it "should raise BadRequest error" do
|
149
|
+
lambda { Impermium.listing_user_feedback(@reporter_user_id, "MODERATOR",
|
150
|
+
@ip, @listing_id, nil)
|
151
|
+
}.should raise_error(Impermium::BadRequest, /desired_result/)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "successful request" do
|
157
|
+
use_vcr_cassette
|
158
|
+
it "should return an OK response" do
|
159
|
+
res = Impermium.listing_user_feedback(@reporter_user_id, "ENDUSER", @ip, @listing_id, @desired_result)
|
160
|
+
res.response_id.start_with?("CLID").should be_true
|
161
|
+
res.response_id.should be
|
162
|
+
res.timestamp.should be
|
163
|
+
res.status.should be_nil
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
describe "user API section" do
|
5
|
+
describe "account object" do
|
6
|
+
before(:each) do
|
7
|
+
@user_id = "whi543"
|
8
|
+
@reporter_user_id = "whi789"
|
9
|
+
@ip_address = "1.1.1.1"
|
10
|
+
@analyst_id = "123456"
|
11
|
+
@profile_id = "whi543_profile"
|
12
|
+
@desired_result = {:spam_classifier => { :label => "notspam" }}
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "account method" do
|
16
|
+
describe "missing arguments" do
|
17
|
+
context "missing user_id" do
|
18
|
+
use_vcr_cassette
|
19
|
+
it "should raise BadRequest error" do
|
20
|
+
lambda { Impermium.account(nil, @ip_address) }.should raise_error(Impermium::BadRequest, /user_id/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "missing enduser_ip" do
|
25
|
+
use_vcr_cassette
|
26
|
+
it "should raise BadRequest error" do
|
27
|
+
lambda { Impermium.account(@user_id, '') }.should raise_error(Impermium::BadRequest, /enduser_ip/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "successful account method request" do
|
33
|
+
use_vcr_cassette
|
34
|
+
|
35
|
+
it "should mark user with zero spam classifier score" do
|
36
|
+
res = Impermium.account(@user_id, @ip_address)
|
37
|
+
res.spam_classifier.score.to_i.should == 0
|
38
|
+
res.spam_classifier.label.should == "notspam"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "account_attempt method" do
|
44
|
+
describe "missing arguments" do
|
45
|
+
use_vcr_cassette
|
46
|
+
it "should raise BadRequest error if enduser_ip is missing" do
|
47
|
+
lambda { Impermium.account_attempt('') }.should raise_error(Impermium::BadRequest, /enduser_ip/)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "successful account_attempt request" do
|
52
|
+
use_vcr_cassette
|
53
|
+
it "should log the attempt and return an OK response" do
|
54
|
+
res = Impermium.account_attempt(@ip_address)
|
55
|
+
res.response_id.should be
|
56
|
+
res.timestamp.should be
|
57
|
+
res.status.should be_nil
|
58
|
+
res.message.should be_nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "account_login method" do
|
64
|
+
describe "missing arguments" do
|
65
|
+
context "missing user_id" do
|
66
|
+
use_vcr_cassette
|
67
|
+
it "should raise BadRequest error" do
|
68
|
+
lambda { Impermium.account_login(nil, @ip_address) }.should raise_error(Impermium::BadRequest, /user_id/)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "missing enduser_ip" do
|
73
|
+
use_vcr_cassette
|
74
|
+
it "should raise BadRequest error" do
|
75
|
+
lambda { Impermium.account_login(@user_id, '') }.should raise_error(Impermium::BadRequest, /enduser_ip/)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "successful account_login request" do
|
81
|
+
use_vcr_cassette
|
82
|
+
it "should return an OK response" do
|
83
|
+
res = Impermium.account_login(@user_id, @ip_address)
|
84
|
+
res.response_id.should be
|
85
|
+
res.timestamp.should be
|
86
|
+
res.status.should be_nil
|
87
|
+
res.message.should be_nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "account_analyst_feedback method" do
|
93
|
+
describe "missing arguments" do
|
94
|
+
context "missing analyst_id" do
|
95
|
+
use_vcr_cassette
|
96
|
+
it "should raise BadRequest error" do
|
97
|
+
lambda { Impermium.account_analyst_feedback(nil, @user_id, @desired_result) }.should raise_error(Impermium::BadRequest, /analyst_id/)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "missing user_id" do
|
102
|
+
use_vcr_cassette
|
103
|
+
it "should raise BadRequest error" do
|
104
|
+
lambda { Impermium.account_analyst_feedback(@analyst_id, nil, @desired_result) }.should raise_error(Impermium::BadRequest, /user_id/)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "successful account_analyst_feedback method request" do
|
110
|
+
use_vcr_cassette
|
111
|
+
it "should return an OK response" do
|
112
|
+
res = Impermium.account_analyst_feedback(@analyst_id, @user_id, @desired_result)
|
113
|
+
res.response_id.should be_true
|
114
|
+
res.timestamp.should be_true
|
115
|
+
res.status.should be_nil
|
116
|
+
res.message.should be_nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "account_user_feedback method" do
|
122
|
+
describe "missing arguments" do
|
123
|
+
context "missing reporter_user_id" do
|
124
|
+
use_vcr_cassette
|
125
|
+
it "should raise BadRequest error" do
|
126
|
+
lambda { Impermium.account_user_feedback(nil, "MODERATOR",
|
127
|
+
@ip_address, @user_id, @desired_result)
|
128
|
+
}.should raise_error(Impermium::BadRequest, /reporter_user_id/)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "invalid reporter_user_type" do
|
133
|
+
use_vcr_cassette
|
134
|
+
it "should use default value" do
|
135
|
+
res = Impermium.account_user_feedback(@reporter_user_id, "NOT VALID", @ip_address, @user_id, @desired_result)
|
136
|
+
res.response_id.should be
|
137
|
+
res.timestamp.should be
|
138
|
+
res.status.should be_nil
|
139
|
+
res.message.should be_nil
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "missing reporter_ip" do
|
144
|
+
use_vcr_cassette
|
145
|
+
it "should raise BadRequest" do
|
146
|
+
lambda { Impermium.account_user_feedback(@reporter_user_id, "MODERATOR",
|
147
|
+
"", @user_id, @desired_result)
|
148
|
+
}.should raise_error(Impermium::BadRequest, /reporter_ip/)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context "missing user_id" do
|
153
|
+
use_vcr_cassette
|
154
|
+
it "should raise BadRequest error" do
|
155
|
+
lambda { Impermium.account_user_feedback(@reporter_user_id, "MODERATOR",
|
156
|
+
@ip_address, nil, @desired_result)
|
157
|
+
}.should raise_error(Impermium::BadRequest, /user_id/)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context "missing desired_result" do
|
162
|
+
use_vcr_cassette
|
163
|
+
it "should raise BadRequest error" do
|
164
|
+
lambda { Impermium.account_user_feedback(@reporter_user_id, "MODERATOR",
|
165
|
+
@ip_address, @user_id, nil)
|
166
|
+
}.should raise_error(Impermium::BadRequest, /desired_result/)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe "successful request" do
|
172
|
+
use_vcr_cassette
|
173
|
+
it "should return an OK response" do
|
174
|
+
res = Impermium.account_user_feedback(@reporter_user_id, "ENDUSER", @ip_address, @user_id, @desired_result)
|
175
|
+
res.response_id.start_with?("CLID").should be_true
|
176
|
+
res.response_id.should be
|
177
|
+
res.timestamp.should be
|
178
|
+
res.status.should be_nil
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|