puppet-lint 0.4.0.pre1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -4
- data/Gemfile +2 -5
- data/README.md +2 -149
- data/Rakefile +0 -5
- data/lib/puppet-lint.rb +74 -20
- data/lib/puppet-lint/bin.rb +20 -85
- data/lib/puppet-lint/checkplugin.rb +158 -12
- data/lib/puppet-lint/checks.rb +39 -222
- data/lib/puppet-lint/configuration.rb +12 -31
- data/lib/puppet-lint/data.rb +329 -0
- data/lib/puppet-lint/lexer.rb +37 -30
- data/lib/puppet-lint/lexer/token.rb +14 -16
- data/lib/puppet-lint/monkeypatches/string_prepend.rb +6 -0
- data/lib/puppet-lint/optparser.rb +105 -0
- data/lib/puppet-lint/plugins.rb +28 -9
- data/lib/puppet-lint/plugins/check_classes.rb +162 -238
- data/lib/puppet-lint/plugins/check_comments.rb +40 -25
- data/lib/puppet-lint/plugins/check_conditionals.rb +16 -20
- data/lib/puppet-lint/plugins/check_documentation.rb +14 -20
- data/lib/puppet-lint/plugins/check_nodes.rb +23 -0
- data/lib/puppet-lint/plugins/check_resources.rb +127 -141
- data/lib/puppet-lint/plugins/check_strings.rb +133 -107
- data/lib/puppet-lint/plugins/check_variables.rb +11 -11
- data/lib/puppet-lint/plugins/check_whitespace.rb +86 -92
- data/lib/puppet-lint/tasks/puppet-lint.rb +17 -1
- data/lib/puppet-lint/version.rb +1 -1
- data/puppet-lint.gemspec +4 -2
- data/spec/fixtures/test/manifests/ignore.pp +1 -0
- data/spec/fixtures/test/manifests/ignore_reason.pp +1 -0
- data/spec/puppet-lint/bin_spec.rb +104 -84
- data/spec/puppet-lint/configuration_spec.rb +19 -19
- data/spec/puppet-lint/ignore_overrides_spec.rb +97 -0
- data/spec/puppet-lint/lexer/token_spec.rb +9 -9
- data/spec/puppet-lint/lexer_spec.rb +352 -325
- data/spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +77 -23
- data/spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +14 -12
- data/spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +18 -14
- data/spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +30 -30
- data/spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +31 -26
- data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +34 -28
- data/spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +14 -12
- data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +74 -30
- data/spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb +27 -20
- data/spec/puppet-lint/plugins/check_comments/star_comments_spec.rb +78 -13
- data/spec/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +17 -12
- data/spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +13 -10
- data/spec/puppet-lint/plugins/check_documentation/documentation_spec.rb +21 -16
- data/spec/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +69 -0
- data/spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +42 -38
- data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +22 -10
- data/spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +81 -18
- data/spec/puppet-lint/plugins/check_resources/file_mode_spec.rb +69 -112
- data/spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +27 -20
- data/spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +177 -171
- data/spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +165 -88
- data/spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +97 -22
- data/spec/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +25 -0
- data/spec/puppet-lint/plugins/check_strings/quoted_booleans_spec.rb +97 -111
- data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +10 -9
- data/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +53 -53
- data/spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +26 -14
- data/spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +10 -9
- data/spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb +31 -15
- data/spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +340 -322
- data/spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +30 -23
- data/spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +42 -41
- data/spec/puppet-lint_spec.rb +3 -3
- data/spec/spec_helper.rb +109 -116
- metadata +109 -50
- data/spec/puppet-lint/plugins/check_classes/class_parameter_defaults_spec.rb +0 -60
@@ -1,16 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'documentation' do
|
4
|
+
let(:class_msg) { 'class not documented' }
|
5
|
+
let(:define_msg) { 'defined type not documented' }
|
6
|
+
|
4
7
|
describe 'undocumented class' do
|
5
8
|
let(:code) { "class test {}" }
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
})
|
10
|
+
it 'should only detect a single problem' do
|
11
|
+
expect(problems).to have(1).problem
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should create a warning' do
|
15
|
+
expect(problems).to contain_warning(class_msg).on_line(1).in_column(1)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
@@ -20,19 +22,20 @@ describe 'documentation' do
|
|
20
22
|
class test {}
|
21
23
|
"}
|
22
24
|
|
23
|
-
|
25
|
+
it 'should not detect any problems' do
|
26
|
+
expect(problems).to have(0).problems
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
describe 'undocumented defined type' do
|
27
31
|
let(:code) { "define test {}" }
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
})
|
33
|
+
it 'should only detect a single problem' do
|
34
|
+
expect(problems).to have(1).problem
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should create a warning' do
|
38
|
+
expect(problems).to contain_warning(define_msg).on_line(1).in_column(1)
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
@@ -42,6 +45,8 @@ describe 'documentation' do
|
|
42
45
|
define test {}
|
43
46
|
"}
|
44
47
|
|
45
|
-
|
48
|
+
it 'should not detect any problems' do
|
49
|
+
expect(problems).to have(0).problems
|
50
|
+
end
|
46
51
|
end
|
47
52
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'unquoted_node_name' do
|
4
|
+
let(:msg) { 'unquoted node name found' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'unquoted node name' do
|
8
|
+
let(:code) { "node foo { }" }
|
9
|
+
|
10
|
+
it 'should only detect a single problem' do
|
11
|
+
expect(problems).to have(1).problem
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should create a warning' do
|
15
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(6)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'default node' do
|
20
|
+
let(:code) { "node default { }" }
|
21
|
+
|
22
|
+
it 'should not detect any problems' do
|
23
|
+
expect(problems).to have(0).problems
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'single quoted node name' do
|
28
|
+
let(:code) { "node 'foo' { }" }
|
29
|
+
|
30
|
+
it 'should not detect any problems' do
|
31
|
+
expect(problems).to have(0).problems
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'regex node name' do
|
36
|
+
let(:code) { "node /foo/ { }" }
|
37
|
+
|
38
|
+
it 'should not detect any problems' do
|
39
|
+
expect(problems).to have(0).problems
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with fix enabled' do
|
45
|
+
before do
|
46
|
+
PuppetLint.configuration.fix = true
|
47
|
+
end
|
48
|
+
|
49
|
+
after do
|
50
|
+
PuppetLint.configuration.fix = false
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'unquoted node name' do
|
54
|
+
let(:code) { "node foo { }" }
|
55
|
+
|
56
|
+
it 'should only detect a single problem' do
|
57
|
+
expect(problems).to have(1).problem
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should fix the manifest' do
|
61
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(6)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should quote the node name' do
|
65
|
+
expect(manifest).to eq("node 'foo' { }")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'duplicate_params' do
|
4
|
-
|
4
|
+
let(:msg) { 'duplicate parameter found in resource' }
|
5
|
+
|
6
|
+
context 'resource with duplicate parameters' do
|
5
7
|
let(:code) { "
|
6
8
|
file { '/tmp/foo':
|
7
9
|
ensure => present,
|
@@ -11,17 +13,17 @@ describe 'duplicate_params' do
|
|
11
13
|
}"
|
12
14
|
}
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
16
|
+
it 'should only detect a single problem' do
|
17
|
+
expect(problems).to have(1).problem
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should create an error' do
|
21
|
+
expect(problems).to contain_error(msg).on_line(6).in_column(9)
|
22
|
+
end
|
22
23
|
end
|
23
|
-
|
24
|
-
|
24
|
+
|
25
|
+
context 'bug #145: resource with a hash and no duplicate parameters' do
|
26
|
+
let(:code) { "
|
25
27
|
class {'fooname':
|
26
28
|
hashes => [
|
27
29
|
{ foo => 'bar01',},
|
@@ -29,13 +31,14 @@ describe 'duplicate_params' do
|
|
29
31
|
],
|
30
32
|
}"
|
31
33
|
}
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
|
35
|
+
it 'should not detect any errors' do
|
36
|
+
expect(problems).to have(0).problems
|
37
|
+
end
|
35
38
|
end
|
36
39
|
|
37
|
-
|
38
|
-
let
|
40
|
+
context 'bug #145: resource with a hash and duplicate parameters in subhash' do
|
41
|
+
let(:code) { "
|
39
42
|
class {'fooname':
|
40
43
|
hashes => [
|
41
44
|
{ foo => 'bar01',
|
@@ -43,18 +46,18 @@ describe 'duplicate_params' do
|
|
43
46
|
],
|
44
47
|
}"
|
45
48
|
}
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
|
50
|
+
it 'should only detect a single error' do
|
51
|
+
expect(problems).to have(1).problem
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should create an error' do
|
55
|
+
expect(problems).to contain_error(msg).on_line(5).in_column(13)
|
56
|
+
end
|
54
57
|
end
|
55
58
|
|
56
|
-
|
57
|
-
let
|
59
|
+
context 'bug #145: resource with a hash and duplicate parameters in parent type' do
|
60
|
+
let(:code) { "
|
58
61
|
class {'fooname':
|
59
62
|
hashes => [
|
60
63
|
{ foo => 'bar01', },
|
@@ -64,25 +67,26 @@ describe 'duplicate_params' do
|
|
64
67
|
hashes => 'dupe',
|
65
68
|
}"
|
66
69
|
}
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
|
71
|
+
it 'should only detect a single problem' do
|
72
|
+
expect(problems).to have(1).problem
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should create an error' do
|
76
|
+
expect(problems).to contain_error(msg).on_line(8).in_column(9)
|
77
|
+
end
|
75
78
|
end
|
79
|
+
|
76
80
|
describe 'bug #145: more hash tests and no duplicate parameters' do
|
77
|
-
let
|
81
|
+
let(:code) { "
|
78
82
|
class test {
|
79
83
|
$foo = { param => 'value', }
|
80
84
|
$bar = { param => 'bar', }
|
81
85
|
}"
|
82
86
|
}
|
83
|
-
its (:problems) {
|
84
|
-
should be_empty
|
85
|
-
}
|
86
87
|
|
88
|
+
it 'should not detect any problems' do
|
89
|
+
expect(problems).to have(0).problems
|
90
|
+
end
|
87
91
|
end
|
88
92
|
end
|
@@ -1,23 +1,29 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'ensure_first_param' do
|
4
|
-
|
4
|
+
let(:msg) { "ensure found on line but it's not the first attribute" }
|
5
|
+
|
6
|
+
context 'ensure as only attr in a single line resource' do
|
5
7
|
let(:code) { "file { 'foo': ensure => present }" }
|
6
8
|
|
7
|
-
|
9
|
+
it 'should not detect any problems' do
|
10
|
+
expect(problems).to have(0).problems
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
|
-
|
14
|
+
context 'ensure as only attr in a multi line resource' do
|
11
15
|
let(:code) { "
|
12
16
|
file { 'foo':
|
13
17
|
ensure => present,
|
14
18
|
}"
|
15
19
|
}
|
16
20
|
|
17
|
-
|
21
|
+
it 'should not detect any problems' do
|
22
|
+
expect(problems).to have(0).problems
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
|
-
|
26
|
+
context 'ensure as second attr in a multi line resource' do
|
21
27
|
let(:code) { "
|
22
28
|
file { 'foo':
|
23
29
|
mode => '0000',
|
@@ -25,12 +31,16 @@ describe 'ensure_first_param' do
|
|
25
31
|
}"
|
26
32
|
}
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
|
34
|
+
it 'should only detect a single problem' do
|
35
|
+
expect(problems).to have(1).problem
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should create a warning' do
|
39
|
+
expect(problems).to contain_warning(msg).on_line(4).in_column(9)
|
40
|
+
end
|
31
41
|
end
|
32
42
|
|
33
|
-
|
43
|
+
context 'ensure as first attr in a multi line resource' do
|
34
44
|
let(:code) { "
|
35
45
|
file { 'foo':
|
36
46
|
ensure => present,
|
@@ -38,6 +48,8 @@ describe 'ensure_first_param' do
|
|
38
48
|
}"
|
39
49
|
}
|
40
50
|
|
41
|
-
|
51
|
+
it 'should not detect any problems' do
|
52
|
+
expect(problems).to have(0).problems
|
53
|
+
end
|
42
54
|
end
|
43
55
|
end
|
@@ -1,26 +1,89 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'ensure_not_symlink_target' do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
let(:msg) { 'symlink target specified in ensure attr' }
|
5
|
+
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context 'file resource creating a symlink with seperate target attr' do
|
8
|
+
let(:code) { "
|
9
|
+
file { 'foo':
|
10
|
+
ensure => link,
|
11
|
+
target => '/foo/bar',
|
12
|
+
}"
|
13
|
+
}
|
14
|
+
|
15
|
+
it 'should not detect any problems' do
|
16
|
+
expect(problems).to have(0).problems
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'file resource creating a symlink with target specified in ensure' do
|
21
|
+
let(:code) { "
|
22
|
+
file { 'foo':
|
23
|
+
ensure => '/foo/bar',
|
24
|
+
}"
|
25
|
+
}
|
26
|
+
|
27
|
+
it 'should only detect a single problem' do
|
28
|
+
expect(problems).to have(1).problem
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should create a warning' do
|
32
|
+
expect(problems).to contain_warning(msg).on_line(3).in_column(21)
|
33
|
+
end
|
34
|
+
end
|
13
35
|
end
|
14
36
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
37
|
+
context 'with fix enabled' do
|
38
|
+
before do
|
39
|
+
PuppetLint.configuration.fix = true
|
40
|
+
end
|
41
|
+
|
42
|
+
after do
|
43
|
+
PuppetLint.configuration.fix = false
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'file resource creating a symlink with seperate target attr' do
|
47
|
+
let(:code) { "
|
48
|
+
file { 'foo':
|
49
|
+
ensure => link,
|
50
|
+
target => '/foo/bar',
|
51
|
+
}"
|
52
|
+
}
|
53
|
+
|
54
|
+
it 'should not detect any problems' do
|
55
|
+
expect(problems).to have(0).problems
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should not modify the manifest' do
|
59
|
+
expect(manifest).to eq(code)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'file resource creating a symlink with target specified in ensure' do
|
64
|
+
let(:code) { "
|
65
|
+
file { 'foo':
|
66
|
+
ensure => '/foo/bar',
|
67
|
+
}"
|
68
|
+
}
|
69
|
+
let(:fixed) { "
|
70
|
+
file { 'foo':
|
71
|
+
ensure => symlink,
|
72
|
+
target => '/foo/bar',
|
73
|
+
}"
|
74
|
+
}
|
75
|
+
|
76
|
+
it 'should only detect a single problem' do
|
77
|
+
expect(problems).to have(1).problem
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should fix the problem' do
|
81
|
+
expect(problems).to contain_fixed(msg).on_line(3).in_column(21)
|
82
|
+
end
|
21
83
|
|
22
|
-
|
23
|
-
|
24
|
-
|
84
|
+
it 'should create a new target param' do
|
85
|
+
expect(manifest).to eq(fixed)
|
86
|
+
end
|
87
|
+
end
|
25
88
|
end
|
26
89
|
end
|
@@ -1,110 +1,75 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'file_mode' do
|
4
|
-
|
5
|
-
let(:code) { "file { 'foo': mode => '777' }" }
|
6
|
-
|
7
|
-
its(:problems) do
|
8
|
-
should only_have_problem({
|
9
|
-
:kind => :warning,
|
10
|
-
:message => "mode should be represented as a 4 digit octal value or symbolic mode",
|
11
|
-
:linenumber => 1,
|
12
|
-
:column => 23,
|
13
|
-
})
|
14
|
-
end
|
15
|
-
end
|
4
|
+
let(:msg) { 'mode should be represented as a 4 digit octal value or symbolic mode' }
|
16
5
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
6
|
+
context 'with fix disabled' do
|
7
|
+
context '3 digit file mode' do
|
8
|
+
let(:code) { "file { 'foo': mode => '777' }" }
|
21
9
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
let(:code) { "file { 'foo': mode => '777' }" }
|
10
|
+
it 'should only detect a single problem' do
|
11
|
+
expect(problems).to have(1).problem
|
12
|
+
end
|
27
13
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
:kind => :fixed,
|
32
|
-
:message => 'mode should be represented as a 4 digit octal value or symbolic mode',
|
33
|
-
:linenumber => 1,
|
34
|
-
})
|
14
|
+
it 'should create a warning' do
|
15
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(23)
|
16
|
+
end
|
35
17
|
end
|
36
|
-
end
|
37
18
|
|
38
|
-
|
39
|
-
|
19
|
+
context '4 digit file mode' do
|
20
|
+
let(:code) { "file { 'foo': mode => '0777' }" }
|
40
21
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
describe '4 digit file mode w/fix' do
|
45
|
-
before do
|
46
|
-
PuppetLint.configuration.fix = true
|
47
|
-
end
|
48
|
-
|
49
|
-
after do
|
50
|
-
PuppetLint.configuration.fix = false
|
22
|
+
it 'should not detect any problems' do
|
23
|
+
expect(problems).to have(0).problems
|
24
|
+
end
|
51
25
|
end
|
52
26
|
|
53
|
-
|
54
|
-
|
55
|
-
its(:problems) { should be_empty }
|
56
|
-
its(:manifest) { should == "file { 'foo': mode => '0777' }" }
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'file mode as a variable' do
|
60
|
-
let(:code) { "file { 'foo': mode => $file_mode }" }
|
61
|
-
|
62
|
-
its(:problems) { should be_empty }
|
63
|
-
end
|
27
|
+
context 'file mode as a variable' do
|
28
|
+
let(:code) { "file { 'foo': mode => $file_mode }" }
|
64
29
|
|
65
|
-
|
66
|
-
|
67
|
-
|
30
|
+
it 'should not detect any problems' do
|
31
|
+
expect(problems).to have(0).problems
|
32
|
+
end
|
68
33
|
end
|
69
34
|
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
let(:code) { "file { 'foo': mode => $file_mode }" }
|
75
|
-
|
76
|
-
its(:problems) { should be_empty }
|
77
|
-
its(:manifest) { should == "file { 'foo': mode => $file_mode }" }
|
78
|
-
end
|
35
|
+
context 'symbolic file mode' do
|
36
|
+
let(:code) { "file { 'foo': mode => 'u=rw,og=r' }" }
|
79
37
|
|
80
|
-
|
81
|
-
|
38
|
+
it 'should not detect any problems' do
|
39
|
+
expect(problems).to have(0).problems
|
40
|
+
end
|
41
|
+
end
|
82
42
|
|
83
|
-
|
84
|
-
|
43
|
+
context 'file mode undef unquoted' do
|
44
|
+
let(:code) { "file { 'foo': mode => undef }" }
|
85
45
|
|
86
|
-
|
87
|
-
|
88
|
-
|
46
|
+
it 'should not detect any problems' do
|
47
|
+
expect(problems).to have(0).problems
|
48
|
+
end
|
89
49
|
end
|
90
50
|
|
91
|
-
|
92
|
-
|
93
|
-
end
|
51
|
+
context 'file mode undef quoted' do
|
52
|
+
let(:code) { "file { 'foo': mode => 'undef' }" }
|
94
53
|
|
95
|
-
|
54
|
+
it 'should only detect a single problem' do
|
55
|
+
expect(problems).to have(1).problem
|
56
|
+
end
|
96
57
|
|
97
|
-
|
98
|
-
|
99
|
-
|
58
|
+
it 'should create a warning' do
|
59
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(23)
|
60
|
+
end
|
61
|
+
end
|
100
62
|
|
101
|
-
|
102
|
-
|
63
|
+
context 'mode as audit value' do
|
64
|
+
let(:code) { "file { '/etc/passwd': audit => [ owner, mode ], }" }
|
103
65
|
|
104
|
-
|
66
|
+
it 'should not detect any problems' do
|
67
|
+
expect(problems).to have(0).problems
|
68
|
+
end
|
69
|
+
end
|
105
70
|
end
|
106
71
|
|
107
|
-
|
72
|
+
context 'with fix enabled' do
|
108
73
|
before do
|
109
74
|
PuppetLint.configuration.fix = true
|
110
75
|
end
|
@@ -113,44 +78,36 @@ describe 'file_mode' do
|
|
113
78
|
PuppetLint.configuration.fix = false
|
114
79
|
end
|
115
80
|
|
116
|
-
|
81
|
+
context '3 digit file mode' do
|
82
|
+
let(:code) { "file { 'foo': mode => '777' }" }
|
117
83
|
|
118
|
-
|
119
|
-
|
120
|
-
|
84
|
+
it 'should only detect a single problem' do
|
85
|
+
expect(problems).to have(1).problem
|
86
|
+
end
|
121
87
|
|
122
|
-
|
123
|
-
|
88
|
+
it 'should fix the manifest' do
|
89
|
+
expect(problems).to contain_fixed(msg).on_line(1).in_column(23)
|
90
|
+
end
|
124
91
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
:message => "mode should be represented as a 4 digit octal value or symbolic mode",
|
129
|
-
:linenumber => 1,
|
130
|
-
:column => 23,
|
131
|
-
})
|
92
|
+
it 'should zero pad the file mode' do
|
93
|
+
expect(manifest).to eq("file { 'foo': mode => '0777' }")
|
94
|
+
end
|
132
95
|
end
|
133
|
-
end
|
134
96
|
|
135
|
-
|
136
|
-
|
137
|
-
PuppetLint.configuration.fix = true
|
138
|
-
end
|
97
|
+
context 'file mode undef quoted' do
|
98
|
+
let(:code) { "file { 'foo': mode => 'undef' }" }
|
139
99
|
|
140
|
-
|
141
|
-
|
142
|
-
|
100
|
+
it 'should only detect a single problem' do
|
101
|
+
expect(problems).to have(1).problem
|
102
|
+
end
|
143
103
|
|
144
|
-
|
104
|
+
it 'should create a warning' do
|
105
|
+
expect(problems).to contain_warning(msg).on_line(1).in_column(23)
|
106
|
+
end
|
145
107
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
:message => "mode should be represented as a 4 digit octal value or symbolic mode",
|
150
|
-
:linenumber => 1,
|
151
|
-
:column => 23,
|
152
|
-
})
|
108
|
+
it 'should not modify the original manifest' do
|
109
|
+
expect(manifest).to eq(code)
|
110
|
+
end
|
153
111
|
end
|
154
|
-
its(:manifest) { should == "file { 'foo': mode => 'undef' }" }
|
155
112
|
end
|
156
113
|
end
|