right_support 2.11.3 → 2.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -0
- data/VERSION +1 -1
- data/lib/right_support/notifiers/airbrake.rb +194 -0
- data/lib/right_support/notifiers/base.rb +73 -0
- data/lib/right_support/notifiers/blacklisters/base.rb +48 -0
- data/lib/right_support/notifiers/blacklisters/canonical.rb +60 -0
- data/lib/right_support/notifiers/blacklisters/regular_expression.rb +86 -0
- data/{features/support/file_utils_bundler_mixin.rb → lib/right_support/notifiers/blacklisters/simple.rb} +21 -20
- data/lib/right_support/notifiers/blacklisters/snake_case.rb +60 -0
- data/lib/right_support/notifiers/blacklisters/wildcard.rb +65 -0
- data/lib/right_support/notifiers/blacklisters.rb +34 -0
- data/lib/right_support/notifiers/logger.rb +94 -0
- data/lib/right_support/notifiers/notification.rb +57 -0
- data/lib/right_support/notifiers/utilities/backtrace_decoder.rb +234 -0
- data/lib/right_support/notifiers/utilities.rb +29 -0
- data/lib/right_support/notifiers.rb +32 -0
- data/lib/right_support/rack/request_logger.rb +13 -9
- data/lib/right_support.rb +1 -0
- data/right_support.gemspec +19 -70
- metadata +17 -69
- data/.coveralls.yml +0 -2
- data/.rspec +0 -3
- data/.simplecov +0 -6
- data/.travis.yml +0 -13
- data/Gemfile +0 -51
- data/Gemfile.lock +0 -153
- data/features/balancer_error_handling.feature +0 -34
- data/features/balancer_health_check.feature +0 -33
- data/features/hash_tools.feature +0 -27
- data/features/http_client_timeout.feature +0 -19
- data/features/serialization.feature +0 -113
- data/features/step_definitions/hash_tools_steps.rb +0 -41
- data/features/step_definitions/http_client_steps.rb +0 -27
- data/features/step_definitions/request_balancer_steps.rb +0 -93
- data/features/step_definitions/ruby_steps.rb +0 -176
- data/features/step_definitions/serialization_steps.rb +0 -133
- data/features/step_definitions/server_steps.rb +0 -134
- data/features/support/env.rb +0 -148
- data/right_support.rconf +0 -9
- data/spec/config/feature_set_spec.rb +0 -83
- data/spec/crypto/signed_hash_spec.rb +0 -73
- data/spec/data/hash_tools_spec.rb +0 -602
- data/spec/data/mash_spec.rb +0 -313
- data/spec/data/token_spec.rb +0 -21
- data/spec/data/uuid_spec.rb +0 -45
- data/spec/db/cassandra_model_part1_spec.rb +0 -84
- data/spec/db/cassandra_model_part2_spec.rb +0 -73
- data/spec/db/cassandra_model_spec.rb +0 -375
- data/spec/fixtures/encrypted_priv_rsa.pem +0 -30
- data/spec/fixtures/good_priv_dsa.pem +0 -12
- data/spec/fixtures/good_priv_rsa.pem +0 -15
- data/spec/fixtures/good_pub_dsa.ssh +0 -1
- data/spec/fixtures/good_pub_rsa.pem +0 -5
- data/spec/fixtures/good_pub_rsa.ssh +0 -1
- data/spec/log/exception_logger_spec.rb +0 -76
- data/spec/log/filter_logger_spec.rb +0 -66
- data/spec/log/mixin_spec.rb +0 -141
- data/spec/log/multiplexer_spec.rb +0 -54
- data/spec/log/null_logger_spec.rb +0 -36
- data/spec/log/step_level_logger_spec.rb +0 -49
- data/spec/log/system_logger_spec.rb +0 -172
- data/spec/net/address_helper_spec.rb +0 -57
- data/spec/net/dns_spec.rb +0 -187
- data/spec/net/http_client_spec.rb +0 -181
- data/spec/net/lb/health_check_spec.rb +0 -417
- data/spec/net/lb/round_robin_spec.rb +0 -15
- data/spec/net/lb/sticky_spec.rb +0 -92
- data/spec/net/request_balancer_spec.rb +0 -690
- data/spec/net/s3_helper_spec.rb +0 -160
- data/spec/net/ssl_spec.rb +0 -42
- data/spec/net/string_encoder_spec.rb +0 -58
- data/spec/rack/log_setter_spec.rb +0 -5
- data/spec/rack/request_logger_spec.rb +0 -225
- data/spec/rack/request_tracker_spec.rb +0 -115
- data/spec/rack/runtime_spec.rb +0 -49
- data/spec/ruby/easy_singleton_spec.rb +0 -72
- data/spec/ruby/object_extensions_spec.rb +0 -27
- data/spec/ruby/string_extensions_spec.rb +0 -98
- data/spec/spec_helper.rb +0 -188
- data/spec/stats/activity_spec.rb +0 -425
- data/spec/stats/exceptions_spec.rb +0 -247
- data/spec/stats/helpers_spec.rb +0 -685
- data/spec/validation/openssl_spec.rb +0 -37
- data/spec/validation/ssh_spec.rb +0 -39
@@ -1,134 +0,0 @@
|
|
1
|
-
#-- -*- mode: ruby; encoding: utf-8 -*-
|
2
|
-
# Copyright: Copyright (c) 2011 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require 'webrick'
|
25
|
-
require 'webrick/httpservlet'
|
26
|
-
|
27
|
-
# Mimic a generic HTTP server with various configurable behaviors
|
28
|
-
class MockServer < WEBrick::HTTPServer
|
29
|
-
attr_accessor :thread, :port, :url
|
30
|
-
|
31
|
-
# Overridden factory method that will tolerate Errno::EADDRINUSE in case a certain
|
32
|
-
# TCP port is already used
|
33
|
-
def self.new(*args)
|
34
|
-
tries ||= 0
|
35
|
-
super
|
36
|
-
rescue Errno::EADDRINUSE => e
|
37
|
-
tries += 1
|
38
|
-
if tries > 5
|
39
|
-
raise
|
40
|
-
else
|
41
|
-
retry
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def initialize(options={})
|
46
|
-
@port = options[:port] || (4096 + rand(32768-4096))
|
47
|
-
@url = "http://localhost:#{@port}"
|
48
|
-
|
49
|
-
logger = WEBrick::Log.new(STDERR, WEBrick::Log::FATAL)
|
50
|
-
super(options.merge(:Port => @port, :AccessLog => [], :Logger=>logger))
|
51
|
-
|
52
|
-
# mount servlets via callback
|
53
|
-
yield(self)
|
54
|
-
|
55
|
-
#Start listening for HTTP in a separate thread
|
56
|
-
@thread = Thread.new do
|
57
|
-
self.start()
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Mimic a server that exists but hangs without providing any response, not even
|
63
|
-
# ICMP signals e.g. host unreachable or network unreachable. We simulate this
|
64
|
-
# by pointing at a port of the RightScale (my) load balancer that is not allowed
|
65
|
-
# by the security group, which causes the TCP SYN packets to be dropped with no
|
66
|
-
# acknowledgement.
|
67
|
-
class BlackholedServer
|
68
|
-
attr_accessor :port, :url
|
69
|
-
|
70
|
-
def initialize(options={})
|
71
|
-
@port = options[:port] || (4096 + rand(4096))
|
72
|
-
@url = "my.rightscale.com:#{@port}"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
Before do
|
77
|
-
@mock_servers = []
|
78
|
-
end
|
79
|
-
|
80
|
-
# Kill running reposes after test finishes.
|
81
|
-
After do
|
82
|
-
@mock_servers.each do |server|
|
83
|
-
if server.is_a?(MockServer)
|
84
|
-
server.thread.kill
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
Given /^(an?|\d+)? (overloaded|blackholed) servers?$/ do |number, behavior|
|
90
|
-
number = 0 if number =~ /no/
|
91
|
-
number = 1 if number =~ /an?/
|
92
|
-
number = number.to_i
|
93
|
-
|
94
|
-
number.times do
|
95
|
-
case behavior
|
96
|
-
when 'overloaded'
|
97
|
-
proc = Proc.new do
|
98
|
-
sleep(10)
|
99
|
-
'Hi there! I am overloaded.'
|
100
|
-
end
|
101
|
-
server = MockServer.new do |s|
|
102
|
-
s.mount('/', WEBrick::HTTPServlet::ProcHandler.new(proc))
|
103
|
-
end
|
104
|
-
when 'blackholed'
|
105
|
-
server = BlackholedServer.new()
|
106
|
-
else
|
107
|
-
raise ArgumentError, "Unknown server behavior #{behavior}"
|
108
|
-
end
|
109
|
-
|
110
|
-
@mock_servers << server
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
Given /^(an?|\d+)? servers? that responds? with ([0-9]+)$/ do |number, status_code|
|
115
|
-
number = 0 if number =~ /no/
|
116
|
-
number = 1 if number =~ /an?/
|
117
|
-
number = number.to_i
|
118
|
-
|
119
|
-
status_code = status_code.to_i
|
120
|
-
|
121
|
-
proc = Proc.new do
|
122
|
-
klass = WEBrick::HTTPStatus::CodeToError[status_code]
|
123
|
-
klass.should_not be_nil
|
124
|
-
raise klass, "Simulated #{status_code} response"
|
125
|
-
end
|
126
|
-
|
127
|
-
number.times do
|
128
|
-
server = MockServer.new do |s|
|
129
|
-
s.mount('/', WEBrick::HTTPServlet::ProcHandler.new(proc))
|
130
|
-
end
|
131
|
-
|
132
|
-
@mock_servers << server
|
133
|
-
end
|
134
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010- RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require 'tmpdir'
|
25
|
-
|
26
|
-
require 'rubygems'
|
27
|
-
require 'bundler/setup'
|
28
|
-
|
29
|
-
require 'simplecov'
|
30
|
-
|
31
|
-
$:.unshift(File.expand_path('../../../lib', __FILE__)) #ensure we load THIS project's code, not an installed gem
|
32
|
-
require 'right_support'
|
33
|
-
require 'right_support/ci'
|
34
|
-
|
35
|
-
['pry', 'ruby-debug'].each do |debugger|
|
36
|
-
begin
|
37
|
-
require debugger
|
38
|
-
rescue LoadError
|
39
|
-
# ignore
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
module RandomValueHelper
|
44
|
-
RANDOM_KEY_CLASSES = [String, Integer, Float, TrueClass, FalseClass]
|
45
|
-
RANDOM_VALUE_CLASSES = RANDOM_KEY_CLASSES + [Array, Hash]
|
46
|
-
|
47
|
-
def random_value(klass=nil, key_classes=RANDOM_KEY_CLASSES, depth=0)
|
48
|
-
if klass.nil?
|
49
|
-
if depth < 3 && key_classes.nil?
|
50
|
-
klasses = RANDOM_VALUE_CLASSES
|
51
|
-
else
|
52
|
-
klasses = key_classes
|
53
|
-
end
|
54
|
-
|
55
|
-
klass = klasses[rand(klasses.size)]
|
56
|
-
end
|
57
|
-
|
58
|
-
if klass == String
|
59
|
-
result = ''
|
60
|
-
io = StringIO.new(result, 'w')
|
61
|
-
rand(40).times { io.write(0x61 + rand(26)) }
|
62
|
-
io.close
|
63
|
-
elsif klass == Integer
|
64
|
-
result = rand(0xffffff)
|
65
|
-
elsif klass == Float
|
66
|
-
result = rand(0xffffff) * rand
|
67
|
-
elsif klass == TrueClass
|
68
|
-
result = true
|
69
|
-
elsif klass == FalseClass
|
70
|
-
result = false
|
71
|
-
elsif klass == Array
|
72
|
-
result = []
|
73
|
-
rand(10).times { result << random_value(nil, key_classes,depth+1) }
|
74
|
-
elsif klass == Hash
|
75
|
-
result = {}
|
76
|
-
if string_keys
|
77
|
-
key_type = String
|
78
|
-
else
|
79
|
-
key_type = RANDOM_KEY_CLASSES[rand(RANDOM_KEY_CLASSES.size)]
|
80
|
-
end
|
81
|
-
rand(10).times { result[random_value(key_type, key_classes, depth+1)] = random_value(nil, key_classes, depth+1) }
|
82
|
-
else
|
83
|
-
raise ArgumentError, "Unknown random value type #{klass}"
|
84
|
-
end
|
85
|
-
|
86
|
-
result
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
module RubyAppHelper
|
91
|
-
def ruby_app_root
|
92
|
-
@ruby_app_root ||= Dir.mktmpdir('right_support_cucumber_ruby')
|
93
|
-
end
|
94
|
-
|
95
|
-
def ruby_app_path(*args)
|
96
|
-
path = ruby_app_root
|
97
|
-
until args.empty?
|
98
|
-
item = args.shift
|
99
|
-
path = File.join(path, item)
|
100
|
-
end
|
101
|
-
path
|
102
|
-
end
|
103
|
-
|
104
|
-
# Run a shell command in app_dir, e.g. a rake task
|
105
|
-
def ruby_app_shell(cmd, options={})
|
106
|
-
ignore_errors = options[:ignore_errors] || false
|
107
|
-
log = !!(Cucumber.logger)
|
108
|
-
|
109
|
-
all_output = ''
|
110
|
-
Dir.chdir(ruby_app_root) do
|
111
|
-
Cucumber.logger.debug("bash> #{cmd}\n") if log
|
112
|
-
Bundler.with_clean_env do
|
113
|
-
IO.popen("#{cmd} 2>&1", 'r') do |output|
|
114
|
-
output.sync = true
|
115
|
-
done = false
|
116
|
-
until done
|
117
|
-
begin
|
118
|
-
line = output.readline + "\n"
|
119
|
-
all_output << line
|
120
|
-
Cucumber.logger.debug(line) if log
|
121
|
-
rescue EOFError
|
122
|
-
done = true
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
$?.success?.should(be_true) unless ignore_errors
|
130
|
-
all_output
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
module RightSupportWorld
|
135
|
-
include RandomValueHelper
|
136
|
-
include RubyAppHelper
|
137
|
-
end
|
138
|
-
|
139
|
-
# The Cucumber world
|
140
|
-
World(RightSupportWorld)
|
141
|
-
|
142
|
-
After do
|
143
|
-
FileUtils.rm_rf(ruby_app_root) if File.directory?(ruby_app_root)
|
144
|
-
end
|
145
|
-
|
146
|
-
class Object
|
147
|
-
include RandomValueHelper
|
148
|
-
end
|
data/right_support.rconf
DELETED
@@ -1,83 +0,0 @@
|
|
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
|
@@ -1,73 +0,0 @@
|
|
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
|
-
[true, false].each do |use_envelope|
|
11
|
-
context "given :envelope=>#{use_envelope} option" do
|
12
|
-
context '#sign' do
|
13
|
-
it 'computes a signature' do
|
14
|
-
signature = RightSupport::Crypto::SignedHash.
|
15
|
-
new(@data, :private_key=>@rsa_key, :envelope=>use_envelope).sign(@expires_at)
|
16
|
-
signature.should_not be_nil
|
17
|
-
|
18
|
-
RightSupport::Crypto::SignedHash.
|
19
|
-
new(@data, :public_key=>@rsa_key, :envelope=>use_envelope).
|
20
|
-
verify(signature, @expires_at).should be_true
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context '#verify' do
|
25
|
-
before(:each) do
|
26
|
-
@signature = RightSupport::Crypto::SignedHash.
|
27
|
-
new(@data, :private_key=>@rsa_key, :envelope=>use_envelope).
|
28
|
-
sign(@expires_at)
|
29
|
-
|
30
|
-
@hash = RightSupport::Crypto::SignedHash.
|
31
|
-
new(@data, :public_key=>@rsa_key, :envelope=>use_envelope)
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when the signature and data are good' do
|
35
|
-
it 'returns true' do
|
36
|
-
@hash.verify(@signature, @expires_at).should be_true
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'when expires_at is in the past' do
|
41
|
-
it 'returns false' do
|
42
|
-
@hash.verify(@signature, Time.at(@expires_at.to_i - 86400)).should be_false
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'when expires_at has been tampered with' do
|
47
|
-
it 'returns false' do
|
48
|
-
@hash.verify(@signature + 'xyzzy', @expires_at).should be_false
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'when the data is bad' do
|
53
|
-
before(:each) do
|
54
|
-
modified_data = @data.dup
|
55
|
-
modified_data[modified_data.keys.first] = 'gabba gabba hey!'
|
56
|
-
@modified_hash = RightSupport::Crypto::SignedHash.
|
57
|
-
new(modified_data, :public_key=>@rsa_key, :envelope=>use_envelope)
|
58
|
-
end
|
59
|
-
it 'returns false' do
|
60
|
-
@modified_hash.verify(@signature, @expires_at).should be_false
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'when the signature is bad' do
|
65
|
-
it 'returns false' do
|
66
|
-
@signature << 'xyzzy'
|
67
|
-
@hash.verify(@signature, @expires_at).should be_false
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|