Skip to content

Commit 91ef967

Browse files
committed
(GH-245) Add tests for document validation with CRLF
This commit adds a test and test fixture to ensure that the document validator returns the same linting errors regardless of CRLF or LF line endings.
1 parent be29505 commit 91ef967

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
class example_manifest_with_multiple_lint_errors
3+
{
4+
5+
# --------------------------------------------------------------------
6+
# Set cipher suites order as secure as possible (Enables Perfect Forward Secrecy)
7+
# Remediation list per CIS IIS 8 Benchmark v1.4.0 - 08-24-2015 (minus 3DES)
8+
# Removed DHE per ITSec on 4/6/16
9+
# TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 and TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
10+
# --------------------------------------------------------------------
11+
$cipherSuitesOrder = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256, \
12+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256, \
13+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256, \
14+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256, \
15+
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_P384, \
16+
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_P256"
17+
18+
registry::value { 'Cipher Suites':
19+
key => 'HKLM\\SOFTWARE\\Policies\\Microsoft\\Cryptography\\Configuration\\SSL\\00010002',
20+
type => string,
21+
value => 'Functions',
22+
data => $cipherSuitesOrder,
23+
}
24+
25+
# --------------------------------------------------------------------
26+
# Disable IP Source Routing - Microsoft Security Bulletin MS06-032
27+
# --------------------------------------------------------------------
28+
registry::value { 'DisableIPSourceRouting0':
29+
key => 'HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters',
30+
type => 'dword',
31+
value => 'DisableIPSourceRouting',
32+
data => 2,
33+
}
34+
35+
# --------------------------------------------------------------------
36+
# Disable IPv6 Source Routing - Microsoft Security Bulletin MS06-032
37+
# --------------------------------------------------------------------
38+
registry_value { 'HKLM\System\CurrentControlSet\Services\Tcpip6\Parameters\DisableIPSourceRouting':
39+
ensure => present,
40+
type => dword,
41+
data => 2,
42+
notify => Reboot['after_run'],
43+
}
44+
45+
#Reboot Computer
46+
reboot { 'after_run':
47+
apply => finished,
48+
}
49+
50+
}

server/spec/languageserver/integration/puppet-languageserver/document_validator_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@
146146
end
147147
end
148148

149+
describe "Given a complete manifest with linting errors" do
150+
let(:manifest_fixture) { File.join($fixtures_dir,'manifest_with_lint_errors.pp') }
151+
let(:manifest_lf) { File.open(manifest_fixture, 'r') { |file| file.read } }
152+
let(:manifest_crlf) { File.open(manifest_fixture, 'r') { |file| file.read }.gsub("\n","\r\n") }
153+
154+
it "should return same errors for both LF and CRLF line endings" do
155+
lint_error_lf = subject.validate(manifest_lf, nil)
156+
lint_error_crlf = subject.validate(manifest_crlf, nil)
157+
expect(lint_error_crlf).to eq(lint_error_lf)
158+
end
159+
end
160+
149161
describe "Given a complete manifest with a single linting error" do
150162
let(:manifest) { "
151163
user { 'Bob':

server/spec/languageserver/spec_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
$LOAD_PATH.unshift(File.join(root,'vendor','puppet-lint','lib'))
88

99
require 'puppet-languageserver'
10-
fixtures_dir = File.join(File.dirname(__FILE__),'fixtures')
10+
$fixtures_dir = File.join(File.dirname(__FILE__),'fixtures')
1111

1212
# Currently there is no way to re-initialize the puppet loader so for the moment
1313
# all tests must run off the single puppet config settings instead of per example setting
1414
server_options = PuppetLanguageServer::CommandLineParser.parse([])
15-
server_options[:puppet_settings] = ['--vardir',File.join(fixtures_dir,'cache'),
16-
'--confdir',File.join(fixtures_dir,'confdir')]
15+
server_options[:puppet_settings] = ['--vardir',File.join($fixtures_dir,'cache'),
16+
'--confdir',File.join($fixtures_dir,'confdir')]
1717
PuppetLanguageServer::init_puppet(server_options)
1818

1919
def wait_for_puppet_loading

0 commit comments

Comments
 (0)