# Responses by MockHTTPService are taken directly from # this file. # # Structure # ---------- # # path: # arguments: # sorted by key # method: # HTTP method (GET, POST, DELETE, etc.) # with_token: # no_token: # ====== REST API ===== rest_api: # -- Stubbed Responses -- /method/fql.query: query=select first_name from user where uid = 2901279: get: no_token: '[{"first_name":"Luke"}]' with_token: '[{"first_name":"Luke"}]' query=select read_stream from permissions where uid = 2901279: get: with_token: '[{"read_stream":1}]' 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 = 2901279"}]}' /method/fql.multiquery: 'queries=<%= MultiJson.encode({"query1" => "select post_id from stream where source_id = me()", "query2" => "select fromid from comment where post_id in (select post_id from #query1)", "query3" => "select uid, name from user where uid in (select fromid from #query2)"}) %>': get: with_token: '[{"name":"query1", "fql_result_set":[]},{"name":"query2", "fql_result_set":[]},{"name":"query3", "fql_result_set":[]}]' 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 = 2901279"}]}' 'queries=<%= MultiJson.encode({"query1" => "select first_name from user where uid = 2901279", "query2" => "select first_name from user where uid = 2905623"}) %>': get: with_token: '[{"name":"query1", "fql_result_set":[{"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"first_name":"Alex"}]}]' no_token: '[{"name":"query1", "fql_result_set":[{"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"first_name":"Alex"}]}]' # ====== GRAPH API ===== graph_api: # -- Common Responses -- # Error responses for when a token is required, but not given token_required_responses: &token_required no_token: '{"error":{"type":"OAuthAccessTokenException", "message":"An access token is required to request this resource."}}' # Common mock item responses item_deleted: &item_deleted delete: with_token: 'true' # OAuth error response oauth_error: &oauth_error no_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}' # Subscription error response verification_error: &verification_error with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}' test_user_uninstalled: &test_user_uninstalled post: with_token: '{"id": "777777777", "access_token":"<%= APP_ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}' test_user_installed: &test_user_installed post: with_token: '{"id": "999999999", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}' test_user_befriended: &test_user_befriended post: with_token: 'true' # -- Stubbed Responses -- root: ids=contextoptional,koppel: get: with_token: '{"contextoptional":"{}","koppel":"{}"}' no_token: '{"contextoptional":"{}","koppel":"{}"}' # Ruby 1.8.7 and 1.9.2 generate JSON with different key ordering, hence we have to dynamically generate it here batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "koppel"}]) %>: post: with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"id\":\"456\"}"}]' batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/picture"}]) %>: post: with_token: '[{"headers":[{"name":"Location","value":"http://google.com"}]}]' batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "me/friends"}]) %>: post: with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"data\":[],\"paging\":{}}"}]' batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"me"}, {"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>: post: with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"data\":[],\"paging\":{}}"}]' batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights"}, {"method"=>"get", "relative_url"=>"koppel?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>: post: with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},{"body":"{\"id\":\"123\"}"}]' batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"FEED_ITEM_BATCH/likes"}, {"method"=>"delete", "relative_url"=> "FEED_ITEM_BATCH"}]) %>: post: with_token: '[{"body": "{\"id\": \"MOCK_LIKE\"}"},{"body":true}]' batch=<%= MultiJson.encode([{"method" => "post", "relative_url" => "method/fql.query", "body" => "query=select+first_name+from+user+where+uid%3D2905623"}]) %>: post: with_token: '[{"body":"[{\"first_name\":\"Alex\"}]"}]' # dependencies batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"me", "name" => "getme"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getme"}]) %>: post: with_token: '[null,{"body":"{\"id\":\"123\"}"}]' batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights", "name" => "getdata"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getdata"}]) %>: post: with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]' batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>: post: with_token: '[null,{"body":"{}"}]' batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends", "omit_response_on_success" => false}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>: post: with_token: '[{"body":"{\"data\":[],\"paging\":{}}"},{"body":"{}"}]' batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/friends?limit=5"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=i-dont-exist:$.data.*.id}"}"}]) %>: post: with_token: '{"error":190,"error_description":"Error validating access token."}' # attached files tests batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]: post: with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]' batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]: post: with_token: '[{"body":"{\"id\": \"MOCK_PHOTO\"}"}]' batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}, {"method"=>"post", "relative_url"=>"koppel/photos", "attached_files" => "op2_file0"}]) %>&op1_file0=[FILE]&op2_file0=[FILE]: post: with_token: '[{"body":"{\"id\": \"MOCK_PHOTO\"}"}, {"body":"{\"id\": \"MOCK_PHOTO\"}"}]' /me: no_args: get: <<: *token_required with_token: '{"updated_time": 1}' fields=id: get: with_token: '{"id": "2901279"}' /me/feed: message=Hello, world, from the test suite!: post: with_token: '{"id": "MOCK_FEED_ITEM"}' message=Hello, world, from the test suite, testing comments!: post: with_token: '{"id": "MOCK_FEED_ITEM"}' message=the cats are asleep: post: with_token: '{"id": "FEED_ITEM_CATS"}' message=Hello, world, from the test suite delete method!: post: with_token: '{"id": "FEED_ITEM_DELETE"}' message=Hello, world, from the test suite batch API!: post: with_token: '{"id": "FEED_ITEM_BATCH"}' link=http://oauth.twoalex.com/&message=Hello, world, from the test suite again!&name=OAuth Playground: post: with_token: '{"id": "FEED_ITEM_CONTEXT"}' /me/photos: source=[FILE]: post: <<: *token_required with_token: '{"id": "MOCK_PHOTO"}' message=This is the test message&source=[FILE]: post: <<: *token_required with_token: '{"id": "MOCK_PHOTO"}' url=http://img.slate.com/images/redesign2008/slate_logo.gif: post: <<: *token_required with_token: '{"id": "MOCK_PHOTO_FROM_URL"}' message=my message&url=http://img.slate.com/images/redesign2008/slate_logo.gif: post: <<: *token_required with_token: '{"id": "MOCK_PHOTO_FROM_URL"}' /me/videos: source=[FILE]: post: <<: *token_required with_token: '{"id": "MOCK_PHOTO"}' message=This is the test message&source=[FILE]: post: <<: *token_required with_token: '{"id": "MOCK_PHOTO"}' /koppel: no_args: get: with_token: '{"id": 1, "name": 1, "updated_time": 1}' no_token: '{"id": 1, "name": 1}' /contextoptional: no_args: get: with_token: '{"id": 1, "name": 1}' no_token: '{"id": 1, "name": 1}' /contextoptional/photos: no_args: get: 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"}}' 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"}}' /lukeshepard/friends: no_args: get: <<: *token_required with_token: '{"data": [{}], "paging": {}}' /lukeshepard/picture: type=large: get: no_token: code: 302 headers: Location: https://facebook.com/large with_token: code: 302 headers: Location: https://facebook.com/large /chris.baclig/picture: no_args: get: no_token: code: 302 headers: Location: http://facebook.com/ with_token: code: 302 headers: Location: http://facebook.com/ /comments: ids=http://developers.facebook.com/blog/post/472: get: with_token: '{"http://developers.facebook.com/blog/post/472": []}' no_token: '{"http://developers.facebook.com/blog/post/472": []}' ids=http://developers.facebook.com/blog/post/490,http://developers.facebook.com/blog/post/472: get: with_token: '{"http://developers.facebook.com/blog/post/490": [], "http://developers.facebook.com/blog/post/472": []}' no_token: '{"http://developers.facebook.com/blog/post/490": [], "http://developers.facebook.com/blog/post/472": []}' ids=: get: body: '{"error": {"type": "OAuthException","message": "Cannot specify an empty identifier"}}' code: 400 no_args: get: body: '{"error": {"type": "Exception","message": "No node specified"}}' code: 500 /search: q=facebook: get: 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"}}' 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"}}' "limit=25&q=facebook&until=<%= TEST_DATA['search_time'] %>": get: 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"}}' 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"}}' '/115349521819193_113815981982767': no_args: delete: <<: *token_required /my_page: fields=access_token: get: <<: *token_required with_token: '{"access_token": "<%= APP_ACCESS_TOKEN %>"}' # -- OAuth responses -- /oauth/access_token: client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=<%= OAUTH_CODE %>&redirect_uri=<%= OAUTH_DATA["callback_url"] %>: get: no_token: access_token=<%= ACCESS_TOKEN %> client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=foo&redirect_uri=<%= OAUTH_DATA["callback_url"] %>: get: <<: *oauth_error client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&type=client_cred: post: no_token: access_token=<%= APP_ACCESS_TOKEN %> /oauth/exchange_sessions: client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= OAUTH_DATA["session_key"] %>&type=client_cred: post: no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]' client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= [OAUTH_DATA["session_key"], OAUTH_DATA["session_key"]].join(",") %>&type=client_cred: post: no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]' client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= ["foo"].concat([OAUTH_DATA["session_key"], OAUTH_DATA["session_key"]]).join(",") %>&type=client_cred: post: no_token: '[null, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]' client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo,bar&type=client_cred: post: no_token: '[null, null]' client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo&type=client_cred: post: no_token: '[null]' # -- Subscription Responses -- /<%= APP_ID %>/subscriptions: callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>: post: with_token: code: 200 callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>: post: with_token: '{"error":{"type":"Exception","message":"(#2200) subscription validation failed"}}' callback_url=foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>: post: with_token: '{"error":{"type":"Exception","message":"(#100) callback_url URL is not properly formatted"}}' object=user: delete: with_token: code: 200 object=kittens: delete: with_token: '{"error":{"type":"Exception","message":"(#100) Invalid parameter"}}' no_args: delete: with_token: code: 200 get: with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}' callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>: get: with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}' # -- Mock Item Responses -- /MOCK_FEED_ITEM/likes: no_args: post: with_token: '{"id": "MOCK_LIKE"}' /MOCK_FEED_ITEM/comments: message=it's my comment!: post: with_token: '{"id": "MOCK_COMMENT"}' /MOCK_FEED_ITEM: no_args: <<: *item_deleted /FEED_ITEM_CONTEXT: no_args: <<: *item_deleted get: with_token: '{"link":"http://oauth.twoalex.com/", "name": "OAuth Playground"}' /FEED_ITEM_CATS: no_args: <<: *item_deleted get: with_token: '{"message": "the cats are asleep"}' /FEED_ITEM_DELETE: no_args: <<: *item_deleted /FEED_ITEM_DELETE/likes: no_args: <<: *item_deleted post: with_token: 'true' /MOCK_COMMENT: no_args: <<: *item_deleted get: with_token: "{\"message\": \"it's my comment!\"}" /MOCK_PHOTO: no_args: <<: *item_deleted get: with_token: "{\"name\": \"This is the test message\"}" # -- Mock Test User Responses -- /<%= APP_ID %>/accounts/test-users: installed=false: <<: *test_user_uninstalled installed=false&permissions=read_stream: <<: *test_user_uninstalled installed=true&permissions=: <<: *test_user_installed installed=true&permissions=read_stream: <<: *test_user_installed installed=true&permissions=read_stream,user_interests: post: with_token: '{"id": "888888888", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}' no_args: get: 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.."}]}' /999999999: no_args: <<: *item_deleted get: with_token: '{"name":"Foo Baz"}' name=Foo Baz: post: with_token: 'true' /999999999/friends/888888888: no_args: post: with_token: 'true' /9999999991: no_args: delete: with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}' /888888888: no_args: <<: *item_deleted /888888888/friends/999999999: no_args: <<: *test_user_befriended /777777777: no_args: <<: *item_deleted