warningshot 0.9.4
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.
- data/CHANGELOG +0 -0
- data/CONTRIBUTORS +2 -0
- data/LICENSE +22 -0
- data/README +101 -0
- data/Rakefile +28 -0
- data/TODO +148 -0
- data/bin/warningshot +19 -0
- data/bin/ws-stage.bat +3 -0
- data/bin/ws-stage.sh +3 -0
- data/images/warning_shot.png +0 -0
- data/images/warning_shot_sml.png +0 -0
- data/images/warningshot_green.png +0 -0
- data/images/warningshot_red.png +0 -0
- data/lib/core_ext/hash.rb +14 -0
- data/lib/core_ext/kernel.rb +8 -0
- data/lib/core_ext/object.rb +7 -0
- data/lib/core_ext/string.rb +5 -0
- data/lib/resolvers/core_lib_resolver.rb +76 -0
- data/lib/resolvers/directory_resolver.rb +31 -0
- data/lib/resolvers/file_resolver.rb +87 -0
- data/lib/resolvers/gem_resolver.rb +94 -0
- data/lib/resolvers/integrity_resolver.rb +69 -0
- data/lib/resolvers/manual_resolver.rb +19 -0
- data/lib/resolvers/permission_resolver.rb +72 -0
- data/lib/resolvers/symlink_resolver.rb +43 -0
- data/lib/resolvers/url_resolver.rb +76 -0
- data/lib/warning_shot/config.rb +132 -0
- data/lib/warning_shot/dependency_resolver.rb +155 -0
- data/lib/warning_shot/growl.rb +14 -0
- data/lib/warning_shot/logger.rb +27 -0
- data/lib/warning_shot/resolver.rb +542 -0
- data/lib/warning_shot/template_generator.rb +28 -0
- data/lib/warning_shot/version.rb +7 -0
- data/lib/warning_shot/warning_shot.rb +130 -0
- data/lib/warningshot.rb +16 -0
- data/tasks/gemspec.rb +48 -0
- data/tasks/rpsec.rb +58 -0
- data/tasks/yard.rb +4 -0
- data/templates/binaries.yml +26 -0
- data/templates/core_libs.yml +18 -0
- data/templates/directories.yml +23 -0
- data/templates/files.yml +18 -0
- data/templates/gems.yml +26 -0
- data/templates/manual.yml +29 -0
- data/templates/mounts.yml +8 -0
- data/templates/permissions.yml +31 -0
- data/templates/symlinks.yml +30 -0
- data/templates/urls.yml +21 -0
- data/test/data/mock.yaml +16 -0
- data/test/data/mock.yml +10 -0
- data/test/data/mock_resolver.rb +16 -0
- data/test/data/permission_test.txt +1 -0
- data/test/data/resolvers/file/src/that.txt +1 -0
- data/test/log/warningshot.log +643 -0
- data/test/spec/spec.opts.zoiks +0 -0
- data/test/spec/spec_helper.rb +11 -0
- data/test/spec/unit/resolvers/core_lib_resolver_spec.rb +39 -0
- data/test/spec/unit/resolvers/directory_resolver_spec.rb +39 -0
- data/test/spec/unit/resolvers/file_resolver_spec.rb +134 -0
- data/test/spec/unit/resolvers/gem_resolver_spec.rb +74 -0
- data/test/spec/unit/resolvers/integrity_resolver_spec.rb +103 -0
- data/test/spec/unit/resolvers/manual_resolver_spec.rb +17 -0
- data/test/spec/unit/resolvers/permission_resolver_spec.rb +56 -0
- data/test/spec/unit/resolvers/symlink_resolver_spec.rb +44 -0
- data/test/spec/unit/resolvers/url_resolver_spec.rb +64 -0
- data/test/spec/unit/warning_shot/config_spec.rb +35 -0
- data/test/spec/unit/warning_shot/dependency_resolver_spec.rb +43 -0
- data/test/spec/unit/warning_shot/resolver_spec.rb +347 -0
- data/test/spec/unit/warning_shot/template_generator_spec.rb +21 -0
- data/test/spec/unit/warning_shot/version_spec.rb +7 -0
- data/test/spec/unit/warning_shot/warning_shot_spec.rb +3 -0
- metadata +143 -0
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'lib/warningshot'
|
2
|
+
|
3
|
+
$test_data = "." / "test" / "data"
|
4
|
+
$log_root = "." / "test" / "log"
|
5
|
+
$log_file = $log_root / 'warningshot.log'
|
6
|
+
|
7
|
+
FileUtils.mkdir_p $log_root
|
8
|
+
|
9
|
+
$logger = Logger.new $log_file
|
10
|
+
$logger.formatter = WarningShot::LoggerFormatter.new
|
11
|
+
$logger.level = Logger::DEBUG
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "." / "lib" / "resolvers" / "core_lib_resolver"
|
2
|
+
|
3
|
+
describe WarningShot::CoreLibResolver do
|
4
|
+
before :all do
|
5
|
+
WarningShot::CoreLibResolver.logger = $logger
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
it 'should have tests registered' do
|
10
|
+
WarningShot::CoreLibResolver.tests.empty?.should be(false)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should not have resolutions registered' do
|
14
|
+
WarningShot::CoreLibResolver.resolutions.empty?.should be(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should increment #errors for unloadable core libs' do
|
18
|
+
cld = WarningShot::CoreLibResolver.new 'bogus_core_lib_name'
|
19
|
+
cld.test!
|
20
|
+
|
21
|
+
cld.failed.length.should be(1)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should be able to unload file references from $"' do
|
25
|
+
@originals = $".clone
|
26
|
+
require 'observer'
|
27
|
+
WarningShot::CoreLibResolver.unload(($" - @originals))
|
28
|
+
require('observer').should be(true)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should be able to purge classes from memory' do
|
32
|
+
@original_classes = Symbol.all_symbols
|
33
|
+
WarningShot::CoreLibResolver.purge true
|
34
|
+
require 'observer'
|
35
|
+
WarningShot::CoreLibResolver.purge_classes((Symbol.all_symbols - @original_classes))
|
36
|
+
defined?(Observer).should be(nil)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "." / "lib" / "resolvers" / "directory_resolver"
|
2
|
+
|
3
|
+
describe WarningShot::DirectoryResolver do
|
4
|
+
before :all do
|
5
|
+
WarningShot::DirectoryResolver.logger = $logger
|
6
|
+
|
7
|
+
@@base_path = File.expand_path("." / "test" / "data" / "resolvers" / "directory")
|
8
|
+
end
|
9
|
+
|
10
|
+
after :each do
|
11
|
+
FileUtils.rm_rf @@base_path
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have tests registered' do
|
15
|
+
WarningShot::DirectoryResolver.tests.empty?.should be(false)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have resolutions registered' do
|
19
|
+
WarningShot::DirectoryResolver.resolutions.empty?.should be(false)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'with resolutions enabled & with resolution instructions' do
|
23
|
+
|
24
|
+
it 'should create the directory if it does not exist' do
|
25
|
+
control_dir = File.expand_path('.')
|
26
|
+
test_dir1 = @@base_path / 'test1'
|
27
|
+
test_dir2 = @@base_path / 'test2'
|
28
|
+
resolver = WarningShot::DirectoryResolver.new control_dir,test_dir1, test_dir2
|
29
|
+
resolver.test!
|
30
|
+
resolver.passed.length.should be(1)
|
31
|
+
resolver.failed.length.should be(2)
|
32
|
+
|
33
|
+
resolver.resolve!
|
34
|
+
resolver.resolved.length.should be(2)
|
35
|
+
File.directory?(test_dir1).should be(true)
|
36
|
+
File.directory?(test_dir2).should be(true)
|
37
|
+
end
|
38
|
+
end # End healing enabled, instructions provided
|
39
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require "." / "lib" / "resolvers" / "file_resolver"
|
2
|
+
|
3
|
+
describe WarningShot::FileResolver do
|
4
|
+
before :all do
|
5
|
+
WarningShot::FileResolver.logger = $logger
|
6
|
+
|
7
|
+
@@base_path = File.expand_path("." / "test" / "data" / "resolvers" / "file")
|
8
|
+
@@source_path = @@base_path / 'src'
|
9
|
+
@@dest_path = @@base_path / 'dest'
|
10
|
+
FileUtils.mkdir_p @@dest_path
|
11
|
+
end
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
FileUtils.mkdir_p @@dest_path
|
15
|
+
end
|
16
|
+
|
17
|
+
after :each do
|
18
|
+
FileUtils.rm_rf @@dest_path
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have tests registered' do
|
22
|
+
WarningShot::FileResolver.tests.empty?.should be(false)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have resolutions regsitered' do
|
26
|
+
WarningShot::FileResolver.resolutions.empty?.should be(false)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should treate relative paths as from directory specified by WarningShot::Config[:application]' do
|
30
|
+
pending
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'with healing enabled' do
|
34
|
+
describe 'with heal instructions' do
|
35
|
+
describe 'file does not exist' do
|
36
|
+
it 'should add failed dependencies to #failed' do
|
37
|
+
that_file = @@source_path / 'that.txt'
|
38
|
+
this_file = @@dest_path / 'this.txt'
|
39
|
+
|
40
|
+
fd = WarningShot::FileResolver.new({:source => "file://#{that_file}",:target => this_file})
|
41
|
+
fd.test!
|
42
|
+
|
43
|
+
fd.failed.length.should be(1)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should heal a file from file://' do
|
47
|
+
that_file = @@source_path / 'that.txt'
|
48
|
+
this_file = @@dest_path / 'this.txt'
|
49
|
+
|
50
|
+
fd = WarningShot::FileResolver.new({:source => "file://#{that_file}",:target => this_file})
|
51
|
+
fd.test!
|
52
|
+
fd.failed.length.should be(1)
|
53
|
+
fd.resolve!
|
54
|
+
fd.resolved.length.should be(1)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should heal a file from http://' do
|
58
|
+
fd = WarningShot::FileResolver.new({:source => "http://www.example.com/",:target => (@@dest_path / 'internetz.html')})
|
59
|
+
fd.test!
|
60
|
+
fd.failed.length.should be(1)
|
61
|
+
fd.resolve!
|
62
|
+
fd.resolved.length.should be(1)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should be able to verify the root ca and peer when healing over https' do
|
66
|
+
pending
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should not increment #resolved if the resolution fails' do
|
70
|
+
fd = WarningShot::FileResolver.new({:source => "http://www.example.com/DOESNT.EXIST",:target => (@@dest_path / 'doesnt_exist.html')})
|
71
|
+
fd.test!
|
72
|
+
fd.failed.length.should be(1)
|
73
|
+
fd.resolve!
|
74
|
+
fd.failed.length.should_not be(2)
|
75
|
+
end
|
76
|
+
end # End healing enabled, instructions provided, file does not exists
|
77
|
+
end # End healing enabled, instructions provided
|
78
|
+
|
79
|
+
describe 'without heal instructions' do
|
80
|
+
it 'should be able to return unresolved dependencies' do
|
81
|
+
this_file = @@dest_path / 'this.txt'
|
82
|
+
|
83
|
+
fd = WarningShot::FileResolver.new({:target => this_file})
|
84
|
+
fd.test!
|
85
|
+
fd.resolve!
|
86
|
+
fd.unresolved.length.should be(1)
|
87
|
+
|
88
|
+
fd = WarningShot::FileResolver.new this_file
|
89
|
+
fd.test!
|
90
|
+
fd.resolve!
|
91
|
+
fd.unresolved.length.should be(1)
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'file does not exist' do
|
95
|
+
it 'should add dependency to #failed' do
|
96
|
+
this_file = @@dest_path / 'this.txt'
|
97
|
+
|
98
|
+
fd = WarningShot::FileResolver.new({:target => this_file})
|
99
|
+
fd.test!
|
100
|
+
fd.failed.length.should be(1)
|
101
|
+
fd.resolve!
|
102
|
+
fd.unresolved.length.should be(1)
|
103
|
+
end
|
104
|
+
end # End healing enabled, instructions not provided, file does not exists
|
105
|
+
end # End healing enabled, instructions not provided
|
106
|
+
end # End healing enabled
|
107
|
+
|
108
|
+
describe 'with healing disabled' do
|
109
|
+
describe 'with heal instructions' do
|
110
|
+
describe 'file does not exist' do
|
111
|
+
it 'should add dependency to #failed' do
|
112
|
+
that_file = @@source_path / 'that.txt'
|
113
|
+
this_file = @@dest_path / 'this.txt'
|
114
|
+
|
115
|
+
fd = WarningShot::FileResolver.new({:target => this_file,:source => that_file})
|
116
|
+
fd.test!
|
117
|
+
fd.failed.length.should be(1)
|
118
|
+
end
|
119
|
+
end # End healing disabled, instructions provided, file does not exists
|
120
|
+
end
|
121
|
+
|
122
|
+
describe 'without heal instructions' do
|
123
|
+
describe 'file does not exist' do
|
124
|
+
it 'should add dependency to #failed' do
|
125
|
+
this_file = @@dest_path / 'this.txt'
|
126
|
+
|
127
|
+
fd = WarningShot::FileResolver.new({:target => this_file})
|
128
|
+
fd.test!
|
129
|
+
fd.failed.length.should be(1)
|
130
|
+
end
|
131
|
+
end # End healing disabled, instructions not provided, file does not exists
|
132
|
+
end # End healing disabled, instructions not provided
|
133
|
+
end # End healing disabled
|
134
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#Note, this fails if the gem yard is already installed, which sucks. Waiting on rubyforge to
|
2
|
+
# approve ws-dummy gem
|
3
|
+
|
4
|
+
require "." / "lib" / "resolvers" / "gem_resolver"
|
5
|
+
require 'fileutils'
|
6
|
+
describe WarningShot::GemResolver do
|
7
|
+
before :all do
|
8
|
+
WarningShot::GemResolver.logger = $logger
|
9
|
+
|
10
|
+
FileUtils.rm_rf "./test/output/gems"
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
FileUtils.rm_rf "./test/output/gems"
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have tests registered' do
|
18
|
+
WarningShot::GemResolver.tests.empty?.should be(false)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have resolutions registered' do
|
22
|
+
WarningShot::GemResolver.resolutions.empty?.should be(false)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should provide the command line option gem_path' do
|
26
|
+
WarningShot.parser.to_s.include?("Alternate gem path ':' separated to check. First in path is where gems will be installed").should be(true)
|
27
|
+
WarningShot::Config.configuration.key?(:gem_path).should be(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should provide the command line option minigems' do
|
31
|
+
WarningShot.parser.to_s.include?("Not supported yet.").should be(true)
|
32
|
+
WarningShot::Config.configuration.key?(:minigems).should be(true)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should override Gem.path if gem_path is given' do
|
36
|
+
WarningShot::Config.configuration[:gem_path] = "./test/output/gems:./test/outputs/gems2"
|
37
|
+
WarningShot::GemResolver.load_paths
|
38
|
+
|
39
|
+
Gem.path[0].should == "./test/output/gems"
|
40
|
+
Gem.path[1].should == "./test/outputs/gems2"
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should be able to determine if a gem is installed' do
|
44
|
+
resolver = WarningShot::GemResolver.new({:name => "rake"},{:name => "rspec",:version => ">=1.1.4"})
|
45
|
+
resolver.test!
|
46
|
+
|
47
|
+
resolver.passed.size.should be(2)
|
48
|
+
end
|
49
|
+
|
50
|
+
# The gem name is the healing instructions, so if its provide, there
|
51
|
+
# are instructions
|
52
|
+
it 'should install the gems when healing is enabled' do
|
53
|
+
resolver = WarningShot::GemResolver.new({:name => "yard"})
|
54
|
+
resolver.test!
|
55
|
+
|
56
|
+
resolver.failed.size.should be(1)
|
57
|
+
|
58
|
+
resolver.resolve!
|
59
|
+
resolver.resolved.size.should be(1)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should check for gems in --gempath when specified' do
|
63
|
+
pending
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should install gems in --gempath when specified and resolving' do
|
67
|
+
pending
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should use warningshot_dummy instead of the gems listed above' do
|
71
|
+
#it should also uninstall it before :all and after :all
|
72
|
+
pending
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require "." / "lib" / "resolvers" / "integrity_resolver"
|
2
|
+
|
3
|
+
describe WarningShot::IntegrityResolver do
|
4
|
+
before :all do
|
5
|
+
WarningShot::IntegrityResolver.logger = $logger
|
6
|
+
|
7
|
+
@@base_path = File.expand_path("." / "test" / "data" / "resolvers" / "file")
|
8
|
+
@@source_path = @@base_path / 'src'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have tests registered' do
|
12
|
+
WarningShot::IntegrityResolver.tests.empty?.should be(false)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should not have resolutions registered' do
|
16
|
+
WarningShot::IntegrityResolver.resolutions.empty?.should be(true)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should be able to verify a sha1 digest' do
|
20
|
+
|
21
|
+
that_file = @@source_path / 'that.txt'
|
22
|
+
#These values are flipped from FileResolverRspec so that we dont
|
23
|
+
# have to resolve the file dependency to check the integrity
|
24
|
+
resolver = WarningShot::IntegrityResolver.new({
|
25
|
+
:target => "file://#{that_file}",
|
26
|
+
:source => "",
|
27
|
+
:sha1 => "e87c9091b6f6d30d1a05d66de1acbac6e1998121"
|
28
|
+
})
|
29
|
+
|
30
|
+
resolver.test!
|
31
|
+
resolver.failed.length.should be(0)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should be able to determine if a sha1 digest is wrong' do
|
35
|
+
that_file = @@source_path / 'that.txt'
|
36
|
+
#These values are flipped from FileResolverRspec so that we dont
|
37
|
+
# have to resolve the file dependency to check the integrity
|
38
|
+
resolver = WarningShot::IntegrityResolver.new({
|
39
|
+
:target => "file://#{that_file}",
|
40
|
+
:source => "",
|
41
|
+
:sha1 => "WRONG"
|
42
|
+
})
|
43
|
+
|
44
|
+
resolver.test!
|
45
|
+
resolver.failed.length.should be(1)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should be able to determine if an md5 digest is wrong' do
|
49
|
+
that_file = @@source_path / 'that.txt'
|
50
|
+
#These values are flipped from FileResolverRspec so that we dont
|
51
|
+
# have to resolve the file dependency to check the integrity
|
52
|
+
resolver = WarningShot::IntegrityResolver.new({
|
53
|
+
:target => "file://#{that_file}",
|
54
|
+
:source => "",
|
55
|
+
:md5 => "WRONG"
|
56
|
+
})
|
57
|
+
|
58
|
+
resolver.test!
|
59
|
+
resolver.failed.length.should be(1)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should be able to verify a md5 digest' do
|
63
|
+
that_file = @@source_path / 'that.txt'
|
64
|
+
#These values are flipped from FileResolverRspec so that we dont
|
65
|
+
# have to resolve the file dependency to check the integrity
|
66
|
+
resolver = WarningShot::IntegrityResolver.new({
|
67
|
+
:target => "file://#{that_file}",
|
68
|
+
:source => "",
|
69
|
+
:md5 => "db59da6066bab8885569c012b1f6b173"
|
70
|
+
})
|
71
|
+
|
72
|
+
resolver.test!
|
73
|
+
resolver.failed.length.should be(0)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should use sha1 if md5 and sha1 are given' do
|
77
|
+
that_file = @@source_path / 'that.txt'
|
78
|
+
#These values are flipped from FileResolverRspec so that we dont
|
79
|
+
# have to resolve the file dependency to check the integrity
|
80
|
+
resolver = WarningShot::IntegrityResolver.new({
|
81
|
+
:target => "file://#{that_file}",
|
82
|
+
:source => "",
|
83
|
+
:md5 => "WRONG",
|
84
|
+
:sha1 => "e87c9091b6f6d30d1a05d66de1acbac6e1998121"
|
85
|
+
})
|
86
|
+
|
87
|
+
resolver.test!
|
88
|
+
resolver.failed.length.should be(0)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should be silent if a digest isnt given' do
|
92
|
+
that_file = @@source_path / 'that.txt'
|
93
|
+
#These values are flipped from FileResolverRspec so that we dont
|
94
|
+
# have to resolve the file dependency to check the integrity
|
95
|
+
resolver = WarningShot::IntegrityResolver.new({
|
96
|
+
:target => "file://#{that_file}",
|
97
|
+
:source => ""
|
98
|
+
})
|
99
|
+
|
100
|
+
resolver.test!
|
101
|
+
resolver.failed.length.should be(0)
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "." / "lib" / "resolvers" / "manual_resolver"
|
2
|
+
|
3
|
+
describe WarningShot::ManualResolver do
|
4
|
+
before :all do
|
5
|
+
WarningShot::ManualResolver.logger = $logger
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have tests registered' do
|
9
|
+
WarningShot::ManualResolver.tests.empty?.should be(false)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have resolutions registered' do
|
13
|
+
WarningShot::ManualResolver.resolutions.empty?.should be(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
#Does this need any further test?
|
17
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require '.' / 'lib' / 'resolvers' / 'permission_resolver'
|
2
|
+
|
3
|
+
describe WarningShot::PermissionResolver do
|
4
|
+
before :all do
|
5
|
+
WarningShot::PermissionResolver.logger = $logger
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have tests registered' do
|
9
|
+
WarningShot::PermissionResolver.tests.empty?.should be(false)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have resolutions registered' do
|
13
|
+
WarningShot::PermissionResolver.resolutions.empty?.should be(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should be able to determine if the user permission is correct' do
|
17
|
+
_file = $test_data / 'permission_test.txt'
|
18
|
+
_file2 = $test_data / 'permission_test.fake'
|
19
|
+
|
20
|
+
resolver = WarningShot::PermissionResolver.new({
|
21
|
+
:path => _file, :mode => '0755',
|
22
|
+
:user => 'www-data', :group => 'www-data',
|
23
|
+
:recursive => "none"
|
24
|
+
})
|
25
|
+
|
26
|
+
resolver2 = WarningShot::PermissionResolver.new({
|
27
|
+
:path => _file2, :mode => '0755',
|
28
|
+
:user => 'www-data', :group => 'www-data',
|
29
|
+
:recursive => "none"
|
30
|
+
})
|
31
|
+
|
32
|
+
pending
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should be able to determine if the group permission is correct' do
|
36
|
+
pending
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should be able to determine if the mode is correct' do
|
40
|
+
pending
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'with healing enabled and with healing instructions' do
|
44
|
+
it 'should be able to correct the user' do
|
45
|
+
pending
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should be able to correct the group' do
|
49
|
+
pending
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should be able to correct the mode' do
|
53
|
+
pending
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "." / "lib" / "resolvers" / "symlink_resolver"
|
2
|
+
|
3
|
+
describe WarningShot::SymlinkResolver do
|
4
|
+
before :all do
|
5
|
+
WarningShot::SymlinkResolver.logger = $logger
|
6
|
+
|
7
|
+
@@data_path = File.expand_path("." / "test" / "data")
|
8
|
+
@@base_path = File.expand_path("." / "test" / "data" / "resolvers" / "symlink")
|
9
|
+
end
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
FileUtils.mkdir_p @@base_path
|
13
|
+
end
|
14
|
+
|
15
|
+
after :each do
|
16
|
+
FileUtils.rm_rf @@base_path
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should have tests registered' do
|
20
|
+
WarningShot::SymlinkResolver.tests.empty?.should be(false)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have resolutions registered' do
|
24
|
+
WarningShot::SymlinkResolver.resolutions.empty?.should be(false)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'with healing enabled & with heal instructions' do
|
28
|
+
it 'should create a symlink' do
|
29
|
+
|
30
|
+
symlink_dep = {
|
31
|
+
:source => @@data_path / 'mock_resolver.rb',
|
32
|
+
:target => @@base_path / 'linked_mock_resolver.rb'
|
33
|
+
}
|
34
|
+
resolver = WarningShot::SymlinkResolver.new symlink_dep
|
35
|
+
|
36
|
+
resolver.test!
|
37
|
+
resolver.failed.length.should be(1)
|
38
|
+
resolver.resolve!
|
39
|
+
resolver.resolved.length.should be(1)
|
40
|
+
|
41
|
+
File.symlink?(symlink_dep[:target]).should be(true)
|
42
|
+
end
|
43
|
+
end # End healing enabled, instructions provided
|
44
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require '.' / 'lib' / 'resolvers' / 'url_resolver'
|
2
|
+
|
3
|
+
describe WarningShot::UrlResolver do
|
4
|
+
before :all do
|
5
|
+
WarningShot::UrlResolver.logger = $logger
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have tests registered' do
|
9
|
+
WarningShot::UrlResolver.tests.empty?.should be(false)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have resolutions registered' do
|
13
|
+
WarningShot::UrlResolver.resolutions.empty?.should be(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should extend the command line interface' do
|
17
|
+
WarningShot.parser.to_s.include?("Success is only for 200 instead of 2xx").should be(true)
|
18
|
+
WarningShot.parser.to_s.include?("SSL Verify Peer Depth").should be(true)
|
19
|
+
WarningShot.parser.to_s.include?("Path to root ca certificate").should be(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should be able to determine if an http address is reachable' do
|
23
|
+
resolver = WarningShot::UrlResolver.new "http://example.com"
|
24
|
+
resolver.test!
|
25
|
+
resolver.failed.length.should be(0)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should be able to determine if an https address is reachable' do
|
29
|
+
#Yeah, what https page to use, huh?
|
30
|
+
resolver = WarningShot::UrlResolver.new "https://www.google.com/analytics/home/"
|
31
|
+
resolver.test!
|
32
|
+
resolver.failed.length.should be(0)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should be able to determine if an http address is unreachable' do
|
36
|
+
resolver = WarningShot::UrlResolver.new "http://example.com", "http://127.0.0.1:31337"
|
37
|
+
resolver.test!
|
38
|
+
resolver.failed.length.should be(1)
|
39
|
+
resolver.passed.length.should be(1)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should be able to determine if an https address is unreachable' do
|
43
|
+
resolver = WarningShot::UrlResolver.new "https://www.google.com/analytics/home/", "https://127.0.0.1:31337"
|
44
|
+
resolver.test!
|
45
|
+
resolver.failed.length.should be(1)
|
46
|
+
resolver.passed.length.should be(1)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should be able to receive --strict from the command line' do
|
50
|
+
WarningShot::Config.configuration[:url_strict] = true
|
51
|
+
WarningShot::Config.configuration[:url_strict].should be(true)
|
52
|
+
|
53
|
+
#google redirects, ever heard of no-www.org?
|
54
|
+
resolver = WarningShot::UrlResolver.new "http://example.com","http://google.com"
|
55
|
+
|
56
|
+
resolver.test!
|
57
|
+
resolver.failed.length.should be(1)
|
58
|
+
resolver.passed.length.should be(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should be able to verify CA certificate and peer' do
|
62
|
+
pending
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
describe WarningShot::Config do
|
2
|
+
|
3
|
+
it 'should provide access to configuration' do
|
4
|
+
WarningShot::Config.respond_to? :configuration
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'should be able to parse an ARGV string' do
|
8
|
+
args = ['--no-verbose','--resolve','--environment=rspec_test','-g','-aRspecTest']
|
9
|
+
WarningShot::Config.parse_args(args)
|
10
|
+
WarningShot::Config.configuration[:verbose].should be(false)
|
11
|
+
WarningShot::Config.configuration[:resolve].should be(true)
|
12
|
+
WarningShot::Config.configuration[:environment].should == 'rspec_test'
|
13
|
+
WarningShot::Config.configuration[:growl].should be(true)
|
14
|
+
WarningShot::Config.configuration[:application].should == 'RspecTest'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should provide defaults' do
|
18
|
+
WarningShot::Config.defaults.class.should be(Hash)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should allow access like a hash' do
|
22
|
+
WarningShot::Config.respond_to?(:[]).should be(true)
|
23
|
+
WarningShot::Config.respond_to?(:[]=).should be(true)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should allow configurations to be changed with a block' do
|
27
|
+
WarningShot::Config.use do|c|
|
28
|
+
c[:growl] = true
|
29
|
+
c[:resolve]= true
|
30
|
+
end
|
31
|
+
|
32
|
+
WarningShot::Config[:growl].should be(true)
|
33
|
+
WarningShot::Config[:resolve].should be(true)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
describe WarningShot::DependencyResolver do
|
2
|
+
before :all do
|
3
|
+
@config = {
|
4
|
+
:config_paths => [$test_data],
|
5
|
+
:environment => 'rspec',
|
6
|
+
:log_path => $log_file
|
7
|
+
}
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should accept a glob to find config files' do
|
12
|
+
# Consider taking a glob instead of a set of paths
|
13
|
+
pending
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should create a dependency tree from a set of config files' do
|
17
|
+
@config = {
|
18
|
+
:config_paths => [$test_data],
|
19
|
+
:environment => 'rspec',
|
20
|
+
:log_path => $log_file
|
21
|
+
}
|
22
|
+
|
23
|
+
dr = WarningShot::DependencyResolver.new(@config)
|
24
|
+
|
25
|
+
dr.dependency_tree[:mock].empty?.should be(false)
|
26
|
+
dr.dependency_tree[:mock].class.should be(Array)
|
27
|
+
dr.dependency_tree[:mock].size.should == 10
|
28
|
+
|
29
|
+
dr.dependency_tree.key?(:faux).should be(true)
|
30
|
+
dr.dependency_tree[:faux].empty?.should be(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should respond to #stats' do
|
34
|
+
dr = WarningShot::DependencyResolver.new(@config)
|
35
|
+
dr.respond_to?(:stats).should be(true)
|
36
|
+
dr.stats.class.should be(Hash)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should be able to run a set of resolvers' do
|
40
|
+
pending
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|