rest-core 0.4.0 → 0.7.0
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.
- data/.travis.yml +2 -7
- data/CHANGES.md +13 -2
- data/Gemfile +0 -3
- data/README.md +30 -34
- data/Rakefile +5 -46
- data/lib/rest-core.rb +0 -6
- data/lib/rest-core/version.rb +1 -1
- data/rest-core.gemspec +5 -83
- metadata +11 -87
- data/example/rails2/Gemfile +0 -21
- data/example/rails2/README +0 -4
- data/example/rails2/Rakefile +0 -11
- data/example/rails2/app/controllers/application_controller.rb +0 -128
- data/example/rails2/app/views/application/helper.html.erb +0 -2
- data/example/rails2/config/boot.rb +0 -130
- data/example/rails2/config/environment.rb +0 -15
- data/example/rails2/config/environments/development.rb +0 -17
- data/example/rails2/config/environments/production.rb +0 -28
- data/example/rails2/config/environments/test.rb +0 -30
- data/example/rails2/config/initializers/cookie_verification_secret.rb +0 -7
- data/example/rails2/config/initializers/new_rails_defaults.rb +0 -21
- data/example/rails2/config/initializers/session_store.rb +0 -15
- data/example/rails2/config/preinitializer.rb +0 -23
- data/example/rails2/config/rest-core.yaml +0 -16
- data/example/rails2/config/routes.rb +0 -43
- data/example/rails2/log +0 -0
- data/example/rails2/test/functional/application_controller_test.rb +0 -197
- data/example/rails2/test/test_helper.rb +0 -18
- data/example/rails2/test/unit/rails_util_test.rb +0 -44
- data/example/rails3/Gemfile +0 -20
- data/example/rails3/README +0 -4
- data/example/rails3/Rakefile +0 -7
- data/example/rails3/app/controllers/application_controller.rb +0 -128
- data/example/rails3/app/views/application/helper.html.erb +0 -2
- data/example/rails3/config.ru +0 -4
- data/example/rails3/config/application.rb +0 -23
- data/example/rails3/config/environment.rb +0 -5
- data/example/rails3/config/environments/development.rb +0 -26
- data/example/rails3/config/environments/production.rb +0 -49
- data/example/rails3/config/environments/test.rb +0 -30
- data/example/rails3/config/initializers/secret_token.rb +0 -7
- data/example/rails3/config/initializers/session_store.rb +0 -8
- data/example/rails3/config/rest-core.yaml +0 -16
- data/example/rails3/config/routes.rb +0 -5
- data/example/rails3/test/functional/application_controller_test.rb +0 -197
- data/example/rails3/test/test_helper.rb +0 -18
- data/example/rails3/test/unit/rails_util_test.rb +0 -44
- data/example/sinatra/config.ru +0 -16
- data/lib/rest-core/client/facebook.rb +0 -251
- data/lib/rest-core/client/facebook/rails_util.rb +0 -333
- data/lib/rest-core/client/flurry.rb +0 -96
- data/lib/rest-core/client/flurry/rails_util.rb +0 -74
- data/lib/rest-core/client/github.rb +0 -18
- data/lib/rest-core/client/linkedin.rb +0 -59
- data/lib/rest-core/client/mixi.rb +0 -47
- data/lib/rest-core/client/twitter.rb +0 -101
- data/test/client/facebook/config/rest-core.yaml +0 -8
- data/test/client/facebook/test_api.rb +0 -97
- data/test/client/facebook/test_cache.rb +0 -58
- data/test/client/facebook/test_default.rb +0 -23
- data/test/client/facebook/test_error.rb +0 -65
- data/test/client/facebook/test_handler.rb +0 -84
- data/test/client/facebook/test_load_config.rb +0 -39
- data/test/client/facebook/test_misc.rb +0 -72
- data/test/client/facebook/test_oauth.rb +0 -38
- data/test/client/facebook/test_old.rb +0 -114
- data/test/client/facebook/test_page.rb +0 -106
- data/test/client/facebook/test_parse.rb +0 -128
- data/test/client/facebook/test_serialize.rb +0 -43
- data/test/client/facebook/test_timeout.rb +0 -22
- data/test/client/flurry/test_metrics.rb +0 -83
- data/test/client/twitter/test_api.rb +0 -37
data/example/rails3/config.ru
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
|
2
|
-
# Set up gems listed in the Gemfile.
|
3
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
4
|
-
|
5
|
-
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
6
|
-
|
7
|
-
require 'action_controller/railtie'
|
8
|
-
require 'rails/test_unit/railtie'
|
9
|
-
|
10
|
-
Bundler.require(:default, Rails.env)
|
11
|
-
|
12
|
-
module Rails3
|
13
|
-
class Application < Rails::Application
|
14
|
-
config.encoding = 'utf-8'
|
15
|
-
|
16
|
-
logger = Logger.new($stdout)
|
17
|
-
logger.level = Logger::INFO
|
18
|
-
config.logger = logger
|
19
|
-
|
20
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
21
|
-
config.filter_parameters += [:password]
|
22
|
-
end
|
23
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
Rails3::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# In the development environment your application's code is reloaded on
|
5
|
-
# every request. This slows down response time but is perfect for development
|
6
|
-
# since you don't have to restart the webserver when you make code changes.
|
7
|
-
config.cache_classes = false
|
8
|
-
|
9
|
-
# Log error messages when you accidentally call methods on nil.
|
10
|
-
config.whiny_nils = true
|
11
|
-
|
12
|
-
# Show full error reports and disable caching
|
13
|
-
config.consider_all_requests_local = true
|
14
|
-
config.action_view.debug_rjs = true
|
15
|
-
config.action_controller.perform_caching = false
|
16
|
-
|
17
|
-
# Don't care if the mailer can't send
|
18
|
-
config.action_mailer.raise_delivery_errors = false
|
19
|
-
|
20
|
-
# Print deprecation notices to the Rails logger
|
21
|
-
config.active_support.deprecation = :log
|
22
|
-
|
23
|
-
# Only use best-standards-support built into browsers
|
24
|
-
config.action_dispatch.best_standards_support = :builtin
|
25
|
-
end
|
26
|
-
|
@@ -1,49 +0,0 @@
|
|
1
|
-
Rails3::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# The production environment is meant for finished, "live" apps.
|
5
|
-
# Code is not reloaded between requests
|
6
|
-
config.cache_classes = true
|
7
|
-
|
8
|
-
# Full error reports are disabled and caching is turned on
|
9
|
-
config.consider_all_requests_local = false
|
10
|
-
config.action_controller.perform_caching = true
|
11
|
-
|
12
|
-
# Specifies the header that your server uses for sending files
|
13
|
-
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
-
|
15
|
-
# For nginx:
|
16
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
-
|
18
|
-
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
-
# just comment this out and Rails will serve the files
|
20
|
-
|
21
|
-
# See everything in the log (default is :info)
|
22
|
-
# config.log_level = :debug
|
23
|
-
|
24
|
-
# Use a different logger for distributed setups
|
25
|
-
# config.logger = SyslogLogger.new
|
26
|
-
|
27
|
-
# Use a different cache store in production
|
28
|
-
# config.cache_store = :mem_cache_store
|
29
|
-
|
30
|
-
# Disable Rails's static asset server
|
31
|
-
# In production, Apache or nginx will already do this
|
32
|
-
config.serve_static_assets = false
|
33
|
-
|
34
|
-
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
-
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
-
|
37
|
-
# Disable delivery errors, bad email addresses will be ignored
|
38
|
-
# config.action_mailer.raise_delivery_errors = false
|
39
|
-
|
40
|
-
# Enable threaded mode
|
41
|
-
# config.threadsafe!
|
42
|
-
|
43
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
-
# the I18n.default_locale when a translation can not be found)
|
45
|
-
config.i18n.fallbacks = true
|
46
|
-
|
47
|
-
# Send deprecation notices to registered listeners
|
48
|
-
config.active_support.deprecation = :notify
|
49
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
Rails3::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# The test environment is used exclusively to run your application's
|
5
|
-
# test suite. You never need to work with it otherwise. Remember that
|
6
|
-
# your test database is "scratch space" for the test suite and is wiped
|
7
|
-
# and recreated between test runs. Don't rely on the data there!
|
8
|
-
config.cache_classes = true
|
9
|
-
|
10
|
-
# Log error messages when you accidentally call methods on nil.
|
11
|
-
config.whiny_nils = true
|
12
|
-
|
13
|
-
# Show full error reports and disable caching
|
14
|
-
config.consider_all_requests_local = true
|
15
|
-
config.action_controller.perform_caching = false
|
16
|
-
|
17
|
-
# Raise exceptions instead of rendering exception templates
|
18
|
-
config.action_dispatch.show_exceptions = false
|
19
|
-
|
20
|
-
# Disable request forgery protection in test environment
|
21
|
-
config.action_controller.allow_forgery_protection = false
|
22
|
-
|
23
|
-
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
24
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
25
|
-
# like if you have constraints or database-specific column types
|
26
|
-
# config.active_record.schema_format = :sql
|
27
|
-
|
28
|
-
# Print deprecation notices to the stderr
|
29
|
-
config.active_support.deprecation = :stderr
|
30
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# Your secret key for verifying the integrity of signed cookies.
|
4
|
-
# If you change this key, all old signed cookies will become invalid!
|
5
|
-
# Make sure the secret is at least 30 characters and all random,
|
6
|
-
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
Rails3::Application.config.secret_token = '74c293b4c5df1981d2f92785aa5538a21b0901293d693e6bb828669cbb1f1d1f5ddd1b3e21325304c90e952a4866a9eec7620379b6f6c27aae0670cdefda97ae'
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
Rails3::Application.config.session_store :cookie_store, :key => '_rails3_session'
|
4
|
-
|
5
|
-
# Use the database for sessions instead of the cookie-based default,
|
6
|
-
# which shouldn't be used to store highly confidential information
|
7
|
-
# (create the session table with "rails generate session_migration")
|
8
|
-
# Rails3::Application.config.session_store :active_record_store
|
@@ -1,197 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'test_helper'
|
3
|
-
require 'webmock'
|
4
|
-
|
5
|
-
WebMock.disable_net_connect!
|
6
|
-
|
7
|
-
class ApplicationControllerTest < ActionController::TestCase
|
8
|
-
include WebMock::API
|
9
|
-
|
10
|
-
def setup
|
11
|
-
body = rand(2) == 0 ? '{"error":{"type":"OAuthException"}}' :
|
12
|
-
'{"error_code":104}'
|
13
|
-
|
14
|
-
stub_request(:get, 'https://graph.facebook.com/me').
|
15
|
-
to_return(:body => body)
|
16
|
-
end
|
17
|
-
|
18
|
-
def teardown
|
19
|
-
WebMock.reset!
|
20
|
-
end
|
21
|
-
|
22
|
-
def assert_url expected
|
23
|
-
assert_equal(expected, normalize_url(assigns(:rc_facebook_authorize_url)))
|
24
|
-
if @response.status == 200 # js redirect
|
25
|
-
assert_equal(
|
26
|
-
expected,
|
27
|
-
normalize_url(
|
28
|
-
@response.body.match(/window\.top\.location\.href = '(.+?)'/)[1]))
|
29
|
-
|
30
|
-
assert_equal(
|
31
|
-
CGI.escapeHTML(expected),
|
32
|
-
normalize_url(
|
33
|
-
@response.body.match(/content="0;url=(.+?)"/)[1], '&'))
|
34
|
-
|
35
|
-
assert_equal(
|
36
|
-
CGI.escapeHTML(expected),
|
37
|
-
normalize_url(
|
38
|
-
@response.body.match(/<a href="(.+?)" target="_top">/)[1], '&'))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_index
|
43
|
-
get(:index)
|
44
|
-
assert_response :redirect
|
45
|
-
|
46
|
-
url = normalize_url(
|
47
|
-
'https://graph.facebook.com/oauth/authorize?client_id=123&' \
|
48
|
-
'scope=&redirect_uri=http%3A%2F%2Ftest.host%2F')
|
49
|
-
|
50
|
-
assert_url(url)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_canvas
|
54
|
-
get(:canvas)
|
55
|
-
assert_response :success
|
56
|
-
|
57
|
-
url = normalize_url(
|
58
|
-
'https://graph.facebook.com/oauth/authorize?client_id=123&' \
|
59
|
-
'scope=publish_stream&' \
|
60
|
-
'redirect_uri=http%3A%2F%2Fapps.facebook.com%2Fcan%2Fcanvas')
|
61
|
-
|
62
|
-
assert_url(url)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_diff_canvas
|
66
|
-
get(:diff_canvas)
|
67
|
-
assert_response :success
|
68
|
-
|
69
|
-
url = normalize_url(
|
70
|
-
'https://graph.facebook.com/oauth/authorize?client_id=123&' \
|
71
|
-
'scope=email&' \
|
72
|
-
'redirect_uri=http%3A%2F%2Fapps.facebook.com%2FToT%2Fdiff_canvas')
|
73
|
-
|
74
|
-
assert_url(url)
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_iframe_canvas
|
78
|
-
get(:iframe_canvas)
|
79
|
-
assert_response :success
|
80
|
-
|
81
|
-
url = normalize_url(
|
82
|
-
'https://graph.facebook.com/oauth/authorize?client_id=123&' \
|
83
|
-
'scope=&' \
|
84
|
-
'redirect_uri=http%3A%2F%2Fapps.facebook.com%2Fzzz%2Fiframe_canvas')
|
85
|
-
|
86
|
-
assert_url(url)
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_options
|
90
|
-
get(:options)
|
91
|
-
assert_response :redirect
|
92
|
-
|
93
|
-
url = normalize_url(
|
94
|
-
'https://graph.facebook.com/oauth/authorize?client_id=123&' \
|
95
|
-
'scope=bogus&' \
|
96
|
-
'redirect_uri=http%3A%2F%2Ftest.host%2Foptions')
|
97
|
-
|
98
|
-
assert_url(url)
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_protected
|
102
|
-
assert_nil @controller.public_methods.find{ |m| m.to_s =~ /^rest_graph/ }
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_no_auto
|
106
|
-
get(:no_auto)
|
107
|
-
assert_response :success
|
108
|
-
assert_equal 'XD', @response.body
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_app_id
|
112
|
-
get(:diff_app_id)
|
113
|
-
assert_response :success
|
114
|
-
assert_equal 'zzz', @response.body
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_cache
|
118
|
-
WebMock.reset!
|
119
|
-
stub_request(:get, 'https://graph.facebook.com/cache').
|
120
|
-
to_return(:body => '{"message":"ok"}')
|
121
|
-
|
122
|
-
get(:cache)
|
123
|
-
assert_response :success
|
124
|
-
assert_equal '{"message":"ok"}', @response.body
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_handler
|
128
|
-
WebMock.reset!
|
129
|
-
stub_request(:get, 'https://graph.facebook.com/me?access_token=aloha').
|
130
|
-
to_return(:body => '["snowman"]')
|
131
|
-
|
132
|
-
Rails.cache[:fbs] = RestCore::Facebook.new(:access_token => 'aloha').fbs
|
133
|
-
get(:handler_)
|
134
|
-
assert_response :success
|
135
|
-
assert_equal '["snowman"]', @response.body
|
136
|
-
ensure
|
137
|
-
Rails.cache.clear
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_session
|
141
|
-
WebMock.reset!
|
142
|
-
stub_request(:get, 'https://graph.facebook.com/me?access_token=wozilla').
|
143
|
-
to_return(:body => '["fireball"]')
|
144
|
-
|
145
|
-
@request.session[RestCore::Facebook::RailsUtil.rc_facebook_storage_key] =
|
146
|
-
RestCore::Facebook.new(:access_token => 'wozilla').fbs
|
147
|
-
|
148
|
-
get(:session_)
|
149
|
-
assert_response :success
|
150
|
-
assert_equal '["fireball"]', @response.body
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_cookies
|
154
|
-
WebMock.reset!
|
155
|
-
stub_request(:get, 'https://graph.facebook.com/me?access_token=blizzard').
|
156
|
-
to_return(:body => '["yeti"]')
|
157
|
-
|
158
|
-
@request.cookies[RestCore::Facebook::RailsUtil.rc_facebook_storage_key] =
|
159
|
-
RestCore::Facebook.new(:access_token => 'blizzard').fbs
|
160
|
-
|
161
|
-
get(:cookies_)
|
162
|
-
assert_response :success
|
163
|
-
assert_equal '["yeti"]', @response.body
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_error
|
167
|
-
get(:error)
|
168
|
-
rescue => e
|
169
|
-
assert_equal RestCore::Facebook::Error, e.class
|
170
|
-
end
|
171
|
-
|
172
|
-
def test_reinitailize
|
173
|
-
get(:reinitialize)
|
174
|
-
assert_response :success
|
175
|
-
assert_equal({'a' => 'b'}, YAML.load(@response.body))
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_helper
|
179
|
-
get(:helper)
|
180
|
-
assert_response :success
|
181
|
-
assert_equal "#{RestCore::Facebook.default_app_id}\n" \
|
182
|
-
"#{RestCore::Flurry .default_api_key}",
|
183
|
-
@response.body.strip
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_no_ns_pollution
|
187
|
-
get(:no_ns_pollution)
|
188
|
-
assert_response :success
|
189
|
-
assert_equal 'Timeout::Error', @response.body.strip
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_defaults
|
193
|
-
get(:defaults)
|
194
|
-
assert_response :success
|
195
|
-
assert_equal 'true', @response.body.strip
|
196
|
-
end
|
197
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
|
-
require File.expand_path('../../config/environment', __FILE__)
|
4
|
-
begin
|
5
|
-
require 'rails/test_help'
|
6
|
-
rescue LoadError # for rails2
|
7
|
-
require 'test_help'
|
8
|
-
end
|
9
|
-
|
10
|
-
class ActiveSupport::TestCase
|
11
|
-
def normalize_query query, amp='&'
|
12
|
-
'?' + query[1..-1].split(amp).sort.join(amp)
|
13
|
-
end
|
14
|
-
|
15
|
-
def normalize_url url, amp='&'
|
16
|
-
url.sub(/\?.+/){ |query| normalize_query(query, amp) }
|
17
|
-
end
|
18
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'test_helper'
|
3
|
-
require 'rr'
|
4
|
-
|
5
|
-
class RailsUtilTest < ActiveSupport::TestCase
|
6
|
-
include RR::Adapters::TestUnit
|
7
|
-
|
8
|
-
def setup_mock url
|
9
|
-
mock(RestCore::Facebook::RailsUtil).rc_facebook_in_canvas?{ false }
|
10
|
-
mock(RestCore::Facebook::RailsUtil).request{
|
11
|
-
mock(Object.new).url{ url }
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_rest_graph_normalized_request_uri_0
|
16
|
-
setup_mock( 'http://test.com/?code=123&lang=en')
|
17
|
-
assert_equal('http://test.com/?lang=en',
|
18
|
-
RestCore::Facebook::RailsUtil.rc_facebook_normalized_request_uri)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_rest_graph_normalized_request_uri_1
|
22
|
-
setup_mock( 'http://test.com/?lang=en&code=123')
|
23
|
-
assert_equal('http://test.com/?lang=en',
|
24
|
-
RestCore::Facebook::RailsUtil.rc_facebook_normalized_request_uri)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_rest_graph_normalized_request_uri_2
|
28
|
-
setup_mock( 'http://test.com/?session=abc&lang=en&code=123')
|
29
|
-
assert_equal('http://test.com/?lang=en',
|
30
|
-
RestCore::Facebook::RailsUtil.rc_facebook_normalized_request_uri)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_rest_graph_normalized_request_uri_3
|
34
|
-
setup_mock( 'http://test.com/?code=123')
|
35
|
-
assert_equal('http://test.com/',
|
36
|
-
RestCore::Facebook::RailsUtil.rc_facebook_normalized_request_uri)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_rest_graph_normalized_request_uri_4
|
40
|
-
setup_mock( 'http://test.com/?signed_request=abc&code=123')
|
41
|
-
assert_equal('http://test.com/',
|
42
|
-
RestCore::Facebook::RailsUtil.rc_facebook_normalized_request_uri)
|
43
|
-
end
|
44
|
-
end
|