hoodoo 1.18.0 → 1.19.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.
- checksums.yaml +4 -4
- data/lib/hoodoo/data/resources/caller.rb +1 -0
- data/lib/hoodoo/presenters/base.rb +21 -3
- data/lib/hoodoo/services/middleware/middleware.rb +2 -0
- data/lib/hoodoo/services/services/session.rb +24 -11
- data/lib/hoodoo/version.rb +1 -1
- data/spec/data/resources/caller_spec.rb +2 -1
- data/spec/presenters/base_spec.rb +130 -62
- data/spec/services/middleware/amqp_log_writer_spec.rb +10 -8
- data/spec/services/middleware/middleware_logging_spec.rb +2 -0
- data/spec/services/middleware/middleware_permissions_spec.rb +10 -8
- data/spec/services/services/session_spec.rb +27 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 686b88cd1d3e169957a22f9bbd1b2e0680143344
|
4
|
+
data.tar.gz: bbb4fe6fdfd02d447ca76c9972ede50aec481ba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02bde4ca9622f8b7ce1524341c4e997d54717cc8282addfb86d44ad87333942a6caa6d97bf8d28cd860e40cf50f34cb8c97a90d7015249625dd711e950375658
|
7
|
+
data.tar.gz: c16e8ea17f27fb117816c6e1416ba65248e6d9e3b0b113e05f88f04499afb949d3a00c37412e5073385f1b6b5e3fd5b883173a110d5c9cf874ef717a2f442ea1
|
@@ -86,7 +86,16 @@ module Hoodoo
|
|
86
86
|
# is internationalised but this is omitted, then a value
|
87
87
|
# of "en-nz" is used as a default.
|
88
88
|
#
|
89
|
-
|
89
|
+
# +created_by+:: Optional fingerprint of the Caller whose credentials
|
90
|
+
# were used to create the Session under which the
|
91
|
+
# resource instance was created. Absent if omitted.
|
92
|
+
#
|
93
|
+
def self.render( data,
|
94
|
+
uuid = nil,
|
95
|
+
created_at = nil,
|
96
|
+
language = 'en-nz',
|
97
|
+
created_by = nil )
|
98
|
+
|
90
99
|
target = {}
|
91
100
|
data = data || {}
|
92
101
|
|
@@ -117,7 +126,8 @@ module Hoodoo
|
|
117
126
|
'created_at' => Hoodoo::Utilities.standard_datetime( created_at.to_datetime )
|
118
127
|
} )
|
119
128
|
|
120
|
-
target[ '
|
129
|
+
target[ 'created_by' ] = created_by unless created_by.nil?
|
130
|
+
target[ 'language' ] = language if self.is_internationalised?()
|
121
131
|
|
122
132
|
end
|
123
133
|
|
@@ -157,6 +167,10 @@ module Hoodoo
|
|
157
167
|
# +created_at+:: Same as the +created_at+ parameter to ::render, except
|
158
168
|
# mandatory.
|
159
169
|
#
|
170
|
+
# +created_by+:: Optional fingerprint of the Caller whose credentials
|
171
|
+
# were used to create the Session under which the
|
172
|
+
# resource instance was created.
|
173
|
+
#
|
160
174
|
# +language+:: Optional value for resource's +language+ field; taken
|
161
175
|
# from the +context+ parameter if omitted.
|
162
176
|
#
|
@@ -180,12 +194,13 @@ module Hoodoo
|
|
180
194
|
def self.render_in( context, data, options = {} )
|
181
195
|
uuid = options[ :uuid ]
|
182
196
|
created_at = options[ :created_at ]
|
197
|
+
created_by = options[ :created_by ]
|
183
198
|
language = options[ :language ] || context.request.locale
|
184
199
|
secured_with = options[ :secured_with ]
|
185
200
|
embeds = options[ :embeds ]
|
186
201
|
references = options[ :references ]
|
187
202
|
|
188
|
-
target = self.render( data, uuid, created_at, language )
|
203
|
+
target = self.render( data, uuid, created_at, language, created_by )
|
189
204
|
|
190
205
|
if secured_with.is_a?( ::ActiveRecord::Base )
|
191
206
|
result_hash = {}
|
@@ -233,6 +248,9 @@ module Hoodoo
|
|
233
248
|
'kind' => data[ :kind ]
|
234
249
|
}
|
235
250
|
|
251
|
+
created_by = data[ :created_by ]
|
252
|
+
common_fields[ 'created_by' ] = created_by unless created_by.nil?
|
253
|
+
|
236
254
|
if self.is_internationalised?
|
237
255
|
common_fields[ 'internationalised' ] = data[ 'internationalised' ]
|
238
256
|
Hoodoo::Presenters::CommonResourceFields.get_schema.properties[ 'language' ].required = true
|
@@ -164,6 +164,7 @@ module Hoodoo; module Services
|
|
164
164
|
'caller_version' => 1,
|
165
165
|
'caller_id' => 'c5ea12fb7f414a46850e73ee1bf6d95e',
|
166
166
|
'caller_identity_name' => 'c5ea12fb7f414a46850e73ee1bf6d95e',
|
167
|
+
'caller_fingerprint' => '7bc0b402a77543a49d0b1b671253fb25',
|
167
168
|
'identity' => { 'caller_id' => 'c5ea12fb7f414a46850e73ee1bf6d95e' },
|
168
169
|
'permissions' => Hoodoo::Services::Permissions.new( {
|
169
170
|
'default' => { 'else' => Hoodoo::Services::Permissions::ALLOW }
|
@@ -1210,6 +1211,7 @@ module Hoodoo; module Services
|
|
1210
1211
|
'caller_id' => session.caller_id,
|
1211
1212
|
'caller_version' => session.caller_version,
|
1212
1213
|
'caller_identity_name' => session.caller_identity_name,
|
1214
|
+
'caller_fingerprint' => session.caller_fingerprint,
|
1213
1215
|
'identity' => Hoodoo::Utilities.stringify( ( session.identity || {} ).to_h() )
|
1214
1216
|
}
|
1215
1217
|
end
|
@@ -39,6 +39,13 @@ module Hoodoo
|
|
39
39
|
#
|
40
40
|
attr_accessor :caller_identity_name
|
41
41
|
|
42
|
+
# An optional property of a session is the Caller's fingerprint, a
|
43
|
+
# UUID assigned to some Callers which can be persisted by resource
|
44
|
+
# instances when created and rendered in the +created_by+ field
|
45
|
+
# via e.g. Hoodoo::Presenters::Base.#render_in.
|
46
|
+
#
|
47
|
+
attr_accessor :caller_fingerprint
|
48
|
+
|
42
49
|
# Callers can change; if so, related sessions must be invalidated.
|
43
50
|
# This must be achieved by keeping a version count on the Caller. A
|
44
51
|
# session is associated with a particular Caller version and if the
|
@@ -126,25 +133,29 @@ module Hoodoo
|
|
126
133
|
#
|
127
134
|
# Options are:
|
128
135
|
#
|
129
|
-
# +session_id+::
|
130
|
-
#
|
131
|
-
#
|
136
|
+
# +session_id+:: UUID of this session. If unset, a new UUID is
|
137
|
+
# generated for you. You can read the UUID with
|
138
|
+
# the #session_id accessor method.
|
139
|
+
#
|
140
|
+
# +caller_id+:: UUID of the Caller instance associated with this
|
141
|
+
# session. This can be set either now or later, but
|
142
|
+
# the session cannot be saved without it.
|
132
143
|
#
|
133
|
-
# +
|
134
|
-
# session. This can be set either now or later, but
|
135
|
-
# the session cannot be saved without it.
|
144
|
+
# +caller_version+:: Version of the Caller instance; defaults to zero.
|
136
145
|
#
|
137
|
-
# +
|
146
|
+
# +caller_fingerprint:: Optional Caller fingerprint UUID. Default to
|
147
|
+
# +nil+.
|
138
148
|
#
|
139
149
|
# +memcached_host+:: Host for Memcached connections.
|
140
150
|
#
|
141
151
|
def initialize( options = {} )
|
142
152
|
@created_at = Time.now.utc
|
143
153
|
|
144
|
-
self.session_id
|
145
|
-
self.memcached_host
|
146
|
-
self.caller_id
|
147
|
-
self.caller_version
|
154
|
+
self.session_id = options[ :session_id ] || Hoodoo::UUID.generate()
|
155
|
+
self.memcached_host = options[ :memcached_host ]
|
156
|
+
self.caller_id = options[ :caller_id ]
|
157
|
+
self.caller_version = options[ :caller_version ] || 0
|
158
|
+
self.caller_fingerprint = options[ :caller_fingerprint ]
|
148
159
|
end
|
149
160
|
|
150
161
|
# Save this session to the transient store, in a manner that will allow
|
@@ -471,6 +482,7 @@ module Hoodoo
|
|
471
482
|
caller_id
|
472
483
|
caller_version
|
473
484
|
caller_identity_name
|
485
|
+
caller_fingerprint
|
474
486
|
|
475
487
|
).each do | property |
|
476
488
|
value = self.send( property )
|
@@ -516,6 +528,7 @@ module Hoodoo
|
|
516
528
|
caller_id
|
517
529
|
caller_version
|
518
530
|
caller_identity_name
|
531
|
+
caller_fingerprint
|
519
532
|
|
520
533
|
).each do | property |
|
521
534
|
value = hash[ property ]
|
data/lib/hoodoo/version.rb
CHANGED
@@ -12,7 +12,7 @@ module Hoodoo
|
|
12
12
|
# The Hoodoo gem version. If this changes, be sure to re-run
|
13
13
|
# <tt>bundle install</tt> or <tt>bundle update</tt>.
|
14
14
|
#
|
15
|
-
VERSION = '1.
|
15
|
+
VERSION = '1.19.0'
|
16
16
|
|
17
17
|
# The Hoodoo gem date. If this changes, be sure to re-run
|
18
18
|
# <tt>bundle install</tt> or <tt>bundle update</tt>.
|
@@ -6,10 +6,11 @@ describe Hoodoo::Data::Resources::Caller do
|
|
6
6
|
|
7
7
|
expect(schema.is_internationalised?()).to eq(true)
|
8
8
|
|
9
|
-
expect(schema.properties.count).to eq(
|
9
|
+
expect(schema.properties.count).to eq(6)
|
10
10
|
|
11
11
|
expect(schema.properties['authentication_secret']).to be_a(Hoodoo::Presenters::Text)
|
12
12
|
expect(schema.properties['name']).to be_a(Hoodoo::Presenters::Text)
|
13
|
+
expect(schema.properties['fingerprint']).to be_a(Hoodoo::Presenters::UUID)
|
13
14
|
expect(schema.properties['identity']).to be_a(Hoodoo::Presenters::Hash)
|
14
15
|
expect(schema.properties['permissions']).to be_a(Hoodoo::Presenters::Object)
|
15
16
|
expect(schema.properties['permissions'].properties['resources']).to be_a(Hoodoo::Presenters::Hash)
|
@@ -328,30 +328,60 @@ describe '#schema' do
|
|
328
328
|
expect(Hoodoo::Data::Resources::World.validate(data, false).errors).to eq([])
|
329
329
|
end
|
330
330
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
:
|
337
|
-
:
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
331
|
+
context 'should return' do
|
332
|
+
before :each do
|
333
|
+
@input = Hoodoo::Utilities.stringify( {
|
334
|
+
:errors_id => Hoodoo::UUID.generate,
|
335
|
+
:test_tags => 'foo,bar,baz',
|
336
|
+
:test_object => {
|
337
|
+
:nested_object => {
|
338
|
+
:name => 'Some name',
|
339
|
+
:obj_suffix => '!'
|
340
|
+
},
|
341
|
+
:test_array => [
|
342
|
+
{ :name => 'Some name 0', :ary_suffix => '00' },
|
343
|
+
{ :name => 'Some name 1' }
|
344
|
+
]
|
345
|
+
}
|
346
|
+
} )
|
347
|
+
end
|
346
348
|
|
347
|
-
data
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
349
|
+
it 'no errors with valid data for resource' do
|
350
|
+
rendered = Hoodoo::Data::Resources::World.render(
|
351
|
+
@input,
|
352
|
+
Hoodoo::UUID.generate,
|
353
|
+
Time.now
|
354
|
+
)
|
353
355
|
|
354
|
-
|
356
|
+
expect(Hoodoo::Data::Resources::World.validate(rendered, true).errors).to eq([])
|
357
|
+
end
|
358
|
+
|
359
|
+
it 'no errors with valid data for resource with fingerprint' do
|
360
|
+
rendered = Hoodoo::Data::Resources::World.render(
|
361
|
+
@input,
|
362
|
+
Hoodoo::UUID.generate,
|
363
|
+
Time.now,
|
364
|
+
'en-gb',
|
365
|
+
Hoodoo::UUID.generate
|
366
|
+
)
|
367
|
+
|
368
|
+
expect(Hoodoo::Data::Resources::World.validate(rendered, true).errors).to eq([])
|
369
|
+
end
|
370
|
+
|
371
|
+
it 'a complaint about missing language if internationalised' do
|
372
|
+
rendered = Hoodoo::Data::Resources::World.render(
|
373
|
+
@input,
|
374
|
+
Hoodoo::UUID.generate,
|
375
|
+
Time.now,
|
376
|
+
nil
|
377
|
+
)
|
378
|
+
|
379
|
+
expect(Hoodoo::Data::Resources::World.validate(rendered, true).errors).to eq([{
|
380
|
+
'code' => 'generic.required_field_missing',
|
381
|
+
'message' => 'Field `language` is required',
|
382
|
+
'reference' => 'language'
|
383
|
+
}])
|
384
|
+
end
|
355
385
|
end
|
356
386
|
|
357
387
|
it 'should return correct errors invalid data' do
|
@@ -654,48 +684,70 @@ describe '#schema' do
|
|
654
684
|
})
|
655
685
|
end
|
656
686
|
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
:
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
687
|
+
context 'should render correctly as a resource' do
|
688
|
+
before :each do
|
689
|
+
@uuid = Hoodoo::UUID.generate
|
690
|
+
@time = Time.now
|
691
|
+
@input = Hoodoo::Utilities.stringify({
|
692
|
+
:errors_id => Hoodoo::UUID.generate,
|
693
|
+
:test_tags => 'foo,bar,baz',
|
694
|
+
:test_object => {
|
695
|
+
:nested_object => {
|
696
|
+
:name => 'Some name',
|
697
|
+
:obj_suffix => '!'
|
698
|
+
},
|
699
|
+
:test_array => [
|
700
|
+
{ :name => 'Some name 0', :ary_suffix => '00' },
|
701
|
+
{ :name => 'Some name 1' }
|
702
|
+
]
|
703
|
+
}
|
704
|
+
})
|
705
|
+
|
706
|
+
@output = {
|
707
|
+
'id' => @uuid,
|
708
|
+
'kind' => 'World',
|
709
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( @time ),
|
710
|
+
'language' => 'en-gb',
|
711
|
+
'errors_id' => @input['errors_id'],
|
712
|
+
'test_tags' => 'foo,bar,baz',
|
713
|
+
'test_object' => {
|
714
|
+
'nested_object' => {
|
715
|
+
'name' => 'Some name',
|
716
|
+
'obj_suffix' => '!'
|
717
|
+
},
|
718
|
+
'test_array' => [
|
719
|
+
{ 'name' => 'Some name 0', 'ary_suffix' => '00' },
|
720
|
+
{ 'name' => 'Some name 1' }
|
721
|
+
]
|
722
|
+
}
|
670
723
|
}
|
671
|
-
|
724
|
+
end
|
672
725
|
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
'
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
})
|
726
|
+
it 'with a UUID' do
|
727
|
+
expect(
|
728
|
+
Hoodoo::Data::Resources::World.render(
|
729
|
+
@input,
|
730
|
+
@uuid,
|
731
|
+
@time,
|
732
|
+
'en-gb'
|
733
|
+
)
|
734
|
+
).to( eq( @output ) )
|
735
|
+
end
|
736
|
+
|
737
|
+
it 'with a UUID and fingerprint' do
|
738
|
+
fingerprint = Hoodoo::UUID.generate()
|
739
|
+
@output[ 'created_by' ] = fingerprint
|
740
|
+
|
741
|
+
expect(
|
742
|
+
Hoodoo::Data::Resources::World.render(
|
743
|
+
@input,
|
744
|
+
@uuid,
|
745
|
+
@time,
|
746
|
+
'en-gb',
|
747
|
+
fingerprint
|
748
|
+
)
|
749
|
+
).to( eq( @output ) )
|
750
|
+
end
|
699
751
|
end
|
700
752
|
|
701
753
|
it 'should complain about resources with no creation date' do
|
@@ -803,6 +855,22 @@ describe '#schema' do
|
|
803
855
|
})
|
804
856
|
end
|
805
857
|
|
858
|
+
it 'renders with fingerprint' do
|
859
|
+
data = {}
|
860
|
+
t = Time.now.utc
|
861
|
+
u = Hoodoo::UUID.generate
|
862
|
+
f = Hoodoo::UUID.generate
|
863
|
+
options = { :uuid => u, :created_at => t, :created_by => f }
|
864
|
+
expect(TestPresenter5.render_in(@con, data, options)).to eq({
|
865
|
+
'id' => u,
|
866
|
+
'kind' => 'TestPresenter5',
|
867
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( t ),
|
868
|
+
'created_by' => f,
|
869
|
+
'language' => 'de',
|
870
|
+
'three' => 'default_three'
|
871
|
+
})
|
872
|
+
end
|
873
|
+
|
806
874
|
it 'overrides language' do
|
807
875
|
data = {}
|
808
876
|
t = Time.now.utc
|
@@ -3,14 +3,16 @@ require 'timecop'
|
|
3
3
|
|
4
4
|
describe Hoodoo::Services::Middleware::AMQPLogWriter do
|
5
5
|
before :each do
|
6
|
-
@session_id
|
7
|
-
@caller_id
|
8
|
-
@caller_version
|
9
|
-
@
|
10
|
-
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
6
|
+
@session_id = Hoodoo::UUID.generate
|
7
|
+
@caller_id = Hoodoo::UUID.generate
|
8
|
+
@caller_version = 2
|
9
|
+
@caller_fingerprint = Hoodoo::UUID.generate
|
10
|
+
@session = Hoodoo::Services::Session.new( {
|
11
|
+
:session_id => @session_id,
|
12
|
+
:memcached_host => '0.0.0.0:0',
|
13
|
+
:caller_id => @caller_id,
|
14
|
+
:caller_version => @caller_version,
|
15
|
+
:caller_fingerprint => @caller_fingerprint
|
14
16
|
} )
|
15
17
|
|
16
18
|
@permissions_hash = {
|
@@ -392,6 +392,7 @@ describe Hoodoo::Services::Middleware do
|
|
392
392
|
expect( data[ :session ][ 'caller_id' ] ).to be_present
|
393
393
|
expect( data[ :session ][ 'caller_version' ] ).to be_present
|
394
394
|
expect( data[ :session ][ 'caller_identity_name' ] ).to be_present
|
395
|
+
expect( data[ :session ][ 'caller_fingerprint' ] ).to be_present
|
395
396
|
expect( data[ :session ][ 'identity' ] ).to be_present
|
396
397
|
|
397
398
|
expect( data[ :session ][ 'permissions' ] ).to_not be_present
|
@@ -423,6 +424,7 @@ describe Hoodoo::Services::Middleware do
|
|
423
424
|
expect( data[ :session ][ 'caller_id' ] ).to be_present
|
424
425
|
expect( data[ :session ][ 'caller_version' ] ).to be_present
|
425
426
|
expect( data[ :session ][ 'caller_identity_name' ] ).to be_present
|
427
|
+
expect( data[ :session ][ 'caller_fingerprint' ] ).to be_present
|
426
428
|
expect( data[ :session ][ 'identity' ] ).to be_present
|
427
429
|
expect( data[ :session ][ 'permissions' ] ).to be_present
|
428
430
|
expect( data[ :session ][ 'scoping' ] ).to be_present
|
@@ -306,14 +306,16 @@ describe Hoodoo::Services::Middleware do
|
|
306
306
|
before :each do
|
307
307
|
spec_helper_use_mock_memcached()
|
308
308
|
|
309
|
-
@session_id
|
310
|
-
@caller_id
|
311
|
-
@caller_version
|
312
|
-
@
|
313
|
-
|
314
|
-
:
|
315
|
-
:
|
316
|
-
:
|
309
|
+
@session_id = Hoodoo::UUID.generate
|
310
|
+
@caller_id = Hoodoo::UUID.generate
|
311
|
+
@caller_version = 1
|
312
|
+
@caller_fingerprint = Hoodoo::UUID.generate
|
313
|
+
@session = Hoodoo::Services::Session.new( {
|
314
|
+
:session_id => @session_id,
|
315
|
+
:memcached_host => '0.0.0.0:0',
|
316
|
+
:caller_id => @caller_id,
|
317
|
+
:caller_version => @caller_version,
|
318
|
+
:caller_fingerprint => @caller_fingerprint
|
317
319
|
} )
|
318
320
|
|
319
321
|
# Grant top-level access to all of the Clock endpoints
|
@@ -16,6 +16,7 @@ describe Hoodoo::Services::Session do
|
|
16
16
|
expect( s.memcached_host ).to be_nil
|
17
17
|
expect( s.caller_id ).to be_nil
|
18
18
|
expect( s.caller_version ).to eq( 0 )
|
19
|
+
expect( s.caller_fingerprint ).to be_nil
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'initialises with given options' do
|
@@ -23,13 +24,15 @@ describe Hoodoo::Services::Session do
|
|
23
24
|
:session_id => '1234',
|
24
25
|
:memcached_host => 'abcd',
|
25
26
|
:caller_id => '0987',
|
26
|
-
:caller_version => 2
|
27
|
+
:caller_version => 2,
|
28
|
+
:caller_fingerprint => 'asdf'
|
27
29
|
)
|
28
30
|
expect( s.created_at ).to be_a( Time )
|
29
31
|
expect( s.session_id ).to eq( '1234' )
|
30
32
|
expect( s.memcached_host ).to eq( 'abcd' )
|
31
33
|
expect( s.caller_id ).to eq( '0987' )
|
32
34
|
expect( s.caller_version ).to eq( 2 )
|
35
|
+
expect( s.caller_fingerprint ).to eq( 'asdf' )
|
33
36
|
end
|
34
37
|
|
35
38
|
it 'reports not expired when it has no expiry' do
|
@@ -48,7 +51,8 @@ describe Hoodoo::Services::Session do
|
|
48
51
|
:session_id => '1234',
|
49
52
|
:memcached_host => 'abcd',
|
50
53
|
:caller_id => '0987',
|
51
|
-
:caller_version => 2
|
54
|
+
:caller_version => 2,
|
55
|
+
:caller_fingerprint => 'asdf'
|
52
56
|
)
|
53
57
|
p = Hoodoo::Services::Permissions.new
|
54
58
|
|
@@ -59,15 +63,16 @@ describe Hoodoo::Services::Session do
|
|
59
63
|
h = s.to_h
|
60
64
|
|
61
65
|
expect( h ).to eq( {
|
62
|
-
'session_id'
|
63
|
-
'caller_id'
|
64
|
-
'caller_version'
|
66
|
+
'session_id' => '1234',
|
67
|
+
'caller_id' => '0987',
|
68
|
+
'caller_version' => 2,
|
69
|
+
'caller_fingerprint' => 'asdf',
|
65
70
|
|
66
|
-
'created_at'
|
71
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( s.created_at ),
|
67
72
|
|
68
|
-
'identity'
|
69
|
-
'scoping'
|
70
|
-
'permissions'
|
73
|
+
'identity' => { 'foo' => 'foo', 'bar' => 'bar' },
|
74
|
+
'scoping' => { 'baz' => [ 'foo', 'bar', 'baz' ] },
|
75
|
+
'permissions' => p.to_h()
|
71
76
|
} )
|
72
77
|
end
|
73
78
|
|
@@ -77,16 +82,17 @@ describe Hoodoo::Services::Session do
|
|
77
82
|
c = Time.now.utc
|
78
83
|
e = Time.now.utc + 10
|
79
84
|
h = {
|
80
|
-
'session_id'
|
81
|
-
'caller_id'
|
82
|
-
'caller_version'
|
85
|
+
'session_id' => '1234',
|
86
|
+
'caller_id' => '0987',
|
87
|
+
'caller_version' => 2,
|
88
|
+
'caller_fingerprint' => 'asdf',
|
83
89
|
|
84
|
-
'created_at'
|
85
|
-
'expires_at'
|
90
|
+
'created_at' => Hoodoo::Utilities.standard_datetime( c ),
|
91
|
+
'expires_at' => Hoodoo::Utilities.standard_datetime( e ),
|
86
92
|
|
87
|
-
'identity'
|
88
|
-
'scoping'
|
89
|
-
'permissions'
|
93
|
+
'identity' => { 'foo' => 'foo', 'bar' => 'bar' },
|
94
|
+
'scoping' => { 'baz' => [ 'foo', 'bar', 'baz' ] },
|
95
|
+
'permissions' => p.to_h()
|
90
96
|
}
|
91
97
|
|
92
98
|
s.from_h!( h )
|
@@ -94,6 +100,7 @@ describe Hoodoo::Services::Session do
|
|
94
100
|
expect( s.session_id ).to eq( '1234' )
|
95
101
|
expect( s.caller_id ).to eq( '0987' )
|
96
102
|
expect( s.caller_version ).to eq( 2 )
|
103
|
+
expect( s.caller_fingerprint ).to eq( 'asdf' )
|
97
104
|
expect( s.created_at ).to eq( Time.parse( Hoodoo::Utilities.standard_datetime( c ) ) )
|
98
105
|
expect( s.expires_at ).to eq( Time.parse( Hoodoo::Utilities.standard_datetime( e ) ) )
|
99
106
|
expect( s.identity.foo ).to eq( 'foo' )
|
@@ -107,7 +114,8 @@ describe Hoodoo::Services::Session do
|
|
107
114
|
:session_id => '1234',
|
108
115
|
:memcached_host => 'abcd',
|
109
116
|
:caller_id => '0987',
|
110
|
-
:caller_version => 2
|
117
|
+
:caller_version => 2,
|
118
|
+
:caller_fingerprint => 'asdf'
|
111
119
|
)
|
112
120
|
|
113
121
|
expect( s1.save_to_store ).to eq( :ok )
|
@@ -137,6 +145,7 @@ describe Hoodoo::Services::Session do
|
|
137
145
|
expect( s2.memcached_host ).to be_nil
|
138
146
|
expect( s2.caller_id ).to eq( s1.caller_id )
|
139
147
|
expect( s2.caller_version ).to eq( s1.caller_version )
|
148
|
+
expect( s2.caller_fingerprint ).to eq( s1.caller_fingerprint )
|
140
149
|
end
|
141
150
|
|
142
151
|
it 'can be deleted' do
|