right_support 2.6.17 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/.rspec +4 -0
  2. data/CHANGELOG.rdoc +37 -0
  3. data/Gemfile +29 -0
  4. data/Gemfile.lock +111 -0
  5. data/README.rdoc +2 -0
  6. data/Rakefile +62 -0
  7. data/VERSION +1 -0
  8. data/features/balancer_error_handling.feature +34 -0
  9. data/features/balancer_health_check.feature +33 -0
  10. data/features/continuous_integration.feature +51 -0
  11. data/features/continuous_integration_cucumber.feature +28 -0
  12. data/features/continuous_integration_rspec1.feature +28 -0
  13. data/features/continuous_integration_rspec2.feature +28 -0
  14. data/features/http_client_timeout.feature +19 -0
  15. data/features/serialization.feature +95 -0
  16. data/features/step_definitions/http_client_steps.rb +27 -0
  17. data/features/step_definitions/request_balancer_steps.rb +93 -0
  18. data/features/step_definitions/ruby_steps.rb +176 -0
  19. data/features/step_definitions/serialization_steps.rb +96 -0
  20. data/features/step_definitions/server_steps.rb +134 -0
  21. data/features/support/env.rb +138 -0
  22. data/features/support/file_utils_bundler_mixin.rb +45 -0
  23. data/lib/right_support/ci/java_cucumber_formatter.rb +22 -8
  24. data/lib/right_support/ci/java_spec_formatter.rb +26 -8
  25. data/lib/right_support/ci/rake_task.rb +3 -0
  26. data/lib/right_support/ci.rb +24 -0
  27. data/lib/right_support/crypto/signed_hash.rb +22 -0
  28. data/lib/right_support/data/serializer.rb +24 -2
  29. data/lib/right_support/net/address_helper.rb +20 -8
  30. data/lib/right_support/net/dns.rb +20 -8
  31. data/lib/right_support/net/http_client.rb +22 -0
  32. data/lib/right_support/net/request_balancer.rb +27 -21
  33. data/lib/right_support/net/s3_helper.rb +20 -8
  34. data/lib/right_support/net/ssl/open_ssl_patch.rb +22 -0
  35. data/lib/right_support/net/ssl.rb +20 -8
  36. data/lib/right_support/ruby/easy_singleton.rb +22 -0
  37. data/lib/right_support/ruby/object_extensions.rb +22 -0
  38. data/lib/right_support/ruby/string_extensions.rb +1 -1
  39. data/lib/right_support.rb +13 -10
  40. data/right_support.gemspec +180 -18
  41. data/right_support.rconf +8 -0
  42. data/spec/config/feature_set_spec.rb +83 -0
  43. data/spec/crypto/signed_hash_spec.rb +60 -0
  44. data/spec/data/hash_tools_spec.rb +471 -0
  45. data/spec/data/uuid_spec.rb +45 -0
  46. data/spec/db/cassandra_model_part1_spec.rb +84 -0
  47. data/spec/db/cassandra_model_part2_spec.rb +73 -0
  48. data/spec/db/cassandra_model_spec.rb +359 -0
  49. data/spec/fixtures/encrypted_priv_rsa.pem +30 -0
  50. data/spec/fixtures/good_priv_dsa.pem +12 -0
  51. data/spec/fixtures/good_priv_rsa.pem +15 -0
  52. data/spec/fixtures/good_pub_dsa.ssh +1 -0
  53. data/spec/fixtures/good_pub_rsa.pem +5 -0
  54. data/spec/fixtures/good_pub_rsa.ssh +1 -0
  55. data/spec/log/exception_logger_spec.rb +76 -0
  56. data/spec/log/filter_logger_spec.rb +8 -0
  57. data/spec/log/mixin_spec.rb +62 -0
  58. data/spec/log/multiplexer_spec.rb +54 -0
  59. data/spec/log/null_logger_spec.rb +36 -0
  60. data/spec/log/system_logger_spec.rb +92 -0
  61. data/spec/net/address_helper_spec.rb +57 -0
  62. data/spec/net/balancing/health_check_spec.rb +382 -0
  63. data/spec/net/balancing/round_robin_spec.rb +15 -0
  64. data/spec/net/balancing/sticky_policy_spec.rb +92 -0
  65. data/spec/net/dns_spec.rb +152 -0
  66. data/spec/net/http_client_spec.rb +171 -0
  67. data/spec/net/request_balancer_spec.rb +579 -0
  68. data/spec/net/s3_helper_spec.rb +160 -0
  69. data/spec/net/ssl_spec.rb +42 -0
  70. data/spec/net/string_encoder_spec.rb +58 -0
  71. data/spec/rack/log_setter_spec.rb +5 -0
  72. data/spec/rack/request_logger_spec.rb +68 -0
  73. data/spec/rack/request_tracker_spec.rb +5 -0
  74. data/spec/ruby/easy_singleton_spec.rb +72 -0
  75. data/spec/ruby/object_extensions_spec.rb +27 -0
  76. data/spec/ruby/string_extensions_spec.rb +98 -0
  77. data/spec/spec_helper.rb +181 -0
  78. data/spec/stats/activity_spec.rb +193 -0
  79. data/spec/stats/exceptions_spec.rb +123 -0
  80. data/spec/stats/helpers_spec.rb +603 -0
  81. data/spec/validation/openssl_spec.rb +37 -0
  82. data/spec/validation/ssh_spec.rb +39 -0
  83. metadata +218 -19
@@ -1,23 +1,185 @@
1
- # -*- mode: ruby; encoding: utf-8 -*-
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 -*-
2
5
 
3
- require 'rubygems'
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{right_support}
8
+ s.version = "2.7.0"
4
9
 
5
- spec = Gem::Specification.new do |s|
6
- s.required_rubygems_version = nil if s.respond_to? :required_rubygems_version=
7
- s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
8
-
9
- s.name = 'right_support'
10
- s.version = '2.6.17'
11
- s.date = '2013-01-29'
12
-
13
- s.authors = ['Tony Spataro', 'Sergey Sergyenko', 'Ryan Williamson', 'Lee Kirchhoff', 'Sergey Enin', 'Alexey Karpik', 'Scott Messier']
14
- s.email = 'support@rightscale.com'
15
- s.homepage= 'https://github.com/rightscale/right_support'
16
-
17
- s.summary = %q{Reusable foundation code.}
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Tony Spataro", "Sergey Sergyenko", "Ryan Williamson", "Lee Kirchhoff", "Alexey Karpik", "Scott Messier"]
12
+ s.date = %q{2013-01-26}
18
13
  s.description = %q{A toolkit of useful, reusable foundation code created by RightScale.}
14
+ s.email = %q{support@rightscale.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".rspec",
21
+ "CHANGELOG.rdoc",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "features/balancer_error_handling.feature",
29
+ "features/balancer_health_check.feature",
30
+ "features/continuous_integration.feature",
31
+ "features/continuous_integration_cucumber.feature",
32
+ "features/continuous_integration_rspec1.feature",
33
+ "features/continuous_integration_rspec2.feature",
34
+ "features/http_client_timeout.feature",
35
+ "features/serialization.feature",
36
+ "features/step_definitions/http_client_steps.rb",
37
+ "features/step_definitions/request_balancer_steps.rb",
38
+ "features/step_definitions/ruby_steps.rb",
39
+ "features/step_definitions/serialization_steps.rb",
40
+ "features/step_definitions/server_steps.rb",
41
+ "features/support/env.rb",
42
+ "features/support/file_utils_bundler_mixin.rb",
43
+ "lib/right_support.rb",
44
+ "lib/right_support/ci.rb",
45
+ "lib/right_support/ci/java_cucumber_formatter.rb",
46
+ "lib/right_support/ci/java_spec_formatter.rb",
47
+ "lib/right_support/ci/rake_task.rb",
48
+ "lib/right_support/config.rb",
49
+ "lib/right_support/config/feature_set.rb",
50
+ "lib/right_support/config/recursive_true_class.rb",
51
+ "lib/right_support/config/yaml_config.rb",
52
+ "lib/right_support/crypto.rb",
53
+ "lib/right_support/crypto/signed_hash.rb",
54
+ "lib/right_support/data.rb",
55
+ "lib/right_support/data/hash_tools.rb",
56
+ "lib/right_support/data/serializer.rb",
57
+ "lib/right_support/data/uuid.rb",
58
+ "lib/right_support/db.rb",
59
+ "lib/right_support/db/cassandra_model.rb",
60
+ "lib/right_support/log.rb",
61
+ "lib/right_support/log/exception_logger.rb",
62
+ "lib/right_support/log/filter_logger.rb",
63
+ "lib/right_support/log/mixin.rb",
64
+ "lib/right_support/log/multiplexer.rb",
65
+ "lib/right_support/log/null_logger.rb",
66
+ "lib/right_support/log/system_logger.rb",
67
+ "lib/right_support/net.rb",
68
+ "lib/right_support/net/address_helper.rb",
69
+ "lib/right_support/net/dns.rb",
70
+ "lib/right_support/net/http_client.rb",
71
+ "lib/right_support/net/lb.rb",
72
+ "lib/right_support/net/lb/health_check.rb",
73
+ "lib/right_support/net/lb/round_robin.rb",
74
+ "lib/right_support/net/lb/sticky.rb",
75
+ "lib/right_support/net/request_balancer.rb",
76
+ "lib/right_support/net/s3_helper.rb",
77
+ "lib/right_support/net/ssl.rb",
78
+ "lib/right_support/net/ssl/open_ssl_patch.rb",
79
+ "lib/right_support/net/string_encoder.rb",
80
+ "lib/right_support/rack.rb",
81
+ "lib/right_support/rack/log_setter.rb",
82
+ "lib/right_support/rack/request_logger.rb",
83
+ "lib/right_support/rack/request_tracker.rb",
84
+ "lib/right_support/ruby.rb",
85
+ "lib/right_support/ruby/easy_singleton.rb",
86
+ "lib/right_support/ruby/object_extensions.rb",
87
+ "lib/right_support/ruby/string_extensions.rb",
88
+ "lib/right_support/stats.rb",
89
+ "lib/right_support/stats/activity.rb",
90
+ "lib/right_support/stats/exceptions.rb",
91
+ "lib/right_support/stats/helpers.rb",
92
+ "lib/right_support/validation.rb",
93
+ "lib/right_support/validation/openssl.rb",
94
+ "lib/right_support/validation/ssh.rb",
95
+ "right_support.gemspec",
96
+ "right_support.rconf",
97
+ "spec/config/feature_set_spec.rb",
98
+ "spec/crypto/signed_hash_spec.rb",
99
+ "spec/data/hash_tools_spec.rb",
100
+ "spec/data/uuid_spec.rb",
101
+ "spec/db/cassandra_model_part1_spec.rb",
102
+ "spec/db/cassandra_model_part2_spec.rb",
103
+ "spec/db/cassandra_model_spec.rb",
104
+ "spec/fixtures/encrypted_priv_rsa.pem",
105
+ "spec/fixtures/good_priv_dsa.pem",
106
+ "spec/fixtures/good_priv_rsa.pem",
107
+ "spec/fixtures/good_pub_dsa.ssh",
108
+ "spec/fixtures/good_pub_rsa.pem",
109
+ "spec/fixtures/good_pub_rsa.ssh",
110
+ "spec/log/exception_logger_spec.rb",
111
+ "spec/log/filter_logger_spec.rb",
112
+ "spec/log/mixin_spec.rb",
113
+ "spec/log/multiplexer_spec.rb",
114
+ "spec/log/null_logger_spec.rb",
115
+ "spec/log/system_logger_spec.rb",
116
+ "spec/net/address_helper_spec.rb",
117
+ "spec/net/balancing/health_check_spec.rb",
118
+ "spec/net/balancing/round_robin_spec.rb",
119
+ "spec/net/balancing/sticky_policy_spec.rb",
120
+ "spec/net/dns_spec.rb",
121
+ "spec/net/http_client_spec.rb",
122
+ "spec/net/request_balancer_spec.rb",
123
+ "spec/net/s3_helper_spec.rb",
124
+ "spec/net/ssl_spec.rb",
125
+ "spec/net/string_encoder_spec.rb",
126
+ "spec/rack/log_setter_spec.rb",
127
+ "spec/rack/request_logger_spec.rb",
128
+ "spec/rack/request_tracker_spec.rb",
129
+ "spec/ruby/easy_singleton_spec.rb",
130
+ "spec/ruby/object_extensions_spec.rb",
131
+ "spec/ruby/string_extensions_spec.rb",
132
+ "spec/spec_helper.rb",
133
+ "spec/stats/activity_spec.rb",
134
+ "spec/stats/exceptions_spec.rb",
135
+ "spec/stats/helpers_spec.rb",
136
+ "spec/validation/openssl_spec.rb",
137
+ "spec/validation/ssh_spec.rb"
138
+ ]
139
+ s.homepage = %q{https://github.com/rightscale/right_support}
140
+ s.licenses = ["MIT"]
141
+ s.require_paths = ["lib"]
142
+ s.rubygems_version = %q{1.3.7}
143
+ s.summary = %q{Reusable foundation code.}
144
+
145
+ if s.respond_to? :specification_version then
146
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
147
+ s.specification_version = 3
19
148
 
20
- basedir = File.dirname(__FILE__)
21
- candidates = ['right_support.gemspec', 'LICENSE', 'README.rdoc'] + Dir['lib/**/*']
22
- s.files = candidates.sort
149
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
150
+ s.add_development_dependency(%q<rake>, ["~> 0.9"])
151
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
152
+ s.add_development_dependency(%q<ruby-debug>, [">= 0.10"])
153
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0.11.6"])
154
+ s.add_development_dependency(%q<rdoc>, [">= 2.4.2"])
155
+ s.add_development_dependency(%q<rspec>, ["~> 2.0"])
156
+ s.add_development_dependency(%q<cucumber>, ["~> 1.0"])
157
+ s.add_development_dependency(%q<flexmock>, ["~> 0.8"])
158
+ s.add_development_dependency(%q<syntax>, ["~> 1.0.0"])
159
+ s.add_development_dependency(%q<nokogiri>, ["~> 1.5"])
160
+ else
161
+ s.add_dependency(%q<rake>, ["~> 0.9"])
162
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
163
+ s.add_dependency(%q<ruby-debug>, [">= 0.10"])
164
+ s.add_dependency(%q<ruby-debug19>, [">= 0.11.6"])
165
+ s.add_dependency(%q<rdoc>, [">= 2.4.2"])
166
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
167
+ s.add_dependency(%q<cucumber>, ["~> 1.0"])
168
+ s.add_dependency(%q<flexmock>, ["~> 0.8"])
169
+ s.add_dependency(%q<syntax>, ["~> 1.0.0"])
170
+ s.add_dependency(%q<nokogiri>, ["~> 1.5"])
171
+ end
172
+ else
173
+ s.add_dependency(%q<rake>, ["~> 0.9"])
174
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
175
+ s.add_dependency(%q<ruby-debug>, [">= 0.10"])
176
+ s.add_dependency(%q<ruby-debug19>, [">= 0.11.6"])
177
+ s.add_dependency(%q<rdoc>, [">= 2.4.2"])
178
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
179
+ s.add_dependency(%q<cucumber>, ["~> 1.0"])
180
+ s.add_dependency(%q<flexmock>, ["~> 0.8"])
181
+ s.add_dependency(%q<syntax>, ["~> 1.0.0"])
182
+ s.add_dependency(%q<nokogiri>, ["~> 1.5"])
183
+ end
23
184
  end
185
+
@@ -0,0 +1,8 @@
1
+ ruby do
2
+ version 'ree-1.8.7-2010.02'
3
+ rubygems '1.3.7'
4
+ gemset 'right_support'
5
+ end
6
+ bundler do
7
+ version '1.1.4'
8
+ end
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+
4
+ describe RightSupport::Config::FeatureSet do
5
+
6
+ class SweetestClass
7
+ attr_accessor :config
8
+ end
9
+
10
+ module HashHelper
11
+ def deep_stringify_keys
12
+ new_hash = {}
13
+ self.each do |key, value|
14
+ new_hash.merge!(key.to_s => (value.is_a?(Hash) ?\
15
+ value.extend(HashHelper).deep_stringify_keys\
16
+ : value))
17
+ end
18
+ end
19
+ end
20
+
21
+ #generating yml config on fly
22
+ before(:all) do
23
+ config_hash = {}
24
+ config_hash['speak'] = {}
25
+ config_hash['speak']['belarusian'] = true
26
+ config_hash['speak']['klingonese'] = false
27
+ config_hash['eat'] = {}
28
+ config_hash['eat']['khlav kalash'] = 'YES!'
29
+ config_hash.send(:extend, HashHelper)
30
+ config_string = config_hash.deep_stringify_keys.to_yaml
31
+ yaml_config = config_string.gsub('!ruby/symbol ', ':').sub('---','').split('\n').map(&:rstrip).join('\n').strip
32
+
33
+ @test_class = SweetestClass.new
34
+ @test_class.instance_eval{ @config = RightSupport::Config.features(yaml_config) }
35
+ end
36
+
37
+ context 'features set config works correctly' do
38
+
39
+ it 'evaluates non existed feature as true' do
40
+ @test_class.config['I saw Tom Collins'].should be_true
41
+ end
42
+
43
+ it 'evaluates not existed feature as true recursively' do
44
+ @test_class.config['I']['saw']['Tom']['Collins'].should be_true
45
+ end
46
+
47
+ it 'evaluates true correctly' do
48
+ @test_class.config['speak', 'belarusian'].should be_true
49
+ end
50
+
51
+ it 'evaluates false correctly' do
52
+ @test_class.config['speak', 'klingonese'].should_not be_true
53
+ end
54
+
55
+ it 'evaluates string as string' do
56
+ @test_class.config['eat']['khlav kalash'].should == 'YES!'
57
+ end
58
+
59
+ it 'supports [][] calling' do
60
+ @test_class.config['speak']['klingonese'].should_not be_true
61
+ end
62
+
63
+ it 'load hash as config source' do
64
+ hash_config = {:'tom collins'=>{:invisible=>'sure!'}}
65
+ @test_class.instance_eval{ @config = RightSupport::Config.features(hash_config)}
66
+ @test_class.config[:'tom collins'][:invisible].should == 'sure!'
67
+ end
68
+
69
+ it 'raise error on wrong yaml' do
70
+ wrong_yaml_config = {:a=>:b}.to_yaml + "::\n\na"
71
+ lambda do
72
+ @test_class.instance_eval{ @config = RightSupport::Config.features(wrong_yaml_config)}
73
+ end.should raise_error(ArgumentError)
74
+ end
75
+
76
+ it 'works correctly with empty source' do
77
+ @test_class.instance_eval{ @config = RightSupport::Config.features({}) }
78
+ @test_class.config['I']['saw']['Tom']['Collins']['really'].should be_true
79
+ end
80
+
81
+ end
82
+
83
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe RightSupport::Crypto::SignedHash do
4
+ before(:all) do
5
+ @data = random_value(Hash)
6
+ @rsa_key = OpenSSL::PKey::RSA.generate(1024)
7
+ @expires_at = Time.at(Time.now.to_i + 60*60) #one hour from now
8
+ end
9
+
10
+ context :sign do
11
+ it 'computes a signature' do
12
+ signature = RightSupport::Crypto::SignedHash.new(@data, :private_key=>@rsa_key).sign(@expires_at)
13
+ signature.should_not be_nil
14
+ RightSupport::Crypto::SignedHash.new(@data, :public_key=>@rsa_key).verify(signature, @expires_at).should be_true
15
+ end
16
+ end
17
+
18
+ context :verify do
19
+ before(:each) do
20
+ @signature = RightSupport::Crypto::SignedHash.new(@data, :private_key=>@rsa_key).sign(@expires_at)
21
+ @hash = RightSupport::Crypto::SignedHash.new(@data, :public_key=>@rsa_key)
22
+ end
23
+
24
+ context 'when the signature and data are good' do
25
+ it 'returns true' do
26
+ @hash.verify(@signature, @expires_at).should be_true
27
+ end
28
+ end
29
+
30
+ context 'when expires_at is in the past' do
31
+ it 'returns false' do
32
+ @hash.verify(@signature, Time.at(@expires_at.to_i - 86400)).should be_false
33
+ end
34
+ end
35
+
36
+ context 'when expires_at has been tampered with' do
37
+ it 'returns false' do
38
+ @hash.verify(@signature + 'xyzzy', @expires_at).should be_false
39
+ end
40
+ end
41
+
42
+ context 'when the data is bad' do
43
+ before(:each) do
44
+ modified_data = @data.dup
45
+ modified_data[modified_data.keys.first] = 'gabba gabba hey!'
46
+ @modified_hash = RightSupport::Crypto::SignedHash.new(modified_data, :public_key=>@rsa_key)
47
+ end
48
+ it 'returns false' do
49
+ @modified_hash.verify(@signature, @expires_at).should be_false
50
+ end
51
+ end
52
+
53
+ context 'when the signature is bad' do
54
+ it 'returns false' do
55
+ @signature << 'xyzzy'
56
+ @hash.verify(@signature, @expires_at).should be_false
57
+ end
58
+ end
59
+ end
60
+ end