oauth2 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/oauth2/access_token.rb +7 -7
- data/lib/oauth2/client.rb +3 -3
- data/lib/oauth2/mac_token.rb +6 -8
- data/lib/oauth2/response.rb +22 -22
- data/lib/oauth2/strategy/assertion.rb +2 -2
- data/lib/oauth2/strategy/client_credentials.rb +2 -2
- data/lib/oauth2/version.rb +55 -11
- data/oauth2.gemspec +3 -6
- metadata +18 -29
- data/Rakefile +0 -39
- data/spec/helper.rb +0 -42
- data/spec/oauth2/access_token_spec.rb +0 -169
- data/spec/oauth2/client_spec.rb +0 -215
- data/spec/oauth2/mac_token_spec.rb +0 -119
- data/spec/oauth2/response_spec.rb +0 -91
- data/spec/oauth2/strategy/assertion_spec.rb +0 -56
- data/spec/oauth2/strategy/auth_code_spec.rb +0 -88
- data/spec/oauth2/strategy/base_spec.rb +0 -7
- data/spec/oauth2/strategy/client_credentials_spec.rb +0 -81
- data/spec/oauth2/strategy/implicit_spec.rb +0 -28
- data/spec/oauth2/strategy/password_spec.rb +0 -57
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe OAuth2::Strategy::Implicit do
|
4
|
-
let(:client) { OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com') }
|
5
|
-
|
6
|
-
subject { client.implicit }
|
7
|
-
|
8
|
-
describe '#authorize_url' do
|
9
|
-
it 'includes the client_id' do
|
10
|
-
expect(subject.authorize_url).to include('client_id=abc')
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'includes the type' do
|
14
|
-
expect(subject.authorize_url).to include('response_type=token')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'includes passed in options' do
|
18
|
-
cb = 'http://myserver.local/oauth/callback'
|
19
|
-
expect(subject.authorize_url(:redirect_uri => cb)).to include("redirect_uri=#{Rack::Utils.escape(cb)}")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#get_token' do
|
24
|
-
it 'raises NotImplementedError' do
|
25
|
-
expect { subject.get_token }.to raise_error(NotImplementedError)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe OAuth2::Strategy::Password do
|
4
|
-
let(:client) do
|
5
|
-
cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
|
6
|
-
cli.connection.build do |b|
|
7
|
-
b.adapter :test do |stub|
|
8
|
-
stub.post('/oauth/token') do |env|
|
9
|
-
case @mode
|
10
|
-
when 'formencoded'
|
11
|
-
[200, {'Content-Type' => 'application/x-www-form-urlencoded'}, 'expires_in=600&access_token=salmon&refresh_token=trout']
|
12
|
-
when 'json'
|
13
|
-
[200, {'Content-Type' => 'application/json'}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout"}']
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
cli
|
19
|
-
end
|
20
|
-
subject { client.password }
|
21
|
-
|
22
|
-
describe '#authorize_url' do
|
23
|
-
it 'raises NotImplementedError' do
|
24
|
-
expect { subject.authorize_url }.to raise_error(NotImplementedError)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
%w(json formencoded).each do |mode|
|
29
|
-
describe "#get_token (#{mode})" do
|
30
|
-
before do
|
31
|
-
@mode = mode
|
32
|
-
@access = subject.get_token('username', 'password')
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'returns AccessToken with same Client' do
|
36
|
-
expect(@access.client).to eq(client)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'returns AccessToken with #token' do
|
40
|
-
expect(@access.token).to eq('salmon')
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'returns AccessToken with #refresh_token' do
|
44
|
-
expect(@access.refresh_token).to eq('trout')
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'returns AccessToken with #expires_in' do
|
48
|
-
expect(@access.expires_in).to eq(600)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'returns AccessToken with #expires_at' do
|
52
|
-
expect(@access.expires_at).not_to be_nil
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|