doorkeeper 1.0.0.rc2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of doorkeeper might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1
- data/lib/doorkeeper/version.rb +1 -1
- data/spec/controllers/applications_controller_spec.rb +4 -4
- data/spec/controllers/authorizations_controller_spec.rb +9 -9
- data/spec/controllers/protected_resources_controller_spec.rb +10 -10
- data/spec/controllers/token_info_controller_spec.rb +4 -4
- data/spec/controllers/tokens_controller_spec.rb +4 -4
- data/spec/lib/config_spec.rb +21 -21
- data/spec/lib/models/expirable_spec.rb +13 -13
- data/spec/lib/models/revocable_spec.rb +5 -5
- data/spec/lib/models/scopes_spec.rb +3 -3
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +5 -5
- data/spec/lib/oauth/authorization_code_request_spec.rb +7 -7
- data/spec/lib/oauth/client/credentials_spec.rb +8 -8
- data/spec/lib/oauth/client/methods_spec.rb +8 -8
- data/spec/lib/oauth/client_credentials/creator_spec.rb +2 -2
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +10 -9
- data/spec/lib/oauth/client_credentials/validation_spec.rb +6 -6
- data/spec/lib/oauth/client_credentials_request_spec.rb +7 -7
- data/spec/lib/oauth/client_spec.rb +8 -8
- data/spec/lib/oauth/code_request_spec.rb +4 -4
- data/spec/lib/oauth/error_response_spec.rb +22 -15
- data/spec/lib/oauth/error_spec.rb +1 -1
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +13 -13
- data/spec/lib/oauth/helpers/unique_token_spec.rb +2 -2
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +13 -13
- data/spec/lib/oauth/invalid_token_response_spec.rb +9 -4
- data/spec/lib/oauth/password_access_token_request_spec.rb +7 -7
- data/spec/lib/oauth/pre_authorization_spec.rb +14 -14
- data/spec/lib/oauth/refresh_token_request_spec.rb +8 -8
- data/spec/lib/oauth/scopes_spec.rb +27 -19
- data/spec/lib/oauth/token_request_spec.rb +4 -4
- data/spec/lib/oauth/token_response_spec.rb +11 -11
- data/spec/lib/oauth/token_spec.rb +9 -9
- data/spec/lib/server_spec.rb +1 -1
- data/spec/models/doorkeeper/access_token_spec.rb +15 -15
- data/spec/models/doorkeeper/application_spec.rb +21 -21
- data/spec/requests/flows/authorization_code_spec.rb +1 -1
- data/spec/requests/flows/client_credentials_spec.rb +1 -1
- data/spec/requests/flows/refresh_token_spec.rb +6 -6
- data/spec/requests/protected_resources/private_api_spec.rb +3 -3
- data/spec/routing/custom_controller_routes_spec.rb +16 -16
- data/spec/routing/default_routes_spec.rb +7 -7
- data/spec/routing/scoped_routes_spec.rb +7 -7
- data/spec/support/helpers/authorization_request_helper.rb +3 -3
- data/spec/support/helpers/model_helper.rb +6 -6
- data/spec/support/helpers/request_spec_helper.rb +9 -9
- data/spec/support/shared/controllers_shared_context.rb +6 -6
- data/spec/support/shared/models_shared_examples.rb +6 -6
- data/spec/validators/redirect_uri_validator_spec.rb +12 -12
- metadata +4 -4
@@ -12,20 +12,20 @@ describe 'Revocable' do
|
|
12
12
|
describe :revoke do
|
13
13
|
it "updates :revoked_at attribute with current time" do
|
14
14
|
clock = double :now => double
|
15
|
-
subject.
|
15
|
+
expect(subject).to receive(:update_column).with(:revoked_at, clock.now)
|
16
16
|
subject.revoke(clock)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe :revoked? do
|
21
21
|
it "is revoked if :revoked_at is set" do
|
22
|
-
subject.
|
23
|
-
subject.
|
22
|
+
allow(subject).to receive(:revoked_at).and_return(double)
|
23
|
+
expect(subject).to be_revoked
|
24
24
|
end
|
25
25
|
|
26
26
|
it "is not revoked if :revoked_at is not set" do
|
27
|
-
subject.
|
28
|
-
subject.
|
27
|
+
allow(subject).to receive(:revoked_at).and_return(nil)
|
28
|
+
expect(subject).not_to be_revoked
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -16,17 +16,17 @@ describe 'Doorkeeper::Models::Scopes' do
|
|
16
16
|
|
17
17
|
describe :scopes do
|
18
18
|
it 'is a `Scopes` class' do
|
19
|
-
subject.scopes.
|
19
|
+
expect(subject.scopes).to be_a(Doorkeeper::OAuth::Scopes)
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'includes scopes' do
|
23
|
-
subject.scopes.
|
23
|
+
expect(subject.scopes).to include('public')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
describe :scopes_string do
|
28
28
|
it 'is a `Scopes` class' do
|
29
|
-
subject.scopes_string.
|
29
|
+
expect(subject.scopes_string).to eq('public admin')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -12,25 +12,25 @@ module Doorkeeper::OAuth::Authorization
|
|
12
12
|
describe :uri_with_query do
|
13
13
|
it 'returns the uri with query' do
|
14
14
|
uri = subject.uri_with_query 'http://example.com/', :parameter => 'value'
|
15
|
-
uri.
|
15
|
+
expect(uri).to eq('http://example.com/?parameter=value')
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'rejects nil values' do
|
19
19
|
uri = subject.uri_with_query 'http://example.com/', :parameter => ""
|
20
|
-
uri.
|
20
|
+
expect(uri).to eq('http://example.com/?')
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'preserves original query parameters' do
|
24
24
|
uri = subject.uri_with_query 'http://example.com/?query1=value', :parameter => 'value'
|
25
|
-
uri.
|
26
|
-
uri.
|
25
|
+
expect(uri).to match(/query1=value/)
|
26
|
+
expect(uri).to match(/parameter=value/)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
describe :uri_with_fragment do
|
31
31
|
it 'returns uri with parameters as fragments' do
|
32
32
|
uri = subject.uri_with_fragment 'http://example.com/', :parameter => 'value'
|
33
|
-
uri.
|
33
|
+
expect(uri).to eq('http://example.com/#parameter=value')
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -18,7 +18,7 @@ module Doorkeeper::OAuth
|
|
18
18
|
|
19
19
|
it "issues the token with same grant's scopes" do
|
20
20
|
subject.authorize
|
21
|
-
Doorkeeper::AccessToken.last.scopes.
|
21
|
+
expect(Doorkeeper::AccessToken.last.scopes).to eq(grant.scopes)
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'revokes the grant' do
|
@@ -30,37 +30,37 @@ module Doorkeeper::OAuth
|
|
30
30
|
it 'requires the grant to be accessible' do
|
31
31
|
grant.revoke
|
32
32
|
subject.validate
|
33
|
-
subject.error.
|
33
|
+
expect(subject.error).to eq(:invalid_grant)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'requires the grant' do
|
37
37
|
subject.grant = nil
|
38
38
|
subject.validate
|
39
|
-
subject.error.
|
39
|
+
expect(subject.error).to eq(:invalid_grant)
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'requires the client' do
|
43
43
|
subject.client = nil
|
44
44
|
subject.validate
|
45
|
-
subject.error.
|
45
|
+
expect(subject.error).to eq(:invalid_client)
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'requires the redirect_uri' do
|
49
49
|
subject.redirect_uri = nil
|
50
50
|
subject.validate
|
51
|
-
subject.error.
|
51
|
+
expect(subject.error).to eq(:invalid_request)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "matches the redirect_uri with grant's one" do
|
55
55
|
subject.redirect_uri = 'http://other.com'
|
56
56
|
subject.validate
|
57
|
-
subject.error.
|
57
|
+
expect(subject.error).to eq(:invalid_grant)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "matches the client with grant's one" do
|
61
61
|
subject.client = FactoryGirl.create :application
|
62
62
|
subject.validate
|
63
|
-
subject.error.
|
63
|
+
expect(subject.error).to eq(:invalid_grant)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -5,8 +5,8 @@ require 'doorkeeper/oauth/client'
|
|
5
5
|
class Doorkeeper::OAuth::Client
|
6
6
|
describe Credentials do
|
7
7
|
it 'is blank when any of the credentials is blank' do
|
8
|
-
Credentials.new(nil, "something").
|
9
|
-
Credentials.new("something", nil).
|
8
|
+
expect(Credentials.new(nil, "something")).to be_blank
|
9
|
+
expect(Credentials.new("something", nil)).to be_blank
|
10
10
|
end
|
11
11
|
|
12
12
|
describe :from_request do
|
@@ -17,30 +17,30 @@ class Doorkeeper::OAuth::Client
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'accepts anything that responds to #call' do
|
20
|
-
method.
|
20
|
+
expect(method).to receive(:call).with(request)
|
21
21
|
Credentials.from_request request, method
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'delegates methods received as symbols to Credentials class' do
|
25
|
-
Credentials.
|
25
|
+
expect(Credentials).to receive(:from_params).with(request)
|
26
26
|
Credentials.from_request request, :from_params
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'stops at the first credentials found' do
|
30
30
|
not_called_method = double
|
31
|
-
not_called_method.
|
31
|
+
expect(not_called_method).not_to receive(:call)
|
32
32
|
credentials = Credentials.from_request request, lambda { |r| }, method, not_called_method
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'returns new Credentials' do
|
36
36
|
credentials = Credentials.from_request request, method
|
37
|
-
credentials.
|
37
|
+
expect(credentials).to be_a(Credentials)
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'returns uid and secret from extractor method' do
|
41
41
|
credentials = Credentials.from_request request, method
|
42
|
-
credentials.uid.
|
43
|
-
credentials.secret.
|
42
|
+
expect(credentials.uid).to eq('uid')
|
43
|
+
expect(credentials.secret).to eq('secret')
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -18,16 +18,16 @@ class Doorkeeper::OAuth::Client
|
|
18
18
|
request = double :parameters => { :client_id => client_id, :client_secret => client_secret }
|
19
19
|
uid, secret = subject.from_params(request)
|
20
20
|
|
21
|
-
uid.
|
22
|
-
secret.
|
21
|
+
expect(uid).to eq("some-uid")
|
22
|
+
expect(secret).to eq("some-secret")
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'is blank when there are no credentials' do
|
26
26
|
request = double :parameters => {}
|
27
27
|
uid, secret = subject.from_params(request)
|
28
28
|
|
29
|
-
uid.
|
30
|
-
secret.
|
29
|
+
expect(uid).to be_blank
|
30
|
+
expect(secret).to be_blank
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -38,16 +38,16 @@ class Doorkeeper::OAuth::Client
|
|
38
38
|
request = double :authorization => "Basic #{credentials}"
|
39
39
|
uid, secret = subject.from_basic(request)
|
40
40
|
|
41
|
-
uid.
|
42
|
-
secret.
|
41
|
+
expect(uid).to eq("some-uid")
|
42
|
+
expect(secret).to eq("some-secret")
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'is blank if Authorization is not Basic' do
|
46
46
|
request = double :authorization => "#{credentials}"
|
47
47
|
uid, secret = subject.from_basic(request)
|
48
48
|
|
49
|
-
uid.
|
50
|
-
secret.
|
49
|
+
expect(uid).to be_blank
|
50
|
+
expect(secret).to be_blank
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -12,9 +12,9 @@ class Doorkeeper::OAuth::ClientCredentialsRequest
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'returns false if creation fails' do
|
15
|
-
Doorkeeper::AccessToken.
|
15
|
+
expect(Doorkeeper::AccessToken).to receive(:create).and_return(false)
|
16
16
|
created = subject.call(client, scopes)
|
17
|
-
created.
|
17
|
+
expect(created).to be_false
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -15,14 +15,14 @@ class Doorkeeper::OAuth::ClientCredentialsRequest
|
|
15
15
|
let(:scopes) { 'some scope' }
|
16
16
|
|
17
17
|
it 'creates and sets the token' do
|
18
|
-
creator.
|
18
|
+
expect(creator).to receive(:call).and_return('token')
|
19
19
|
subject.create client, scopes, creator
|
20
20
|
|
21
|
-
subject.token.
|
21
|
+
expect(subject.token).to eq('token')
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'creates with correct token parameters' do
|
25
|
-
creator.
|
25
|
+
expect(creator).to receive(:call).with(client, scopes, {
|
26
26
|
:expires_in => 100,
|
27
27
|
:use_refresh_token => false
|
28
28
|
})
|
@@ -31,25 +31,26 @@ class Doorkeeper::OAuth::ClientCredentialsRequest
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'has error set to :server_error if creator fails' do
|
34
|
-
creator.
|
34
|
+
expect(creator).to receive(:call).and_return(false)
|
35
35
|
subject.create client, scopes, creator
|
36
36
|
|
37
|
-
subject.error.
|
37
|
+
expect(subject.error).to eq(:server_error)
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'when validation fails' do
|
41
41
|
before do
|
42
|
-
validation.
|
43
|
-
|
42
|
+
allow(validation).to receive(:valid?).and_return(false)
|
43
|
+
allow(validation).to receive(:error).and_return(:validation_error)
|
44
|
+
expect(creator).not_to receive(:create)
|
44
45
|
end
|
45
46
|
|
46
47
|
it 'has error set from validation' do
|
47
48
|
subject.create client, scopes, creator
|
48
|
-
subject.error.
|
49
|
+
expect(subject.error).to eq(:validation_error)
|
49
50
|
end
|
50
51
|
|
51
52
|
it 'returns false' do
|
52
|
-
subject.create(client, scopes, creator).
|
53
|
+
expect(subject.create(client, scopes, creator)).to be_false
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
@@ -10,19 +10,19 @@ class Doorkeeper::OAuth::ClientCredentialsRequest
|
|
10
10
|
subject { Validation.new(server, request) }
|
11
11
|
|
12
12
|
it 'is valid with valid request' do
|
13
|
-
subject.
|
13
|
+
expect(subject).to be_valid
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'is invalid when client is not present' do
|
17
|
-
request.
|
18
|
-
subject.
|
17
|
+
allow(request).to receive(:client).and_return(nil)
|
18
|
+
expect(subject).not_to be_valid
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'with scopes' do
|
22
22
|
it 'is invalid when scopes are not included in the server' do
|
23
|
-
server.
|
24
|
-
request.
|
25
|
-
subject.
|
23
|
+
allow(server).to receive(:scopes).and_return(Doorkeeper::OAuth::Scopes.from_string('email'))
|
24
|
+
allow(request).to receive(:original_scopes).and_return('invalid')
|
25
|
+
expect(subject).not_to be_valid
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -16,13 +16,13 @@ module Doorkeeper::OAuth
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'issues an access token for the current client' do
|
19
|
-
token_creator.
|
19
|
+
expect(token_creator).to receive(:create).with(client, nil)
|
20
20
|
subject.authorize
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'has successful response when issue was created' do
|
24
24
|
subject.authorize
|
25
|
-
subject.response.
|
25
|
+
expect(subject.response).to be_a(TokenResponse)
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'if issue was not created' do
|
@@ -32,12 +32,12 @@ module Doorkeeper::OAuth
|
|
32
32
|
|
33
33
|
it 'has an error response' do
|
34
34
|
subject.authorize
|
35
|
-
subject.response.
|
35
|
+
expect(subject.response).to be_a(Doorkeeper::OAuth::ErrorResponse)
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'delegates the error to issuer' do
|
39
39
|
subject.authorize
|
40
|
-
subject.error.
|
40
|
+
expect(subject.error).to eq(:invalid)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -45,18 +45,18 @@ module Doorkeeper::OAuth
|
|
45
45
|
let(:default_scopes) { Doorkeeper::OAuth::Scopes.from_string("public email") }
|
46
46
|
|
47
47
|
before do
|
48
|
-
server.
|
48
|
+
allow(server).to receive(:default_scopes).and_return(default_scopes)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'issues an access token with default scopes if none was requested' do
|
52
|
-
token_creator.
|
52
|
+
expect(token_creator).to receive(:create).with(client, default_scopes)
|
53
53
|
subject.authorize
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'issues an access token with requested scopes' do
|
57
57
|
subject = ClientCredentialsRequest.new(server, client, :scope => "email")
|
58
58
|
subject.issuer = token_creator
|
59
|
-
token_creator.
|
59
|
+
expect(token_creator).to receive(:create).with(client, Doorkeeper::OAuth::Scopes.from_string("email"))
|
60
60
|
subject.authorize
|
61
61
|
end
|
62
62
|
end
|
@@ -10,13 +10,13 @@ module Doorkeeper::OAuth
|
|
10
10
|
|
11
11
|
it 'finds the client via uid' do
|
12
12
|
client = double
|
13
|
-
method.
|
14
|
-
Client.find('uid', method).
|
13
|
+
expect(method).to receive(:call).with('uid').and_return(client)
|
14
|
+
expect(Client.find('uid', method)).to be_a(Client)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns nil if client was not found' do
|
18
|
-
method.
|
19
|
-
Client.find('uid', method).
|
18
|
+
expect(method).to receive(:call).with('uid').and_return(nil)
|
19
|
+
expect(Client.find('uid', method)).to be_nil
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -24,15 +24,15 @@ module Doorkeeper::OAuth
|
|
24
24
|
it 'returns the authenticated client via credentials' do
|
25
25
|
credentials = Client::Credentials.new("some-uid", "some-secret")
|
26
26
|
authenticator = double
|
27
|
-
authenticator.
|
28
|
-
Client.authenticate(credentials, authenticator).
|
27
|
+
expect(authenticator).to receive(:call).with("some-uid", "some-secret").and_return(double)
|
28
|
+
expect(Client.authenticate(credentials, authenticator)).to be_a(Client)
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'retunrs nil if client was not authenticated' do
|
32
32
|
credentials = Client::Credentials.new("some-uid", "some-secret")
|
33
33
|
authenticator = double
|
34
|
-
authenticator.
|
35
|
-
Client.authenticate(credentials, authenticator).
|
34
|
+
expect(authenticator).to receive(:call).with("some-uid", "some-secret").and_return(nil)
|
35
|
+
expect(Client.authenticate(credentials, authenticator)).to be_nil
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -26,19 +26,19 @@ module Doorkeeper::OAuth
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'returns a code response' do
|
29
|
-
subject.authorize.
|
29
|
+
expect(subject.authorize).to be_a(CodeResponse)
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'does not create grant when not authorizable' do
|
33
|
-
pre_auth.
|
33
|
+
allow(pre_auth).to receive(:authorizable?).and_return(false)
|
34
34
|
expect do
|
35
35
|
subject.authorize
|
36
36
|
end.to_not change { Doorkeeper::AccessGrant.count }
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'returns a error response' do
|
40
|
-
pre_auth.
|
41
|
-
subject.authorize.
|
40
|
+
allow(pre_auth).to receive(:authorizable?).and_return(false)
|
41
|
+
expect(subject.authorize).to be_a(ErrorResponse)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -5,50 +5,57 @@ require 'doorkeeper/oauth/error_response'
|
|
5
5
|
|
6
6
|
module Doorkeeper::OAuth
|
7
7
|
describe ErrorResponse do
|
8
|
-
|
8
|
+
describe '#status' do
|
9
|
+
it 'should have a status of unauthorized' do
|
10
|
+
expect(subject.status).to eq(:unauthorized)
|
11
|
+
end
|
12
|
+
end
|
9
13
|
|
10
14
|
describe :from_request do
|
11
15
|
it 'has the error from request' do
|
12
16
|
error = ErrorResponse.from_request double(:error => :some_error)
|
13
|
-
error.name.
|
17
|
+
expect(error.name).to eq(:some_error)
|
14
18
|
end
|
15
19
|
|
16
20
|
it 'ignores state if request does not respond to state' do
|
17
21
|
error = ErrorResponse.from_request double(:error => :some_error)
|
18
|
-
error.state.
|
22
|
+
expect(error.state).to be_nil
|
19
23
|
end
|
20
24
|
|
21
25
|
it 'has state if request responds to state' do
|
22
26
|
error = ErrorResponse.from_request double(:error => :some_error, :state => :hello)
|
23
|
-
error.state.
|
27
|
+
expect(error.state).to eq(:hello)
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
31
|
it 'ignores empty error values' do
|
28
32
|
subject = ErrorResponse.new(:error => :some_error, :state => nil)
|
29
|
-
subject.body.
|
33
|
+
expect(subject.body).not_to have_key(:state)
|
30
34
|
end
|
31
35
|
|
32
36
|
describe '.body' do
|
33
|
-
subject { ErrorResponse.new(:name => :some_error, :state => :some_state) }
|
37
|
+
subject { ErrorResponse.new(:name => :some_error, :state => :some_state).body }
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
|
39
|
+
describe '#body' do
|
40
|
+
it { should have_key(:error) }
|
41
|
+
it { should have_key(:error_description) }
|
42
|
+
it { should have_key(:state) }
|
43
|
+
end
|
38
44
|
end
|
39
45
|
|
40
46
|
describe '.authenticate_info' do
|
41
|
-
|
47
|
+
let(:error_response) { ErrorResponse.new(:name => :some_error, :state => :some_state) }
|
48
|
+
subject { error_response.authenticate_info }
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
50
|
+
it { should include("realm=\"#{error_response.realm}\"") }
|
51
|
+
it { should include("error=\"#{error_response.name}\"") }
|
52
|
+
it { should include("error_description=\"#{error_response.description}\"") }
|
46
53
|
end
|
47
54
|
|
48
55
|
describe '.headers' do
|
49
|
-
subject { ErrorResponse.new(:name => :some_error, :state => :some_state) }
|
56
|
+
subject { ErrorResponse.new(:name => :some_error, :state => :some_state).headers }
|
50
57
|
|
51
|
-
|
58
|
+
it { should include "WWW-Authenticate" }
|
52
59
|
end
|
53
60
|
end
|
54
61
|
end
|