|
131 | 131 | expect(subject.name_to_principal(unknown_name)).to be_nil
|
132 | 132 | end
|
133 | 133 |
|
| 134 | + it "should print a debug message if the account does not exist" do |
| 135 | + expect(Puppet).to receive(:debug).with(/No mapping between account names and security IDs was done/) |
| 136 | + subject.name_to_principal(unknown_name) |
| 137 | + end |
| 138 | + |
134 | 139 | it "should return a Puppet::Util::Windows::SID::Principal instance for any valid sid" do
|
135 | 140 | expect(subject.name_to_principal(sid)).to be_an_instance_of(Puppet::Util::Windows::SID::Principal)
|
136 | 141 | end
|
137 | 142 |
|
| 143 | + it "should not print debug messages for valid sid" do |
| 144 | + expect(Puppet).not_to receive(:debug).with(/Could not retrieve raw SID bytes from/) |
| 145 | + expect(Puppet).not_to receive(:debug).with(/No mapping between account names and security IDs was done/) |
| 146 | + subject.name_to_principal(sid) |
| 147 | + end |
| 148 | + |
| 149 | + it "should print a debug message for invalid sid" do |
| 150 | + expect(Puppet).not_to receive(:debug).with(/Could not retrieve raw SID bytes from/) |
| 151 | + expect(Puppet).to receive(:debug).with(/No mapping between account names and security IDs was done/) |
| 152 | + subject.name_to_principal('S-1-5-21-INVALID-SID') |
| 153 | + end |
| 154 | + |
138 | 155 | it "should accept unqualified account name" do
|
139 | 156 | # NOTE: lookup by name works in localized environments only for a few instances
|
140 | 157 | # this works in French Windows, even though the account is really Syst\u00E8me
|
141 | 158 | expect(subject.name_to_principal('SYSTEM').sid).to eq(sid)
|
142 | 159 | end
|
143 | 160 |
|
| 161 | + it "should not print debug messages for unqualified account name" do |
| 162 | + expect(Puppet).not_to receive(:debug).with(/Could not retrieve raw SID bytes from/) |
| 163 | + expect(Puppet).not_to receive(:debug).with(/No mapping between account names and security IDs was done/) |
| 164 | + subject.name_to_principal('SYSTEM') |
| 165 | + end |
| 166 | + |
144 | 167 | it "should be case-insensitive" do
|
145 | 168 | # NOTE: lookup by name works in localized environments only for a few instances
|
146 | 169 | # this works in French Windows, even though the account is really Syst\u00E8me
|
147 | 170 | expect(subject.name_to_principal('SYSTEM')).to eq(subject.name_to_principal('system'))
|
148 | 171 | end
|
149 | 172 |
|
| 173 | + it "should not print debug messages for wrongly cased account name" do |
| 174 | + expect(Puppet).not_to receive(:debug).with(/Could not retrieve raw SID bytes from/) |
| 175 | + expect(Puppet).not_to receive(:debug).with(/No mapping between account names and security IDs was done/) |
| 176 | + subject.name_to_principal('system') |
| 177 | + end |
| 178 | + |
150 | 179 | it "should be leading and trailing whitespace-insensitive" do
|
151 | 180 | # NOTE: lookup by name works in localized environments only for a few instances
|
152 | 181 | # this works in French Windows, even though the account is really Syst\u00E8me
|
153 | 182 | expect(subject.name_to_principal('SYSTEM')).to eq(subject.name_to_principal(' SYSTEM '))
|
154 | 183 | end
|
155 | 184 |
|
| 185 | + it "should not print debug messages for account name with leading and trailing whitespace" do |
| 186 | + expect(Puppet).not_to receive(:debug).with(/Could not retrieve raw SID bytes from/) |
| 187 | + expect(Puppet).not_to receive(:debug).with(/No mapping between account names and security IDs was done/) |
| 188 | + subject.name_to_principal(' SYSTEM ') |
| 189 | + end |
| 190 | + |
156 | 191 | it "should accept domain qualified account names" do
|
157 | 192 | # NOTE: lookup by name works in localized environments only for a few instances
|
158 | 193 | # this works in French Windows, even though the account is really AUTORITE NT\\Syst\u00E8me
|
159 | 194 | expect(subject.name_to_principal('NT AUTHORITY\SYSTEM').sid).to eq(sid)
|
160 | 195 | end
|
161 | 196 |
|
162 |
| - it "should print a debug message on failures" do |
163 |
| - expect(Puppet).to receive(:debug).with(/Could not retrieve raw SID bytes from 'NonExistingUser'/) |
164 |
| - expect(Puppet).to receive(:debug).with(/No mapping between account names and security IDs was done/) |
165 |
| - subject.name_to_principal('NonExistingUser') |
| 197 | + it "should not print debug messages for domain qualified account names" do |
| 198 | + expect(Puppet).not_to receive(:debug).with(/Could not retrieve raw SID bytes from/) |
| 199 | + expect(Puppet).not_to receive(:debug).with(/No mapping between account names and security IDs was done/) |
| 200 | + subject.name_to_principal('NT AUTHORITY\SYSTEM') |
166 | 201 | end
|
167 | 202 | end
|
168 | 203 |
|
|
0 commit comments