rack-oauth2 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -11,12 +11,17 @@ module Rack
11
11
  end
12
12
 
13
13
  class Request < Token::Request
14
+ attr_accessor :assertion_type, :assertion
15
+
14
16
  def initialize(env)
15
- # TODO
17
+ super
18
+ @grant_type = 'assertion'
19
+ @assertion_type = params['assertion_type']
20
+ @assertion = params['assertion']
16
21
  end
17
22
 
18
23
  def required_params
19
- # TODO
24
+ super + [:assertion_type, :assertion]
20
25
  end
21
26
  end
22
27
 
data/rack-oauth2.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-oauth2}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["nov matake"]
@@ -47,6 +47,7 @@ Gem::Specification.new do |s|
47
47
  "spec/rack/oauth2/server/authorization/token_spec.rb",
48
48
  "spec/rack/oauth2/server/authorization_spec.rb",
49
49
  "spec/rack/oauth2/server/error_spec.rb",
50
+ "spec/rack/oauth2/server/token/assertion_spec.rb",
50
51
  "spec/rack/oauth2/server/token/authorization_code_spec.rb",
51
52
  "spec/rack/oauth2/server/token/password_spec.rb",
52
53
  "spec/rack/oauth2/server/token/refresh_token_spec.rb",
@@ -65,6 +66,7 @@ Gem::Specification.new do |s|
65
66
  "spec/rack/oauth2/server/authorization/token_spec.rb",
66
67
  "spec/rack/oauth2/server/authorization_spec.rb",
67
68
  "spec/rack/oauth2/server/error_spec.rb",
69
+ "spec/rack/oauth2/server/token/assertion_spec.rb",
68
70
  "spec/rack/oauth2/server/token/authorization_code_spec.rb",
69
71
  "spec/rack/oauth2/server/token/password_spec.rb",
70
72
  "spec/rack/oauth2/server/token/refresh_token_spec.rb",
@@ -0,0 +1,43 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Rack::OAuth2::Server::Token::Assertion do
4
+
5
+ context "when valid assertion is given" do
6
+
7
+ before do
8
+ # NOTE: for some reason, test fails when called Rack::OAuth2::Server::Authorization::Token directly
9
+ @app = Rack::OAuth2::Server::Token.new(simple_app) do |request, response|
10
+ response.access_token = "access_token"
11
+ end
12
+ @request = Rack::MockRequest.new @app
13
+ end
14
+
15
+ it "should return access_token as json response body" do
16
+ response = @request.get("/?grant_type=assertion&client_id=valid_client&assertion=valid_assertion&assertion_type=something")
17
+ response.status.should == 200
18
+ response.content_type.should == "application/json"
19
+ response.body.should == "{\"access_token\":\"access_token\"}"
20
+ end
21
+
22
+ end
23
+
24
+ context "when invalid assertion is given" do
25
+
26
+ before do
27
+ # NOTE: for some reason, test fails when called Rack::OAuth2::Server::Authorization::Code directly
28
+ @app = Rack::OAuth2::Server::Token.new(simple_app) do |request, response|
29
+ raise Rack::OAuth2::Server::Unauthorized.new(:invalid_grant, 'Invalid assertion.')
30
+ end
31
+ @request = Rack::MockRequest.new @app
32
+ end
33
+
34
+ it "should return error message as json response body" do
35
+ response = @request.get("/?grant_type=assertion&client_id=valid_client&assertion=invalid_assertion&assertion_type=something")
36
+ response.status.should == 401
37
+ response.content_type.should == "application/json"
38
+ response.body.should == "{\"error_description\":\"Invalid assertion.\",\"error\":\"invalid_grant\"}"
39
+ end
40
+
41
+ end
42
+
43
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake
@@ -102,6 +102,7 @@ files:
102
102
  - spec/rack/oauth2/server/authorization/token_spec.rb
103
103
  - spec/rack/oauth2/server/authorization_spec.rb
104
104
  - spec/rack/oauth2/server/error_spec.rb
105
+ - spec/rack/oauth2/server/token/assertion_spec.rb
105
106
  - spec/rack/oauth2/server/token/authorization_code_spec.rb
106
107
  - spec/rack/oauth2/server/token/password_spec.rb
107
108
  - spec/rack/oauth2/server/token/refresh_token_spec.rb
@@ -148,6 +149,7 @@ test_files:
148
149
  - spec/rack/oauth2/server/authorization/token_spec.rb
149
150
  - spec/rack/oauth2/server/authorization_spec.rb
150
151
  - spec/rack/oauth2/server/error_spec.rb
152
+ - spec/rack/oauth2/server/token/assertion_spec.rb
151
153
  - spec/rack/oauth2/server/token/authorization_code_spec.rb
152
154
  - spec/rack/oauth2/server/token/password_spec.rb
153
155
  - spec/rack/oauth2/server/token/refresh_token_spec.rb