hoodoo 2.5.1 → 2.6.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 +5 -5
- data/lib/hoodoo/active/active_record/manually_dated.rb +2 -1
- data/lib/hoodoo/active/active_record/secure.rb +121 -10
- data/lib/hoodoo/active/active_record/security_helper.rb +143 -0
- data/lib/hoodoo/active/active_record/writer.rb +150 -120
- data/lib/hoodoo/client/client.rb +6 -0
- data/lib/hoodoo/communicators/pool.rb +1 -1
- data/lib/hoodoo/services/services/context.rb +6 -0
- data/lib/hoodoo/services/services/request.rb +6 -6
- data/lib/hoodoo/version.rb +2 -2
- data/spec/active/active_record/secure_spec.rb +213 -0
- data/spec/active/active_record/security_helper_spec.rb +201 -0
- data/spec/active/active_record/writer_spec.rb +14 -0
- data/spec/client/client_spec.rb +11 -2
- data/spec/services/services/context_spec.rb +27 -13
- metadata +6 -3
@@ -101,6 +101,13 @@ describe Hoodoo::ActiveRecord::Writer do
|
|
101
101
|
expect( result ).to eq( :success )
|
102
102
|
expect_no_error( record )
|
103
103
|
end
|
104
|
+
|
105
|
+
it 'via alias' do
|
106
|
+
record = klass.new( unique_attributes() )
|
107
|
+
result = record.update_in( @context )
|
108
|
+
expect( result ).to eq( :success )
|
109
|
+
expect_no_error( record )
|
110
|
+
end
|
104
111
|
end
|
105
112
|
|
106
113
|
context 'with AR validations present' do
|
@@ -140,6 +147,13 @@ describe Hoodoo::ActiveRecord::Writer do
|
|
140
147
|
expect( result ).to eq( :failure )
|
141
148
|
expect_correct_error( record, error_reference )
|
142
149
|
end
|
150
|
+
|
151
|
+
it 'via alias' do
|
152
|
+
record = klass.new( record_to_copy().attributes() )
|
153
|
+
result = record.update_in( @context )
|
154
|
+
expect( result ).to eq( :failure )
|
155
|
+
expect_correct_error( record, error_reference )
|
156
|
+
end
|
143
157
|
end
|
144
158
|
|
145
159
|
context 'with AR validations present' do
|
data/spec/client/client_spec.rb
CHANGED
@@ -240,6 +240,8 @@ describe Hoodoo::Client do
|
|
240
240
|
end
|
241
241
|
|
242
242
|
before :all do
|
243
|
+
$alternating_test = ( rand( 2 ) == 0 ) # 50% chance of starting true / false
|
244
|
+
|
243
245
|
@old_test_session = Hoodoo::Services::Middleware.test_session()
|
244
246
|
@port = spec_helper_start_svc_app_in_thread_for( RSpecClientTestService )
|
245
247
|
@https_port = spec_helper_start_svc_app_in_thread_for( RSpecClientTestService, true )
|
@@ -293,13 +295,20 @@ describe Hoodoo::Client do
|
|
293
295
|
endpoint_opts[ :assume_identity_of ] = @assume_identity_of unless @assume_identity_of.nil?
|
294
296
|
endpoint_opts[ :deja_vu ] = @deja_vu if @deja_vu == true
|
295
297
|
|
296
|
-
|
298
|
+
# Alternate between checks of alternative locales and use of the
|
299
|
+
# native #resource interface versus the #endpoint alias.
|
300
|
+
#
|
301
|
+
if $alternating_test == true
|
297
302
|
override_locale = SecureRandom.urlsafe_base64( 2 )
|
298
303
|
endpoint_opts[ :locale ] = override_locale
|
299
304
|
@expected_locale = override_locale.downcase
|
305
|
+
|
306
|
+
@endpoint = @client.endpoint( :RSpecClientTestTarget, 1, endpoint_opts )
|
307
|
+
else
|
308
|
+
@endpoint = @client.resource( :RSpecClientTestTarget, 1, endpoint_opts )
|
300
309
|
end
|
301
310
|
|
302
|
-
|
311
|
+
$alternating_test = ! $alternating_test
|
303
312
|
end
|
304
313
|
|
305
314
|
# Automatic expectations based on HEADER_TO_PROPERTY are fine here as they
|
@@ -19,7 +19,7 @@ describe Hoodoo::Services::Context do
|
|
19
19
|
comprised_of RSpecTestContextInterface
|
20
20
|
end
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'initialises correctly' do
|
23
23
|
ses = Hoodoo::Services::Session.new
|
24
24
|
req = Hoodoo::Services::Request.new
|
25
25
|
res = Hoodoo::Services::Response.new( Hoodoo::UUID.generate() )
|
@@ -34,19 +34,33 @@ describe Hoodoo::Services::Context do
|
|
34
34
|
expect(con.owning_interaction).to eq(int)
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
context 'reports endpoints' do
|
38
|
+
before :each do
|
39
|
+
ses = Hoodoo::Services::Session.new
|
40
|
+
req = Hoodoo::Services::Request.new
|
41
|
+
res = Hoodoo::Services::Response.new( Hoodoo::UUID.generate() )
|
42
|
+
mid = Hoodoo::Services::Middleware.new( RSpecTestContext.new )
|
43
|
+
int = Hoodoo::Services::Middleware::Interaction.new( {}, mid )
|
43
44
|
|
44
|
-
|
45
|
+
@con = Hoodoo::Services::Context.new( ses, req, res, int )
|
46
|
+
end
|
47
|
+
|
48
|
+
shared_examples 'an endpoint' do | endpoint_method |
|
49
|
+
it 'with the expected properties' do
|
50
|
+
expect(@con.send(endpoint_method, :RSpecTestResource)).to be_a( Hoodoo::Services::Middleware::InterResourceLocal )
|
51
|
+
expect(@con.send(endpoint_method, :RSpecTestResource).instance_variable_get( '@discovery_result' ) ).to be_a( Hoodoo::Services::Discovery::ForLocal )
|
52
|
+
expect(@con.send(endpoint_method, :RSpecTestResource).instance_variable_get( '@discovery_result' ) .interface_class).to eq( RSpecTestContextInterface )
|
53
|
+
expect(@con.send(endpoint_method, :AnotherResource)).to be_a( Hoodoo::Services::Middleware::InterResourceRemote )
|
54
|
+
expect(@con.send(endpoint_method, :AnotherResource).instance_variable_get( '@discovery_result' ) ).to be_a( Hoodoo::Services::Discovery::ForRemote )
|
55
|
+
end
|
56
|
+
end
|
45
57
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
58
|
+
context 'via native "#resource" and' do
|
59
|
+
it_behaves_like 'an endpoint', :resource
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'via alias "#endpoint" and' do
|
63
|
+
it_behaves_like 'an endpoint', :endpoint
|
64
|
+
end
|
51
65
|
end
|
52
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoodoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loyalty New Zealand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dalli
|
@@ -297,6 +297,7 @@ files:
|
|
297
297
|
- lib/hoodoo/active/active_record/manually_dated.rb
|
298
298
|
- lib/hoodoo/active/active_record/search_helper.rb
|
299
299
|
- lib/hoodoo/active/active_record/secure.rb
|
300
|
+
- lib/hoodoo/active/active_record/security_helper.rb
|
300
301
|
- lib/hoodoo/active/active_record/support.rb
|
301
302
|
- lib/hoodoo/active/active_record/translated.rb
|
302
303
|
- lib/hoodoo/active/active_record/uuid.rb
|
@@ -420,6 +421,7 @@ files:
|
|
420
421
|
- spec/active/active_record/manually_dated_spec.rb
|
421
422
|
- spec/active/active_record/search_helper_spec.rb
|
422
423
|
- spec/active/active_record/secure_spec.rb
|
424
|
+
- spec/active/active_record/security_helper_spec.rb
|
423
425
|
- spec/active/active_record/support_spec.rb
|
424
426
|
- spec/active/active_record/translated_spec.rb
|
425
427
|
- spec/active/active_record/uuid_spec.rb
|
@@ -554,7 +556,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
554
556
|
version: '0'
|
555
557
|
requirements: []
|
556
558
|
rubyforge_project:
|
557
|
-
rubygems_version: 2.
|
559
|
+
rubygems_version: 2.6.14
|
558
560
|
signing_key:
|
559
561
|
specification_version: 4
|
560
562
|
summary: Opinionated APIs
|
@@ -567,6 +569,7 @@ test_files:
|
|
567
569
|
- spec/active/active_record/manually_dated_spec.rb
|
568
570
|
- spec/active/active_record/search_helper_spec.rb
|
569
571
|
- spec/active/active_record/secure_spec.rb
|
572
|
+
- spec/active/active_record/security_helper_spec.rb
|
570
573
|
- spec/active/active_record/support_spec.rb
|
571
574
|
- spec/active/active_record/translated_spec.rb
|
572
575
|
- spec/active/active_record/uuid_spec.rb
|