-
Notifications
You must be signed in to change notification settings - Fork 81
/
should_tolerate_mixed_case.rb
161 lines (146 loc) · 5.68 KB
/
should_tolerate_mixed_case.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
require 'pathname'
require Pathname.new(__FILE__).dirname.dirname.dirname.dirname + 'lib/systest/util/registry'
# Include our utility methods in the singleton class of the test case instance.
class << self
include Systest::Util::Registry
end
test_name "Registry Value Management (Mixed Case)"
# JJM - The whole purpose of this test is to exercise situations where the user
# specifies registry valies in a case-insensitive but case-preserving way.
# This has particular "gotchas" with regard to autorequire.
#
# Note how SUBKEY1 is capitalized in some resources but downcased in other
# resources. On windows these refer to the same thing, and case is preserved.
# In puppet, however, resource namevars are case sensisitve unless otherwise
# noted.
# Generate a unique key name
keyname = "PuppetLabsTest_MixedCase_#{randomstring(8)}"
# This is the keypath we'll use for this entire test. We will actually create this key and delete it.
vendor_path = "HKLM\\Software\\Vendor"
keypath = "#{vendor_path}\\#{keyname}"
master_manifest_content = <<HERE
notify { fact_phase: message => "fact_phase: $fact_phase" }
registry_key { '#{vendor_path}': ensure => present }
registry_key { '32:#{vendor_path}': ensure => present }
class phase1 {
Registry_key { ensure => present }
registry_key { '#{keypath}': }
registry_key { '#{keypath}\\SUBKEY1': }
# NOTE THE DIFFERENCE IN CASE IN SubKey1 and SUBKEY1 above
registry_key { '#{keypath}\\SubKey1\\SUBKEY2': }
registry_key { '32:#{keypath}': }
registry_key { '32:#{keypath}\\SUBKEY1': }
registry_key { '32:#{keypath}\\SubKey1\\SUBKEY2': }
# The Default Value
# NOTE THE DIFFERENCE IN CASE IN SubKey1 and SUBKEY1 above
registry_value { '#{keypath}\\SubKey1\\\\':
data => "Default Data",
}
# String Values
registry_value { '#{keypath}\\SubKey1\\ValueString1':
data => "Should be a string",
}
registry_value { '#{keypath}\\SubKey1\\ValueString2':
type => string,
data => "Should be a string",
}
registry_value { '#{keypath}\\SubKey1\\ValueString3':
ensure => present,
type => string,
data => "Should be a string",
}
registry_value { '#{keypath}\\SubKey1\\ValueString4':
data => "Should be a string",
type => string,
ensure => present,
}
registry_value { '#{keypath}\\SubKey1\\SubKey2\\ValueString1':
data => "Should be a string",
}
registry_value { '#{keypath}\\SubKey1\\SubKey2\\ValueString2':
type => string,
data => "Should be a string",
}
registry_value { '#{keypath}\\SubKey1\\SubKey2\\ValueString3':
ensure => present,
type => string,
data => "Should be a string",
}
registry_value { '#{keypath}\\SubKey1\\SubKey2\\ValueString4':
data => "Should be a string",
type => string,
ensure => present,
}
# The Default Value
# NOTE THE DIFFERENCE IN CASE IN SubKey1 and SUBKEY1 above
registry_value { '32:#{keypath}\\SubKey1\\\\':
data => "Default Data",
}
# String Values
registry_value { '32:#{keypath}\\SubKey1\\ValueString1':
data => "Should be a string",
}
registry_value { '32:#{keypath}\\SubKey1\\ValueString2':
type => string,
data => "Should be a string",
}
registry_value { '32:#{keypath}\\SubKey1\\ValueString3':
ensure => present,
type => string,
data => "Should be a string",
}
registry_value { '32:#{keypath}\\SubKey1\\ValueString4':
data => "Should be a string",
type => string,
ensure => present,
}
registry_value { '32:#{keypath}\\SubKey1\\SubKey2\\ValueString1':
data => "Should be a string",
}
registry_value { '32:#{keypath}\\SubKey1\\SubKey2\\ValueString2':
type => string,
data => "Should be a string",
}
registry_value { '32:#{keypath}\\SubKey1\\SubKey2\\ValueString3':
ensure => present,
type => string,
data => "Should be a string",
}
registry_value { '32:#{keypath}\\SubKey1\\SubKey2\\ValueString4':
data => "Should be a string",
type => string,
ensure => present,
}
}
case $fact_phase {
default: { include phase1 }
}
HERE
# Setup the master to use the modules specified in the --modules option
setup_master master_manifest_content
step "Start the master" do
with_master_running_on(master, master_options) do
# A set of keys we expect Puppet to create
phase1_resources_created = [
/Registry_key\[HKLM.Software.Vendor.PuppetLabsTest\w+\].ensure: created/,
/Registry_key\[HKLM.Software.Vendor.PuppetLabsTest\w+\\SUBKEY1\].ensure: created/,
/Registry_key\[32:HKLM.Software.Vendor.PuppetLabsTest\w+\].ensure: created/,
/Registry_key\[32:HKLM.Software.Vendor.PuppetLabsTest\w+\\SUBKEY1\].ensure: created/,
/Registry_value\[HKLM.Software.Vendor.PuppetLabsTest\w+\\SubKey1\\\\\].ensure: created/,
/Registry_value\[HKLM.Software.Vendor.PuppetLabsTest\w+\\SubKey1\\ValueString1\].ensure: created/,
/Registry_value\[HKLM.Software.Vendor.PuppetLabsTest\w+\\SubKey1\\ValueString2\].ensure: created/,
/Registry_value\[HKLM.Software.Vendor.PuppetLabsTest\w+\\SubKey1\\ValueString3\].ensure: created/,
/Registry_value\[HKLM.Software.Vendor.PuppetLabsTest\w+\\SubKey1\\ValueString4\].ensure: created/,
]
windows_agents.each do |agent|
this_agent_args = agent_args % get_test_file_path(agent, agent_lib_dir)
step "Registry Tolerate Mixed Case Values - Phase 1.a - Create some values"
on agent, puppet_agent(this_agent_args, :environment => { 'FACTER_FACT_PHASE' => '1' }), :acceptable_exit_codes => agent_exit_codes do
phase1_resources_created.each do |val_re|
assert_match(val_re, result.stdout, "Expected output to contain #{val_re.inspect}.")
end
assert_no_match(/err:/, result.stdout, "Expected no error messages.")
end
end
end
end