~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to test/network/client/resource.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    include PuppetTest::ServerTest
12
12
    include PuppetTest::Support::Utils
13
13
 
 
14
    def setup
 
15
        super
 
16
 
 
17
        Puppet::Type.type(:user).provider(:directoryservice).stubs(:get_macosx_version_major).returns "10.5"
 
18
    end
 
19
 
14
20
    def mkresourceserver
15
21
        Puppet::Network::Handler.resource.new
16
22
    end
29
35
        client = mkclient()
30
36
 
31
37
        # Test describing
32
 
        tobj = nil
33
 
        assert_nothing_raised {
34
 
            tobj = client.describe("file", file)
35
 
        }
36
 
 
37
 
        assert(tobj, "Did not get response")
38
 
 
39
 
        assert_instance_of(Puppet::TransObject, tobj)
40
 
 
41
 
        Puppet::Type.allclear
42
 
        obj = nil
43
 
        assert_nothing_raised {
44
 
            obj = tobj.to_type
45
 
        }
46
 
        assert_events([], obj)
47
 
        File.unlink(file)
48
 
        assert_events([:file_created], obj)
49
 
        File.unlink(file)
 
38
        tresource = client.describe("file", file)
 
39
 
 
40
        assert(tresource, "Did not get response")
 
41
 
 
42
        assert_instance_of(Puppet::TransObject, tresource)
 
43
 
 
44
        resource = tresource.to_ral
 
45
        assert_equal(File.stat(file).mode & 007777, resource[:mode], "Did not get mode")
50
46
 
51
47
        # Now test applying
52
 
        Puppet::Type.allclear
53
 
        result = nil
54
 
        assert_nothing_raised {
55
 
            result = client.apply(tobj)
56
 
        }
 
48
        result = client.apply(tresource)
57
49
        assert(FileTest.exists?(file), "File was not created on apply")
58
 
 
59
 
        # Lastly, test "list"
60
 
        Puppet::Type.allclear
61
 
        list = nil
62
 
        assert_nothing_raised {
63
 
            list = client.list("user")
64
 
        }
65
 
 
66
 
        assert_instance_of(Puppet::TransBucket, list)
67
 
 
68
 
        count = 0
69
 
        list.each do |tobj|
70
 
            break if count > 3
71
 
            assert_instance_of(Puppet::TransObject, tobj)
72
 
 
73
 
            Puppet::Type.allclear
74
 
            tobj2 = nil
75
 
            assert_nothing_raised {
76
 
                tobj2 = client.describe(tobj.type, tobj.name)
77
 
            }
78
 
 
79
 
            obj = nil
80
 
            Puppet::Type.allclear
81
 
            assert_nothing_raised {
82
 
                obj = tobj2.to_type
83
 
            }
84
 
            assert_events([], obj)
85
 
 
86
 
            count += 1
87
 
        end
88
50
    end
89
51
end
90
52