hoodoo 1.9.1 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTI0YTQ0YmNkMzAxZjU3ZWUwZmExZTBlODJlNzkzNjg1NDgwNzA5NA==
4
+ ODE5N2QwMWIyMWIxNDgxYTliZmUyODdjZThkZmFlOTFiYzEzYWEyMg==
5
5
  data.tar.gz: !binary |-
6
- NDAzOWM3ODQwYTM1ZjUwNDBhMjRlMWFkOTBjNzBiOGY3NTBlNzJjNg==
6
+ OGVmODcxY2UxYzNiNTE0NmFlODhhYjhlZjFlZjhiZDA4OGY0MjNkYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGM5ODcxOGMwYjQ4Y2FmYWQ3ODdlOTRjZWEyMWEzN2JiZDQxMzdhOTEyN2Mz
10
- ZTA4ZTEwNzgxNjQ1ZTAyNjMwYTQyMzM2Yjc3YmVkNzY2Njg5YjBhMTJjOTU0
11
- Y2I0ZTcxODIxYzA2YjQwYjQ4NDJmZmM4MDJjNjI2Y2Q5ZmQwYmQ=
9
+ NmZiODc1NjM5MDYxMzI4NWRmYjEyOTNmNGQyN2YxNmU5MGNlMmQ4NjEzMzZl
10
+ Y2YzZjAzMjBjZWMxZDgwNTkzN2M1M2M5Y2Y3OWZlYTJhMGM3NTkwY2NmNzgx
11
+ OGJmODhhOTQxZmJmNGFiMzUyOTI3NGExYmJiYTNhOTM2NGY3YTE=
12
12
  data.tar.gz: !binary |-
13
- NTkyNjNjNTAwYmViNjczMmI4YjA2OTA3ZDE0NGVhNDRlMDFmMzBjMjIyMWY5
14
- ZmRhNDRhYjI1ZjRmMDUxMzExMDNmODIxN2NiOTc1ZGE2YjY4MzcyNzFiZDEz
15
- YjQyMmU3YTNmN2I1Y2I4ODZlNzk4OTA0OWM0NTkyMjM2M2VmMWY=
13
+ ODA0YmQ2ZmZjOTgwMGFkZGNhZWVkZTA3MzI5ZjVmZTE2ZTE2ZTVlYWQ1NDJi
14
+ MGU0MWJhZmU4MmVkMWFmMzMwOWFhNTQwNDRlMjEwYjQ0YTIzOTBhNjgwODIz
15
+ YWNiODZkN2FhMjc1MjRjYmM1MmNmMDhhMGNjNGVjMTI0NDFkYzg=
@@ -85,8 +85,8 @@ module Hoodoo
85
85
  # As an instance-based method, the return value and error handling
86
86
  # semantics differ from the class-based counterpart. Instead of
87
87
  # checking "persisted?", check the return value of +persist_in+. This
88
- # means you can also use +persist_in+ to save a previousl persisted, but
89
- # now updated record, should you so wish.
88
+ # means you can also use +persist_in+ to save a previously persisted,
89
+ # but now updated record, should you so wish.
90
90
  #
91
91
  # def create( context )
92
92
  # attributes = mapping_of( context.request.body )
@@ -217,7 +217,7 @@ module Hoodoo
217
217
  # must-be-unique fields (within your defined scope) automatically.
218
218
  #
219
219
  # Using this method for data storage instead of plain ActiveRecord
220
- # +send+ or <tt>send!</tt> will also help your code auto-inherit any
220
+ # +save+ or <tt>save!</tt> will also help your code auto-inherit any
221
221
  # additional future write-related enhancements in Hoodoo should they
222
222
  # arise, without necessarily needing service code changes.
223
223
  #
@@ -2637,11 +2637,13 @@ module Hoodoo; module Services
2637
2637
  end
2638
2638
  end
2639
2639
 
2640
- # Flatten the resulting sub-arrays and make sure values are unique.
2640
+ # Flatten remaining sub-arrays and make sure values are unique. Sort
2641
+ # keys and sort directions are deduplicated intelligently within the
2642
+ # #process_query_hash method.
2641
2643
 
2642
2644
  query_hash.each do | key, value |
2643
2645
  value.flatten!
2644
- value.uniq!
2646
+ value.uniq! unless key == 'sort' || key == 'direction'
2645
2647
  end
2646
2648
 
2647
2649
  # For search and filter strings, decode the key/value pairs as a
@@ -2720,11 +2722,11 @@ module Hoodoo; module Services
2720
2722
  # 0 created asc
2721
2723
  # 1 name desc
2722
2724
  # 2 title
2723
- # => as specified with default direction for sort key 'title'
2725
+ # => mismatched sort vs direction list length
2724
2726
  #
2725
2727
  # 0 created asc
2726
2728
  # 1 desc
2727
- # => error as there's no way to guess the sort key for the 'desc'
2729
+ # => mismatched sort vs direction list length
2728
2730
 
2729
2731
  sort_keys = query_hash[ 'sort' ] || [ interface.to_list.default_sort_key ]
2730
2732
  sort_directions = query_hash[ 'direction' ] || []
@@ -12,6 +12,6 @@ module Hoodoo
12
12
  # The Hoodoo gem version. If this changes, ensure that the date in
13
13
  # "hoodoo.gemspec" is correct and run "bundle install" (or "update").
14
14
  #
15
- VERSION = '1.9.1'
15
+ VERSION = '1.9.2'
16
16
 
17
17
  end
@@ -0,0 +1,37 @@
1
+ # Adapted from https://gist.github.com/nickyp/886884.
2
+
3
+ require 'rubygems'
4
+ require 'openssl'
5
+
6
+ certd = File.join( File.dirname( __FILE__ ), 'ssl.pem' )
7
+ keyd = File.join( File.dirname( __FILE__ ), 'ssl.key' )
8
+
9
+ key = OpenSSL::PKey::RSA.new(2048)
10
+ public_key = key.public_key
11
+
12
+ subject = "/C=BE/O=127.0.0.1/OU=127.0.0.1/CN=127.0.0.1"
13
+
14
+ cert = OpenSSL::X509::Certificate.new
15
+ cert.subject = cert.issuer = OpenSSL::X509::Name.parse(subject)
16
+ cert.not_before = Time.now
17
+ cert.not_after = Time.now + 365 * 24 * 60 * 60 * 99
18
+ cert.public_key = public_key
19
+ cert.serial = 0x0
20
+ cert.version = 2
21
+
22
+ ef = OpenSSL::X509::ExtensionFactory.new
23
+ ef.subject_certificate = cert
24
+ ef.issuer_certificate = cert
25
+ cert.extensions = [
26
+ ef.create_extension("basicConstraints","CA:TRUE", true),
27
+ ef.create_extension("subjectKeyIdentifier", "hash"),
28
+ ]
29
+ cert.add_extension ef.create_extension("authorityKeyIdentifier",
30
+ "keyid:always,issuer:always")
31
+
32
+ cert.sign key, OpenSSL::Digest::SHA256.new
33
+
34
+ open keyd, 'w' do |io| io.write key.to_pem end
35
+ open certd, 'w' do |io| io.write cert.to_pem end
36
+
37
+ puts "OK"
@@ -29,7 +29,8 @@ class RSpecTestServiceStubInterface < Hoodoo::Services::Interface
29
29
  endpoint :rspec_test_service_stub, RSpecTestServiceStubImplementation
30
30
  embeds :emb, :embs
31
31
  to_list do
32
- sort :extra => [:up, :down]
32
+ sort :extra => [:up, :down]
33
+ sort :conventional => [:asc, :desc]
33
34
  search :foo, :bar
34
35
  filter :baz, :boo
35
36
  end
@@ -681,16 +682,43 @@ describe Hoodoo::Services::Middleware do
681
682
  expect(context.request.list.sort_data).to eq({'extra'=>'up', 'created_at'=>'desc'})
682
683
  end
683
684
 
684
- get '/v2/rspec_test_service_stub?sort=extra&sort=created_at&direction=up,desc', nil, { 'CONTENT_TYPE' => 'application/json; charset=utf-8' }
685
+ get '/v2/rspec_test_service_stub?sort=extra&sort=created_at&direction=up&direction=desc', nil, { 'CONTENT_TYPE' => 'application/json; charset=utf-8' }
686
+ expect(last_response.status).to eq(200)
687
+ end
688
+
689
+ it 'should handle legitimate duplicated sort values (form 1)' do
690
+ expect_any_instance_of(RSpecTestServiceStubImplementation).to receive(:list).once do | ignored_rspec_mock_instance, context |
691
+ expect(context.request.list.sort_data).to eq({'conventional' => 'desc', 'extra'=>'up', 'created_at'=>'desc'})
692
+ end
693
+
694
+ get '/v2/rspec_test_service_stub?sort=conventional,extra,created_at&direction=desc,up,desc', nil, { 'CONTENT_TYPE' => 'application/json; charset=utf-8' }
695
+ expect(last_response.status).to eq(200)
696
+ end
697
+
698
+ it 'should handle legitimate duplicated sort values (form 2)' do
699
+ expect_any_instance_of(RSpecTestServiceStubImplementation).to receive(:list).once do | ignored_rspec_mock_instance, context |
700
+ expect(context.request.list.sort_data).to eq({'conventional' => 'desc', 'extra'=>'up', 'created_at'=>'desc'})
701
+ end
702
+
703
+ get '/v2/rspec_test_service_stub?sort=conventional&direction=desc&sort=extra&sort=created_at&direction=up&direction=desc', nil, { 'CONTENT_TYPE' => 'application/json; charset=utf-8' }
704
+ expect(last_response.status).to eq(200)
705
+ end
706
+
707
+ it 'should handle a mixture of sort forms' do
708
+ expect_any_instance_of(RSpecTestServiceStubImplementation).to receive(:list).once do | ignored_rspec_mock_instance, context |
709
+ expect(context.request.list.sort_data).to eq({'conventional' => 'desc', 'extra'=>'up', 'created_at'=>'desc'})
710
+ end
711
+
712
+ get '/v2/rspec_test_service_stub?sort=conventional&direction=desc&sort=extra,created_at&direction=up,desc', nil, { 'CONTENT_TYPE' => 'application/json; charset=utf-8' }
685
713
  expect(last_response.status).to eq(200)
686
714
  end
687
715
 
688
- it 'should respond to several sort query parameters, with duplicates' do
716
+ it 'should de-duplicate unnecessarily duplicated sort query parameters' do
689
717
  expect_any_instance_of(RSpecTestServiceStubImplementation).to receive(:list).once do | ignored_rspec_mock_instance, context |
690
- expect(context.request.list.sort_data).to eq({'created_at'=>'desc', 'extra'=>'up'})
718
+ expect(context.request.list.sort_data).to eq({'created_at'=>'desc', 'extra'=>'down', 'conventional' => 'desc'})
691
719
  end
692
720
 
693
- get '/v2/rspec_test_service_stub?sort=extra,extra&sort=created_at&sort=extra&direction=up,desc', nil, { 'CONTENT_TYPE' => 'application/json; charset=utf-8' }
721
+ get '/v2/rspec_test_service_stub?sort=created_at,extra,extra&sort=conventional&direction=desc,down,down,desc', nil, { 'CONTENT_TYPE' => 'application/json; charset=utf-8' }
694
722
  expect(last_response.status).to eq(200)
695
723
  end
696
724
 
@@ -43,7 +43,7 @@ describe Hoodoo::Services::Service do
43
43
 
44
44
  it 'should correctly report its component classes' do
45
45
  RSpecTestService.comprised_of( RSpecTestInterfaceA,
46
- RSpecTestInterfaceB )
46
+ RSpecTestInterfaceB )
47
47
 
48
48
  expect(RSpecTestService.component_interfaces).to eq([
49
49
  RSpecTestInterfaceA,
@@ -1,19 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
- class RSpecTestContextImplementation < Hoodoo::Services::Implementation
4
- end
3
+ describe Hoodoo::Services::Context do
5
4
 
6
- class RSpecTestContextInterface < Hoodoo::Services::Interface
7
- interface :RSpecTestResource do
8
- endpoint :rspec_test_service_stub, RSpecTestContextImplementation
5
+ before :all do
6
+ Hoodoo::Services::Middleware.flush_services_for_test()
9
7
  end
10
- end
11
8
 
12
- class RSpecTestContext < Hoodoo::Services::Service
13
- comprised_of RSpecTestContextInterface
14
- end
9
+ class RSpecTestContextImplementation < Hoodoo::Services::Implementation
10
+ end
15
11
 
16
- describe Hoodoo::Services::Context do
12
+ class RSpecTestContextInterface < Hoodoo::Services::Interface
13
+ interface :RSpecTestResource do
14
+ endpoint :rspec_test_service_stub, RSpecTestContextImplementation
15
+ end
16
+ end
17
+
18
+ class RSpecTestContext < Hoodoo::Services::Service
19
+ comprised_of RSpecTestContextInterface
20
+ end
17
21
 
18
22
  it 'should initialise correctly' do
19
23
  ses = Hoodoo::Services::Session.new
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: 1.9.1
4
+ version: 1.9.2
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: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kgio
@@ -409,6 +409,7 @@ files:
409
409
  - spec/data/types/permissions_spec.rb
410
410
  - spec/errors/error_descriptions_spec.rb
411
411
  - spec/errors/errors_spec.rb
412
+ - spec/files/regenerate.rb
412
413
  - spec/integration/service_actions_spec.rb
413
414
  - spec/logger/fast_writer_spec.rb
414
415
  - spec/logger/logger_spec.rb
@@ -541,6 +542,7 @@ test_files:
541
542
  - spec/data/types/permissions_spec.rb
542
543
  - spec/errors/error_descriptions_spec.rb
543
544
  - spec/errors/errors_spec.rb
545
+ - spec/files/regenerate.rb
544
546
  - spec/integration/service_actions_spec.rb
545
547
  - spec/logger/fast_writer_spec.rb
546
548
  - spec/logger/logger_spec.rb