oauth_provider 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +151 -0
- data/lib/oauth_provider.rb +52 -0
- data/lib/oauth_provider/backends.rb +9 -0
- data/lib/oauth_provider/backends/abstract.rb +75 -0
- data/lib/oauth_provider/backends/data_mapper.rb +115 -0
- data/lib/oauth_provider/backends/data_mapper/consumer.rb +25 -0
- data/lib/oauth_provider/backends/data_mapper/user_access.rb +25 -0
- data/lib/oauth_provider/backends/data_mapper/user_request.rb +25 -0
- data/lib/oauth_provider/backends/in_memory.rb +47 -0
- data/lib/oauth_provider/backends/mysql.rb +90 -0
- data/lib/oauth_provider/backends/sequel.rb +81 -0
- data/lib/oauth_provider/backends/sqlite3.rb +75 -0
- data/lib/oauth_provider/consumer.rb +40 -0
- data/lib/oauth_provider/fixes.rb +8 -0
- data/lib/oauth_provider/provider.rb +73 -0
- data/lib/oauth_provider/token.rb +25 -0
- data/lib/oauth_provider/user_access.rb +25 -0
- data/lib/oauth_provider/user_request.rb +46 -0
- data/lib/oauth_provider/version.rb +3 -0
- data/spec/backend_spec.rb +3 -0
- data/spec/backends/abstract_spec.rb +11 -0
- data/spec/consumer_spec.rb +65 -0
- data/spec/helpers/backend_helper.rb +85 -0
- data/spec/provider_spec.rb +107 -0
- data/spec/spec_helper.rb +93 -0
- data/spec/token_spec.rb +20 -0
- data/spec/user_access_spec.rb +10 -0
- data/spec/user_request_spec.rb +52 -0
- metadata +116 -0
data/spec/token_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
describe "A Token" do
|
2
|
+
describe "being generated" do
|
3
|
+
it "has a shared and secret key" do
|
4
|
+
t = OAuthProvider::Token.generate
|
5
|
+
t.shared_key.should_not be_nil
|
6
|
+
t.secret_key.should_not be_nil
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
it "correctly generates the query string" do
|
11
|
+
t = OAuthProvider::Token.new("shared", "secret")
|
12
|
+
t.query_string.should == "oauth_token=shared&oauth_token_secret=secret"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "is equal to another token when both the shared and secret keys match" do
|
16
|
+
token1 = OAuthProvider::Token.new("123", "456")
|
17
|
+
token2 = OAuthProvider::Token.new("123", "456")
|
18
|
+
token1.should == token2
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
describe "A User Access" do
|
2
|
+
it "stores the User Request shared_key" do
|
3
|
+
provider = create_provider
|
4
|
+
consumer = provider.add_consumer("foo")
|
5
|
+
user_request = consumer.issue_request
|
6
|
+
user_request.authorize
|
7
|
+
user_access = user_request.upgrade
|
8
|
+
user_access.request_shared_key.should == user_request.shared_key
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
describe "A User Request" do
|
2
|
+
it "can be authorized" do
|
3
|
+
provider = create_provider
|
4
|
+
consumer = provider.add_consumer("foo")
|
5
|
+
user_request = consumer.issue_request
|
6
|
+
user_request.authorize
|
7
|
+
consumer.find_user_request(user_request.shared_key).should be_authorized
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "which has been authorized" do
|
11
|
+
it "can be upgraded" do
|
12
|
+
provider = create_provider
|
13
|
+
consumer = provider.add_consumer("foo")
|
14
|
+
user_request = consumer.issue_request
|
15
|
+
user_request.authorize
|
16
|
+
user_access = user_request.upgrade
|
17
|
+
consumer.find_user_access(user_access.shared_key).should == user_access
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can be upgraded with a custom token" do
|
21
|
+
provider = create_provider
|
22
|
+
consumer = provider.add_consumer("foo")
|
23
|
+
user_request = consumer.issue_request(true)
|
24
|
+
user_access = user_request.upgrade(OAuthProvider::Token.new("shared key", "secret key"))
|
25
|
+
user_access.shared_key.should == "shared key"
|
26
|
+
user_access.secret_key.should == "secret key"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "which has not been authorized" do
|
31
|
+
it "cannot be upgraded" do
|
32
|
+
provider = create_provider
|
33
|
+
consumer = provider.add_consumer("foo")
|
34
|
+
user_request = consumer.issue_request
|
35
|
+
lambda { user_request.upgrade }.
|
36
|
+
should raise_error(OAuthProvider::UserRequestNotAuthorized)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "which has been upgraded" do
|
41
|
+
it "has been destroyed" do
|
42
|
+
provider = create_provider
|
43
|
+
consumer = provider.add_consumer("foo")
|
44
|
+
user_request = consumer.issue_request
|
45
|
+
user_request.authorize
|
46
|
+
user_request.upgrade
|
47
|
+
|
48
|
+
lambda { consumer.find_user_request(user_request.shared_key) }.
|
49
|
+
should raise_error(OAuthProvider::UserRequestNotFound)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oauth_provider
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Travis Reeder
|
14
|
+
- tim@spork.in
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-08-05 00:00:00 -07:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: oauth
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
description: Makes it easy(er) to make an oauth provider.
|
37
|
+
email: travis@appoxy.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- README
|
44
|
+
files:
|
45
|
+
- lib/oauth_provider.rb
|
46
|
+
- lib/oauth_provider/backends.rb
|
47
|
+
- lib/oauth_provider/backends/abstract.rb
|
48
|
+
- lib/oauth_provider/backends/data_mapper.rb
|
49
|
+
- lib/oauth_provider/backends/data_mapper/consumer.rb
|
50
|
+
- lib/oauth_provider/backends/data_mapper/user_access.rb
|
51
|
+
- lib/oauth_provider/backends/data_mapper/user_request.rb
|
52
|
+
- lib/oauth_provider/backends/in_memory.rb
|
53
|
+
- lib/oauth_provider/backends/mysql.rb
|
54
|
+
- lib/oauth_provider/backends/sequel.rb
|
55
|
+
- lib/oauth_provider/backends/sqlite3.rb
|
56
|
+
- lib/oauth_provider/consumer.rb
|
57
|
+
- lib/oauth_provider/fixes.rb
|
58
|
+
- lib/oauth_provider/provider.rb
|
59
|
+
- lib/oauth_provider/token.rb
|
60
|
+
- lib/oauth_provider/user_access.rb
|
61
|
+
- lib/oauth_provider/user_request.rb
|
62
|
+
- lib/oauth_provider/version.rb
|
63
|
+
- README
|
64
|
+
- spec/backends/abstract_spec.rb
|
65
|
+
- spec/backend_spec.rb
|
66
|
+
- spec/consumer_spec.rb
|
67
|
+
- spec/helpers/backend_helper.rb
|
68
|
+
- spec/provider_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
- spec/token_spec.rb
|
71
|
+
- spec/user_access_spec.rb
|
72
|
+
- spec/user_request_spec.rb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://github.com/appoxy/oauth_provider
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options:
|
79
|
+
- --charset=UTF-8
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
|
+
requirements: []
|
101
|
+
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.3.7
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: Oauth provider gem.
|
107
|
+
test_files:
|
108
|
+
- spec/backends/abstract_spec.rb
|
109
|
+
- spec/backend_spec.rb
|
110
|
+
- spec/consumer_spec.rb
|
111
|
+
- spec/helpers/backend_helper.rb
|
112
|
+
- spec/provider_spec.rb
|
113
|
+
- spec/spec_helper.rb
|
114
|
+
- spec/token_spec.rb
|
115
|
+
- spec/user_access_spec.rb
|
116
|
+
- spec/user_request_spec.rb
|