~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to spec/unit/type/user.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../../spec_helper'
 
4
 
 
5
module UserTestFunctions
 
6
    def mkuser(name)
 
7
        user = nil;
 
8
        lambda {
 
9
            user = Puppet::Type.type(:user).create(
 
10
                :name => name,
 
11
                :comment => "Puppet Testing User",
 
12
                :gid => Puppet::Util::SUIDManager.gid,
 
13
                :shell => "/bin/sh",
 
14
                :home => "/home/%s" % name
 
15
        ) }.should_not raise_error
 
16
        user.should_not be_nil
 
17
        user
 
18
    end
 
19
 
 
20
    def test_provider_class(klass)
 
21
        klass.should_not be_nil
 
22
        klass.should be_an_instance_of(Class)
 
23
        superclasses = []
 
24
        while klass = klass.superclass
 
25
            superclasses << klass
 
26
        end
 
27
        superclasses.should include(Puppet::Provider)
 
28
    end
 
29
end
 
30
 
 
31
describe Puppet::Type.type(:user) do
 
32
 
 
33
    include UserTestFunctions
 
34
 
 
35
    it "should have a default provider inheriting from Puppet::Provider" do
 
36
        test_provider_class Puppet::Type.type(:user).defaultprovider
 
37
    end
 
38
 
 
39
    it "should be able to create a instance" do
 
40
        mkuser "123testuser1"
 
41
    end
 
42
end
 
43
 
 
44
describe Puppet::Type.type(:user), "instances" do
 
45
 
 
46
    include UserTestFunctions
 
47
 
 
48
    it "should have a valid provider" do
 
49
        user = mkuser "123testuser2"
 
50
        user.provider.should_not be_nil
 
51
        test_provider_class user.provider.class
 
52
    end
 
53
 
 
54
end
 
55
 
 
56