diff options
| author | Daniel Pittman <daniel@rimspace.net> | 2011-03-03 00:40:50 -0800 |
|---|---|---|
| committer | Daniel Pittman <daniel@rimspace.net> | 2011-03-03 16:30:08 -0800 |
| commit | 3954576bca044e4fa9c3d74047fdd0833be0c5b6 (patch) | |
| tree | fd69d9a95d3ddb9eb465f086fa94fe307307edc3 /spec/unit | |
| parent | 53b6df3781fe67a3e7fd686cb93cad50c40c6ce3 (diff) | |
| download | puppet-3954576bca044e4fa9c3d74047fdd0833be0c5b6.tar.gz puppet-3954576bca044e4fa9c3d74047fdd0833be0c5b6.tar.xz puppet-3954576bca044e4fa9c3d74047fdd0833be0c5b6.zip | |
(#6582) eliminate fakeresource use in ssh_authorized_key spec.
We replace it with an instance of the actual resource we are testing, which
reduces the number of ways this code is tied to the specific implementation.
Reviewed-By: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'spec/unit')
| -rwxr-xr-x | spec/unit/provider/host/parsed_spec.rb | 1 | ||||
| -rwxr-xr-x | spec/unit/provider/ssh_authorized_key/parsed_spec.rb | 44 |
2 files changed, 18 insertions, 27 deletions
diff --git a/spec/unit/provider/host/parsed_spec.rb b/spec/unit/provider/host/parsed_spec.rb index 3ed479974..048d77ba2 100755 --- a/spec/unit/provider/host/parsed_spec.rb +++ b/spec/unit/provider/host/parsed_spec.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') +require 'shared_behaviours/all_parsedfile_providers' require 'puppet_spec/files' diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb index 6d67ee3bb..7a1bd77f4 100755 --- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb @@ -1,15 +1,13 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') - +require 'shared_behaviours/all_parsedfile_providers' require 'puppet_spec/files' -require 'puppettest/fakes' provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed) describe provider_class do include PuppetSpec::Files - include PuppetTest before :each do @sshauthkey_class = Puppet::Type.type(:ssh_authorized_key) @@ -25,15 +23,13 @@ describe provider_class do end def mkkey(args) - fakeresource = fakeresource(:ssh_authorized_key, args[:name]) - fakeresource.stubs(:should).with(:user).returns @user - fakeresource.stubs(:should).with(:target).returns @keyfile - - key = @provider.new(fakeresource) + args[:target] = @keyfile + args[:user] = @user + resource = Puppet::Type.type(:ssh_authorized_key).new(args) + key = @provider.new(resource) args.each do |p,v| key.send(p.to_s + "=", v) end - key end @@ -50,30 +46,24 @@ describe provider_class do it "should be able to generate a basic authorized_keys file" do - key = mkkey( - { - :name => "Just Testing", - :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", - :type => "ssh-dss", - :ensure => :present, - - :options => [:absent] - }) + key = mkkey(:name => "Just Testing", + :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", + :type => "ssh-dss", + :ensure => :present, + :options => [:absent] + ) genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just Testing\n" end it "should be able to generate a authorized_keys file with options" do - key = mkkey( - { - :name => "root@localhost", - :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", - :type => "ssh-rsa", - :ensure => :present, - - :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"] - }) + key = mkkey(:name => "root@localhost", + :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj", + :type => "ssh-rsa", + :ensure => :present, + :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"] + ) genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root@localhost\n" end |
