end
dir = File.dirname(private_key_path)
- Puppet::Util.recmkdir(dir,0700) unless File.directory?(dir)
+ unless File.directory?(dir)
+ require 'fileutils'
+ FileUtils.mkdir_p(dir, :mode => 0700)
+ end
unless [private_key_path,public_key_path].all?{|path| File.exists?(path) }
output = Puppet::Util.execute(['/usr/bin/ssh-keygen','-t', 'rsa', '-b', '4096', '-f', private_key_path, '-P', '', '-q'])
raise Puppet::ParseError, "Something went wrong during key generation! Output: #{output}" unless output.empty?
File.stubs(:exists?).with("/tmp/a/b/c").returns(false)
File.stubs(:exists?).with("/tmp/a/b/c.pub").returns(false)
File.stubs(:directory?).with("/tmp/a/b").returns(false)
- Puppet::Util.expects(:recmkdir).with("/tmp/a/b",0700)
+ FileUtils.expects(:mkdir_p).with("/tmp/a/b", :mode => 0700)
Puppet::Util.expects(:execute).returns("")
result = @scope.function_ssh_keygen('/tmp/a/b/c')
result.length.should == 2