summaryrefslogtreecommitdiffstats
path: root/spec/unit/ral/provider
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-05-15 19:11:08 -0500
committerLuke Kanies <luke@madstop.com>2008-05-15 19:11:08 -0500
commitd02334f114a73facd2b3a90f35cb1f3c04365e2f (patch)
treec0b4cd7dea99a5349e704bd62575b5dc154c317b /spec/unit/ral/provider
parente7bef08bbac951dd1b798273af3ff2b098bf9187 (diff)
downloadpuppet-d02334f114a73facd2b3a90f35cb1f3c04365e2f.tar.gz
puppet-d02334f114a73facd2b3a90f35cb1f3c04365e2f.tar.xz
puppet-d02334f114a73facd2b3a90f35cb1f3c04365e2f.zip
Moving all tests that are in 'ral' up a level.
This directory only existed as an organizational method, and the code never matched it, so I'm fixing it.
Diffstat (limited to 'spec/unit/ral/provider')
-rwxr-xr-xspec/unit/ral/provider/interface/redhat.rb268
-rwxr-xr-xspec/unit/ral/provider/interface/sunos.rb239
-rwxr-xr-xspec/unit/ral/provider/mount.rb130
-rwxr-xr-xspec/unit/ral/provider/mount/parsed.rb185
-rwxr-xr-xspec/unit/ral/provider/ssh_authorized_key/parsed.rb74
5 files changed, 0 insertions, 896 deletions
diff --git a/spec/unit/ral/provider/interface/redhat.rb b/spec/unit/ral/provider/interface/redhat.rb
deleted file mode 100755
index 9bf1b9722..000000000
--- a/spec/unit/ral/provider/interface/redhat.rb
+++ /dev/null
@@ -1,268 +0,0 @@
-#!/usr/bin/env ruby
-#
-# Created by Luke Kanies on 2007-11-20.
-# Copyright (c) 2006. All rights reserved.
-
-require File.dirname(__FILE__) + '/../../../../spec_helper'
-
-provider_class = Puppet::Type.type(:interface).provider(:redhat)
-
-describe provider_class do
- it "should not be functional on systems without a network-scripts directory" do
- FileTest.expects(:exists?).with("/etc/sysconfig/network-scripts").returns(false)
- provider_class.should_not be_suitable
- end
-
- it "should be functional on systems with a network-scripts directory" do
- FileTest.expects(:exists?).with("/etc/sysconfig/network-scripts").returns(true)
- provider_class.should be_suitable
- end
-end
-
-describe provider_class, " when determining the file path" do
- it "should always contain '/etc/sysconfig/network-scripts/ifcfg-'" do
- provider = provider_class.new(:name => "192.168.0.1")
- provider.file_path.should =~ %r{^/etc/sysconfig/network-scripts/ifcfg-}
- end
-
- it "should include the interface name and the description when the interface is an alias" do
- provider = provider_class.new(:name => "192.168.0.1", :interface => "eth0")
- provider.interface_type = :alias
- resource = stub 'resource'
- resource.stubs(:[]).with(:interface_desc).returns("blah")
- provider.resource = resource
- provider.file_path.should == "/etc/sysconfig/network-scripts/ifcfg-eth0:blah"
- end
-
- it "should just include the description when the interface is not an alias" do
- provider = provider_class.new(:name => "192.168.0.1")
- provider.interface_type = :normal
- resource = stub 'resource'
- resource.stubs(:[]).with(:interface_desc).returns("eth0")
- provider.resource = resource
- provider.file_path.should == "/etc/sysconfig/network-scripts/ifcfg-eth0"
- end
-
- it "should use the interface description if one is available" do
- provider = provider_class.new(:name => "192.168.0.1")
- provider.interface_type = :normal
- resource = stub 'resource'
- resource.stubs(:[]).with(:interface_desc).returns("eth0")
- provider.resource = resource
- provider.file_path.should == "/etc/sysconfig/network-scripts/ifcfg-eth0"
- end
-
- it "should use the name if no interface description is available" do
- provider = provider_class.new(:name => "192.168.0.1")
- provider.interface_type = :normal
- provider.file_path.should == "/etc/sysconfig/network-scripts/ifcfg-192.168.0.1"
- end
-
- it "should fail if no name or interface description can be found" do
- provider = provider_class.new()
- proc { provider.file_path }.should raise_error
- end
-end
-
-describe provider_class, " when returning instances" do
- it "should consider each file in the network-scripts directory an interface instance" do
- Dir.expects(:glob).with("/etc/sysconfig/network-scripts/ifcfg-*").returns(%w{one two})
- one = {:name => "one"}
- two = {:name => "two"}
- Puppet::Type::Interface::ProviderRedhat.expects(:parse).with("one").returns(one)
- Puppet::Type::Interface::ProviderRedhat.expects(:parse).with("two").returns(two)
- Puppet::Type::Interface::ProviderRedhat.expects(:new).with(one).returns(:one)
- Puppet::Type::Interface::ProviderRedhat.expects(:new).with(two).returns(:two)
- Puppet::Type::Interface::ProviderRedhat.instances.should == [:one, :two]
- end
-end
-
-describe provider_class, " when parsing" do
- it "should return an unmodified provider if the file does not exist" do
- FileTest.expects(:exist?).with("/my/file").returns(false)
- provider = mock 'provider'
- Puppet::Type::Interface::ProviderRedhat.expects(:new).returns(provider)
- Puppet::Type::Interface::ProviderRedhat.parse("/my/file").should equal(provider)
- end
-
- it "should set each attribute in the file on the provider" do
- FileTest.expects(:exist?).with("/my/file").returns(true)
- File.expects(:readlines).with("/my/file").returns(%w{one=two three=four})
- provider = mock 'provider'
- Puppet::Type::Interface::ProviderRedhat.expects(:new).returns(provider)
- provider.expects(:one=).with('two')
- provider.expects(:three=).with('four')
- Puppet::Type::Interface::ProviderRedhat.parse("/my/file").should equal(provider)
- end
-end
-
-describe provider_class, " when setting the device to a value containing ':'" do
- before do
- @provider = Puppet::Type::Interface::ProviderRedhat.new
- @provider.device = "one:two"
- end
- it "should set the interface type to :alias" do
- @provider.interface_type.should == :alias
- end
- it "should set the interface to the string to the left of the ':'" do
- @provider.interface.should == "one"
- end
- it "should set the ifnum to the string to the right of the ':'" do
- @provider.ifnum.should == "two"
- end
-end
-
-describe provider_class, " when setting the device to a value starting with 'dummy-'" do
- before do
- @provider = Puppet::Type::Interface::ProviderRedhat.new
- @provider.device = "dummy5"
- end
- it "should set the interface type to :loopback" do
- @provider.interface_type.should == :loopback
- end
- it "should set the interface to 'dummy'" do
- @provider.interface.should == "dummy"
- end
- it "should set the ifnum to remainder of value after removing 'dummy'" do
- @provider.ifnum.should == "5"
- end
-end
-
-describe provider_class, " when setting the device to a value containing neither 'dummy-' nor ':'" do
- before do
- @provider = Puppet::Type::Interface::ProviderRedhat.new
- @provider.device = "whatever"
- end
- it "should set the interface type to :normal" do
- @provider.interface_type.should == :normal
- end
- it "should set the interface to the device value" do
- @provider.interface.should == "whatever"
- end
-end
-
-describe provider_class, " when setting the on_boot value" do
- before do
- @provider = Puppet::Type::Interface::ProviderRedhat.new
- end
- it "should set it to :true if the value is 'yes'" do
- @provider.on_boot = "yes"
- @provider.onboot.should == :true
- end
- it "should set it to :false if the value is not 'yes'" do
- @provider.on_boot = "no"
- @provider.onboot.should == :false
- end
-end
-
-describe provider_class, " when setting the ipaddr value" do
- before do
- @provider = Puppet::Type::Interface::ProviderRedhat.new
- end
-
- it "should set the name to the provided value" do
- @provider.ipaddr = "yay"
- @provider.name.should == "yay"
- end
-end
-
-describe provider_class, " when generating" do
- before do
- @provider = Puppet::Type::Interface::ProviderRedhat.new
- @provider.interface_type = :alias
- @provider.stubs(:device).returns("mydevice")
- @provider.stubs(:on_boot).returns("myboot")
- @provider.stubs(:name).returns("myname")
- @provider.stubs(:netmask).returns("mynetmask")
- @provider.interface_type = :alias
-
- @text = @provider.generate
- end
-
- it "should set the bootproto to none if the interface is an alias" do
- @text.should =~ /^BOOTPROTO=none$/
- end
-
- it "should set the bootproto to static if the interface is a loopback" do
- @provider.interface_type = :loopback
- @text = @provider.generate
- @text.should =~ /^BOOTPROTO=static$/
- end
-
- it "should set the broadcast address to nothing" do
- @text.should =~ /^BROADCAST=$/
- end
-
- it "should set the netmask to mynetmask" do
- @text.should =~ /^NETMASK=mynetmask$/
- end
-
- it "should set the device to the provider's device" do
- @text.should =~ /^DEVICE=mydevice$/
- end
-
- it "should set the onboot to the provider's on_boot value" do
- @text.should =~ /^ONBOOT=myboot$/
- end
-
- it "should set the ipaddr to the provider's name" do
- @text.should =~ /^IPADDR=myname$/
- end
-end
-
-describe provider_class, " when creating and destroying" do
- before do
- @provider = provider_class.new(:interface => "eth0", :name => "testing")
- @path = "/etc/sysconfig/network-scripts/ifcfg-testing"
- end
-
- it "should consider the interface present if the file exists" do
- FileTest.expects(:exist?).with(@path).returns(true)
- @provider.should be_exists
- end
-
- it "should consider the interface absent if the file does not exist" do
- FileTest.expects(:exist?).with(@path).returns(false)
- @provider.should_not be_exists
- end
-
- it "should remove the file if the interface is being destroyed" do
- File.expects(:unlink).with(@path)
- @provider.destroy
- end
-
- it "should mark :ensure as :absent if the interface is destroyed" do
- File.stubs(:unlink)
- @provider.destroy
- @provider.ensure.should == :absent
- end
-
- it "should mark :ensure as :present if the interface is being created" do
- resource = stub 'resource', :name => 'testing'
- resource.stubs(:should).with { |name| name == :ensure }.returns(:present)
- resource.stubs(:should).with { |name| name != :ensure }.returns(nil)
- @provider.resource = resource
- @provider.create
- @provider.ensure.should == :present
- end
-
- it "should write the generated text to disk when the interface is flushed" do
- fh = mock("filehandle")
- File.expects(:open).yields(fh)
- fh.expects(:puts).with("generated")
- resource = stub 'resource', :name => 'testing'
- resource.stubs(:[]).with(:interface_desc).returns(nil)
- resource.stubs(:should).with { |name| name == :ensure }.returns(:present)
- resource.stubs(:should).with { |name| name != :ensure }.returns(nil)
- @provider.resource = resource
- @provider.create
-
- @provider.stubs(:generate).returns("generated")
- @provider.flush
- end
-
- it "should not write the generated text to disk when the interface is flushed if :ensure == :absent" do
- @provider.ensure = :absent
- @provider.flush
- end
-end
diff --git a/spec/unit/ral/provider/interface/sunos.rb b/spec/unit/ral/provider/interface/sunos.rb
deleted file mode 100755
index 7b9f462e6..000000000
--- a/spec/unit/ral/provider/interface/sunos.rb
+++ /dev/null
@@ -1,239 +0,0 @@
-#!/usr/bin/env ruby
-#
-# Created by Luke Kanies on 2007-11-25.
-# Copyright (c) 2006. All rights reserved.
-
-require File.dirname(__FILE__) + '/../../../../spec_helper'
-
-require 'puppet/provider/interface/sunos'
-
-
-provider_class = Puppet::Type.type(:interface).provider(:sunos)
-
-describe provider_class do
- it "should not be functional on non-SunOS kernels" do
- Facter.expects(:value).with(:kernel).returns("Linux")
- provider_class.should_not be_suitable
- end
-
- it "should be functional on SunOS kernels" do
- Facter.expects(:value).with(:kernel).returns("SunOS")
- provider_class.should be_suitable
- end
-
- it "should pick its file path by combining '/etc/hostname.' with the interface if one is set" do
- provider = provider_class.new(:record_type => :sunos, :interface_type => :normal, :name => "testing", :interface => 'eth0')
- provider.file_path.should == "/etc/hostname.eth0"
- end
-
- it "should pick its file path by combining '/etc/hostname.' with the resource's interface if one is not set in the provider" do
- provider = provider_class.new(:record_type => :sunos, :interface_type => :normal, :name => "testing")
- resource = mock 'resource'
- resource.stubs(:[]).with(:interface).returns("eth0")
- provider.resource = resource
- provider.file_path.should == "/etc/hostname.eth0"
- end
-
- it "should fail when picking its file path if there is no resource nor an interface set in the provider" do
- provider = provider_class.new(:record_type => :sunos, :interface_type => :normal, :name => "testing")
- proc { provider.file_path }.should raise_error(Puppet::Error)
- end
-end
-
-describe provider_class, " when listing interfaces" do
- it "should return an instance for every file matching /etc/hostname.*, created with the interface name set from the file" do
- Dir.expects(:glob).with("/etc/hostname.*").returns(%w{/etc/hostname.one /etc/hostname.two})
- one_instance = stub 'one_instance', :parse => nil
- two_instance = stub 'two_instance', :parse => nil
- provider_class.expects(:new).with(:interface => "one").returns(one_instance)
- provider_class.expects(:new).with(:interface => "two").returns(two_instance)
-
- provider_class.instances.should == [one_instance, two_instance]
- end
-
- it "should call parse on each instance being returned" do
- Dir.expects(:glob).with("/etc/hostname.*").returns(%w{/etc/hostname.one})
- one_instance = mock 'one_instance'
- provider_class.expects(:new).with(:interface => "one").returns(one_instance)
-
- one_instance.expects(:parse)
-
- provider_class.instances
- end
-
- it "should assign matching providers to any prefetched instances" do
- Dir.expects(:glob).with("/etc/hostname.*").returns(%w{one two})
- one_instance = stub 'one_instance', :name => "one", :parse => nil
- two_instance = stub 'two_instance', :name => "two", :parse => nil
- provider_class.expects(:new).with(:interface => "one").returns(one_instance)
- provider_class.expects(:new).with(:interface => "two").returns(two_instance)
-
- resources = {"one" => mock("one"), "three" => mock('three')}
- resources["one"].expects(:provider=).with(one_instance)
-
- provider_class.prefetch(resources)
- end
-end
-
-describe provider_class, " when creating and destroying" do
- before do
- @provider = provider_class.new(:interface => "eth0", :name => "testing")
- end
-
- it "should consider the interface present if the file exists" do
- FileTest.expects(:exist?).with("/etc/hostname.eth0").returns(true)
- @provider.should be_exists
- end
-
- it "should consider the interface absent if the file does not exist" do
- FileTest.expects(:exist?).with("/etc/hostname.eth0").returns(false)
- @provider.should_not be_exists
- end
-
- it "should remove the file if the interface is being destroyed" do
- File.expects(:unlink).with("/etc/hostname.eth0")
- @provider.destroy
- end
-
- it "should mark :ensure as :absent if the interface is destroyed" do
- File.stubs(:unlink)
- @provider.destroy
- @provider.ensure.should == :absent
- end
-
- it "should mark :ensure as :present if the interface is being created" do
- resource = stub 'resource', :name => 'testing'
- resource.stubs(:should).with { |name| name == :ensure }.returns(:present)
- resource.stubs(:should).with { |name| name != :ensure }.returns(nil)
- @provider.resource = resource
- @provider.create
- @provider.ensure.should == :present
- end
-
- it "should write the generated text to disk when the interface is flushed" do
- fh = mock("filehandle")
- File.expects(:open).yields(fh)
- fh.expects(:print).with("testing\n")
- resource = stub 'resource', :name => 'testing'
- resource.stubs(:should).with { |name| name == :ensure }.returns(:present)
- resource.stubs(:should).with { |name| name != :ensure }.returns(nil)
- @provider.resource = resource
- @provider.create
- @provider.flush
- end
-
- it "should not write the generated text to disk when the interface is flushed if :ensure == :absent" do
- @provider.ensure = :absent
- @provider.flush
- end
-end
-
-describe provider_class, " when parsing a non-existant file" do
- it "should mark the interface as absent" do
- @provider = provider_class.new(:interface => "eth0", :name => "testing")
- FileTest.expects(:exist?).with("/etc/hostname.eth0").returns(false)
- @provider.parse
- @provider.ensure.should == :absent
- end
-end
-
-describe provider_class, " when parsing an existing file" do
- before do
- @provider = provider_class.new(:interface => "eth0", :name => "testing")
- FileTest.stubs(:exist?).with("/etc/hostname.eth0").returns(true)
- end
-
- def set_text(text)
- File.stubs(:read).with("/etc/hostname.eth0").returns(text)
- end
-
- it "should retain the interface name" do
- set_text "testing"
- @provider.parse
- @provider.ensure.should == :present
- @provider.interface.should == "eth0"
- end
-
- it "should mark the interface as present" do
- set_text "testing"
- @provider.parse
- @provider.ensure.should == :present
- end
-
- it "should mark the interface as an alias if the first word is 'addif'" do
- set_text "addif testing"
- @provider.parse
- @provider.interface_type.should == :alias
- end
-
- it "should not mark the interface as normal if the first word is not 'addif'" do
- set_text "testing"
- @provider.parse
- @provider.interface_type.should == :normal
- end
-
- it "should start the interface on boot of the last word is 'up'" do
- set_text "testing up"
- @provider.parse
- @provider.onboot.should == :true
- end
-
- it "should not start the interface on boot of the last word is not 'up'" do
- set_text "testing"
- @provider.parse
- @provider.onboot.should == :false
- end
-
- it "should set the interface to the first non-behavioural word" do
- set_text "addif testing up"
- @provider.parse
- @provider.name.should == "testing"
- end
-
- it "should consider any remaining terms to be interface options" do
- set_text "addif testing -O up"
- @provider.parse
- @provider.ifopts.should == "-O"
- end
-end
-
-describe provider_class, " when generating" do
- before do
- @provider = provider_class.new(:interface => "eth0", :name => "testing")
- end
-
- it "should prefix the text with 'addif' if the interface is an alias" do
- @provider.interface_type = :alias
- @provider.generate.should == "addif testing"
- end
-
- it "should not prefix the text with 'addif' if the interface is not an alias" do
- @provider.generate.should == "testing"
- end
-
- it "should put the ifopts after the name if they are present" do
- @provider.ifopts = "-O"
- @provider.generate.should == "testing -O"
- end
-
- it "should mark the interface up if onboot is enabled" do
- @provider.onboot = :true
- @provider.generate.should == "testing up"
- end
-
- it "should use the resource name if no provider name is present" do
- provider = provider_class.new(:interface => "eth0")
- resource = stub 'resource', :name => "rtest"
- provider.resource = resource
- provider.generate.should == "rtest"
- end
-
- it "should use the provider name if present" do
- @provider.generate.should == "testing"
- end
-
- it "should fail if neither a resource nor the provider name is present" do
- provider = provider_class.new(:interface => "eth0")
- proc { provider.generate }.should raise_error
- end
-end
diff --git a/spec/unit/ral/provider/mount.rb b/spec/unit/ral/provider/mount.rb
deleted file mode 100755
index 0b90d53c9..000000000
--- a/spec/unit/ral/provider/mount.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../../spec_helper'
-
-require 'puppet/provider/mount'
-
-describe Puppet::Provider::Mount do
- before :each do
- @mounter = Object.new
- @mounter.extend(Puppet::Provider::Mount)
-
- @name = "/"
-
- @resource = stub 'resource'
- @resource.stubs(:[]).with(:name).returns(@name)
-
- @mounter.stubs(:resource).returns(@resource)
- end
-
- describe Puppet::Provider::Mount, " when mounting" do
-
- it "should use the 'mountcmd' method to mount" do
- @mounter.stubs(:options).returns(nil)
- @mounter.expects(:mountcmd)
-
- @mounter.mount
- end
-
- it "should flush before mounting if a flush method exists" do
- @mounter.meta_def(:flush) { }
- @mounter.expects(:flush)
- @mounter.stubs(:mountcmd)
- @mounter.stubs(:options).returns(nil)
-
- @mounter.mount
- end
-
- it "should add the options following '-o' if they exist and are not set to :absent" do
- @mounter.stubs(:options).returns("ro")
- @mounter.expects(:mountcmd).with { |*ary| ary[0] == "-o" and ary[1] == "ro" }
-
- @mounter.mount
- end
-
- it "should specify the filesystem name to the mount command" do
- @mounter.stubs(:options).returns(nil)
- @mounter.expects(:mountcmd).with { |*ary| ary[-1] == @name }
-
- @mounter.mount
- end
- end
-
- describe Puppet::Provider::Mount, " when remounting" do
-
- it "should use '-o remount' if the resource specifies it supports remounting" do
- @mounter.stubs(:info)
- @resource.stubs(:[]).with(:remounts).returns(:true)
- @mounter.expects(:mountcmd).with("-o", "remount", @name)
- @mounter.remount
- end
-
- it "should unmount and mount if the resource does not specify it supports remounting" do
- @mounter.stubs(:info)
- @resource.stubs(:[]).with(:remounts).returns(false)
- @mounter.expects(:unmount)
- @mounter.expects(:mount)
- @mounter.remount
- end
-
- it "should log that it is remounting" do
- @resource.stubs(:[]).with(:remounts).returns(:true)
- @mounter.stubs(:mountcmd)
- @mounter.expects(:info).with("Remounting")
- @mounter.remount
- end
- end
-
- describe Puppet::Provider::Mount, " when unmounting" do
-
- it "should call the :umount command with the resource name" do
- @mounter.expects(:umount).with(@name)
- @mounter.unmount
- end
- end
-
- describe Puppet::Provider::Mount, " when determining if it is mounted" do
-
- it "should parse the results of running the mount command with no arguments" do
- Facter.stubs(:value).returns("whatever")
- @mounter.expects(:mountcmd).returns("")
-
- @mounter.mounted?
- end
-
- it "should match ' on /private/var/automount<name>' if the operating system is Darwin" do
- Facter.stubs(:value).with("operatingsystem").returns("Darwin")
- @mounter.expects(:mountcmd).returns("/dev/whatever on /private/var/automount/\ndevfs on /dev")
-
- @mounter.should be_mounted
- end
-
- it "should match ' on <name>' if the operating system is Darwin" do
- Facter.stubs(:value).with("operatingsystem").returns("Darwin")
- @mounter.expects(:mountcmd).returns("/dev/disk03 on / (local, journaled)\ndevfs on /dev")
-
- @mounter.should be_mounted
- end
-
- it "should match '^<name> on' if the operating system is Solaris" do
- Facter.stubs(:value).with("operatingsystem").returns("Solaris")
- @mounter.expects(:mountcmd).returns("/ on /dev/dsk/whatever\n/var on /dev/dsk/other")
-
- @mounter.should be_mounted
- end
-
- it "should match ' on <name>' if the operating system is not Darwin or Solaris" do
- Facter.stubs(:value).with("operatingsystem").returns("Debian")
- @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on / and stuff\n/dev/other/disk on /var and stuff")
-
- @mounter.should be_mounted
- end
-
- it "should not be considered mounted if it did not match the mount output" do
- Facter.stubs(:value).with("operatingsystem").returns("Debian")
- @mounter.expects(:mountcmd).returns("/dev/dsk/whatever on /something/else and stuff\n/dev/other/disk on /var and stuff")
-
- @mounter.should_not be_mounted
- end
- end
-end
diff --git a/spec/unit/ral/provider/mount/parsed.rb b/spec/unit/ral/provider/mount/parsed.rb
deleted file mode 100755
index 21276d911..000000000
--- a/spec/unit/ral/provider/mount/parsed.rb
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/usr/bin/env ruby
-#
-# Created by Luke Kanies on 2007-9-12.
-# Copyright (c) 2006. All rights reserved.
-
-require File.dirname(__FILE__) + '/../../../../spec_helper'
-
-require 'puppettest/support/utils'
-require 'puppettest/fileparsing'
-
-module ParsedMountTesting
- include PuppetTest::Support::Utils
- include PuppetTest::FileParsing
-
- def fake_fstab
- os = Facter['operatingsystem']
- if os == "Solaris"
- name = "solaris.fstab"
- elsif os == "FreeBSD"
- name = "freebsd.fstab"
- else
- # Catchall for other fstabs
- name = "linux.fstab"
- end
- oldpath = @provider_class.default_target
- return fakefile(File::join("data/types/mount", name))
- end
-
- def mkmountargs
- mount = nil
-
- if defined? @pcount
- @pcount += 1
- else
- @pcount = 1
- end
- args = {
- :name => "/fspuppet%s" % @pcount,
- :device => "/dev/dsk%s" % @pcount,
- }
-
- @provider_class.fields(:parsed).each do |field|
- unless args.include? field
- args[field] = "fake%s%s" % [field, @pcount]
- end
- end
-
- return args
- end
-
- def mkmount
- hash = mkmountargs()
- #hash[:provider] = @provider_class.name
-
- fakeresource = stub :type => :mount, :name => hash[:name]
- fakeresource.stubs(:[]).with(:name).returns(hash[:name])
- fakeresource.stubs(:should).with(:target).returns(nil)
-
- mount = @provider_class.new(fakeresource)
- hash[:record_type] = :parsed
- hash[:ensure] = :present
- mount.property_hash = hash
-
- return mount
- end
-
- # Here we just create a fake host type that answers to all of the methods
- # but does not modify our actual system.
- def mkfaketype
- @provider.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram))
- end
-end
-
-provider_class = Puppet::Type.type(:mount).provider(:parsed)
-
-describe provider_class do
- before :each do
- @mount_class = Puppet.type(:mount)
- @provider_class = @mount_class.provider(:parsed)
- end
-
-
- describe provider_class do
- include ParsedMountTesting
-
- it "should be able to parse all of the example mount tabs" do
- tab = fake_fstab
- @provider = @provider_class
-
- # LAK:FIXME Again, a relatively bad test, but I don't know how to rspec-ify this.
- # I suppose this is more of an integration test? I dunno.
- fakedataparse(tab) do
- # Now just make we've got some mounts we know will be there
- hashes = @provider_class.target_records(tab).find_all { |i| i.is_a? Hash }
- (hashes.length > 0).should be_true
- root = hashes.find { |i| i[:name] == "/" }
-
- proc { @provider_class.to_file(hashes) }.should_not raise_error
- end
- end
-
- # LAK:FIXME I can't mock Facter because this test happens at parse-time.
- it "should default to /etc/vfstab on Solaris and /etc/fstab everywhere else" do
- should = case Facter.value(:operatingsystem)
- when "Solaris": "/etc/vfstab"
- else
- "/etc/fstab"
- end
- Puppet::Type.type(:mount).provider(:parsed).default_target.should == should
- end
- end
-
- describe provider_class, " when mounting an absent filesystem" do
- include ParsedMountTesting
-
- # #730 - Make sure 'flush' is called when a mount is moving from absent to mounted
- it "should flush the fstab to disk" do
- mount = mkmount
-
- # Mark the mount as absent
- mount.property_hash[:ensure] = :absent
-
- mount.stubs(:mountcmd) # just so we don't actually try to mount anything
-
- mount.expects(:flush)
- mount.mount
- end
- end
-
- describe provider_class, " when modifying the filesystem tab" do
- include ParsedMountTesting
- before do
- @mount = mkmount
- @target = @provider_class.default_target
-
- # Never write to disk, only to RAM.
- @provider_class.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram))
- end
-
- it "should write the mount to disk when :flush is called" do
- @mount.flush
-
- text = @provider_class.target_object(@provider_class.default_target).read
- text.should == @mount.class.to_line(@mount.property_hash) + "\n"
- end
- end
-
- describe provider_class, " when parsing information about the root filesystem" do
- confine "Mount type not tested on Darwin" => Facter["operatingsystem"].value != "Darwin"
- include ParsedMountTesting
-
- before do
- @mount = @mount_class.create :name => "/"
- @provider = @mount.provider
- end
-
- it "should have a filesystem tab" do
- FileTest.should be_exist(@provider_class.default_target)
- end
-
- it "should find the root filesystem" do
- @provider_class.prefetch("/" => @mount)
- @mount.provider.property_hash[:ensure].should == :present
- end
-
- it "should determine that the root fs is mounted" do
- @provider_class.prefetch("/" => @mount)
- @mount.provider.should be_mounted
- end
-
- after do
- Puppet::Type.allclear
- end
- end
-
- describe provider_class, " when mounting and unmounting" do
- include ParsedMountTesting
-
- it "should call the 'mount' command to mount the filesystem"
-
- it "should call the 'unmount' command to unmount the filesystem"
-
- it "should specify the filesystem when remounting a filesystem"
- end
-end
diff --git a/spec/unit/ral/provider/ssh_authorized_key/parsed.rb b/spec/unit/ral/provider/ssh_authorized_key/parsed.rb
deleted file mode 100755
index 459001cb5..000000000
--- a/spec/unit/ral/provider/ssh_authorized_key/parsed.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../../../spec_helper'
-
-require 'puppettest'
-require 'puppettest/support/utils'
-require 'puppettest/fileparsing'
-
-provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed)
-
-describe provider_class do
- include PuppetTest
- include PuppetTest::FileParsing
-
- before :each do
- @sshauthkey_class = Puppet.type(:ssh_authorized_key)
- @provider = @sshauthkey_class.provider(:parsed)
- end
-
- after :each do
- @provider.initvars
- end
-
- def mkkey(args)
- fakeresource = fakeresource(:ssh_authorized_key, args[:name])
-
- key = @provider.new(fakeresource)
- args.each do |p,v|
- key.send(p.to_s + "=", v)
- end
-
- return key
- end
-
- def genkey(key)
- @provider.filetype = :ram
- file = @provider.default_target
-
- key.flush
- text = @provider.target_object(file).read
- return text
- end
-
- it "should be able to parse each example" do
- fakedata("data/providers/ssh_authorized_key/parsed").each { |file|
- puts "Parsing %s" % file
- fakedataparse(file)
- }
- end
-
- 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]
- })
-
- 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"]
- })
-
- genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root@localhost\n"
- end
-end