oauth20 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -14,7 +14,7 @@ module OAuth2
14
14
  @redirect_uri = request.redirect_uri
15
15
 
16
16
  @code = OAuth2::AuthCode.new({
17
- :user_id => request.user.id,
17
+ :user_id => request.user.email,
18
18
  :client_key => request.client.key,
19
19
  :key => OAuth2::Utils.generate_key
20
20
  })
@@ -0,0 +1,110 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "oauth20"
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Petr Janda"]
12
+ s.date = "2011-10-23"
13
+ s.description = "OAuth 2.0"
14
+ s.email = "petrjanda@me.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/oauth20.rb",
29
+ "lib/oauth20/access_token.rb",
30
+ "lib/oauth20/auth_code.rb",
31
+ "lib/oauth20/auth_error.rb",
32
+ "lib/oauth20/auth_request.rb",
33
+ "lib/oauth20/auth_response.rb",
34
+ "lib/oauth20/client.rb",
35
+ "lib/oauth20/storage.rb",
36
+ "lib/oauth20/storages/mysql_strategy.rb",
37
+ "lib/oauth20/storages/redis_strategy.rb",
38
+ "lib/oauth20/storages/strategy.rb",
39
+ "lib/oauth20/token_request.rb",
40
+ "lib/oauth20/token_response.rb",
41
+ "lib/oauth20/user.rb",
42
+ "lib/oauth20/utils.rb",
43
+ "oauth20.gemspec",
44
+ "spec/integration/auth_request_spec.rb",
45
+ "spec/oauth2/access_token_spec.rb",
46
+ "spec/oauth2/auth_code_spec.rb",
47
+ "spec/oauth2/auth_request_spec.rb",
48
+ "spec/oauth2/auth_response_spec.rb",
49
+ "spec/oauth2/client_spec.rb",
50
+ "spec/oauth2/storage_spec.rb",
51
+ "spec/oauth2/storages/redis_strategy_spec.rb",
52
+ "spec/oauth2/token_request_spec.rb",
53
+ "spec/oauth2/token_response_spec.rb",
54
+ "spec/oauth2/user_spec.rb",
55
+ "spec/oauth2/utils_spec.rb",
56
+ "spec/oauth20_spec.rb",
57
+ "spec/spec_helper.rb"
58
+ ]
59
+ s.homepage = "http://github.com/petrjanda/oauth20"
60
+ s.licenses = ["MIT"]
61
+ s.require_paths = ["lib"]
62
+ s.rubygems_version = "1.8.10"
63
+ s.summary = "OAuth 2.0"
64
+
65
+ if s.respond_to? :specification_version then
66
+ s.specification_version = 3
67
+
68
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
+ s.add_runtime_dependency(%q<timecop>, [">= 0"])
70
+ s.add_runtime_dependency(%q<json>, [">= 0"])
71
+ s.add_runtime_dependency(%q<redis>, [">= 0"])
72
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
73
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
74
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
75
+ s.add_development_dependency(%q<rcov>, [">= 0"])
76
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
77
+ s.add_development_dependency(%q<mocha>, [">= 0"])
78
+ s.add_runtime_dependency(%q<timecop>, [">= 0"])
79
+ s.add_runtime_dependency(%q<json>, [">= 0"])
80
+ s.add_runtime_dependency(%q<redis>, [">= 0"])
81
+ else
82
+ s.add_dependency(%q<timecop>, [">= 0"])
83
+ s.add_dependency(%q<json>, [">= 0"])
84
+ s.add_dependency(%q<redis>, [">= 0"])
85
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
86
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
87
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
88
+ s.add_dependency(%q<rcov>, [">= 0"])
89
+ s.add_dependency(%q<shoulda>, [">= 0"])
90
+ s.add_dependency(%q<mocha>, [">= 0"])
91
+ s.add_dependency(%q<timecop>, [">= 0"])
92
+ s.add_dependency(%q<json>, [">= 0"])
93
+ s.add_dependency(%q<redis>, [">= 0"])
94
+ end
95
+ else
96
+ s.add_dependency(%q<timecop>, [">= 0"])
97
+ s.add_dependency(%q<json>, [">= 0"])
98
+ s.add_dependency(%q<redis>, [">= 0"])
99
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
100
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
101
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
102
+ s.add_dependency(%q<rcov>, [">= 0"])
103
+ s.add_dependency(%q<shoulda>, [">= 0"])
104
+ s.add_dependency(%q<mocha>, [">= 0"])
105
+ s.add_dependency(%q<timecop>, [">= 0"])
106
+ s.add_dependency(%q<json>, [">= 0"])
107
+ s.add_dependency(%q<redis>, [">= 0"])
108
+ end
109
+ end
110
+
@@ -12,8 +12,6 @@ describe OAuth2::AuthRequest do
12
12
  :scope => 'post',
13
13
  :state => 'a'
14
14
  })
15
-
16
- @request.user = {}
17
15
  end
18
16
 
19
17
  describe "should store params" do
@@ -47,6 +45,7 @@ describe OAuth2::AuthRequest do
47
45
  context 'with user' do
48
46
  before do
49
47
  @request.stubs(:validate!).returns(true)
48
+ @request.user = OAuth2::User.new({:email => 'petrjanda@me.com'})
50
49
  OAuth2::AuthCode.any_instance.stubs(:save).returns(true)
51
50
  end
52
51
 
@@ -6,20 +6,40 @@ describe OAuth2::AuthResponse do
6
6
  @client.stubs(:key).returns('1234')
7
7
  @client.stubs(:redirect_uri).returns('http://www.google.com/cb')
8
8
  OAuth2::Client.stubs(:find_by_key).returns(@client)
9
- OAuth2::AuthCode.any_instance.expects(:save).returns(true)
9
+ OAuth2::AuthCode.any_instance.stubs(:save).returns(true)
10
10
 
11
- req = OAuth2::AuthRequest.new('1', 'code', {
11
+ @req = OAuth2::AuthRequest.new('1', 'code', {
12
12
  :redirect_uri => 'http://www.google.com/cb',
13
13
  :scope => 'post',
14
14
  :state => 'a'
15
15
  })
16
16
 
17
+ @req.user = OAuth2::User.new({:email => 'petrjanda@me.com'})
18
+
17
19
  OAuth2::Utils.stubs(:generate_key).returns('1234')
20
+ end
21
+
22
+ it "should create new auth code" do
23
+ OAuth2::Utils.stubs(:generate_key).returns("1234")
24
+
25
+ code = OAuth2::AuthCode.new({})
18
26
 
19
- @res = OAuth2::AuthResponse.new(req)
27
+ OAuth2::AuthCode.expects(:new).with({
28
+ :user_id => @req.user.email,
29
+ :client_key => @req.client.key,
30
+ :key => '1234'
31
+ }).returns(code)
32
+
33
+ code.expects(:save).returns(true)
34
+
35
+ @res = OAuth2::AuthResponse.new(@req)
20
36
  end
21
37
 
22
38
  describe "to_url" do
39
+ before do
40
+ @res = OAuth2::AuthResponse.new(@req)
41
+ end
42
+
23
43
  it "should be valid" do
24
44
  @res.to_url.should == 'http://www.google.com/cb?code=1234&state=a&scope=post'
25
45
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth20
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Petr Janda
@@ -224,6 +224,7 @@ files:
224
224
  - lib/oauth20/token_response.rb
225
225
  - lib/oauth20/user.rb
226
226
  - lib/oauth20/utils.rb
227
+ - oauth20.gemspec
227
228
  - spec/integration/auth_request_spec.rb
228
229
  - spec/oauth2/access_token_spec.rb
229
230
  - spec/oauth2/auth_code_spec.rb