rpx_now 0.6.1 → 0.6.4
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/.gitignore +5 -0
- data/README.markdown +1 -0
- data/Rakefile +1 -2
- data/VERSION +1 -1
- data/lib/rpx_now.rb +15 -13
- data/lib/rpx_now/{request.rb → api.rb} +26 -11
- data/rpx_now.gemspec +13 -12
- data/spec/integration/mapping_spec.rb +40 -0
- data/spec/rpx_now/{request_spec.rb → api_spec.rb} +16 -7
- data/spec/rpx_now/user_proxy_spec.rb +10 -9
- data/spec/rpx_now_spec.rb +108 -72
- metadata +9 -8
- data/pkg/rpx_now-0.5.10.gem +0 -0
- data/pkg/rpx_now-0.5.11.gem +0 -0
data/README.markdown
CHANGED
@@ -111,6 +111,7 @@ Author
|
|
111
111
|
- [dbalatero](http://github.com/dbalatero)
|
112
112
|
- [jackdempsey](http://jackndempsey.blogspot.com)
|
113
113
|
- [Patrick Reagan (reagent)](http://sneaq.net)
|
114
|
+
- [Joris Trooster (trooster)](http://www.interstroom.nl)
|
114
115
|
|
115
116
|
[Michael Grosser](http://pragmatig.wordpress.com)
|
116
117
|
grosser.michael@gmail.com
|
data/Rakefile
CHANGED
@@ -18,8 +18,7 @@ begin
|
|
18
18
|
gem.email = "grosser.michael@gmail.com"
|
19
19
|
gem.homepage = "http://github.com/grosser/#{project_name}"
|
20
20
|
gem.authors = ["Michael Grosser"]
|
21
|
-
gem.add_dependency ['
|
22
|
-
gem.files = ['**/*']
|
21
|
+
gem.add_dependency ['json']
|
23
22
|
gem.rubyforge_project = 'rpx-now'
|
24
23
|
end
|
25
24
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.4
|
data/lib/rpx_now.rb
CHANGED
@@ -2,7 +2,7 @@ require 'net/http'
|
|
2
2
|
require 'net/https'
|
3
3
|
require 'json'
|
4
4
|
|
5
|
-
require 'rpx_now/
|
5
|
+
require 'rpx_now/api'
|
6
6
|
require 'rpx_now/contacts_collection'
|
7
7
|
require 'rpx_now/user_integration'
|
8
8
|
require 'rpx_now/user_proxy'
|
@@ -22,7 +22,7 @@ module RPXNow
|
|
22
22
|
# - nil when token was invalid / data was not found
|
23
23
|
def user_data(token, options={})
|
24
24
|
begin
|
25
|
-
data =
|
25
|
+
data = Api.call("auth_info", options.merge(:token => token))
|
26
26
|
if block_given? then yield(data) else parse_user_data(data) end
|
27
27
|
rescue ServerError
|
28
28
|
return nil if $!.to_s=~/Data not found/
|
@@ -33,7 +33,7 @@ module RPXNow
|
|
33
33
|
# set the users status
|
34
34
|
def set_status(identifier, status, options={})
|
35
35
|
options = options.merge(:identifier => identifier, :status => status)
|
36
|
-
data =
|
36
|
+
data = Api.call("set_status", options)
|
37
37
|
rescue ServerError
|
38
38
|
return nil if $!.to_s=~/Data not found/
|
39
39
|
raise
|
@@ -41,25 +41,25 @@ module RPXNow
|
|
41
41
|
|
42
42
|
# maps an identifier to an primary-key (e.g. user.id)
|
43
43
|
def map(identifier, primary_key, options={})
|
44
|
-
|
44
|
+
Api.call("map", options.merge(:identifier => identifier, :primaryKey => primary_key))
|
45
45
|
end
|
46
46
|
|
47
47
|
# un-maps an identifier to an primary-key (e.g. user.id)
|
48
48
|
def unmap(identifier, primary_key, options={})
|
49
|
-
|
49
|
+
Api.call("unmap", options.merge(:identifier => identifier, :primaryKey => primary_key))
|
50
50
|
end
|
51
51
|
|
52
52
|
# returns an array of identifiers which are mapped to one of your primary-keys (e.g. user.id)
|
53
53
|
def mappings(primary_key, options={})
|
54
|
-
|
54
|
+
Api.call("mappings", options.merge(:primaryKey => primary_key))['identifiers']
|
55
55
|
end
|
56
56
|
|
57
57
|
def all_mappings(options={})
|
58
|
-
|
58
|
+
Api.call("all_mappings", options)['mappings']
|
59
59
|
end
|
60
60
|
|
61
61
|
def contacts(identifier, options={})
|
62
|
-
data =
|
62
|
+
data = Api.call("get_contacts", options.merge(:identifier => identifier))
|
63
63
|
RPXNow::ContactsCollection.new(data['response'])
|
64
64
|
end
|
65
65
|
alias get_contacts contacts
|
@@ -67,13 +67,15 @@ module RPXNow
|
|
67
67
|
def embed_code(subdomain,url,options={})
|
68
68
|
options = {:width => '400', :height => '240', :language => 'en'}.merge(options)
|
69
69
|
<<-EOF
|
70
|
-
<iframe src="https://#{subdomain}.#{
|
70
|
+
<iframe src="https://#{subdomain}.#{Api::HOST}/openid/embed?token_url=#{url}&language_preference=#{options[:language]}"
|
71
71
|
scrolling="no" frameBorder="no" style="width:#{options[:width]}px;height:#{options[:height]}px;">
|
72
72
|
</iframe>
|
73
73
|
EOF
|
74
74
|
end
|
75
75
|
|
76
76
|
def popup_code(text, subdomain, url, options = {})
|
77
|
+
options = options.dup
|
78
|
+
options[:language] ||= 'en'
|
77
79
|
if options[:unobtrusive]
|
78
80
|
unobtrusive_popup_code(text, subdomain, url, options)
|
79
81
|
else
|
@@ -100,23 +102,23 @@ module RPXNow
|
|
100
102
|
|
101
103
|
def unobtrusive_popup_code(text, subdomain, url, options={})
|
102
104
|
version = extract_version! options
|
103
|
-
|
105
|
+
%Q(<a class="rpxnow" href="https://#{subdomain}.#{Api::HOST}/openid/v#{version}/signin?token_url=#{url}&language_preference=#{options[:language]}">#{text}</a>)
|
104
106
|
end
|
105
107
|
|
106
108
|
def obtrusive_popup_code(text, subdomain, url, options = {})
|
107
109
|
version = extract_version! options
|
108
110
|
<<-EOF
|
109
|
-
<a class="rpxnow" onclick="return false;" href="https://#{subdomain}.#{
|
111
|
+
<a class="rpxnow" onclick="return false;" href="https://#{subdomain}.#{Api::HOST}/openid/v#{version}/signin?token_url=#{url}">
|
110
112
|
#{text}
|
111
113
|
</a>
|
112
|
-
<script src="https://#{
|
114
|
+
<script src="https://#{Api::HOST}/openid/v#{version}/widget" type="text/javascript"></script>
|
113
115
|
<script type="text/javascript">
|
114
116
|
//<![CDATA[
|
115
117
|
RPXNOW.token_url = "#{url}";
|
116
118
|
|
117
119
|
RPXNOW.realm = "#{subdomain}";
|
118
120
|
RPXNOW.overlay = true;
|
119
|
-
RPXNOW.language_preference = '#{options[:language]
|
121
|
+
RPXNOW.language_preference = '#{options[:language]}';
|
120
122
|
//]]>
|
121
123
|
</script>
|
122
124
|
EOF
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module RPXNow
|
2
|
-
|
2
|
+
# low-level interaction with rpxnow.com api
|
3
|
+
# - send requests
|
4
|
+
# - parse response
|
5
|
+
# - handle server errors
|
6
|
+
class Api
|
3
7
|
HOST = 'rpxnow.com'
|
4
8
|
SSL_CERT = File.join(File.dirname(__FILE__), '..', '..', 'certs', 'ssl_cert.pem')
|
5
9
|
|
6
|
-
def self.
|
10
|
+
def self.call(method, data)
|
7
11
|
version = RPXNow.extract_version! data
|
8
12
|
path = "/api/v#{version}/#{method}"
|
9
13
|
response = request(path, {:apiKey => RPXNow.api_key}.merge(data))
|
@@ -13,18 +17,29 @@ module RPXNow
|
|
13
17
|
private
|
14
18
|
|
15
19
|
def self.request(path, data)
|
20
|
+
client.request(request_object(path, data))
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.request_object(path, data)
|
16
24
|
request = Net::HTTP::Post.new(path)
|
17
|
-
request.form_data = data
|
18
|
-
|
25
|
+
request.form_data = stringify_keys(data)
|
26
|
+
request
|
27
|
+
end
|
28
|
+
|
29
|
+
# symbol keys -> string keys
|
30
|
+
# because of ruby 1.9.x bug in Net::HTTP
|
31
|
+
# http://redmine.ruby-lang.org/issues/show/1351
|
32
|
+
def self.stringify_keys(hash)
|
33
|
+
hash.map{|k,v| [k.to_s,v]}
|
19
34
|
end
|
20
35
|
|
21
|
-
def self.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
36
|
+
def self.client
|
37
|
+
client = Net::HTTP.new(HOST, 443)
|
38
|
+
client.use_ssl = true
|
39
|
+
client.ca_file = SSL_CERT
|
40
|
+
client.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
41
|
+
client.verify_depth = 5
|
42
|
+
client
|
28
43
|
end
|
29
44
|
|
30
45
|
def self.parse_response(response)
|
data/rpx_now.gemspec
CHANGED
@@ -5,17 +5,18 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rpx_now}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-09}
|
13
13
|
s.email = %q{grosser.michael@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.markdown"
|
16
16
|
]
|
17
17
|
s.files = [
|
18
|
-
"
|
18
|
+
".gitignore",
|
19
|
+
"CHANGELOG",
|
19
20
|
"MIGRATION",
|
20
21
|
"README.markdown",
|
21
22
|
"Rakefile",
|
@@ -23,17 +24,16 @@ Gem::Specification.new do |s|
|
|
23
24
|
"certs/ssl_cert.pem",
|
24
25
|
"init.rb",
|
25
26
|
"lib/rpx_now.rb",
|
27
|
+
"lib/rpx_now/api.rb",
|
26
28
|
"lib/rpx_now/contacts_collection.rb",
|
27
|
-
"lib/rpx_now/request.rb",
|
28
29
|
"lib/rpx_now/user_integration.rb",
|
29
30
|
"lib/rpx_now/user_proxy.rb",
|
30
|
-
"pkg/rpx_now-0.5.10.gem",
|
31
|
-
"pkg/rpx_now-0.5.11.gem",
|
32
31
|
"rdoc/README.rdoc",
|
33
32
|
"rpx_now.gemspec",
|
34
33
|
"spec/fixtures/get_contacts_response.json",
|
34
|
+
"spec/integration/mapping_spec.rb",
|
35
|
+
"spec/rpx_now/api_spec.rb",
|
35
36
|
"spec/rpx_now/contacts_collection_spec.rb",
|
36
|
-
"spec/rpx_now/request_spec.rb",
|
37
37
|
"spec/rpx_now/user_proxy_spec.rb",
|
38
38
|
"spec/rpx_now_spec.rb",
|
39
39
|
"spec/spec_helper.rb"
|
@@ -48,8 +48,9 @@ Gem::Specification.new do |s|
|
|
48
48
|
"spec/rpx_now_spec.rb",
|
49
49
|
"spec/rpx_now/contacts_collection_spec.rb",
|
50
50
|
"spec/rpx_now/user_proxy_spec.rb",
|
51
|
-
"spec/rpx_now/
|
52
|
-
"spec/spec_helper.rb"
|
51
|
+
"spec/rpx_now/api_spec.rb",
|
52
|
+
"spec/spec_helper.rb",
|
53
|
+
"spec/integration/mapping_spec.rb"
|
53
54
|
]
|
54
55
|
|
55
56
|
if s.respond_to? :specification_version then
|
@@ -57,11 +58,11 @@ Gem::Specification.new do |s|
|
|
57
58
|
s.specification_version = 3
|
58
59
|
|
59
60
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
60
|
-
s.add_runtime_dependency(%q<
|
61
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
61
62
|
else
|
62
|
-
s.add_dependency(%q<
|
63
|
+
s.add_dependency(%q<json>, [">= 0"])
|
63
64
|
end
|
64
65
|
else
|
65
|
-
s.add_dependency(%q<
|
66
|
+
s.add_dependency(%q<json>, [">= 0"])
|
66
67
|
end
|
67
68
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe RPXNow do
|
4
|
+
describe :mapping_integration do
|
5
|
+
before do
|
6
|
+
@k1 = 'http://test.myopenid.com'
|
7
|
+
RPXNow.unmap(@k1, 1)
|
8
|
+
@k2 = 'http://test-2.myopenid.com'
|
9
|
+
RPXNow.unmap(@k2, 1)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has no mappings when nothing was mapped" do
|
13
|
+
RPXNow.mappings(1).should == []
|
14
|
+
end
|
15
|
+
|
16
|
+
it "unmaps mapped keys" do
|
17
|
+
RPXNow.map(@k2, 1)
|
18
|
+
RPXNow.unmap(@k2, 1)
|
19
|
+
RPXNow.mappings(1).should == []
|
20
|
+
end
|
21
|
+
|
22
|
+
it "maps keys to a primary key and then retrieves them" do
|
23
|
+
RPXNow.map(@k1, 1)
|
24
|
+
RPXNow.map(@k2, 1)
|
25
|
+
RPXNow.mappings(1).sort.should == [@k2,@k1]
|
26
|
+
end
|
27
|
+
|
28
|
+
it "does not add duplicate mappings" do
|
29
|
+
RPXNow.map(@k1, 1)
|
30
|
+
RPXNow.map(@k1, 1)
|
31
|
+
RPXNow.mappings(1).should == [@k1]
|
32
|
+
end
|
33
|
+
|
34
|
+
it "finds all mappings" do
|
35
|
+
RPXNow.map(@k1, 1)
|
36
|
+
RPXNow.map(@k2, 2)
|
37
|
+
RPXNow.all_mappings.sort.should == [["1", ["http://test.myopenid.com"]], ["2", ["http://test-2.myopenid.com"]]]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,41 +1,50 @@
|
|
1
1
|
require 'spec/spec_helper'
|
2
2
|
|
3
|
-
describe RPXNow::
|
3
|
+
describe RPXNow::Api do
|
4
4
|
describe 'ssl cert' do
|
5
5
|
it "has an absolute path" do
|
6
|
-
RPXNow::
|
6
|
+
RPXNow::Api::SSL_CERT[0..0].should == '/' #start with '/'
|
7
7
|
end
|
8
8
|
|
9
9
|
it "exists" do
|
10
|
-
File.read(RPXNow::
|
10
|
+
File.read(RPXNow::Api::SSL_CERT).to_s.should_not be_empty
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe :parse_response do
|
15
15
|
it "parses json when status is ok" do
|
16
16
|
response = mock(:code=>'200', :body=>%Q({"stat":"ok","data":"xx"}))
|
17
|
-
RPXNow::
|
17
|
+
RPXNow::Api.send(:parse_response, response)['data'].should == "xx"
|
18
18
|
end
|
19
19
|
|
20
20
|
it "raises when there is a communication error" do
|
21
21
|
response = stub(:code=>'200', :body=>%Q({"err":"wtf","stat":"ok"}))
|
22
22
|
lambda{
|
23
|
-
RPXNow::
|
23
|
+
RPXNow::Api.send(:parse_response,response)
|
24
24
|
}.should raise_error(RPXNow::ApiError)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "raises when service has downtime" do
|
28
28
|
response = stub(:code=>'200', :body=>%Q({"err":{"code":-1},"stat":"ok"}))
|
29
29
|
lambda{
|
30
|
-
RPXNow::
|
30
|
+
RPXNow::Api.send(:parse_response,response)
|
31
31
|
}.should raise_error(RPXNow::ServiceUnavailableError)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "raises when service is down" do
|
35
35
|
response = stub(:code=>'400',:body=>%Q({"stat":"err"}))
|
36
36
|
lambda{
|
37
|
-
RPXNow::
|
37
|
+
RPXNow::Api.send(:parse_response,response)
|
38
38
|
}.should raise_error(RPXNow::ServiceUnavailableError)
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
describe :request_object do
|
43
|
+
it "converts symbols to string keys" do
|
44
|
+
mock = ''
|
45
|
+
mock.should_receive(:form_data=).with([['symbol', 'value']])
|
46
|
+
Net::HTTP::Post.should_receive(:new).and_return(mock)
|
47
|
+
RPXNow::Api.send(:request_object, 'something', :symbol=>'value')
|
48
|
+
end
|
49
|
+
end
|
41
50
|
end
|
@@ -9,23 +9,24 @@ class User
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe RPXNow::UserProxy do
|
12
|
-
before
|
13
|
-
|
12
|
+
before { @user = User.new }
|
13
|
+
|
14
|
+
it "has a proxy" do
|
15
|
+
@user.rpx.class.should == RPXNow::UserProxy
|
14
16
|
end
|
15
17
|
|
16
18
|
it "has identifiers" do
|
17
|
-
RPXNow.
|
18
|
-
|
19
|
+
RPXNow.should_receive(:mappings).with(@user.id).and_return(['identifiers'])
|
20
|
+
@user.rpx.identifiers.should == ['identifiers']
|
19
21
|
end
|
20
22
|
|
21
23
|
it "can map" do
|
22
|
-
|
23
|
-
|
24
|
+
RPXNow.should_receive(:map).with('identifier', @user.id)
|
25
|
+
@user.rpx.map('identifier')
|
24
26
|
end
|
25
27
|
|
26
28
|
it "can unmap" do
|
27
|
-
RPXNow.
|
28
|
-
|
29
|
-
User.new.rpx.identifiers.should == []
|
29
|
+
RPXNow.should_receive(:unmap).with('identifier', @user.id)
|
30
|
+
@user.rpx.unmap('identifier')
|
30
31
|
end
|
31
32
|
end
|
data/spec/rpx_now_spec.rb
CHANGED
@@ -7,17 +7,63 @@ describe RPXNow do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe :api_key= do
|
10
|
-
|
10
|
+
before do
|
11
11
|
RPXNow.api_key='XX'
|
12
|
-
|
12
|
+
end
|
13
|
+
|
14
|
+
it "is stored" do
|
15
|
+
RPXNow.api_key.should == 'XX'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "stores the api key, so i do not have to supply everytime" do
|
19
|
+
RPXNow::Api.should_receive(:request).
|
20
|
+
with(anything, hash_including(:apiKey => 'XX')).
|
21
|
+
and_return fake_response
|
13
22
|
RPXNow.mappings(1)
|
14
23
|
end
|
24
|
+
|
25
|
+
it "is not overwritten when overwriting for a single request" do
|
26
|
+
RPXNow::Api.should_receive(:request).
|
27
|
+
with(anything, hash_including(:apiKey => 'YY')).
|
28
|
+
and_return fake_response
|
29
|
+
RPXNow.mappings(1, :apiKey => 'YY')
|
30
|
+
RPXNow.api_key.should == 'XX'
|
31
|
+
end
|
15
32
|
end
|
16
33
|
|
17
34
|
describe :api_version= do
|
18
|
-
it "
|
19
|
-
RPXNow.api_version
|
20
|
-
|
35
|
+
it "is 2 by default" do
|
36
|
+
RPXNow.api_version.should == 2
|
37
|
+
end
|
38
|
+
|
39
|
+
it "is stored" do
|
40
|
+
RPXNow.api_version='XX'
|
41
|
+
RPXNow.api_version.should == 'XX'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "used for every request" do
|
45
|
+
RPXNow.api_version='XX'
|
46
|
+
RPXNow::Api.should_receive(:request).
|
47
|
+
with('/api/vXX/mappings', anything).
|
48
|
+
and_return fake_response
|
49
|
+
RPXNow.mappings(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "is not overwritten when overwriting for a single request" do
|
53
|
+
RPXNow.api_version='XX'
|
54
|
+
RPXNow::Api.should_receive(:request).
|
55
|
+
with('/api/vYY/mappings', anything).
|
56
|
+
and_return fake_response
|
57
|
+
RPXNow.mappings(1, :api_version => 'YY')
|
58
|
+
RPXNow.api_version.should == 'XX'
|
59
|
+
end
|
60
|
+
|
61
|
+
it "is not passed in data for request" do
|
62
|
+
RPXNow.api_version='XX'
|
63
|
+
RPXNow::Api.should_receive(:request).
|
64
|
+
with(anything, hash_not_including(:api_version => 'YY')).
|
65
|
+
and_return fake_response
|
66
|
+
RPXNow.mappings(1, :api_version => 'YY')
|
21
67
|
end
|
22
68
|
end
|
23
69
|
|
@@ -59,12 +105,29 @@ describe RPXNow do
|
|
59
105
|
it "defaults to obtrusive output" do
|
60
106
|
RPXNow.popup_code('sign on', 'subdomain', 'http://fake.domain.com/').should =~ /script src=/
|
61
107
|
end
|
62
|
-
|
63
|
-
it "
|
64
|
-
|
65
|
-
RPXNow.popup_code('
|
108
|
+
|
109
|
+
it "does not change supplied options" do
|
110
|
+
options = {:xxx => 1}
|
111
|
+
RPXNow.popup_code('a','b','c', options)
|
112
|
+
options.should == {:xxx => 1}
|
66
113
|
end
|
67
|
-
|
114
|
+
|
115
|
+
describe 'unobstrusive' do
|
116
|
+
it "can build an unobtrusive widget" do
|
117
|
+
expected = %Q(<a class="rpxnow" href="https://subdomain.rpxnow.com/openid/v2/signin?token_url=http://fake.domain.com/&language_preference=en">sign on</a>)
|
118
|
+
actual = RPXNow.popup_code('sign on', 'subdomain', 'http://fake.domain.com/', :unobtrusive => true)
|
119
|
+
expected.should == actual
|
120
|
+
end
|
121
|
+
|
122
|
+
it "can change api version" do
|
123
|
+
RPXNow.popup_code('x', 'y', 'z', :unobtrusive => true, :api_version => 'XX').should include("openid/vXX/signin?")
|
124
|
+
end
|
125
|
+
|
126
|
+
it "can change language" do
|
127
|
+
RPXNow.popup_code('x', 'y', 'z', :unobtrusive => true, :language => 'XX').should include("&language_preference=XX")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
68
131
|
it "allows to specify the version of the widget" do
|
69
132
|
RPXNow.popup_code('x','y','z', :api_version => 300).should =~ %r(/openid/v300/signin)
|
70
133
|
end
|
@@ -114,26 +177,26 @@ describe RPXNow do
|
|
114
177
|
:identifier => 'https://www.google.com/accounts/o8/id?id=AItOawmaOlyYezg_WfbgP_qjaUyHjmqZD9qNIVM',
|
115
178
|
:username => 'grosser.michael',
|
116
179
|
}
|
117
|
-
RPXNow::
|
180
|
+
RPXNow::Api.should_receive(:request).and_return @response
|
118
181
|
RPXNow.user_data('').should == expected
|
119
182
|
end
|
120
183
|
|
121
184
|
it "adds a :id when primaryKey was returned" do
|
122
185
|
@response_body['profile']['primaryKey'] = "2"
|
123
186
|
response = fake_response(@response_body)
|
124
|
-
RPXNow::
|
187
|
+
RPXNow::Api.should_receive(:request).and_return response
|
125
188
|
RPXNow.user_data('')[:id].should == '2'
|
126
189
|
end
|
127
190
|
|
128
191
|
it "handles primaryKeys that are not numeric" do
|
129
192
|
@response_body['profile']['primaryKey'] = "dbalatero"
|
130
193
|
response = fake_response(@response_body)
|
131
|
-
RPXNow::
|
194
|
+
RPXNow::Api.should_receive(:request).and_return response
|
132
195
|
RPXNow.user_data('')[:id].should == 'dbalatero'
|
133
196
|
end
|
134
197
|
|
135
198
|
it "hands JSON response to supplied block" do
|
136
|
-
RPXNow::
|
199
|
+
RPXNow::Api.should_receive(:request).and_return @response
|
137
200
|
response = nil
|
138
201
|
RPXNow.user_data(''){|data| response = data}
|
139
202
|
response.delete('stat') # dunno why it happens, but is not important...
|
@@ -141,34 +204,42 @@ describe RPXNow do
|
|
141
204
|
end
|
142
205
|
|
143
206
|
it "returns what the supplied block returned" do
|
144
|
-
RPXNow::
|
207
|
+
RPXNow::Api.should_receive(:request).and_return @response
|
145
208
|
RPXNow.user_data(''){|data| "x"}.should == 'x'
|
146
209
|
end
|
147
210
|
|
148
211
|
it "can send additional parameters" do
|
149
|
-
RPXNow::
|
150
|
-
|
151
|
-
|
212
|
+
RPXNow::Api.should_receive(:request).
|
213
|
+
with(anything, hash_including(:extended => 'true')).
|
214
|
+
and_return @response
|
152
215
|
RPXNow.user_data('',:extended=>'true')
|
153
216
|
end
|
154
217
|
|
218
|
+
# these 2 tests are kind of duplicates of the api_version/key tests,
|
219
|
+
# but i want to be extra-sure user_data works
|
155
220
|
it "works with api version as option" do
|
156
|
-
RPXNow::
|
221
|
+
RPXNow::Api.should_receive(:request).
|
222
|
+
with('/api/v123/auth_info', anything).
|
223
|
+
and_return @response
|
157
224
|
RPXNow.user_data('id', :extended=>'abc', :api_version=>123)
|
158
225
|
RPXNow.api_version.should == API_VERSION
|
159
226
|
end
|
160
227
|
|
161
228
|
it "works with apiKey as option" do
|
162
|
-
RPXNow::
|
229
|
+
RPXNow::Api.should_receive(:request).
|
230
|
+
with('/api/v2/auth_info', hash_including(:apiKey=>'THE KEY')).
|
231
|
+
and_return @response
|
163
232
|
RPXNow.user_data('id', :extended=>'abc', :apiKey=>'THE KEY')
|
164
233
|
RPXNow.api_key.should == API_KEY
|
165
234
|
end
|
166
235
|
end
|
167
236
|
|
168
237
|
describe :set_status do
|
169
|
-
it "
|
170
|
-
RPXNow::
|
171
|
-
|
238
|
+
it "sets the status" do
|
239
|
+
RPXNow::Api.should_receive(:request).
|
240
|
+
with("/api/v2/set_status", :identifier=>"identifier", :status=>"Chillen...", :apiKey=>API_KEY).
|
241
|
+
and_return fake_response
|
242
|
+
RPXNow.set_status('identifier', 'Chillen...')
|
172
243
|
end
|
173
244
|
end
|
174
245
|
|
@@ -185,73 +256,38 @@ describe RPXNow do
|
|
185
256
|
describe :contacts do
|
186
257
|
it "finds all contacts" do
|
187
258
|
response = fake_response(JSON.parse(File.read('spec/fixtures/get_contacts_response.json')))
|
188
|
-
RPXNow::
|
259
|
+
RPXNow::Api.should_receive(:request).
|
260
|
+
with('/api/v2/get_contacts',:identifier=>'xx', :apiKey=>API_KEY).
|
261
|
+
and_return response
|
189
262
|
RPXNow.contacts('xx').size.should == 5
|
190
263
|
end
|
191
264
|
end
|
192
265
|
|
193
266
|
describe :mappings do
|
194
|
-
it "
|
195
|
-
|
196
|
-
|
267
|
+
it "shows all mappings" do
|
268
|
+
RPXNow::Api.should_receive(:request).
|
269
|
+
with("/api/v2/mappings", :apiKey=>API_KEY, :primaryKey=>1).
|
270
|
+
and_return fake_response("identifiers" => ["http://test.myopenid.com/"])
|
197
271
|
RPXNow.mappings(1).should == ["http://test.myopenid.com/"]
|
198
272
|
end
|
199
273
|
end
|
200
274
|
|
201
275
|
describe :map do
|
202
|
-
it "
|
203
|
-
RPXNow::
|
276
|
+
it "maps a identifier" do
|
277
|
+
RPXNow::Api.should_receive(:request).
|
278
|
+
with("/api/v2/map", :apiKey=>API_KEY, :primaryKey=>1, :identifier=>"http://test.myopenid.com").
|
279
|
+
and_return fake_response
|
204
280
|
RPXNow.map('http://test.myopenid.com',1)
|
205
281
|
end
|
206
282
|
end
|
207
283
|
|
208
284
|
describe :unmap do
|
209
285
|
it "unmaps a indentifier" do
|
210
|
-
RPXNow::
|
286
|
+
RPXNow::Api.should_receive(:request).
|
287
|
+
with("/api/v2/unmap", :apiKey=>API_KEY, :primaryKey=>1, :identifier=>"http://test.myopenid.com").
|
288
|
+
and_return fake_response
|
211
289
|
RPXNow.unmap('http://test.myopenid.com', 1)
|
212
290
|
end
|
213
|
-
|
214
|
-
it "can be called with a specific version" do
|
215
|
-
RPXNow::Request.should_receive(:request).with{|a,b|a == "/api/v300/unmap"}.and_return fake_response
|
216
|
-
RPXNow.unmap('http://test.myopenid.com', 1, :api_key=>'xxx', :api_version=>300)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
describe :mapping_integration do
|
221
|
-
before do
|
222
|
-
@k1 = 'http://test.myopenid.com'
|
223
|
-
RPXNow.unmap(@k1, 1)
|
224
|
-
@k2 = 'http://test-2.myopenid.com'
|
225
|
-
RPXNow.unmap(@k2, 1)
|
226
|
-
end
|
227
|
-
|
228
|
-
it "has no mappings when nothing was mapped" do
|
229
|
-
RPXNow.mappings(1).should == []
|
230
|
-
end
|
231
|
-
|
232
|
-
it "unmaps mapped keys" do
|
233
|
-
RPXNow.map(@k2, 1)
|
234
|
-
RPXNow.unmap(@k2, 1)
|
235
|
-
RPXNow.mappings(1).should == []
|
236
|
-
end
|
237
|
-
|
238
|
-
it "maps keys to a primary key and then retrieves them" do
|
239
|
-
RPXNow.map(@k1, 1)
|
240
|
-
RPXNow.map(@k2, 1)
|
241
|
-
RPXNow.mappings(1).sort.should == [@k2,@k1]
|
242
|
-
end
|
243
|
-
|
244
|
-
it "does not add duplicate mappings" do
|
245
|
-
RPXNow.map(@k1, 1)
|
246
|
-
RPXNow.map(@k1, 1)
|
247
|
-
RPXNow.mappings(1).should == [@k1]
|
248
|
-
end
|
249
|
-
|
250
|
-
it "finds all mappings" do
|
251
|
-
RPXNow.map(@k1, 1)
|
252
|
-
RPXNow.map(@k2, 2)
|
253
|
-
RPXNow.all_mappings.sort.should == [["1", ["http://test.myopenid.com"]], ["2", ["http://test-2.myopenid.com"]]]
|
254
|
-
end
|
255
291
|
end
|
256
292
|
|
257
293
|
it "has a VERSION" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpx_now
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-09 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: json
|
17
17
|
type: :runtime
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,6 +31,7 @@ extensions: []
|
|
31
31
|
extra_rdoc_files:
|
32
32
|
- README.markdown
|
33
33
|
files:
|
34
|
+
- .gitignore
|
34
35
|
- CHANGELOG
|
35
36
|
- MIGRATION
|
36
37
|
- README.markdown
|
@@ -39,17 +40,16 @@ files:
|
|
39
40
|
- certs/ssl_cert.pem
|
40
41
|
- init.rb
|
41
42
|
- lib/rpx_now.rb
|
43
|
+
- lib/rpx_now/api.rb
|
42
44
|
- lib/rpx_now/contacts_collection.rb
|
43
|
-
- lib/rpx_now/request.rb
|
44
45
|
- lib/rpx_now/user_integration.rb
|
45
46
|
- lib/rpx_now/user_proxy.rb
|
46
|
-
- pkg/rpx_now-0.5.10.gem
|
47
|
-
- pkg/rpx_now-0.5.11.gem
|
48
47
|
- rdoc/README.rdoc
|
49
48
|
- rpx_now.gemspec
|
50
49
|
- spec/fixtures/get_contacts_response.json
|
50
|
+
- spec/integration/mapping_spec.rb
|
51
|
+
- spec/rpx_now/api_spec.rb
|
51
52
|
- spec/rpx_now/contacts_collection_spec.rb
|
52
|
-
- spec/rpx_now/request_spec.rb
|
53
53
|
- spec/rpx_now/user_proxy_spec.rb
|
54
54
|
- spec/rpx_now_spec.rb
|
55
55
|
- spec/spec_helper.rb
|
@@ -85,5 +85,6 @@ test_files:
|
|
85
85
|
- spec/rpx_now_spec.rb
|
86
86
|
- spec/rpx_now/contacts_collection_spec.rb
|
87
87
|
- spec/rpx_now/user_proxy_spec.rb
|
88
|
-
- spec/rpx_now/
|
88
|
+
- spec/rpx_now/api_spec.rb
|
89
89
|
- spec/spec_helper.rb
|
90
|
+
- spec/integration/mapping_spec.rb
|
data/pkg/rpx_now-0.5.10.gem
DELETED
Binary file
|
data/pkg/rpx_now-0.5.11.gem
DELETED
Binary file
|