oauth2 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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