koala 0.10.0 → 1.0.0.rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/.gitignore +3 -0
  2. data/CHANGELOG +39 -7
  3. data/Gemfile +3 -0
  4. data/Manifest +8 -1
  5. data/Rakefile +13 -14
  6. data/koala.gemspec +36 -19
  7. data/lib/koala/graph_api.rb +188 -123
  8. data/lib/koala/http_services.rb +93 -18
  9. data/lib/koala/rest_api.rb +73 -6
  10. data/lib/koala/test_users.rb +21 -8
  11. data/lib/koala/uploadable_io.rb +115 -0
  12. data/lib/koala.rb +86 -86
  13. data/readme.md +18 -12
  14. data/spec/cases/api_base_spec.rb +101 -0
  15. data/spec/cases/graph_and_rest_api_spec.rb +31 -0
  16. data/spec/cases/graph_api_spec.rb +25 -0
  17. data/spec/cases/http_services/http_service_spec.rb +54 -0
  18. data/spec/cases/http_services/net_http_service_spec.rb +350 -0
  19. data/spec/cases/http_services/typhoeus_service_spec.rb +144 -0
  20. data/spec/cases/oauth_spec.rb +374 -0
  21. data/spec/cases/realtime_updates_spec.rb +184 -0
  22. data/spec/cases/rest_api_spec.rb +25 -0
  23. data/spec/{koala/test_users/test_users_tests.rb → cases/test_users_spec.rb} +78 -72
  24. data/spec/cases/uploadable_io_spec.rb +151 -0
  25. data/spec/fixtures/beach.jpg +0 -0
  26. data/spec/{facebook_data.yml → fixtures/facebook_data.yml} +13 -9
  27. data/spec/{mock_facebook_responses.yml → fixtures/mock_facebook_responses.yml} +312 -289
  28. data/spec/spec_helper.rb +18 -0
  29. data/spec/support/graph_api_shared_examples.rb +424 -0
  30. data/spec/{koala → support}/live_testing_data_helper.rb +39 -42
  31. data/spec/{mock_http_service.rb → support/mock_http_service.rb} +94 -81
  32. data/spec/support/rest_api_shared_examples.rb +161 -0
  33. data/spec/support/setup_mocks_or_live.rb +52 -0
  34. data/spec/support/uploadable_io_shared_examples.rb +76 -0
  35. metadata +130 -43
  36. data/init.rb +0 -2
  37. data/spec/koala/api_base_tests.rb +0 -102
  38. data/spec/koala/graph_and_rest_api/graph_and_rest_api_no_token_tests.rb +0 -10
  39. data/spec/koala/graph_and_rest_api/graph_and_rest_api_with_token_tests.rb +0 -11
  40. data/spec/koala/graph_api/graph_api_no_access_token_tests.rb +0 -114
  41. data/spec/koala/graph_api/graph_api_with_access_token_tests.rb +0 -150
  42. data/spec/koala/graph_api/graph_collection_tests.rb +0 -104
  43. data/spec/koala/net_http_service_tests.rb +0 -186
  44. data/spec/koala/oauth/oauth_tests.rb +0 -438
  45. data/spec/koala/realtime_updates/realtime_updates_tests.rb +0 -187
  46. data/spec/koala/rest_api/rest_api_no_access_token_tests.rb +0 -94
  47. data/spec/koala/rest_api/rest_api_with_access_token_tests.rb +0 -36
  48. data/spec/koala_spec.rb +0 -18
  49. data/spec/koala_spec_helper.rb +0 -48
  50. data/spec/koala_spec_without_mocks.rb +0 -19
@@ -1,289 +1,312 @@
1
- # Responses by MockHTTPService are taken directly from
2
- # this file.
3
- #
4
- # Structure
5
- # ----------
6
- #
7
- # path:
8
- # arguments: # sorted by key
9
- # method: # HTTP method (GET, POST, DELETE, etc.)
10
- # with_token:
11
- # no_token:
12
-
13
- # ====== REST API =====
14
- rest_api:
15
-
16
- # -- Stubbed Responses --
17
- /method/fql.query:
18
- query=select first_name from user where uid = 216743:
19
- get:
20
- no_token: '[{"first_name":"Chris"}]'
21
- with_token: '[{"first_name":"Chris"}]'
22
- query=select read_stream from permissions where uid = 216743:
23
- get:
24
- with_token: '[{"read_stream":1}]'
25
- no_token: '{"error_code":104,"error_msg":"Requires valid signature","request_args":[{"key":"method","value":"fql.query"},{"key":"format","value":"json"},{"key":"query","value":"select read_stream from permissions where uid = 216743"}]}'
26
-
27
-
28
- # ====== GRAPH API =====
29
- graph_api:
30
-
31
- # -- Common Responses --
32
-
33
- # Error responses for when a token is required, but not given
34
- token_required_responses: &token_required
35
- no_token: '{"error":{"type":"OAuthAccessTokenException", "message":"An access token is required to request this resource."}}'
36
-
37
- # Common mock item responses
38
- item_deleted: &item_deleted
39
- delete:
40
- with_token: 'true'
41
-
42
- # OAuth error response
43
- oauth_error: &oauth_error
44
- no_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
45
-
46
- # Subscription error response
47
- verification_error: &verification_error
48
- with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
49
-
50
- test_user_no_perms: &test_user_no_perms
51
- post:
52
- with_token: '{"id": "777777777", "access_token":"119908831367602|o3wswWQ88LYjEC9-ukR_gjRIOMw.", "login_url":"https://www.facebook.com/platform/test_account.."}'
53
-
54
- # -- Stubbed Responses --
55
- root:
56
- ids=contextoptional,naitik:
57
- get:
58
- with_token: '[{}, {}]'
59
- no_token: '[{}, {}]'
60
- /me:
61
- no_args:
62
- get:
63
- <<: *token_required
64
- with_token: '{"updated_time": 1}'
65
- fields=id:
66
- get:
67
- with_token: '{"id": "216743"}'
68
-
69
- /me/feed:
70
- message=Hello, world, from the test suite!:
71
- post:
72
- with_token: '{"id": "MOCK_FEED_ITEM"}'
73
- message=Hello, world, from the test suite, testing comments!:
74
- post:
75
- with_token: '{"id": "MOCK_FEED_ITEM"}'
76
- message=the cats are asleep:
77
- post:
78
- with_token: '{"id": "FEED_ITEM_CATS"}'
79
- message=Hello, world, from the test suite delete method!:
80
- post:
81
- with_token: '{"id": "FEED_ITEM_DELETE"}'
82
- link=http://www.contextoptional.com/&message=Hello, world, from the test suite again!&name=Context Optional:
83
- post:
84
- with_token: '{"id": "FEED_ITEM_CONTEXT"}'
85
-
86
- /koppel:
87
- no_args:
88
- get:
89
- with_token: '{"id": 1, "name": 1, "updated_time": 1}'
90
- no_token: '{"id": 1, "name": 1}'
91
-
92
- /contextoptional:
93
- no_args:
94
- get:
95
- with_token: '{"id": 1, "name": 1}'
96
- no_token: '{"id": 1, "name": 1}'
97
-
98
- /contextoptional/photos:
99
- no_args:
100
- get:
101
- with_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
102
- no_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
103
-
104
- /lukeshepard/likes:
105
- no_args:
106
- get:
107
- <<: *token_required
108
- with_token: '{"data": [{}]}'
109
-
110
- /chris.baclig/picture:
111
- no_args:
112
- get:
113
- no_token:
114
- code: 302
115
- headers:
116
- Location: http://facebook.com/
117
- with_token:
118
- code: 302
119
- headers:
120
- Location: http://facebook.com/
121
- type=large:
122
- get:
123
- no_token:
124
- code: 302
125
- headers:
126
- Location: http://facebook.com/large
127
- with_token:
128
- code: 302
129
- headers:
130
- Location: http://facebook.com/large
131
-
132
-
133
- /search:
134
- q=facebook:
135
- get:
136
- with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
137
- no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
138
- "limit=25&q=facebook&until=2010-09-23T21:17:33+0000":
139
- get:
140
- with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
141
- no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
142
-
143
- '/115349521819193_113815981982767':
144
- no_args:
145
- delete:
146
- <<: *token_required
147
-
148
- # -- OAuth responses --
149
- /oauth/access_token:
150
- client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=<%= OAUTH_CODE %>&redirect_uri=<%= OAUTH_DATA["callback_url"] %>:
151
- get:
152
- no_token: access_token=<%= ACCESS_TOKEN %>
153
- client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=foo&redirect_uri=<%= OAUTH_DATA["callback_url"] %>:
154
- get:
155
- <<: *oauth_error
156
- client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&type=client_cred:
157
- post:
158
- no_token: access_token=<%= ACCESS_TOKEN %>
159
- /oauth/exchange_sessions:
160
- client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= OAUTH_DATA["session_key"] %>&type=client_cred:
161
- post:
162
- no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
163
- client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= OAUTH_DATA["multiple_session_keys"].join(",") %>&type=client_cred:
164
- post:
165
- no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
166
- client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= ["foo"].concat(OAUTH_DATA["multiple_session_keys"]).join(",") %>&type=client_cred:
167
- post:
168
- no_token: '[null, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
169
- client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo,bar&type=client_cred:
170
- post:
171
- no_token: '[null, null]'
172
- client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo&type=client_cred:
173
- post:
174
- no_token: '[null]'
175
-
176
-
177
-
178
- # -- Subscription Responses --
179
- /<%= APP_ID %>/subscriptions:
180
- callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
181
- post:
182
- with_token:
183
- code: 200
184
- callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
185
- post:
186
- with_token: '{"error":{"type":"Exception","message":"(#2200) subscription validation failed"}}'
187
- callback_url=foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
188
- post:
189
- with_token: '{"error":{"type":"Exception","message":"(#100) callback_url URL is not properly formatted"}}'
190
- object=user:
191
- delete:
192
- with_token:
193
- code: 200
194
- object=kittens:
195
- delete:
196
- with_token: '{"error":{"type":"Exception","message":"(#100) Invalid parameter"}}'
197
- no_args:
198
- delete:
199
- with_token:
200
- code: 200
201
- get:
202
- with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'
203
-
204
-
205
- callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>:
206
- get:
207
- with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'
208
-
209
- # -- Mock Item Responses --
210
-
211
- /MOCK_FEED_ITEM/likes:
212
- no_args:
213
- post:
214
- with_token: '{"id": "MOCK_LIKE"}'
215
-
216
- /MOCK_FEED_ITEM/comments:
217
- message=it's my comment!:
218
- post:
219
- with_token: '{"id": "MOCK_COMMENT"}'
220
-
221
- /MOCK_FEED_ITEM:
222
- no_args:
223
- <<: *item_deleted
224
-
225
- /FEED_ITEM_CONTEXT:
226
- no_args:
227
- <<: *item_deleted
228
- get:
229
- with_token: '{"link":"http://www.contextoptional.com/", "name": "Context Optional"}'
230
-
231
- /FEED_ITEM_CATS:
232
- no_args:
233
- <<: *item_deleted
234
- get:
235
- with_token: '{"message": "the cats are asleep"}'
236
-
237
- /FEED_ITEM_DELETE:
238
- no_args:
239
- <<: *item_deleted
240
-
241
- /MOCK_COMMENT:
242
- no_args:
243
- <<: *item_deleted
244
- get:
245
- with_token: "{\"message\": \"it\'s my comment!\"}"
246
-
247
- # -- Mock Test User Responses --
248
- /<%= APP_ID %>/accounts/test-users:
249
- installed=false:
250
- <<: *test_user_no_perms
251
- installed=false&permissions=read_stream:
252
- <<: *test_user_no_perms
253
- installed=true&permissions=read_stream:
254
- post:
255
- with_token: '{"id": "999999999", "access_token":"119908831367602|o3wswWQ88LYjEC9-ukR_gjRIOMw.", "login_url":"https://www.facebook.com/platform/test_account.."}'
256
- installed=true&permissions=read_stream,user_interests:
257
- post:
258
- with_token: '{"id": "888888888", "access_token":"119908831367602|o3wswWQ88LYjEC9-ukR_gjRIOMw.", "login_url":"https://www.facebook.com/platform/test_account.."}'
259
- no_args:
260
- get:
261
- with_token: '{"data":[{"id": "999999999", "access_token":"119908831367602|o3wswWQ88LYjEC9-ukR_gjRIOMw.", "login_url":"https://www.facebook.com/platform/test_account.."}, {"id": "888888888", "access_token":"119908831367602|o3wswWQ88LYjEC9-ukR_gjRIOMw.", "login_url":"https://www.facebook.com/platform/test_account.."}]}'
262
-
263
- /999999999:
264
- no_args:
265
- <<: *item_deleted
266
-
267
- /9999999991:
268
- no_args:
269
- delete:
270
- with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
271
-
272
- /888888888:
273
- no_args:
274
- <<: *item_deleted
275
-
276
- /777777777:
277
- no_args:
278
- <<: *item_deleted
279
-
280
- /999999999/friends/888888888:
281
- no_args:
282
- get:
283
- with_token: 'true'
284
-
285
- /888888888/friends/999999999:
286
- no_args:
287
- get:
288
- with_token: 'true'
289
-
1
+ # Responses by MockHTTPService are taken directly from
2
+ # this file.
3
+ #
4
+ # Structure
5
+ # ----------
6
+ #
7
+ # path:
8
+ # arguments: # sorted by key
9
+ # method: # HTTP method (GET, POST, DELETE, etc.)
10
+ # with_token:
11
+ # no_token:
12
+
13
+ # ====== REST API =====
14
+ rest_api:
15
+
16
+ # -- Stubbed Responses --
17
+ /method/fql.query:
18
+ query=select first_name from user where uid = 216743:
19
+ get:
20
+ no_token: '[{"first_name":"Chris"}]'
21
+ with_token: '[{"first_name":"Chris"}]'
22
+ query=select read_stream from permissions where uid = 216743:
23
+ get:
24
+ with_token: '[{"read_stream":1}]'
25
+ no_token: '{"error_code":104,"error_msg":"Requires valid signature","request_args":[{"key":"method","value":"fql.query"},{"key":"format","value":"json"},{"key":"query","value":"select read_stream from permissions where uid = 216743"}]}'
26
+
27
+
28
+ # ====== GRAPH API =====
29
+ graph_api:
30
+
31
+ # -- Common Responses --
32
+
33
+ # Error responses for when a token is required, but not given
34
+ token_required_responses: &token_required
35
+ no_token: '{"error":{"type":"OAuthAccessTokenException", "message":"An access token is required to request this resource."}}'
36
+
37
+ # Common mock item responses
38
+ item_deleted: &item_deleted
39
+ delete:
40
+ with_token: 'true'
41
+
42
+ # OAuth error response
43
+ oauth_error: &oauth_error
44
+ no_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
45
+
46
+ # Subscription error response
47
+ verification_error: &verification_error
48
+ with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
49
+
50
+ test_user_no_perms: &test_user_no_perms
51
+ post:
52
+ with_token: '{"id": "777777777", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}'
53
+
54
+ test_user_befriended: &test_user_befriended
55
+ post:
56
+ with_token: 'true'
57
+
58
+ # -- Stubbed Responses --
59
+ root:
60
+ ids=contextoptional,naitik:
61
+ get:
62
+ with_token: '[{}, {}]'
63
+ no_token: '[{}, {}]'
64
+ /me:
65
+ no_args:
66
+ get:
67
+ <<: *token_required
68
+ with_token: '{"updated_time": 1}'
69
+ fields=id:
70
+ get:
71
+ with_token: '{"id": "216743"}'
72
+
73
+ /me/feed:
74
+ message=Hello, world, from the test suite!:
75
+ post:
76
+ with_token: '{"id": "MOCK_FEED_ITEM"}'
77
+ message=Hello, world, from the test suite, testing comments!:
78
+ post:
79
+ with_token: '{"id": "MOCK_FEED_ITEM"}'
80
+ message=the cats are asleep:
81
+ post:
82
+ with_token: '{"id": "FEED_ITEM_CATS"}'
83
+ message=Hello, world, from the test suite delete method!:
84
+ post:
85
+ with_token: '{"id": "FEED_ITEM_DELETE"}'
86
+ link=http://oauth.twoalex.com/&message=Hello, world, from the test suite again!&name=OAuth Playground:
87
+ post:
88
+ with_token: '{"id": "FEED_ITEM_CONTEXT"}'
89
+ /me/photos:
90
+ source=[FILE]:
91
+ post:
92
+ <<: *token_required
93
+ with_token: '{"id": "MOCK_PHOTO"}'
94
+ message=This is the test message&source=[FILE]:
95
+ post:
96
+ <<: *token_required
97
+ with_token: '{"id": "MOCK_PHOTO"}'
98
+ /koppel:
99
+ no_args:
100
+ get:
101
+ with_token: '{"id": 1, "name": 1, "updated_time": 1}'
102
+ no_token: '{"id": 1, "name": 1}'
103
+
104
+ /contextoptional:
105
+ no_args:
106
+ get:
107
+ with_token: '{"id": 1, "name": 1}'
108
+ no_token: '{"id": 1, "name": 1}'
109
+
110
+ /contextoptional/photos:
111
+ no_args:
112
+ get:
113
+ with_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
114
+ no_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
115
+
116
+ /lukeshepard/likes:
117
+ no_args:
118
+ get:
119
+ <<: *token_required
120
+ with_token: '{"data": [{}]}'
121
+
122
+ /chris.baclig/picture:
123
+ no_args:
124
+ get:
125
+ no_token:
126
+ code: 302
127
+ headers:
128
+ Location: http://facebook.com/
129
+ with_token:
130
+ code: 302
131
+ headers:
132
+ Location: http://facebook.com/
133
+ type=large:
134
+ get:
135
+ no_token:
136
+ code: 302
137
+ headers:
138
+ Location: http://facebook.com/large
139
+ with_token:
140
+ code: 302
141
+ headers:
142
+ Location: http://facebook.com/large
143
+
144
+
145
+ /search:
146
+ q=facebook:
147
+ get:
148
+ with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
149
+ no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
150
+ "limit=25&q=facebook&until=2010-09-23T21:17:33+0000":
151
+ get:
152
+ with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
153
+ no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
154
+
155
+ '/115349521819193_113815981982767':
156
+ no_args:
157
+ delete:
158
+ <<: *token_required
159
+
160
+ # -- OAuth responses --
161
+ /oauth/access_token:
162
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=<%= OAUTH_CODE %>&redirect_uri=<%= OAUTH_DATA["callback_url"] %>:
163
+ get:
164
+ no_token: access_token=<%= ACCESS_TOKEN %>
165
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=foo&redirect_uri=<%= OAUTH_DATA["callback_url"] %>:
166
+ get:
167
+ <<: *oauth_error
168
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&type=client_cred:
169
+ post:
170
+ no_token: access_token=<%= ACCESS_TOKEN %>
171
+ /oauth/exchange_sessions:
172
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= OAUTH_DATA["session_key"] %>&type=client_cred:
173
+ post:
174
+ no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
175
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= OAUTH_DATA["multiple_session_keys"].join(",") %>&type=client_cred:
176
+ post:
177
+ no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
178
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= ["foo"].concat(OAUTH_DATA["multiple_session_keys"]).join(",") %>&type=client_cred:
179
+ post:
180
+ no_token: '[null, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
181
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo,bar&type=client_cred:
182
+ post:
183
+ no_token: '[null, null]'
184
+ client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo&type=client_cred:
185
+ post:
186
+ no_token: '[null]'
187
+
188
+
189
+
190
+ # -- Subscription Responses --
191
+ /<%= APP_ID %>/subscriptions:
192
+ callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
193
+ post:
194
+ with_token:
195
+ code: 200
196
+ callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
197
+ post:
198
+ with_token: '{"error":{"type":"Exception","message":"(#2200) subscription validation failed"}}'
199
+ callback_url=foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
200
+ post:
201
+ with_token: '{"error":{"type":"Exception","message":"(#100) callback_url URL is not properly formatted"}}'
202
+ object=user:
203
+ delete:
204
+ with_token:
205
+ code: 200
206
+ object=kittens:
207
+ delete:
208
+ with_token: '{"error":{"type":"Exception","message":"(#100) Invalid parameter"}}'
209
+ no_args:
210
+ delete:
211
+ with_token:
212
+ code: 200
213
+ get:
214
+ with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'
215
+
216
+
217
+ callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>:
218
+ get:
219
+ with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'
220
+
221
+ # -- Mock Item Responses --
222
+
223
+ /MOCK_FEED_ITEM/likes:
224
+ no_args:
225
+ post:
226
+ with_token: '{"id": "MOCK_LIKE"}'
227
+
228
+ /MOCK_FEED_ITEM/comments:
229
+ message=it's my comment!:
230
+ post:
231
+ with_token: '{"id": "MOCK_COMMENT"}'
232
+
233
+ /MOCK_FEED_ITEM:
234
+ no_args:
235
+ <<: *item_deleted
236
+
237
+ /FEED_ITEM_CONTEXT:
238
+ no_args:
239
+ <<: *item_deleted
240
+ get:
241
+ with_token: '{"link":"http://oauth.twoalex.com/", "name": "OAuth Playground"}'
242
+
243
+ /FEED_ITEM_CATS:
244
+ no_args:
245
+ <<: *item_deleted
246
+ get:
247
+ with_token: '{"message": "the cats are asleep"}'
248
+
249
+ /FEED_ITEM_DELETE:
250
+ no_args:
251
+ <<: *item_deleted
252
+
253
+ /FEED_ITEM_DELETE/likes:
254
+ no_args:
255
+ <<: *item_deleted
256
+ post:
257
+ with_token: 'true'
258
+
259
+ /MOCK_COMMENT:
260
+ no_args:
261
+ <<: *item_deleted
262
+ get:
263
+ with_token: "{\"message\": \"it's my comment!\"}"
264
+ /MOCK_PHOTO:
265
+ no_args:
266
+ <<: *item_deleted
267
+ get:
268
+ with_token: "{\"name\": \"This is the test message\"}"
269
+
270
+ # -- Mock Test User Responses --
271
+ /<%= APP_ID %>/accounts/test-users:
272
+ installed=false:
273
+ <<: *test_user_no_perms
274
+ installed=false&permissions=read_stream:
275
+ <<: *test_user_no_perms
276
+ installed=true&permissions=read_stream:
277
+ post:
278
+ with_token: '{"id": "999999999", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}'
279
+ installed=true&permissions=read_stream,user_interests:
280
+ post:
281
+ with_token: '{"id": "888888888", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}'
282
+ no_args:
283
+ get:
284
+ with_token: '{"data":[{"id": "999999999", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}, {"id": "888888888", "access_token":"119908831367602|o3wswWQ88LYjEC9-ukR_gjRIOMw.", "login_url":"https://www.facebook.com/platform/test_account.."}]}'
285
+
286
+ /999999999:
287
+ no_args:
288
+ <<: *item_deleted
289
+
290
+ /999999999/friends/888888888:
291
+ no_args:
292
+ post:
293
+ with_token: 'true'
294
+
295
+
296
+ /9999999991:
297
+ no_args:
298
+ delete:
299
+ with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
300
+
301
+ /888888888:
302
+ no_args:
303
+ <<: *item_deleted
304
+
305
+ /888888888/friends/999999999:
306
+ no_args:
307
+ <<: *test_user_befriended
308
+
309
+
310
+ /777777777:
311
+ no_args:
312
+ <<: *item_deleted
@@ -0,0 +1,18 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'although not required, bundler is recommened for running the tests'
5
+ end
6
+
7
+ # load the libraries
8
+ require 'koala'
9
+
10
+ # load testing data libraries
11
+ require 'support/live_testing_data_helper'
12
+ require 'support/mock_http_service'
13
+ require 'support/rest_api_shared_examples'
14
+ require 'support/graph_api_shared_examples'
15
+ require 'support/uploadable_io_shared_examples'
16
+ require 'support/setup_mocks_or_live'
17
+
18
+ BEACH_BALL_PATH = File.join(File.dirname(__FILE__), "fixtures", "beach.jpg")