disiid_user 3.1.4 → 4.0.1
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.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/disiid_user.gemspec +7 -5
- data/lib/disiid_user/version.rb +1 -1
- data/spec/disiid_user_spec.rb +36 -8
- data/spec/spec_helper.rb +19 -1
- data/spec/stub_user.rb +44 -14
- metadata +58 -43
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aa044938972c66d9e4fa7c5f005b589fdedc8d5a
|
4
|
+
data.tar.gz: 83f7a1427949832bd5b0caa9d813d8dc7d0a374b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dbd2a1293b0f9c721f91d466a07195f1eae238b45ca84bf3882969e430c7c05ae817c62074e0e99c9f3b0dcc378632807615dc45c32591fb35f615a4450e7936
|
7
|
+
data.tar.gz: bb62f8268cb8b65a80d5a8e3937f0047900fe651ad9a916b048b34b171fd59dbfc519e2510ea788b1783a53e302115b136ac10e15db02b10aa8bf7165a4d62c1
|
data/Gemfile
CHANGED
data/disiid_user.gemspec
CHANGED
@@ -11,7 +11,8 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://disi.unitn.it"
|
12
12
|
s.summary = %q{DISI ID global user}
|
13
13
|
s.description = %q{DISI - UniTN internal development}
|
14
|
-
|
14
|
+
s.license = "MIT"
|
15
|
+
|
15
16
|
s.required_rubygems_version = ">= 1.3.6"
|
16
17
|
s.rubyforge_project = "disiid_user"
|
17
18
|
|
@@ -21,9 +22,10 @@ Gem::Specification.new do |s|
|
|
21
22
|
s.require_paths = ["lib"]
|
22
23
|
|
23
24
|
# specify any dependencies here; for example:
|
24
|
-
s.add_development_dependency "rspec"
|
25
|
-
s.add_development_dependency "
|
25
|
+
s.add_development_dependency "rspec", '~> 3'
|
26
|
+
s.add_development_dependency "rspec-mocks", '~> 3'
|
27
|
+
s.add_development_dependency "bundler", '~> 1'
|
26
28
|
# runtime dependencies
|
27
|
-
s.add_runtime_dependency "activeresource", '~>
|
28
|
-
s.add_runtime_dependency "activerecord", '~>
|
29
|
+
s.add_runtime_dependency "activeresource", '~> 4'
|
30
|
+
s.add_runtime_dependency "activerecord", '~> 4'
|
29
31
|
end
|
data/lib/disiid_user/version.rb
CHANGED
data/spec/disiid_user_spec.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'stub_user'
|
3
|
+
require 'fakeweb'
|
4
|
+
#require 'webmock/rspec'
|
5
|
+
require 'active_resource'
|
6
|
+
require 'active_resource/http_mock'
|
3
7
|
|
4
8
|
# admin@example.org
|
5
9
|
# 6a002a40-bc63-4095-9bb0-f31bf386bf55
|
@@ -39,8 +43,14 @@ describe DisiidUser do
|
|
39
43
|
shared_examples_for "new user from identity" do
|
40
44
|
it { should be_instance_of(User) }
|
41
45
|
it { should be_new_record }
|
42
|
-
its(:identity_url) { should == 'http://openid.provider.local/users/6a002a40-bc63-4095-9bb0-f31bf386bf55' }
|
43
|
-
its(:uuid) { should == '6a002a40-bc63-4095-9bb0-f31bf386bf55' }
|
46
|
+
# its(:identity_url) { should == 'http://openid.provider.local/users/6a002a40-bc63-4095-9bb0-f31bf386bf55' }
|
47
|
+
# its(:uuid) { should == '6a002a40-bc63-4095-9bb0-f31bf386bf55' }
|
48
|
+
it "has correct identity url" do
|
49
|
+
expect(subject.identity_url).to eq 'http://openid.provider.local/users/6a002a40-bc63-4095-9bb0-f31bf386bf55'
|
50
|
+
end
|
51
|
+
it "has correct uuid" do
|
52
|
+
expect(subject.uuid).to eq '6a002a40-bc63-4095-9bb0-f31bf386bf55'
|
53
|
+
end
|
44
54
|
end
|
45
55
|
|
46
56
|
describe ".build_from_identity" do
|
@@ -243,15 +253,21 @@ describe DisiidUser do
|
|
243
253
|
end
|
244
254
|
|
245
255
|
context 'when exists' do
|
256
|
+
|
246
257
|
before {
|
247
|
-
@user.identity_url = "http://openid.provider.local/users/6a002a40-bc63-4095-9bb0-f31bf386bf55"
|
258
|
+
@user.identity_url = "http://openid.provider.local/users/6a002a40-bc63-4095-9bb0-f31bf386bf55"
|
259
|
+
ActiveResource::HttpMock.respond_to do |mock|
|
260
|
+
mock.get "/users/#{@user.uuid}.xml?auth_token=#{DisiidUser::RemoteUser.auth_token}", {"Accept" => "application/xml"}, File.read("#{File.dirname(__FILE__)}/#{@user.uuid}.xml"), 200
|
261
|
+
mock.get "/users/#{@user.uuid}.json?auth_token=#{DisiidUser::RemoteUser.auth_token}", {"Accept" => "application/json"}, File.read("#{File.dirname(__FILE__)}/#{@user.uuid}.json"), 200
|
262
|
+
end
|
248
263
|
}
|
249
264
|
|
250
265
|
[:xml, :json].each { |format|
|
251
266
|
it "should have remote attributes in #{format} format" do
|
252
267
|
DisiidUser::RemoteUser.format = format
|
268
|
+
DisiidUser::RemoteUser.auth_token = 'sometoken'
|
253
269
|
ActiveSupport.parse_json_times = true
|
254
|
-
|
270
|
+
expect(@user.email).not_to be_nil
|
255
271
|
@user.email.should == 'admin@example.org'
|
256
272
|
@user.first_name.should == 'John'
|
257
273
|
@user.last_name.should == 'Smith'
|
@@ -275,13 +291,17 @@ describe DisiidUser do
|
|
275
291
|
@user.remote_updated_at.should == DateTime.parse('2011-12-06T11:15:33Z')
|
276
292
|
# for this to evaluate to boolean
|
277
293
|
# XML tag should contain type="boolean" attribute
|
278
|
-
@user.hide_photo.
|
294
|
+
expect(@user.hide_photo).to be false
|
279
295
|
end
|
280
296
|
}
|
281
297
|
|
282
298
|
it 'should have assign methods like email=(...)' do
|
283
|
-
|
284
|
-
|
299
|
+
DisiidUser::RemoteUser.format = :xml
|
300
|
+
DisiidUser::RemoteUser.auth_token = 'sometoken'
|
301
|
+
DisiidUser::RemoteUser.site = "http://openid.provider.local"
|
302
|
+
|
303
|
+
@user.email ='new@email.com'
|
304
|
+
expect(@user.email).to eq 'new@email.com'
|
285
305
|
|
286
306
|
@user.homepage = 'http://some.page.com'
|
287
307
|
@user.homepage.should == 'http://some.page.com'
|
@@ -290,6 +310,7 @@ describe DisiidUser do
|
|
290
310
|
|
291
311
|
it 'should get all roles, including remote' do
|
292
312
|
@user.local_roles = 'manager'
|
313
|
+
|
293
314
|
@user.roles.should include 'admin' # remote
|
294
315
|
@user.roles.should include 'manager' # local
|
295
316
|
end
|
@@ -306,7 +327,14 @@ describe DisiidUser do
|
|
306
327
|
end # context 'when exists'
|
307
328
|
|
308
329
|
context 'when search' do
|
309
|
-
before {
|
330
|
+
before {
|
331
|
+
DisiidUser::RemoteUser.auth_token = 'sometoken'
|
332
|
+
ActiveResource::HttpMock.respond_to do |mock|
|
333
|
+
mock.get "/users.xml?auth_token=#{DisiidUser::RemoteUser.auth_token}&q=e", {"Accept" => "application/xml"}, File.read("#{File.dirname(__FILE__)}/users.xml"), 200
|
334
|
+
mock.get "/users.json?auth_token=#{DisiidUser::RemoteUser.auth_token}&q=e", {"Accept" => "application/json"}, File.read("#{File.dirname(__FILE__)}/users.json"), 200
|
335
|
+
end
|
336
|
+
|
337
|
+
}
|
310
338
|
|
311
339
|
it 'should find a list of users with activeresource' do
|
312
340
|
@users = DisiidUser::RemoteUser.find(:all , :params => {:q => 'e', :auth_token => 'sometoken'})
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,25 @@ require 'rspec'
|
|
2
2
|
require 'disiid_user'
|
3
3
|
require 'active_record/errors'
|
4
4
|
|
5
|
+
##
|
6
|
+
# keep compatibility to rspec 2.x
|
7
|
+
module DoubleAliases
|
8
|
+
def mock(*args, &block)
|
9
|
+
double(*args, &block)
|
10
|
+
end
|
11
|
+
alias stub mock
|
12
|
+
end
|
13
|
+
|
5
14
|
RSpec.configure do |config|
|
6
|
-
config.
|
15
|
+
config.include DoubleAliases
|
16
|
+
config.color = true
|
7
17
|
config.formatter = 'documentation'
|
18
|
+
# keep compatibility to rspec 2.x
|
19
|
+
config.expect_with :rspec do |c|
|
20
|
+
c.syntax = [:should, :expect]
|
21
|
+
end
|
22
|
+
# keep compatibility to rspec 2.x
|
23
|
+
config.mock_with :rspec do |c|
|
24
|
+
c.syntax = [:should, :expect]
|
25
|
+
end
|
8
26
|
end
|
data/spec/stub_user.rb
CHANGED
@@ -23,11 +23,13 @@ class User
|
|
23
23
|
def self.scope(*args); end
|
24
24
|
|
25
25
|
include DisiidUser
|
26
|
+
|
26
27
|
end
|
27
28
|
|
28
29
|
class FakeResponse
|
29
30
|
attr_accessor :body
|
30
31
|
def initialize(body); @body = body; end
|
32
|
+
|
31
33
|
end
|
32
34
|
|
33
35
|
# Stub ActiveRecord so that it won't do real HTTP requests
|
@@ -35,30 +37,57 @@ module ActiveResource
|
|
35
37
|
class Connection
|
36
38
|
# taps into ActiveRecord to read data from stub files
|
37
39
|
# instead of doing a real HTTP request
|
38
|
-
def get(path, *args)
|
39
|
-
|
40
|
-
|
40
|
+
## def get(path, *args)
|
41
|
+
# def get(path, headers = {})
|
42
|
+
# read_from_file(path)
|
43
|
+
# rescue; raise ActiveResource::ResourceNotFound; end
|
44
|
+
#
|
45
|
+
# # stubs PUT request so to not do it for real
|
46
|
+
## def put(path, payload, headers)
|
47
|
+
# def put(path, body = '', headers = {})
|
48
|
+
# read_from_file(path)
|
49
|
+
# rescue; raise ActiveResource::ResourceNotFound; end
|
50
|
+
#
|
51
|
+
# def patch(path, body = '', headers = {})
|
52
|
+
# read_from_file(path)
|
53
|
+
# rescue; raise ActiveResource::ResourceNotFound; end
|
41
54
|
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
55
|
+
# # taps into ActiveRecord to read data from stub files
|
56
|
+
# # instead of doing a real HTTP request
|
57
|
+
# def get(path, *args)
|
58
|
+
# read_from_file(path)
|
59
|
+
# rescue; raise ActiveResource::ResourceNotFound; end
|
60
|
+
#
|
61
|
+
# # stubs PUT request so to not do it for real
|
62
|
+
# def put(path, payload, headers)
|
63
|
+
# read_from_file(path)
|
64
|
+
# rescue; raise ActiveResource::ResourceNotFound; end
|
46
65
|
|
47
66
|
private
|
48
67
|
|
49
68
|
def read_from_file(fake_url_path)
|
50
|
-
if matched = /users\.(xml|json)/.match(fake_url_path)
|
51
|
-
filename = "#{File.dirname(__FILE__)}/users.#{matched[1]}"
|
69
|
+
# if matched = /users\.(xml|json)/.match(fake_url_path)
|
70
|
+
# filename = "#{File.dirname(__FILE__)}/users.#{matched[1]}"
|
71
|
+
# else
|
72
|
+
# # /collection_name/uuid?query
|
73
|
+
# record = /\/[^\/]+\/([^\/\?]+)/.match(fake_url_path)[1]
|
74
|
+
# # record string includes .xml or .json too
|
75
|
+
# filename = "#{File.dirname(__FILE__)}/#{record}".sub(/\?.*$/, '')
|
76
|
+
# end
|
77
|
+
# fake_url_path
|
78
|
+
# /users.xml?uuid=XXX
|
79
|
+
# /users.xml
|
80
|
+
if fake_url_path.match("uuid=")
|
81
|
+
name = fake_url_path.split("?uuid=")[1]
|
82
|
+
ext = fake_url_path.split("?uuid=")[0].split(".")[1]
|
83
|
+
filename = "#{File.dirname(__FILE__)}/#{name}.#{ext}"
|
52
84
|
else
|
53
|
-
#
|
54
|
-
record = /\/[^\/]+\/([^\/\?]+)/.match(fake_url_path)[1]
|
55
|
-
# record string includes .xml or .json too
|
56
|
-
filename = "#{File.dirname(__FILE__)}/#{record}".sub(/\?.*$/, '')
|
85
|
+
filename = "#{File.dirname(__FILE__)}/#{fake_url_path.split("?")[0].sub(/^\//, '')}"
|
57
86
|
end
|
58
87
|
# format is either ActiveResource::Formats::XmlFormat or JsonFormat
|
59
88
|
# 3.0.x defaults to XML, 3.1.x defaults to JSON
|
60
89
|
data = open(filename).read
|
61
|
-
/3\.1/.match(ActiveResource::VERSION::STRING) ? FakeResponse.new(data) : format.decode(data)
|
90
|
+
{ :body => /3\.1/.match(ActiveResource::VERSION::STRING) ? FakeResponse.new(data) : format.decode(data) }
|
62
91
|
end
|
63
92
|
end
|
64
93
|
end
|
@@ -74,3 +103,4 @@ module Rails
|
|
74
103
|
def self.cache; StubCache; end
|
75
104
|
end
|
76
105
|
|
106
|
+
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disiid_user
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 4.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Danilo Severina
|
@@ -10,52 +9,78 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rspec
|
17
|
-
requirement:
|
18
|
-
none: false
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - "~>"
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
20
|
+
version: '3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec-mocks
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3'
|
23
35
|
type: :development
|
24
36
|
prerelease: false
|
25
|
-
version_requirements:
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '3'
|
26
42
|
- !ruby/object:Gem::Dependency
|
27
43
|
name: bundler
|
28
|
-
requirement:
|
29
|
-
none: false
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
30
45
|
requirements:
|
31
|
-
- -
|
46
|
+
- - "~>"
|
32
47
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
48
|
+
version: '1'
|
34
49
|
type: :development
|
35
50
|
prerelease: false
|
36
|
-
version_requirements:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1'
|
37
56
|
- !ruby/object:Gem::Dependency
|
38
57
|
name: activeresource
|
39
|
-
requirement:
|
40
|
-
none: false
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
41
59
|
requirements:
|
42
|
-
- - ~>
|
60
|
+
- - "~>"
|
43
61
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
62
|
+
version: '4'
|
45
63
|
type: :runtime
|
46
64
|
prerelease: false
|
47
|
-
version_requirements:
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '4'
|
48
70
|
- !ruby/object:Gem::Dependency
|
49
71
|
name: activerecord
|
50
|
-
requirement:
|
51
|
-
none: false
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
52
73
|
requirements:
|
53
|
-
- - ~>
|
74
|
+
- - "~>"
|
54
75
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
76
|
+
version: '4'
|
56
77
|
type: :runtime
|
57
78
|
prerelease: false
|
58
|
-
version_requirements:
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '4'
|
59
84
|
description: DISI - UniTN internal development
|
60
85
|
email:
|
61
86
|
- tech@disi.unitn.it
|
@@ -63,8 +88,8 @@ executables: []
|
|
63
88
|
extensions: []
|
64
89
|
extra_rdoc_files: []
|
65
90
|
files:
|
66
|
-
- .gitignore
|
67
|
-
- .rvmrc-template
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rvmrc-template"
|
68
93
|
- Gemfile
|
69
94
|
- Rakefile
|
70
95
|
- TODO
|
@@ -82,37 +107,27 @@ files:
|
|
82
107
|
- spec/users.json
|
83
108
|
- spec/users.xml
|
84
109
|
homepage: http://disi.unitn.it
|
85
|
-
licenses:
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
86
113
|
post_install_message:
|
87
114
|
rdoc_options: []
|
88
115
|
require_paths:
|
89
116
|
- lib
|
90
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
118
|
requirements:
|
93
|
-
- -
|
119
|
+
- - ">="
|
94
120
|
- !ruby/object:Gem::Version
|
95
121
|
version: '0'
|
96
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
123
|
requirements:
|
99
|
-
- -
|
124
|
+
- - ">="
|
100
125
|
- !ruby/object:Gem::Version
|
101
126
|
version: 1.3.6
|
102
127
|
requirements: []
|
103
128
|
rubyforge_project: disiid_user
|
104
|
-
rubygems_version:
|
129
|
+
rubygems_version: 2.4.3
|
105
130
|
signing_key:
|
106
|
-
specification_version:
|
131
|
+
specification_version: 4
|
107
132
|
summary: DISI ID global user
|
108
|
-
test_files:
|
109
|
-
- spec/596568c5-d6e7-4328-815c-c532aeed1198.xml
|
110
|
-
- spec/6a002a40-bc63-4095-9bb0-f31bf386bf55.json
|
111
|
-
- spec/6a002a40-bc63-4095-9bb0-f31bf386bf55.xml
|
112
|
-
- spec/disiid_user_spec.rb
|
113
|
-
- spec/remote_user_spec.rb
|
114
|
-
- spec/spec_helper.rb
|
115
|
-
- spec/stub_methods_spec.rb
|
116
|
-
- spec/stub_user.rb
|
117
|
-
- spec/users.json
|
118
|
-
- spec/users.xml
|
133
|
+
test_files: []
|