rpx_now 0.6.24 → 0.7.0
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/lib/rpx_now.rb +13 -7
- data/lib/rpx_now/version.rb +3 -0
- metadata +38 -74
- data/CHANGELOG +0 -38
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -28
- data/MIGRATION +0 -9
- data/Rakefile +0 -22
- data/Readme.md +0 -166
- data/VERSION +0 -1
- data/init.rb +0 -2
- data/rpx_now.gemspec +0 -63
- data/spec/fixtures/get_contacts_response.json +0 -58
- data/spec/integration/mapping_spec.rb +0 -40
- data/spec/rpx_now/api_spec.rb +0 -50
- data/spec/rpx_now/contacts_collection_spec.rb +0 -32
- data/spec/rpx_now/user_proxy_spec.rb +0 -33
- data/spec/rpx_now_spec.rb +0 -414
- data/spec/spec_helper.rb +0 -16
data/lib/rpx_now.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rpx_now/version'
|
1
2
|
require 'rpx_now/api'
|
2
3
|
require 'rpx_now/contacts_collection'
|
3
4
|
require 'cgi'
|
@@ -8,11 +9,9 @@ module RPXNow
|
|
8
9
|
attr_accessor :api_key
|
9
10
|
attr_accessor :api_version
|
10
11
|
attr_accessor :domain
|
11
|
-
|
12
|
+
|
12
13
|
self.api_version = 2
|
13
14
|
self.domain = 'rpxnow.com'
|
14
|
-
|
15
|
-
VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
|
16
15
|
|
17
16
|
# retrieve the users data
|
18
17
|
# - cleaned Hash
|
@@ -101,7 +100,8 @@ module RPXNow
|
|
101
100
|
# popup window for rpx login
|
102
101
|
# options: :language, :flags, :unobtrusive, :api_version, :default_provider, :html
|
103
102
|
def popup_code(text, subdomain, url, options = {})
|
104
|
-
|
103
|
+
options = options.dup
|
104
|
+
if options.delete(:unobtrusive)
|
105
105
|
unobtrusive_popup_code(text, subdomain, url, options)
|
106
106
|
else
|
107
107
|
obtrusive_popup_code(text, subdomain, url, options)
|
@@ -129,7 +129,14 @@ module RPXNow
|
|
129
129
|
# url for unobtrusive popup window
|
130
130
|
# options: :language, :flags, :api_version, :default_provider
|
131
131
|
def popup_url(subdomain, url, options={})
|
132
|
-
|
132
|
+
case options.delete(:fallback_url)
|
133
|
+
when :legacy
|
134
|
+
"#{Api.host(subdomain)}/openid/v#{extract_version(options)}/signin?#{embed_params(url, options)}"
|
135
|
+
when :disable
|
136
|
+
"javacsript:void(0)"
|
137
|
+
else
|
138
|
+
"#{Api.host(subdomain)}/openid/embed?#{embed_params(url, options)}"
|
139
|
+
end
|
133
140
|
end
|
134
141
|
|
135
142
|
def extract_version(options)
|
@@ -175,7 +182,6 @@ module RPXNow
|
|
175
182
|
end
|
176
183
|
|
177
184
|
def unobtrusive_popup_code(text, subdomain, url, options={})
|
178
|
-
options = options.dup
|
179
185
|
html_options = options.delete(:html) || {}
|
180
186
|
html_options[:class] = "rpxnow #{html_options[:class]}".strip
|
181
187
|
html_options[:href] ||= popup_url(subdomain, url, options)
|
@@ -196,4 +202,4 @@ module RPXNow
|
|
196
202
|
class ServerError < RuntimeError; end #backwards compatibility / catch all
|
197
203
|
class ApiError < ServerError; end
|
198
204
|
class ServiceUnavailableError < ServerError; end
|
199
|
-
end
|
205
|
+
end
|
metadata
CHANGED
@@ -1,106 +1,70 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpx_now
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
- 24
|
10
|
-
version: 0.6.24
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Michael Grosser
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2013-06-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json_pure
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
31
|
-
prerelease: false
|
32
|
-
version_requirements: *id001
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
35
30
|
description:
|
36
31
|
email: grosser.michael@gmail.com
|
37
32
|
executables: []
|
38
|
-
|
39
33
|
extensions: []
|
40
|
-
|
41
34
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
44
|
-
- CHANGELOG
|
45
|
-
- Gemfile
|
46
|
-
- Gemfile.lock
|
47
|
-
- MIGRATION
|
48
|
-
- Rakefile
|
49
|
-
- Readme.md
|
50
|
-
- VERSION
|
35
|
+
files:
|
51
36
|
- certs/ssl_cert.pem
|
52
|
-
- init.rb
|
53
37
|
- lib/rpx_now.rb
|
54
38
|
- lib/rpx_now/api.rb
|
55
39
|
- lib/rpx_now/contacts_collection.rb
|
56
40
|
- lib/rpx_now/user_integration.rb
|
57
41
|
- lib/rpx_now/user_proxy.rb
|
58
|
-
- rpx_now.
|
59
|
-
|
60
|
-
- spec/integration/mapping_spec.rb
|
61
|
-
- spec/rpx_now/api_spec.rb
|
62
|
-
- spec/rpx_now/contacts_collection_spec.rb
|
63
|
-
- spec/rpx_now/user_proxy_spec.rb
|
64
|
-
- spec/rpx_now_spec.rb
|
65
|
-
- spec/spec_helper.rb
|
66
|
-
has_rdoc: true
|
67
|
-
homepage: http://github.com/grosser/rpx_now
|
42
|
+
- lib/rpx_now/version.rb
|
43
|
+
homepage: https://github.com/grosser/rpx_now
|
68
44
|
licenses: []
|
69
|
-
|
70
45
|
post_install_message:
|
71
46
|
rdoc_options: []
|
72
|
-
|
73
|
-
require_paths:
|
47
|
+
require_paths:
|
74
48
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
50
|
none: false
|
77
|
-
requirements:
|
78
|
-
- -
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
|
81
|
-
segments:
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
segments:
|
82
56
|
- 0
|
83
|
-
|
84
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
hash: -2533672090780588692
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
59
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
version: "0"
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
93
64
|
requirements: []
|
94
|
-
|
95
65
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.8.25
|
97
67
|
signing_key:
|
98
68
|
specification_version: 3
|
99
69
|
summary: Helper to simplify RPX Now user login/creation
|
100
|
-
test_files:
|
101
|
-
- spec/integration/mapping_spec.rb
|
102
|
-
- spec/rpx_now/api_spec.rb
|
103
|
-
- spec/rpx_now/contacts_collection_spec.rb
|
104
|
-
- spec/rpx_now/user_proxy_spec.rb
|
105
|
-
- spec/rpx_now_spec.rb
|
106
|
-
- spec/spec_helper.rb
|
70
|
+
test_files: []
|
data/CHANGELOG
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
0.6.13
|
2
|
-
------
|
3
|
-
* return an indifferent hash from user_data when possible
|
4
|
-
|
5
|
-
0.6.12
|
6
|
-
-----
|
7
|
-
* url encode obstrusive popup code token-url
|
8
|
-
0.6.0
|
9
|
-
-----
|
10
|
-
* removed optional api key as parameter: RPXNow.user_data(token, api_key, options) --> RPXNow.user_data(token, options), you may use :apiKey=>... instead
|
11
|
-
|
12
|
-
0.5.9
|
13
|
-
-----
|
14
|
-
* Switched from Get to Post requests
|
15
|
-
|
16
|
-
0.5.0
|
17
|
-
----
|
18
|
-
* ApiError is raised when API KEY was invalid (before did only return nil)
|
19
|
-
* ServerError is now seperated into ApiError and ServiceUnavailableError
|
20
|
-
|
21
|
-
0.4.2
|
22
|
-
----
|
23
|
-
* default IDs are strings, not integers, since RPX supports both
|
24
|
-
* Added username field to standart parameters
|
25
|
-
|
26
|
-
0.4
|
27
|
-
----
|
28
|
-
* The RPXNow.api_version= can be set globally
|
29
|
-
* Most methods now support :api_version=>'123', so you can specify the api_version on each call
|
30
|
-
* Added support for unobtrusive code generation. This will make the gem play nicely with developers creating unobtrusive pages with frameworks such as jQuery;
|
31
|
-
* The RPXNOW JSON responses are now parsed by Florian Frank JSON gem (http://json.rubyforge.org/);
|
32
|
-
* Removed the dependency of ActiveSupport. However, if present, ActiveSupport will be used due to its convenience methods Array#to_query and Hash#to_query.
|
33
|
-
* Added support for multiple versions of the widget. By default, everything will point to version 2;
|
34
|
-
* The specs have been updated.
|
35
|
-
|
36
|
-
0.3
|
37
|
-
----
|
38
|
-
* RPXNow::ServerError will be thrown when something is invalid/goes wrong, so watch out (not for invalid tokens in user_data)...
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.1.2)
|
5
|
-
git (1.2.5)
|
6
|
-
jeweler (1.5.2)
|
7
|
-
bundler (~> 1.0.0)
|
8
|
-
git (>= 1.2.5)
|
9
|
-
rake
|
10
|
-
json (1.4.6)
|
11
|
-
rake (0.8.7)
|
12
|
-
rspec (2.5.0)
|
13
|
-
rspec-core (~> 2.5.0)
|
14
|
-
rspec-expectations (~> 2.5.0)
|
15
|
-
rspec-mocks (~> 2.5.0)
|
16
|
-
rspec-core (2.5.1)
|
17
|
-
rspec-expectations (2.5.0)
|
18
|
-
diff-lcs (~> 1.1.2)
|
19
|
-
rspec-mocks (2.5.0)
|
20
|
-
|
21
|
-
PLATFORMS
|
22
|
-
ruby
|
23
|
-
|
24
|
-
DEPENDENCIES
|
25
|
-
jeweler
|
26
|
-
json
|
27
|
-
rake
|
28
|
-
rspec (~> 2)
|
data/MIGRATION
DELETED
data/Rakefile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
task :default => :spec
|
2
|
-
require "rspec/core/rake_task"
|
3
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
4
|
-
t.rspec_opts = '--backtrace --color'
|
5
|
-
end
|
6
|
-
|
7
|
-
begin
|
8
|
-
require 'jeweler'
|
9
|
-
|
10
|
-
Jeweler::Tasks.new do |gem|
|
11
|
-
gem.name = 'rpx_now'
|
12
|
-
gem.summary = "Helper to simplify RPX Now user login/creation"
|
13
|
-
gem.email = "grosser.michael@gmail.com"
|
14
|
-
gem.homepage = "http://github.com/grosser/#{gem.name}"
|
15
|
-
gem.authors = ["Michael Grosser"]
|
16
|
-
gem.add_dependency ['json_pure']
|
17
|
-
end
|
18
|
-
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
|
22
|
-
end
|
data/Readme.md
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
[RPX](http://rpxnow.com) allows users to login to your page through Facebook / Twitter / Myspace / Google / OpenId / MS-LiveId / AOL / ...
|
2
|
-
|
3
|
-
- Simpler then OpenId/OAuth/xxx for developers AND users
|
4
|
-
- Publish user activity to facebook/twitter/myspace/.../-stream
|
5
|
-
- Returning users are greeted by their provider
|
6
|
-
|
7
|
-

|
8
|
-

|
9
|
-

|
10
|
-
|
11
|
-
Usage
|
12
|
-
=====
|
13
|
-
- Get an API key @ [RPX](http://rpxnow.com)
|
14
|
-
- run [MIGRATION](http://github.com/grosser/rpx_now/raw/master/MIGRATION)
|
15
|
-
- Build login view
|
16
|
-
- Receive user-data from RPX to create or login User
|
17
|
-
- for more advanced features have a look at the [RPX API Docs](https://rpxnow.com/docs)
|
18
|
-
|
19
|
-
Install
|
20
|
-
=======
|
21
|
-
- As Rails plugin: `script/plugin install git://github.com/grosser/rpx_now.git `
|
22
|
-
- As gem: `sudo gem install rpx_now`
|
23
|
-
|
24
|
-
Examples
|
25
|
-
========
|
26
|
-
|
27
|
-
[Example application](http://github.com/grosser/rpx_now_example), go play around!
|
28
|
-
|
29
|
-
environment.rb
|
30
|
-
--------------
|
31
|
-
Rails::Initializer.run do |config|
|
32
|
-
config.gem "rpx_now"
|
33
|
-
...
|
34
|
-
|
35
|
-
config.after_initialize do # so rake gems:install works
|
36
|
-
RPXNow.api_key = "YOU RPX API KEY"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
Controller
|
41
|
-
----------
|
42
|
-
This example uses the SessionsController, if you dont have one built it and add routes(rpx_token is a post request)
|
43
|
-
|
44
|
-
skip_before_filter :verify_authenticity_token, :only => [:rpx_token] # RPX does not pass Rails form tokens...
|
45
|
-
|
46
|
-
# user_data
|
47
|
-
# found: {:name=>'John Doe', :username => 'john', :email=>'john@doe.com', :identifier=>'blug.google.com/openid/dsdfsdfs3f3'}
|
48
|
-
# not found: nil (can happen with e.g. invalid tokens)
|
49
|
-
def rpx_token
|
50
|
-
raise "hackers?" unless data = RPXNow.user_data(params[:token])
|
51
|
-
self.current_user = User.find_by_identifier(data[:identifier]) || User.create!(data)
|
52
|
-
redirect_to '/'
|
53
|
-
end
|
54
|
-
|
55
|
-
# getting additional profile fields (these fields are rarely filled)
|
56
|
-
# all possibilities: https://rpxnow.com/docs#profile_data
|
57
|
-
data = RPXNow.user_data(params[:token], :additional => [:gender, :birthday, :photo, :providerName, ...])
|
58
|
-
|
59
|
-
# normal + raw data
|
60
|
-
RPXNow.user_data(params[:token], :additional => [:raw_response])[:raw_response]['profile]['verifiedEmail']
|
61
|
-
|
62
|
-
# only raw data
|
63
|
-
email = RPXNow.user_data(params[:token], :raw_response => true)['profile']['verifiedEmail']
|
64
|
-
|
65
|
-
# with extended info like friends, accessCredentials, portable contacts. (most Providers do not supply them)
|
66
|
-
RPXNow.user_data(params[:token], :extended => true)[:extended]['friends'][...have a look at the RPX API DOCS...]
|
67
|
-
|
68
|
-
View
|
69
|
-
----
|
70
|
-
|
71
|
-
<%=RPXNow.embed_code('My-Rpx-Domain', url_for(:controller=>:session, :action=>:rpx_token, :only_path => false))%>
|
72
|
-
OR
|
73
|
-
<%=RPXNow.popup_code('Login here...', 'My-Rpx-Domain', url_for(:controller=>:session, :action=>:rpx_token, :only_path => false), options)%>
|
74
|
-
|
75
|
-
###Options
|
76
|
-
`:language=>'en'` rpx tries to detect the users language, but you may overwrite it [possible languages](https://rpxnow.com/docs#sign-in_localization)
|
77
|
-
`:default_provider=>'google'` [possible default providers](https://rpxnow.com/docs#sign-in_default_provider)
|
78
|
-
`:flags=>'show_provider_list'` [possible flags](https://rpxnow.com/docs#sign-in_interface)
|
79
|
-
`:html => {:id => 'xxx'}` is added to the popup link (popup_code only)
|
80
|
-
|
81
|
-
###Unobtrusive / JS-last
|
82
|
-
`popup_code` can also be called with `:unobtrusive=>true` ( --> just link without javascript include).
|
83
|
-
To still get the normal popup add `RPXNow.popup_source('My-Rpx-Domain', url_for(:controller=>:session, :action=>:rpx_token, :only_path => false), [options])`.
|
84
|
-
Options like :language / :flags should be given for both.
|
85
|
-
|
86
|
-
Advanced
|
87
|
-
--------
|
88
|
-
### Versions
|
89
|
-
RPXNow.api_version = 2
|
90
|
-
|
91
|
-
### Custom domain (PRX Plus/Pro)
|
92
|
-
RPXNow.domain = 'other-domain.com'
|
93
|
-
|
94
|
-
### Mappings (PRX Plus/Pro)
|
95
|
-
You can map your primary keys (e.g. user.id) to identifiers, so that<br/>
|
96
|
-
users can login to the same account with multiple identifiers.
|
97
|
-
RPXNow.map(identifier, primary_key) #add a mapping
|
98
|
-
RPXNow.unmap(identifier, primary_key) #remove a mapping
|
99
|
-
RPXNow.mappings(primary_key) # [identifier1,identifier2,...]
|
100
|
-
RPXNow.all_mappings # [["1",['google.com/dsdas','yahoo.com/asdas']], ["2",[...]], ... ]
|
101
|
-
|
102
|
-
After a primary key is mapped to an identifier, when a user logs in with this identifier,
|
103
|
-
`RPXNow.user_data` will contain his `primaryKey` as `:id`.
|
104
|
-
A identifyer can only belong to one user (in doubt the last one it was mapped to)
|
105
|
-
|
106
|
-
### User integration (e.g. ActiveRecord)
|
107
|
-
class User < ActiveRecord::Base
|
108
|
-
include RPXNow::UserIntegration
|
109
|
-
end
|
110
|
-
|
111
|
-
user.rpx.identifiers == RPXNow.mappings(user.id)
|
112
|
-
user.rpx.map(identifier) == RPXNow.map(identifier, user.id)
|
113
|
-
user.rpx.unmap(identifier) == RPXNow.unmap(identifier, user.id)
|
114
|
-
|
115
|
-
### Contacts (PRX Pro)
|
116
|
-
Retrieve all contacts for a given user:
|
117
|
-
RPXNow.contacts(identifier).each {|c| puts "#{c['displayName']}: #{c['emails']}}
|
118
|
-
|
119
|
-
### Status updates (PRX Plus/Pro)
|
120
|
-
Send a status update to provider (a tweet/facebook-status/...) :
|
121
|
-
RPXNow.set_status(identifier, "I just registered at yourdomain.com ...")
|
122
|
-
|
123
|
-
### Activity (RPX Plus/Pro)
|
124
|
-
Post a users activity, on their e.g. Facebook profile, complete with images, titels, rating, additional media, customized links and so on ...
|
125
|
-
RPXNow.activity( identifier,
|
126
|
-
:url=>href, :action=>'Im loving my new', :user_generated_content=>'Im loving my new ... ',
|
127
|
-
:title=>product.title, :description=>product.description,
|
128
|
-
:action_links=>[{:text=>'view >>', :href=>product_url(product, :only_path => false)}],
|
129
|
-
:media=>[{:type=>:image, :src=>product.image_url, :href=>product_url(product, :only_path => false)}]
|
130
|
-
}
|
131
|
-
|
132
|
-
### Offline user data access (RPX Plus/Pro)
|
133
|
-
Same response as auth_info but can be called with a identifier at any time.<br/>
|
134
|
-
Offline Profile Access must be enabled.
|
135
|
-
RPXNow.get_user_data(identifier, :extended => true)
|
136
|
-
|
137
|
-
### Auth info
|
138
|
-
Same response as user_data with :raw_response, but without any kind of failure detection or post processing.
|
139
|
-
RPXNow.auth_info(params[:token])
|
140
|
-
|
141
|
-
Author
|
142
|
-
======
|
143
|
-
|
144
|
-
__[rpx_now_gem mailing list](http://groups.google.com/group/rpx_now_gem)__
|
145
|
-
|
146
|
-
|
147
|
-
### [Contributors](http://github.com/grosser/rpx_now/contributors)
|
148
|
-
- [Amunds](http://github.com/Amunds)
|
149
|
-
- [Bob Groeneveld](http://metathoughtfacility.blogspot.com)
|
150
|
-
- [DBA](http://github.com/DBA)
|
151
|
-
- [dbalatero](http://github.com/dbalatero)
|
152
|
-
- [Paul Gallagher](http://tardate.blogspot.com/)
|
153
|
-
- [jackdempsey](http://jackndempsey.blogspot.com)
|
154
|
-
- [Patrick Reagan (reagent)](http://sneaq.net)
|
155
|
-
- [Joris Trooster (trooster)](http://www.interstroom.nl)
|
156
|
-
- [Mick Staugaard (staugaard)](http://mick.staugaard.com/)
|
157
|
-
- [Kasper Weibel](http://github.com/weibel)
|
158
|
-
- [Nicolas Alpi](http://www.notgeeklycorrect.com)
|
159
|
-
- [Ladislav Martincik](http://martincik.com)
|
160
|
-
- [Ben Aldred](http://github.com/benaldred)
|
161
|
-
- [Casper Fabricius](http://casperfabricius.com)
|
162
|
-
- [Avi Flombaum](http://www.aviflombaum.com)
|
163
|
-
|
164
|
-
[Michael Grosser](http://grosser.it)<br/>
|
165
|
-
michael@grosser.it<br/>
|
166
|
-
Hereby placed under public domain, do what you want, just do not hold me accountable...
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.6.24
|
data/init.rb
DELETED
data/rpx_now.gemspec
DELETED
@@ -1,63 +0,0 @@
|
|
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 = %q{rpx_now}
|
8
|
-
s.version = "0.6.24"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = %q{2011-02-21}
|
13
|
-
s.email = %q{grosser.michael@gmail.com}
|
14
|
-
s.files = [
|
15
|
-
"CHANGELOG",
|
16
|
-
"Gemfile",
|
17
|
-
"Gemfile.lock",
|
18
|
-
"MIGRATION",
|
19
|
-
"Rakefile",
|
20
|
-
"Readme.md",
|
21
|
-
"VERSION",
|
22
|
-
"certs/ssl_cert.pem",
|
23
|
-
"init.rb",
|
24
|
-
"lib/rpx_now.rb",
|
25
|
-
"lib/rpx_now/api.rb",
|
26
|
-
"lib/rpx_now/contacts_collection.rb",
|
27
|
-
"lib/rpx_now/user_integration.rb",
|
28
|
-
"lib/rpx_now/user_proxy.rb",
|
29
|
-
"rpx_now.gemspec",
|
30
|
-
"spec/fixtures/get_contacts_response.json",
|
31
|
-
"spec/integration/mapping_spec.rb",
|
32
|
-
"spec/rpx_now/api_spec.rb",
|
33
|
-
"spec/rpx_now/contacts_collection_spec.rb",
|
34
|
-
"spec/rpx_now/user_proxy_spec.rb",
|
35
|
-
"spec/rpx_now_spec.rb",
|
36
|
-
"spec/spec_helper.rb"
|
37
|
-
]
|
38
|
-
s.homepage = %q{http://github.com/grosser/rpx_now}
|
39
|
-
s.require_paths = ["lib"]
|
40
|
-
s.rubygems_version = %q{1.4.2}
|
41
|
-
s.summary = %q{Helper to simplify RPX Now user login/creation}
|
42
|
-
s.test_files = [
|
43
|
-
"spec/integration/mapping_spec.rb",
|
44
|
-
"spec/rpx_now/api_spec.rb",
|
45
|
-
"spec/rpx_now/contacts_collection_spec.rb",
|
46
|
-
"spec/rpx_now/user_proxy_spec.rb",
|
47
|
-
"spec/rpx_now_spec.rb",
|
48
|
-
"spec/spec_helper.rb"
|
49
|
-
]
|
50
|
-
|
51
|
-
if s.respond_to? :specification_version then
|
52
|
-
s.specification_version = 3
|
53
|
-
|
54
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
-
s.add_runtime_dependency(%q<json_pure>, [">= 0"])
|
56
|
-
else
|
57
|
-
s.add_dependency(%q<json_pure>, [">= 0"])
|
58
|
-
end
|
59
|
-
else
|
60
|
-
s.add_dependency(%q<json_pure>, [">= 0"])
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
@@ -1,58 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"response": {
|
3
|
-
"itemsPerPage": 5,
|
4
|
-
"totalResults": 5,
|
5
|
-
"entry": [
|
6
|
-
{
|
7
|
-
"displayName": "Bob Johnson",
|
8
|
-
"emails": [
|
9
|
-
{
|
10
|
-
"type": "other",
|
11
|
-
"value": "bob@example.com"
|
12
|
-
}
|
13
|
-
]
|
14
|
-
},
|
15
|
-
{
|
16
|
-
"displayName": "Cindy Smith",
|
17
|
-
"emails": [
|
18
|
-
{
|
19
|
-
"type": "other",
|
20
|
-
"value": "cindy.smith@example.com"
|
21
|
-
}
|
22
|
-
]
|
23
|
-
},
|
24
|
-
{
|
25
|
-
"displayName": "Fred Williams",
|
26
|
-
"emails": [
|
27
|
-
{
|
28
|
-
"type": "other",
|
29
|
-
"value": "fred.williams@example.com"
|
30
|
-
},
|
31
|
-
{
|
32
|
-
"type": "other",
|
33
|
-
"value": "fred@example.com"
|
34
|
-
}
|
35
|
-
]
|
36
|
-
},
|
37
|
-
{
|
38
|
-
"emails": [
|
39
|
-
{
|
40
|
-
"type": "other",
|
41
|
-
"value": "j.lewis@example.com"
|
42
|
-
}
|
43
|
-
]
|
44
|
-
},
|
45
|
-
{
|
46
|
-
"displayName": "Mary Jones",
|
47
|
-
"emails": [
|
48
|
-
{
|
49
|
-
"type": "other",
|
50
|
-
"value": "mary.jones@example.com"
|
51
|
-
}
|
52
|
-
]
|
53
|
-
}
|
54
|
-
],
|
55
|
-
"startIndex": 1
|
56
|
-
},
|
57
|
-
"stat": "ok"
|
58
|
-
}
|
@@ -1,40 +0,0 @@
|
|
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
|
data/spec/rpx_now/api_spec.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
|
3
|
-
describe RPXNow::Api do
|
4
|
-
describe 'ssl cert' do
|
5
|
-
it "has an absolute path" do
|
6
|
-
RPXNow::Api::SSL_CERT[0..0].should == File.expand_path( RPXNow::Api::SSL_CERT )[0..0] # start with '/' on *nix, drive letter on win
|
7
|
-
end
|
8
|
-
|
9
|
-
it "exists" do
|
10
|
-
File.read(RPXNow::Api::SSL_CERT).to_s.should_not be_empty
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe :parse_response do
|
15
|
-
it "parses json when status is ok" do
|
16
|
-
response = mock(:code=>'200', :body=>%Q({"stat":"ok","data":"xx"}))
|
17
|
-
RPXNow::Api.send(:parse_response, response)['data'].should == "xx"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "raises when there is a communication error" do
|
21
|
-
response = stub(:code=>'200', :body=>%Q({"err":"wtf","stat":"ok"}))
|
22
|
-
lambda{
|
23
|
-
RPXNow::Api.send(:parse_response,response)
|
24
|
-
}.should raise_error(RPXNow::ApiError)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "raises when service has downtime" do
|
28
|
-
response = stub(:code=>'200', :body=>%Q({"err":{"code":-1},"stat":"ok"}))
|
29
|
-
lambda{
|
30
|
-
RPXNow::Api.send(:parse_response,response)
|
31
|
-
}.should raise_error(RPXNow::ServiceUnavailableError)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "raises when service is down" do
|
35
|
-
response = stub(:code=>'400',:body=>%Q({"stat":"err"}))
|
36
|
-
lambda{
|
37
|
-
RPXNow::Api.send(:parse_response,response)
|
38
|
-
}.should raise_error(RPXNow::ServiceUnavailableError)
|
39
|
-
end
|
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
|
50
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
|
3
|
-
describe RPXNow::ContactsCollection do
|
4
|
-
before do
|
5
|
-
data = JSON.parse(File.read('spec/fixtures/get_contacts_response.json'))['response']
|
6
|
-
@collection = RPXNow::ContactsCollection.new(data)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "behaves like an array" do
|
10
|
-
@collection.size.should == 5
|
11
|
-
@collection[0] = "1"
|
12
|
-
@collection[0].should == "1"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "parses entry to items" do
|
16
|
-
@collection[0]['displayName'].should == "Bob Johnson"
|
17
|
-
end
|
18
|
-
|
19
|
-
it "parses emails to list" do
|
20
|
-
@collection[0]['emails'].should == ["bob@example.com"]
|
21
|
-
end
|
22
|
-
|
23
|
-
it "parses emails to list with multiple emails" do
|
24
|
-
@collection[2]['emails'].should == ["fred.williams@example.com","fred@example.com"]
|
25
|
-
end
|
26
|
-
|
27
|
-
it "holds additional_info" do
|
28
|
-
@collection.additional_info['startIndex'].should == 1
|
29
|
-
@collection.additional_info['itemsPerPage'].should == 5
|
30
|
-
@collection.additional_info['totalResults'].should == 5
|
31
|
-
end
|
32
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
require 'rpx_now/user_integration'
|
3
|
-
|
4
|
-
class User
|
5
|
-
include RPXNow::UserIntegration
|
6
|
-
|
7
|
-
def id
|
8
|
-
5
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe RPXNow::UserProxy do
|
13
|
-
before { @user = User.new }
|
14
|
-
|
15
|
-
it "has a proxy" do
|
16
|
-
@user.rpx.class.should == RPXNow::UserProxy
|
17
|
-
end
|
18
|
-
|
19
|
-
it "has identifiers" do
|
20
|
-
RPXNow.should_receive(:mappings).with(@user.id).and_return(['identifiers'])
|
21
|
-
@user.rpx.identifiers.should == ['identifiers']
|
22
|
-
end
|
23
|
-
|
24
|
-
it "can map" do
|
25
|
-
RPXNow.should_receive(:map).with('identifier', @user.id)
|
26
|
-
@user.rpx.map('identifier')
|
27
|
-
end
|
28
|
-
|
29
|
-
it "can unmap" do
|
30
|
-
RPXNow.should_receive(:unmap).with('identifier', @user.id)
|
31
|
-
@user.rpx.unmap('identifier')
|
32
|
-
end
|
33
|
-
end
|
data/spec/rpx_now_spec.rb
DELETED
@@ -1,414 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
|
3
|
-
describe RPXNow do
|
4
|
-
def fake_response(replace={})
|
5
|
-
body = {'stat' => 'ok'}.merge(replace)
|
6
|
-
mock({:code => "200", :body => body.to_json})
|
7
|
-
end
|
8
|
-
|
9
|
-
describe :domain do
|
10
|
-
it 'defaults to rpxnow.com' do
|
11
|
-
RPXNow.domain.should == 'rpxnow.com'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe :domain= do
|
16
|
-
it "is stored" do
|
17
|
-
RPXNow.domain = 'domain.com'
|
18
|
-
RPXNow.domain.should == 'domain.com'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe :api_key= do
|
23
|
-
before do
|
24
|
-
RPXNow.api_key='XX'
|
25
|
-
end
|
26
|
-
|
27
|
-
it "is stored" do
|
28
|
-
RPXNow.api_key.should == 'XX'
|
29
|
-
end
|
30
|
-
|
31
|
-
it "stores the api key, so i do not have to supply everytime" do
|
32
|
-
RPXNow::Api.should_receive(:request).
|
33
|
-
with(anything, hash_including(:apiKey => 'XX')).
|
34
|
-
and_return fake_response
|
35
|
-
RPXNow.mappings(1)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "is not overwritten when overwriting for a single request" do
|
39
|
-
RPXNow::Api.should_receive(:request).
|
40
|
-
with(anything, hash_including(:apiKey => 'YY')).
|
41
|
-
and_return fake_response
|
42
|
-
RPXNow.mappings(1, :apiKey => 'YY')
|
43
|
-
RPXNow.api_key.should == 'XX'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe :api_version= do
|
48
|
-
it "is 2 by default" do
|
49
|
-
RPXNow.api_version.should == 2
|
50
|
-
end
|
51
|
-
|
52
|
-
it "is stored" do
|
53
|
-
RPXNow.api_version='XX'
|
54
|
-
RPXNow.api_version.should == 'XX'
|
55
|
-
end
|
56
|
-
|
57
|
-
it "used for every request" do
|
58
|
-
RPXNow.api_version='XX'
|
59
|
-
RPXNow::Api.should_receive(:request).
|
60
|
-
with('/api/vXX/mappings', anything).
|
61
|
-
and_return fake_response
|
62
|
-
RPXNow.mappings(1)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "is not overwritten when overwriting for a single request" do
|
66
|
-
RPXNow.api_version='XX'
|
67
|
-
RPXNow::Api.should_receive(:request).
|
68
|
-
with('/api/vYY/mappings', anything).
|
69
|
-
and_return fake_response
|
70
|
-
RPXNow.mappings(1, :api_version => 'YY')
|
71
|
-
RPXNow.api_version.should == 'XX'
|
72
|
-
end
|
73
|
-
|
74
|
-
it "is not passed in data for request" do
|
75
|
-
RPXNow.api_version='XX'
|
76
|
-
RPXNow::Api.should_receive(:request).
|
77
|
-
with(anything, hash_not_including(:api_version => 'YY')).
|
78
|
-
and_return fake_response
|
79
|
-
RPXNow.mappings(1, :api_version => 'YY')
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe :embed_code do
|
84
|
-
it "contains the subdomain" do
|
85
|
-
RPXNow.embed_code('xxx','my_url').should =~ /xxx/
|
86
|
-
end
|
87
|
-
|
88
|
-
it "contains the url" do
|
89
|
-
RPXNow.embed_code('xxx','my_url').should =~ /token_url=my_url/
|
90
|
-
end
|
91
|
-
|
92
|
-
it "defaults to no language" do
|
93
|
-
RPXNow.embed_code('xxx', 'my_url').should_not =~ /language_preference/
|
94
|
-
end
|
95
|
-
|
96
|
-
it "has a changeable language" do
|
97
|
-
RPXNow.embed_code('xxx', 'my_url', :language => 'es').should =~ /language_preference=es/
|
98
|
-
end
|
99
|
-
|
100
|
-
it "defaults to 400px width" do
|
101
|
-
RPXNow.embed_code('xxx', 'my_url').should =~ /width:400px;/
|
102
|
-
end
|
103
|
-
|
104
|
-
it "has a changeable width" do
|
105
|
-
RPXNow.embed_code('xxx', 'my_url', :width => '300').should =~ /width:300px;/
|
106
|
-
end
|
107
|
-
|
108
|
-
it "defaults to 240px height" do
|
109
|
-
RPXNow.embed_code('xxx', 'my_url').should =~ /height:240px;/
|
110
|
-
end
|
111
|
-
|
112
|
-
it "has a changeable height" do
|
113
|
-
RPXNow.embed_code('xxx', 'my_url', :height => '500').should =~ /height:500px;/
|
114
|
-
end
|
115
|
-
|
116
|
-
it "has id on iframe" do
|
117
|
-
RPXNow.embed_code('xxx','my_url').should =~ /id=\"rpx_now_embed\"/
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe :popup_code do
|
122
|
-
it "defaults to obtrusive output" do
|
123
|
-
RPXNow.popup_code('sign on', 'subdomain', 'http://fake.domain.com/').should =~ /script src=/
|
124
|
-
end
|
125
|
-
|
126
|
-
it "does not change supplied options" do
|
127
|
-
options = {:xxx => 1}
|
128
|
-
RPXNow.popup_code('a','b','c', options)
|
129
|
-
options.should == {:xxx => 1}
|
130
|
-
end
|
131
|
-
|
132
|
-
it "adds html params to link" do
|
133
|
-
options = {:html => {:id => "xxxx"}}
|
134
|
-
RPXNow.popup_code('a','b','c', options).should =~ /id="xxxx"/
|
135
|
-
end
|
136
|
-
|
137
|
-
it "adds rpxnow to given html class" do
|
138
|
-
options = {:html => {:class => "c1 c2"}}
|
139
|
-
RPXNow.popup_code('a','b','c', options).should =~ /class="rpxnow c1 c2"/
|
140
|
-
end
|
141
|
-
|
142
|
-
describe 'obstrusive' do
|
143
|
-
it "does not encode token_url for popup" do
|
144
|
-
expected = %Q(RPXNOW.token_url = 'http://fake.domain.com/')
|
145
|
-
RPXNow.popup_code('sign on', 'subdomain', 'http://fake.domain.com/').should include(expected)
|
146
|
-
end
|
147
|
-
it "encodes token_url for unobtrusive fallback link" do
|
148
|
-
expected = %Q(<a class="rpxnow" href="https://subdomain.rpxnow.com/openid/v2/signin?token_url=http%3A%2F%2Ffake.domain.com%2F">sign on</a>)
|
149
|
-
RPXNow.popup_code('sign on', 'subdomain', 'http://fake.domain.com/').should include(expected)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe 'unobstrusive' do
|
154
|
-
it "can build an unobtrusive widget with encoded token_url" do
|
155
|
-
expected = %Q(<a class="rpxnow" href="https://subdomain.rpxnow.com/openid/v2/signin?token_url=http%3A%2F%2Ffake.domain.com%2F">sign on</a>)
|
156
|
-
actual = RPXNow.popup_code('sign on', 'subdomain', 'http://fake.domain.com/', :unobtrusive => true)
|
157
|
-
actual.should == expected
|
158
|
-
end
|
159
|
-
|
160
|
-
it "can change api version" do
|
161
|
-
RPXNow.popup_code('x', 'y', 'z', :unobtrusive => true, :api_version => 'XX').should include("openid/vXX/signin?")
|
162
|
-
end
|
163
|
-
|
164
|
-
it "can change language" do
|
165
|
-
RPXNow.popup_code('x', 'y', 'z', :unobtrusive => true, :language => 'XX').should include("language_preference=XX")
|
166
|
-
end
|
167
|
-
|
168
|
-
it "can add flags" do
|
169
|
-
RPXNow.popup_code('x', 'y', 'z', :unobtrusive => true, :flags => 'test').should include("flags=test")
|
170
|
-
end
|
171
|
-
|
172
|
-
it "can add default_provider" do
|
173
|
-
RPXNow.popup_code('x', 'y', 'z', :unobtrusive => true, :default_provider => 'test').should include("default_provider=test")
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
it "allows to specify the version of the widget" do
|
178
|
-
RPXNow.popup_code('x','y','z', :api_version => 300).should =~ %r(/openid/v300/signin)
|
179
|
-
end
|
180
|
-
|
181
|
-
it "defaults to widget version 2" do
|
182
|
-
RPXNow.popup_code('x','y','z').should =~ %r(/openid/v2/signin)
|
183
|
-
end
|
184
|
-
|
185
|
-
describe 'language' do
|
186
|
-
it "defaults to no language" do
|
187
|
-
RPXNow.popup_code('x','y','z').should_not =~ /RPXNOW.language_preference/
|
188
|
-
end
|
189
|
-
|
190
|
-
it "has a changeable language" do
|
191
|
-
RPXNow.popup_code('x','y','z', :language=>'de').should =~ /RPXNOW.language_preference = 'de'/
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
describe 'flags' do
|
196
|
-
it "defaults to no language" do
|
197
|
-
RPXNow.popup_code('x','y','z').should_not =~ /RPXNOW.flags/
|
198
|
-
end
|
199
|
-
|
200
|
-
it "can have flags" do
|
201
|
-
RPXNow.popup_code('x','y','z', :flags=>'test').should =~ /RPXNOW.flags = 'test'/
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe 'default_provider' do
|
206
|
-
it "defaults to no provider" do
|
207
|
-
RPXNow.popup_code('x','y','z').should_not =~ /RPXNOW.default_provider/
|
208
|
-
end
|
209
|
-
|
210
|
-
it "can have default_provider" do
|
211
|
-
RPXNow.popup_code('x','y','z', :default_provider=>'test').should =~ /RPXNOW.default_provider = 'test'/
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
describe :user_data do
|
217
|
-
before do
|
218
|
-
@response_body = {
|
219
|
-
"profile" => {
|
220
|
-
"verifiedEmail" => "grosser.michael@googlemail.com",
|
221
|
-
"displayName" => "Michael Grosser",
|
222
|
-
"preferredUsername" => "grosser.michael",
|
223
|
-
"identifier" => "https:\/\/www.google.com\/accounts\/o8\/id?id=AItOawmaOlyYezg_WfbgP_qjaUyHjmqZD9qNIVM",
|
224
|
-
"email" => "grosser.michael@gmail.com"
|
225
|
-
}
|
226
|
-
}
|
227
|
-
@response = fake_response(@response_body)
|
228
|
-
@fake_user_data = {'profile'=>{}}
|
229
|
-
end
|
230
|
-
|
231
|
-
it "raises ApiError when used with an invalid token" do
|
232
|
-
lambda{
|
233
|
-
RPXNow.user_data('xxxx')
|
234
|
-
}.should raise_error(RPXNow::ApiError)
|
235
|
-
end
|
236
|
-
|
237
|
-
it "is empty when used with an unknown token" do
|
238
|
-
RPXNow.user_data('60d8c6374f4e9d290a7b55f39da7cc6435aef3d3').should == nil
|
239
|
-
end
|
240
|
-
|
241
|
-
it "parses JSON response to user data" do
|
242
|
-
expected = {
|
243
|
-
:name => 'Michael Grosser',
|
244
|
-
:email => 'grosser.michael@googlemail.com',
|
245
|
-
:identifier => 'https://www.google.com/accounts/o8/id?id=AItOawmaOlyYezg_WfbgP_qjaUyHjmqZD9qNIVM',
|
246
|
-
:username => 'grosser.michael',
|
247
|
-
}
|
248
|
-
RPXNow::Api.should_receive(:request).and_return @response
|
249
|
-
RPXNow.user_data('').should == expected
|
250
|
-
end
|
251
|
-
|
252
|
-
it "deprecated: adds raw profile data if i want it" do
|
253
|
-
RPXNow::Api.should_receive(:request).and_return @response
|
254
|
-
RPXNow.should_receive(:warn)
|
255
|
-
RPXNow.user_data('',:additional => [:raw])[:raw]["verifiedEmail"].should == "grosser.michael@googlemail.com"
|
256
|
-
end
|
257
|
-
|
258
|
-
it "adds raw data if i want it" do
|
259
|
-
RPXNow::Api.should_receive(:request).and_return @response
|
260
|
-
RPXNow.user_data('',:additional => [:raw_response])[:raw_response]['profile']["verifiedEmail"].should == "grosser.michael@googlemail.com"
|
261
|
-
end
|
262
|
-
|
263
|
-
it "adds a :id when primaryKey was returned" do
|
264
|
-
@response_body['profile']['primaryKey'] = "2"
|
265
|
-
response = fake_response(@response_body)
|
266
|
-
RPXNow::Api.should_receive(:request).and_return response
|
267
|
-
RPXNow.user_data('')[:id].should == '2'
|
268
|
-
end
|
269
|
-
|
270
|
-
it "handles primaryKeys that are not numeric" do
|
271
|
-
@response_body['profile']['primaryKey'] = "dbalatero"
|
272
|
-
response = fake_response(@response_body)
|
273
|
-
RPXNow::Api.should_receive(:request).and_return response
|
274
|
-
RPXNow.user_data('')[:id].should == 'dbalatero'
|
275
|
-
end
|
276
|
-
|
277
|
-
it "can fetch additional fields" do
|
278
|
-
@response_body['profile']['xxxy'] = "test"
|
279
|
-
response = fake_response(@response_body)
|
280
|
-
RPXNow::Api.should_receive(:request).and_return response
|
281
|
-
RPXNow.user_data('', :additional => [:xxxy])[:xxxy].should == 'test'
|
282
|
-
end
|
283
|
-
|
284
|
-
it "hands JSON response to supplied block" do
|
285
|
-
RPXNow::Api.should_receive(:request).and_return @response
|
286
|
-
response = nil
|
287
|
-
RPXNow.user_data(''){|data| response = data}
|
288
|
-
response.delete('stat') # dunno why it happens, but is not important...
|
289
|
-
response.should == @response_body
|
290
|
-
end
|
291
|
-
|
292
|
-
it "returns what the supplied block returned" do
|
293
|
-
RPXNow::Api.should_receive(:request).and_return @response
|
294
|
-
RPXNow.user_data(''){|data| "x"}.should == 'x'
|
295
|
-
end
|
296
|
-
|
297
|
-
it "can request extended data" do
|
298
|
-
RPXNow::Api.should_receive(:request).
|
299
|
-
with(anything, hash_including(:extended => true)).
|
300
|
-
and_return @response
|
301
|
-
RPXNow.user_data('', :extended=>true)
|
302
|
-
end
|
303
|
-
|
304
|
-
it "returns extended data as an additional field" do
|
305
|
-
@response_body['friends'] = {'x' => 1}
|
306
|
-
@response = fake_response(@response_body)
|
307
|
-
|
308
|
-
RPXNow::Api.should_receive(:request).and_return @response
|
309
|
-
RPXNow.user_data('', :extended=>true)[:extended].should == {'friends' => {'x' => 1}}
|
310
|
-
end
|
311
|
-
|
312
|
-
it "does not pass raw_response to RPX" do
|
313
|
-
RPXNow::Api.should_receive(:request).
|
314
|
-
with(anything, hash_not_including(:raw_response => true)).
|
315
|
-
and_return @response
|
316
|
-
RPXNow.user_data('', :raw_response=>true)
|
317
|
-
end
|
318
|
-
|
319
|
-
it "can return a raw_response" do
|
320
|
-
RPXNow::Api.should_receive(:request).and_return @response
|
321
|
-
RPXNow.user_data('', :raw_response=>true).should == @response_body.merge('stat' => 'ok')
|
322
|
-
end
|
323
|
-
|
324
|
-
# these 2 tests are kind of duplicates of the api_version/key tests,
|
325
|
-
# but i want to be extra-sure user_data works
|
326
|
-
it "works with api version as option" do
|
327
|
-
RPXNow::Api.should_receive(:request).
|
328
|
-
with('/api/v123/auth_info', anything).
|
329
|
-
and_return @response
|
330
|
-
RPXNow.user_data('id', :extended=>'abc', :api_version=>123)
|
331
|
-
RPXNow.api_version.should == API_VERSION
|
332
|
-
end
|
333
|
-
|
334
|
-
it "works with apiKey as option" do
|
335
|
-
RPXNow::Api.should_receive(:request).
|
336
|
-
with('/api/v2/auth_info', hash_including(:apiKey=>'THE KEY')).
|
337
|
-
and_return @response
|
338
|
-
RPXNow.user_data('id', :extended=>'abc', :apiKey=>'THE KEY')
|
339
|
-
RPXNow.api_key.should == API_KEY
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
describe :set_status do
|
344
|
-
it "sets the status" do
|
345
|
-
RPXNow::Api.should_receive(:request).
|
346
|
-
with("/api/v2/set_status", :identifier=>"identifier", :status=>"Chillen...", :apiKey=>API_KEY).
|
347
|
-
and_return fake_response
|
348
|
-
RPXNow.set_status('identifier', 'Chillen...')
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
describe :activity do
|
353
|
-
it "does a api call with the right arguments" do
|
354
|
-
RPXNow::Api.should_receive(:request).with("/api/v2/activity", :identifier=>"identifier", :activity=>'{"test":"something"}', :apiKey=>API_KEY).and_return fake_response
|
355
|
-
RPXNow.activity('identifier', :test => 'something')
|
356
|
-
end
|
357
|
-
|
358
|
-
it "can pass identifier/apiKey" do
|
359
|
-
RPXNow::Api.should_receive(:request).with("/api/v66666/activity", hash_including(:apiKey=>'MYKEY')).and_return fake_response
|
360
|
-
RPXNow.activity('identifier', {:test => 'something'}, :apiKey => 'MYKEY', :api_version => '66666')
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
describe :parse_user_data do
|
365
|
-
it "reads secondary names" do
|
366
|
-
RPXNow.send(:parse_user_data,{'profile'=>{'preferredUsername'=>'1'}}, {})[:name].should == '1'
|
367
|
-
end
|
368
|
-
|
369
|
-
it "parses email when no name is found" do
|
370
|
-
RPXNow.send(:parse_user_data,{'profile'=>{'email'=>'1@xxx.com'}}, {})[:name].should == '1'
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
describe :contacts do
|
375
|
-
it "finds all contacts" do
|
376
|
-
response = fake_response(JSON.parse(File.read('spec/fixtures/get_contacts_response.json')))
|
377
|
-
RPXNow::Api.should_receive(:request).
|
378
|
-
with('/api/v2/get_contacts',:identifier=>'xx', :apiKey=>API_KEY).
|
379
|
-
and_return response
|
380
|
-
RPXNow.contacts('xx').size.should == 5
|
381
|
-
end
|
382
|
-
end
|
383
|
-
|
384
|
-
describe :mappings do
|
385
|
-
it "shows all mappings" do
|
386
|
-
RPXNow::Api.should_receive(:request).
|
387
|
-
with("/api/v2/mappings", :apiKey=>API_KEY, :primaryKey=>1).
|
388
|
-
and_return fake_response("identifiers" => ["http://test.myopenid.com/"])
|
389
|
-
RPXNow.mappings(1).should == ["http://test.myopenid.com/"]
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
describe :map do
|
394
|
-
it "maps a identifier" do
|
395
|
-
RPXNow::Api.should_receive(:request).
|
396
|
-
with("/api/v2/map", :apiKey=>API_KEY, :primaryKey=>1, :identifier=>"http://test.myopenid.com").
|
397
|
-
and_return fake_response
|
398
|
-
RPXNow.map('http://test.myopenid.com',1)
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
describe :unmap do
|
403
|
-
it "unmaps a indentifier" do
|
404
|
-
RPXNow::Api.should_receive(:request).
|
405
|
-
with("/api/v2/unmap", :apiKey=>API_KEY, :primaryKey=>1, :identifier=>"http://test.myopenid.com").
|
406
|
-
and_return fake_response
|
407
|
-
RPXNow.unmap('http://test.myopenid.com', 1)
|
408
|
-
end
|
409
|
-
end
|
410
|
-
|
411
|
-
it "has a VERSION" do
|
412
|
-
RPXNow::VERSION.should =~ /^\d+\.\d+\.\d+$/
|
413
|
-
end
|
414
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
$LOAD_PATH << File.expand_path("../lib", File.dirname(__FILE__))
|
2
|
-
|
3
|
-
# ---- setup environment/plugin
|
4
|
-
require File.expand_path("../init", File.dirname(__FILE__))
|
5
|
-
API_KEY = '4b339169026742245b754fa338b9b0aebbd0a733'
|
6
|
-
API_VERSION = RPXNow.api_version
|
7
|
-
DOMAIN = RPXNow.domain
|
8
|
-
|
9
|
-
# ---- rspec
|
10
|
-
RSpec.configure do |config|
|
11
|
-
config.before do
|
12
|
-
RPXNow.api_key = API_KEY
|
13
|
-
RPXNow.api_version = API_VERSION
|
14
|
-
RPXNow.domain = DOMAIN
|
15
|
-
end
|
16
|
-
end
|