|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
3 | 3 | describe 'ssh_config resource' do |
4 | | - |
5 | 4 | let(:chef_run) do |
6 | 5 | runner = ChefSpec::SoloRunner.new(:step_into => :ssh_config) |
7 | 6 | runner.converge('ssh_test::config') |
|
81 | 80 | allow(IO).to partial_start.reduce(receive(:foreach).with(default_config), :and_yield) |
82 | 81 | allow(IO).to partial_start.reduce(receive(:foreach).with(test_config), :and_yield) |
83 | 82 |
|
84 | | - allow(Etc).to receive(:getpwnam) |
| 83 | + allow(Etc).to receive(:getgrgid).and_raise(Exception.new('This should not happen')) |
| 84 | + allow(Etc).to receive(:getgrgid).with(200).and_return(Struct.new(:name).new('vagrant')) |
| 85 | + allow(Etc).to receive(:getgrgid).with(100).and_return(Struct.new(:name).new('someone')) |
| 86 | + allow(Etc).to receive(:getgrgid).with(0).and_return(Struct.new(:name).new('root')) |
| 87 | + |
| 88 | + allow(Etc).to receive(:getpwnam).and_raise(Exception.new('This should not happen')) |
85 | 89 | allow(Etc).to receive(:getpwnam).with('vagrant').and_return( |
86 | 90 | Struct.new(:gid, :dir).new(200, '/home/vagrant') |
87 | 91 | ) |
|
169 | 173 | it 'can create user ssh configs' do |
170 | 174 | expect(chef_run).to create_file(vagrant_config).with( |
171 | 175 | :owner => 'vagrant', |
172 | | - :group => 200, |
| 176 | + :group => 'vagrant', |
173 | 177 | :mode => 00600 |
174 | 178 | ).with_content( |
175 | 179 | (common_end + github_and_partial_end).join("\n") |
|
179 | 183 | it 'can create the global ssh config' do |
180 | 184 | expect(chef_run).to create_file(default_config).with( |
181 | 185 | :owner => 'root', |
182 | | - :group => 0, |
| 186 | + :group => 'root', |
183 | 187 | :mode => 00644 |
184 | 188 | ).with_content( |
185 | 189 | (common_end + github_and_partial_end).join("\n") |
|
189 | 193 | it 'creates the /etc/ssh directory if it is missing' do |
190 | 194 | expect(chef_run).to create_directory(::File.dirname(default_config)).with( |
191 | 195 | :owner => 'root', |
192 | | - :group => 0, |
| 196 | + :group => 'root', |
193 | 197 | :mode => 00755 |
194 | 198 | ) |
195 | 199 | end |
196 | 200 |
|
197 | 201 | it "creates vagrant's ~/.ssh/config file" do |
198 | 202 | expect(chef_run).to create_directory(::File.dirname(vagrant_config)).with( |
199 | 203 | :owner => 'vagrant', |
200 | | - :group => 200, |
| 204 | + :group => 'vagrant', |
201 | 205 | :mode => 00700 |
202 | 206 | ) |
203 | 207 | end |
|
0 commit comments