xaviershay-twitter-auth 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +119 -0
- data/Rakefile +31 -0
- data/VERSION.yml +4 -0
- data/app/controllers/sessions_controller.rb +66 -0
- data/app/models/twitter_auth/basic_user.rb +63 -0
- data/app/models/twitter_auth/generic_user.rb +93 -0
- data/app/models/twitter_auth/oauth_user.rb +44 -0
- data/app/views/sessions/_login_form.html.erb +17 -0
- data/app/views/sessions/new.html.erb +5 -0
- data/config/routes.rb +6 -0
- data/generators/twitter_auth/USAGE +12 -0
- data/generators/twitter_auth/templates/migration.rb +48 -0
- data/generators/twitter_auth/templates/twitter_auth.yml +47 -0
- data/generators/twitter_auth/templates/user.rb +5 -0
- data/generators/twitter_auth/twitter_auth_generator.rb +34 -0
- data/lib/twitter_auth.rb +99 -0
- data/lib/twitter_auth/controller_extensions.rb +69 -0
- data/lib/twitter_auth/cryptify.rb +30 -0
- data/lib/twitter_auth/dispatcher/basic.rb +46 -0
- data/lib/twitter_auth/dispatcher/oauth.rb +26 -0
- data/lib/twitter_auth/dispatcher/shared.rb +40 -0
- data/rails/init.rb +8 -0
- data/spec/controllers/controller_extensions_spec.rb +162 -0
- data/spec/controllers/sessions_controller_spec.rb +250 -0
- data/spec/fixtures/config/twitter_auth.yml +17 -0
- data/spec/fixtures/factories.rb +18 -0
- data/spec/fixtures/fakeweb.rb +18 -0
- data/spec/fixtures/twitter.rb +5 -0
- data/spec/models/twitter_auth/basic_user_spec.rb +122 -0
- data/spec/models/twitter_auth/generic_user_spec.rb +142 -0
- data/spec/models/twitter_auth/oauth_user_spec.rb +101 -0
- data/spec/schema.rb +41 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +53 -0
- data/spec/twitter_auth/cryptify_spec.rb +51 -0
- data/spec/twitter_auth/dispatcher/basic_spec.rb +83 -0
- data/spec/twitter_auth/dispatcher/oauth_spec.rb +72 -0
- data/spec/twitter_auth/dispatcher/shared_spec.rb +26 -0
- data/spec/twitter_auth_spec.rb +160 -0
- metadata +127 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe TwitterAuth::Cryptify do
|
4
|
+
before do
|
5
|
+
stub_basic!
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have encrypt and decrypt methods' do
|
9
|
+
TwitterAuth::Cryptify.should respond_to(:encrypt)
|
10
|
+
TwitterAuth::Cryptify.should respond_to(:decrypt)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.encrypt' do
|
14
|
+
it 'should return a hash with :encrypted_data and :salt keys' do
|
15
|
+
result = TwitterAuth::Cryptify.encrypt('some string')
|
16
|
+
result.should be_a(Hash)
|
17
|
+
result.key?(:encrypted_data).should be_true
|
18
|
+
result.key?(:salt).should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should make a call to EzCrypto::Key.encrypt_with_password' do
|
22
|
+
EzCrypto::Key.should_receive(:encrypt_with_password).once.and_return('gobbledygook')
|
23
|
+
TwitterAuth::Cryptify.encrypt('some string')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should not have the same encrypted as plaintext data' do
|
27
|
+
TwitterAuth::Cryptify.encrypt('some string')[:encrypted_data].should_not == 'some string'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.decrypt' do
|
32
|
+
before do
|
33
|
+
@salt = TwitterAuth::Cryptify.generate_salt
|
34
|
+
TwitterAuth::Cryptify.stub!(:generate_salt).and_return(@salt)
|
35
|
+
@string = 'decrypted string'
|
36
|
+
@encrypted = TwitterAuth::Cryptify.encrypt(@string)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should return the original string' do
|
40
|
+
TwitterAuth::Cryptify.decrypt(@encrypted).should == @string
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should raise an argument error if encrypted data is provided without a salt' do
|
44
|
+
lambda{TwitterAuth::Cryptify.decrypt('asodiaoie2')}.should raise_error(ArgumentError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should raise an argument error if a string or hash are not provided' do
|
48
|
+
lambda{TwitterAuth::Cryptify.decrypt(23)}.should raise_error(ArgumentError)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe TwitterAuth::Dispatcher::Basic do
|
4
|
+
before do
|
5
|
+
stub_basic!
|
6
|
+
@user = Factory.create(:twitter_basic_user, :login => 'twitterman', :password => 'test')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should require a user as the initialization argument' do
|
10
|
+
lambda{TwitterAuth::Dispatcher::Basic.new(nil)}.should raise_error(TwitterAuth::Error, 'Dispatcher must be initialized with a User.')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should store the user in an attr_accessor' do
|
14
|
+
TwitterAuth::Dispatcher::Basic.new(@user).user.should == @user
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#request' do
|
18
|
+
before do
|
19
|
+
@dispatcher = TwitterAuth::Dispatcher::Basic.new(@user)
|
20
|
+
FakeWeb.register_uri('https://twitter.com:443/fake.json', :string => {'fake' => true}.to_json)
|
21
|
+
FakeWeb.register_uri('https://twitter.com:443/fake.xml', :string => '<fake>true</fake>')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should automatically parse JSON if valid' do
|
25
|
+
@dispatcher.request(:get, '/fake.json').should == {'fake' => true}
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should return XML as a string' do
|
29
|
+
@dispatcher.request(:get, '/fake.xml').should == "<fake>true</fake>"
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should append .json to the path if no extension is provided' do
|
33
|
+
@dispatcher.request(:get, '/fake.json').should == @dispatcher.request(:get, '/fake')
|
34
|
+
end
|
35
|
+
|
36
|
+
%w(get post put delete).each do |method|
|
37
|
+
it "should build a #{method} class based on a :#{method} http_method" do
|
38
|
+
@req = "Net::HTTP::#{method.capitalize}".constantize.new('/fake.json')
|
39
|
+
"Net::HTTP::#{method.capitalize}".constantize.should_receive(:new).and_return(@req)
|
40
|
+
@dispatcher.request(method.to_sym, '/fake')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should start the HTTP session' do
|
45
|
+
@net = TwitterAuth.net
|
46
|
+
TwitterAuth.stub!(:net).and_return(@net)
|
47
|
+
@net.should_receive(:start)
|
48
|
+
lambda{@dispatcher.request(:get, '/fake')}.should raise_error(NoMethodError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should raise a TwitterAuth::Dispatcher::Error if response code isn't 200" do
|
52
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['401', 'Unauthorized'])
|
53
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should set the error message to the JSON message' do
|
57
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['403', 'Forbidden'])
|
58
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should raise a TwitterAuth::Dispatcher::Unauthorized on 401' do
|
62
|
+
FakeWeb.register_uri('https://twitter.com:443/unauthenticated_response.xml', :string => "<hash>\n<request>/unauthenticated_response.xml</request>\n<error>bad response</error>\n</hash>", :status => ['401', 'Unauthorized'])
|
63
|
+
lambda{@dispatcher.request(:get, '/unauthenticated_response.xml')}.should raise_error(TwitterAuth::Dispatcher::Unauthorized)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should set the error message to the XML message' do
|
67
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.xml', :string => "<hash>\n<request>/bad_response.xml</request>\n<error>bad response</error>\n</hash>", :status => ['403', 'Forbidden'])
|
68
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
%w(get post delete put).each do |method|
|
73
|
+
it "should have a ##{method} method that calls request(:#{method})" do
|
74
|
+
dispatcher = TwitterAuth::Dispatcher::Basic.new(@user)
|
75
|
+
if %w(get delete).include?(method)
|
76
|
+
dispatcher.should_receive(:request).with(method.to_sym, '/fake.json')
|
77
|
+
else
|
78
|
+
dispatcher.should_receive(:request).with(method.to_sym, '/fake.json', '')
|
79
|
+
end
|
80
|
+
dispatcher.send(method, '/fake.json')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe TwitterAuth::Dispatcher::Oauth do
|
4
|
+
before do
|
5
|
+
stub_oauth!
|
6
|
+
@user = Factory.create(:twitter_oauth_user, :access_token => 'token', :access_secret => 'secret')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should be a child class of OAuth::AccessToken' do
|
10
|
+
TwitterAuth::Dispatcher::Oauth.new(@user).should be_a(OAuth::AccessToken)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should require initialization of an OauthUser' do
|
14
|
+
lambda{TwitterAuth::Dispatcher::Oauth.new(nil)}.should raise_error(TwitterAuth::Error, 'Dispatcher must be initialized with a User.')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should store the user in an attr_accessor' do
|
18
|
+
TwitterAuth::Dispatcher::Oauth.new(@user).user.should == @user
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should initialize with the user's token and secret" do
|
22
|
+
d = TwitterAuth::Dispatcher::Oauth.new(@user)
|
23
|
+
d.token.should == 'token'
|
24
|
+
d.secret.should == 'secret'
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#request' do
|
28
|
+
before do
|
29
|
+
@dispatcher = TwitterAuth::Dispatcher::Oauth.new(@user)
|
30
|
+
FakeWeb.register_uri(:get, 'https://twitter.com:443/fake.json', :string => {'fake' => true}.to_json)
|
31
|
+
FakeWeb.register_uri(:get, 'https://twitter.com:443/fake.xml', :string => "<fake>true</fake>")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should automatically parse json' do
|
35
|
+
result = @dispatcher.request(:get, '/fake.json')
|
36
|
+
result.should be_a(Hash)
|
37
|
+
result['fake'].should be_true
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should return xml as a string' do
|
41
|
+
@dispatcher.request(:get, '/fake.xml').should == '<fake>true</fake>'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should append .json to the path if no extension is provided' do
|
45
|
+
@dispatcher.request(:get, '/fake').should == @dispatcher.request(:get, '/fake.json')
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should raise a TwitterAuth::Dispatcher::Error if response code isn't 200" do
|
49
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['401', 'Unauthorized'])
|
50
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should set the error message to the JSON message' do
|
54
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.json', :string => {'error' => 'bad response'}.to_json, :status => ['403', 'Forbidden'])
|
55
|
+
lambda{@dispatcher.request(:get, '/bad_response')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should set the error message to the XML message' do
|
59
|
+
FakeWeb.register_uri('https://twitter.com:443/bad_response.xml', :string => "<hash>\n<request>/bad_response.xml</request>\n<error>bad response</error>\n</hash>", :status => ['403', 'Forbidden'])
|
60
|
+
lambda{@dispatcher.request(:get, '/bad_response.xml')}.should raise_error(TwitterAuth::Dispatcher::Error, 'bad response')
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should raise a TwitterAuth::Dispatcher::Unauthorized on 401' do
|
64
|
+
FakeWeb.register_uri('https://twitter.com:443/unauthenticated_response.xml', :string => "<hash>\n<request>/unauthenticated_response.xml</request>\n<error>bad response</error>\n</hash>", :status => ['401', 'Unauthorized'])
|
65
|
+
lambda{@dispatcher.request(:get, '/unauthenticated_response.xml')}.should raise_error(TwitterAuth::Dispatcher::Unauthorized)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should work with verb methods' do
|
69
|
+
@dispatcher.get('/fake').should == @dispatcher.request(:get, '/fake')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe TwitterAuth::Dispatcher::Shared do
|
4
|
+
include TwitterAuth::Dispatcher::Shared
|
5
|
+
|
6
|
+
describe '#append_extension_to' do
|
7
|
+
it 'should leave extensions alone if they exist' do
|
8
|
+
append_extension_to('/fake.json').should == '/fake.json'
|
9
|
+
append_extension_to('/fake.xml').should == '/fake.xml'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should append .json if no extension is provided' do
|
13
|
+
append_extension_to('/fake').should == '/fake.json'
|
14
|
+
append_extension_to('/verify/fake').should == '/verify/fake.json'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should leave extensions alone even with query strings' do
|
18
|
+
append_extension_to('/fake.json?since_id=123').should == '/fake.json?since_id=123'
|
19
|
+
append_extension_to('/fake.xml?since_id=123').should == '/fake.xml?since_id=123'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should add an extension even with query strings' do
|
23
|
+
append_extension_to('/fake?since_id=123').should == '/fake.json?since_id=123'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe TwitterAuth do
|
4
|
+
describe '.base_url' do
|
5
|
+
it 'should have default to https://twitter.com' do
|
6
|
+
TwitterAuth.stub!(:config).and_return({})
|
7
|
+
TwitterAuth.base_url.should == 'https://twitter.com'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should otherwise load from the config[base_url]' do
|
11
|
+
TwitterAuth.stub!(:config).and_return({'base_url' => 'https://example.com'})
|
12
|
+
TwitterAuth.base_url.should == 'https://example.com'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should utilize oauth consumer settings' do
|
16
|
+
@config = TwitterAuth.config
|
17
|
+
TwitterAuth.stub!(:config).and_return(@config.merge('authorize_path' => '/somewhere_else'))
|
18
|
+
TwitterAuth.consumer.authorize_path.should == '/somewhere_else'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".path_prefix" do
|
23
|
+
it 'should be blank if the base url does not have a path' do
|
24
|
+
TwitterAuth.stub!(:base_url).and_return("https://twitter.com:443")
|
25
|
+
TwitterAuth.path_prefix.should == ""
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should return the path prefix if one exists' do
|
29
|
+
TwitterAuth.stub!(:base_url).and_return("https://api.presentlyapp.com/api/twitter")
|
30
|
+
TwitterAuth.path_prefix.should == "/api/twitter"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.api_timeout' do
|
35
|
+
it 'should default to 10' do
|
36
|
+
TwitterAuth.stub!(:config).and_return({})
|
37
|
+
TwitterAuth.api_timeout.should == 10
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should be settable via config' do
|
41
|
+
TwitterAuth.stub!(:config).and_return({'api_timeout' => 15})
|
42
|
+
TwitterAuth.api_timeout.should == 15
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '.remember_for' do
|
47
|
+
it 'should default to 14' do
|
48
|
+
TwitterAuth.stub!(:config).and_return({})
|
49
|
+
TwitterAuth.remember_for.should == 14
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should be settable via config' do
|
53
|
+
TwitterAuth.stub!(:config).and_return({'remember_for' => '7'})
|
54
|
+
TwitterAuth.remember_for.should == 7
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '.net' do
|
59
|
+
before do
|
60
|
+
stub_basic!
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should return a Net::HTTP object' do
|
64
|
+
TwitterAuth.net.should be_a(Net::HTTP)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should be SSL if the base_url is' do
|
68
|
+
TwitterAuth.stub!(:config).and_return({'base_url' => 'http://twitter.com'})
|
69
|
+
TwitterAuth.net.use_ssl?.should be_false
|
70
|
+
TwitterAuth.stub!(:config).and_return({'base_url' => 'https://twitter.com'})
|
71
|
+
TwitterAuth.net.use_ssl?.should be_true
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should work from the base_url' do
|
75
|
+
@net = Net::HTTP.new('example.com',80)
|
76
|
+
Net::HTTP.should_receive(:new).with('example.com',80).and_return(@net)
|
77
|
+
TwitterAuth.stub!(:config).and_return({'base_url' => 'http://example.com'})
|
78
|
+
TwitterAuth.net
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#config' do
|
83
|
+
before do
|
84
|
+
TwitterAuth.send(:instance_variable_set, :@config, nil)
|
85
|
+
@config_file = File.open(File.dirname(__FILE__) + '/fixtures/config/twitter_auth.yml')
|
86
|
+
File.should_receive(:open).any_number_of_times.and_return(@config_file)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should load a hash from RAILS_ROOT/config/twitter.yml' do
|
90
|
+
TwitterAuth.config.should be_a(Hash)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should be able to override the RAILS_ENV' do
|
94
|
+
TwitterAuth.config('development')['oauth_consumer_key'].should == 'devkey'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#consumer' do
|
99
|
+
before do
|
100
|
+
stub_oauth!
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should be an OAuth Consumer' do
|
104
|
+
TwitterAuth.consumer.should be_a(OAuth::Consumer)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should use the credentials from #config' do
|
108
|
+
TwitterAuth.consumer.key.should == 'testkey'
|
109
|
+
TwitterAuth.consumer.secret.should == 'testsecret'
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should use the TwitterAuth base_url' do
|
113
|
+
TwitterAuth.stub!(:base_url).and_return('https://example.com')
|
114
|
+
TwitterAuth.consumer.site.should == TwitterAuth.base_url
|
115
|
+
TwitterAuth.consumer.site.should == 'https://example.com'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#strategy' do
|
120
|
+
it 'should pull and symbolize from the config' do
|
121
|
+
TwitterAuth.stub!(:config).and_return({'strategy' => 'oauth'})
|
122
|
+
TwitterAuth.strategy.should == TwitterAuth.config['strategy'].to_sym
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should raise an argument error if not oauth or basic' do
|
126
|
+
TwitterAuth.stub!(:config).and_return({'strategy' => 'oauth'})
|
127
|
+
lambda{TwitterAuth.strategy}.should_not raise_error(ArgumentError)
|
128
|
+
|
129
|
+
TwitterAuth.stub!(:config).and_return({'strategy' => 'basic'})
|
130
|
+
lambda{TwitterAuth.strategy}.should_not raise_error(ArgumentError)
|
131
|
+
|
132
|
+
TwitterAuth.stub!(:config).and_return({'strategy' => 'invalid_strategy'})
|
133
|
+
lambda{TwitterAuth.strategy}.should raise_error(ArgumentError)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
it '#oauth? should be true if strategy is :oauth' do
|
138
|
+
TwitterAuth.stub!(:config).and_return({'strategy' => 'oauth'})
|
139
|
+
TwitterAuth.oauth?.should be_true
|
140
|
+
TwitterAuth.basic?.should be_false
|
141
|
+
end
|
142
|
+
|
143
|
+
it '#basic? should be true if strategy is :basic' do
|
144
|
+
TwitterAuth.stub!(:config).and_return({'strategy' => 'basic'})
|
145
|
+
TwitterAuth.oauth?.should be_false
|
146
|
+
TwitterAuth.basic?.should be_true
|
147
|
+
end
|
148
|
+
|
149
|
+
describe '#encryption_key' do
|
150
|
+
it 'should raise a Cryptify error if none is found' do
|
151
|
+
TwitterAuth.stub!(:config).and_return({})
|
152
|
+
lambda{TwitterAuth.encryption_key}.should raise_error(TwitterAuth::Cryptify::Error, "You must specify an encryption_key in config/twitter_auth.yml")
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should return the config[encryption_key] value' do
|
156
|
+
TwitterAuth.stub!(:config).and_return({'encryption_key' => 'mickeymouse'})
|
157
|
+
TwitterAuth.encryption_key.should == 'mickeymouse'
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xaviershay-twitter-auth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.19
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Bleigh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-17 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: oauth
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.3.1
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: ezcrypto
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.2
|
34
|
+
version:
|
35
|
+
description: TwitterAuth is a Rails plugin gem that provides Single Sign-On capabilities for Rails applications via Twitter. Both OAuth and HTTP Basic are supported.
|
36
|
+
email: michael@intridea.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README.markdown
|
43
|
+
files:
|
44
|
+
- Rakefile
|
45
|
+
- README.markdown
|
46
|
+
- VERSION.yml
|
47
|
+
- generators/twitter_auth
|
48
|
+
- generators/twitter_auth/templates
|
49
|
+
- generators/twitter_auth/templates/migration.rb
|
50
|
+
- generators/twitter_auth/templates/twitter_auth.yml
|
51
|
+
- generators/twitter_auth/templates/user.rb
|
52
|
+
- generators/twitter_auth/twitter_auth_generator.rb
|
53
|
+
- generators/twitter_auth/USAGE
|
54
|
+
- lib/twitter_auth
|
55
|
+
- lib/twitter_auth/controller_extensions.rb
|
56
|
+
- lib/twitter_auth/cryptify.rb
|
57
|
+
- lib/twitter_auth/dispatcher
|
58
|
+
- lib/twitter_auth/dispatcher/basic.rb
|
59
|
+
- lib/twitter_auth/dispatcher/oauth.rb
|
60
|
+
- lib/twitter_auth/dispatcher/shared.rb
|
61
|
+
- lib/twitter_auth.rb
|
62
|
+
- spec/controllers
|
63
|
+
- spec/controllers/controller_extensions_spec.rb
|
64
|
+
- spec/controllers/sessions_controller_spec.rb
|
65
|
+
- spec/fixtures
|
66
|
+
- spec/fixtures/config
|
67
|
+
- spec/fixtures/config/twitter_auth.yml
|
68
|
+
- spec/fixtures/factories.rb
|
69
|
+
- spec/fixtures/fakeweb.rb
|
70
|
+
- spec/fixtures/twitter.rb
|
71
|
+
- spec/models
|
72
|
+
- spec/models/twitter_auth
|
73
|
+
- spec/models/twitter_auth/basic_user_spec.rb
|
74
|
+
- spec/models/twitter_auth/generic_user_spec.rb
|
75
|
+
- spec/models/twitter_auth/oauth_user_spec.rb
|
76
|
+
- spec/schema.rb
|
77
|
+
- spec/spec.opts
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/twitter_auth
|
80
|
+
- spec/twitter_auth/cryptify_spec.rb
|
81
|
+
- spec/twitter_auth/dispatcher
|
82
|
+
- spec/twitter_auth/dispatcher/basic_spec.rb
|
83
|
+
- spec/twitter_auth/dispatcher/oauth_spec.rb
|
84
|
+
- spec/twitter_auth/dispatcher/shared_spec.rb
|
85
|
+
- spec/twitter_auth_spec.rb
|
86
|
+
- config/routes.rb
|
87
|
+
- app/controllers
|
88
|
+
- app/controllers/sessions_controller.rb
|
89
|
+
- app/models
|
90
|
+
- app/models/twitter_auth
|
91
|
+
- app/models/twitter_auth/basic_user.rb
|
92
|
+
- app/models/twitter_auth/generic_user.rb
|
93
|
+
- app/models/twitter_auth/oauth_user.rb
|
94
|
+
- app/views
|
95
|
+
- app/views/sessions
|
96
|
+
- app/views/sessions/_login_form.html.erb
|
97
|
+
- app/views/sessions/new.html.erb
|
98
|
+
- rails/init.rb
|
99
|
+
has_rdoc: true
|
100
|
+
homepage: http://github.com/mbleigh/twitter-auth
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options:
|
103
|
+
- --inline-source
|
104
|
+
- --charset=UTF-8
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: "0"
|
112
|
+
version:
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: "0"
|
118
|
+
version:
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project: twitter-auth
|
122
|
+
rubygems_version: 1.2.0
|
123
|
+
signing_key:
|
124
|
+
specification_version: 2
|
125
|
+
summary: TwitterAuth is a Rails plugin gem that provides Single Sign-On capabilities for Rails applications via Twitter.
|
126
|
+
test_files: []
|
127
|
+
|