How to use the cobbler.test_basic.BootTest function in cobbler

To help you get started, we’ve selected a few cobbler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cobbler / cobbler / cobbler / test_basic.py View on Github external
self.assertFalse(authorize(self.api, "dne", "sync"), "dne cannot sync")

        # unlike the distro testdistro0, testrepo0 is unowned
        # so any user in the file will be able to edit it.
        for user in [ "admin1", "superlab1", "basement1", "basement2" ]:
           self.assertTrue(authorize(self.api, user, "save_repo", ro), "user %s can save_repo" % user)

        # though dne is still not listed and will be denied
        self.assertFalse(authorize(self.api, "dne", "save_repo", ro), "dne cannot save_repo")

        # if we survive, restore the users file as module testing is done
        if os.path.exists("/tmp/cobbler_ubak"):
           shutil.copyfile("/etc/cobbler/users.conf","/tmp/cobbler_ubak")


class MultiNIC(BootTest):
    
    def test_multi_nic_support(self):


        system = self.api.new_system()
        self.assertTrue(system.set_name("nictest"))
        self.assertTrue(system.set_profile("testprofile0"))
        self.assertTrue(system.set_dns_name("zero","eth0"))
        self.assertTrue(system.set_mac_address("EE:FF:DD:CC:DD:CC","eth1"))
        self.assertTrue(system.set_ip_address("127.0.0.5","eth2"))
        self.assertTrue(system.set_dhcp_tag("zero","eth3"))
        self.assertTrue(system.set_virt_bridge("zero","eth4"))
        self.assertTrue(system.set_gateway("192.168.1.25")) # is global
        self.assertTrue(system.set_name_servers("a.example.org b.example.org")) # is global
        self.assertTrue(system.set_mac_address("AA:AA:BB:BB:CC:CC","eth4"))
        self.assertTrue(system.set_dns_name("fooserver","eth4"))
github cobbler / cobbler / cobbler / test_basic.py View on Github external
def test_invalid_delete_distro_would_orphan_profile(self):
        self.failUnlessRaises(CobblerException, self.api.distros().remove, "testdistro0")

    #def test_working_deletes(self):
    #    self.api.clear()
    #    # self.make_basic_config()
    #    #self.assertTrue(self.api.systems().remove("testsystem0"))
    #    self.api.serialize()
    #    self.assertTrue(self.api.remove_profile("testprofile0"))
    #    self.assertTrue(self.api.remove_distro("testdistro0"))
    #    #self.assertFalse(self.api.find_system(name="testsystem0"))
    #    self.assertFalse(self.api.find_profile(name="testprofile0"))
    #    self.assertFalse(self.api.find_distro(name="testdistro0"))

class TestCheck(BootTest):

   def test_check(self):
       # we can't know if it's supposed to fail in advance
       # (ain't that the halting problem), but it shouldn't ever
       # throw exceptions.
       self.api.check()

class TestSync(BootTest):

   def test_real_run(self):
       # syncing a real test run in an automated environment would
       # break a valid cobbler configuration, so we're not going to
       # test this here.
       pass

class TestListings(BootTest):
github cobbler / cobbler / cobbler / test_basic.py View on Github external
#    self.api.serialize()
    #    self.assertTrue(self.api.remove_profile("testprofile0"))
    #    self.assertTrue(self.api.remove_distro("testdistro0"))
    #    #self.assertFalse(self.api.find_system(name="testsystem0"))
    #    self.assertFalse(self.api.find_profile(name="testprofile0"))
    #    self.assertFalse(self.api.find_distro(name="testdistro0"))

class TestCheck(BootTest):

   def test_check(self):
       # we can't know if it's supposed to fail in advance
       # (ain't that the halting problem), but it shouldn't ever
       # throw exceptions.
       self.api.check()

class TestSync(BootTest):

   def test_real_run(self):
       # syncing a real test run in an automated environment would
       # break a valid cobbler configuration, so we're not going to
       # test this here.
       pass

class TestListings(BootTest):

   def test_listings(self):
       # check to see if the collection listings output something.
       # this is a minimal check, mainly for coverage, not validity
       # self.make_basic_config()
       self.assertTrue(len(self.api.systems().printable()) > 0)
       self.assertTrue(len(self.api.profiles().printable()) > 0)
       self.assertTrue(len(self.api.distros().printable()) > 0)
github cobbler / cobbler / cobbler / test_basic.py View on Github external
pass
        except:
           self.assertTrue(1==2,"wrong exception type")

        # fix the IP and Mac back 
        self.assertTrue(system3.set_ip_address("192.86.75.30","eth6"))
        self.assertTrue(system3.set_mac_address("AE:BE:DE:CE:AE:EE","eth3"))
        # now it works again
        # note that we will not check for duplicate names as we want
        # to test this as an 'edit' operation.
        self.assertTrue(self.api.add_system(system3,check_for_duplicate_names=False,check_for_duplicate_netinfo=True))

        # FIXME: note -- how netinfo is handled when doing renames/copies/edits
        # is more involved and we probably should add tests for that also.

class Ownership(BootTest):

    def test_ownership_params(self):
   
        fd = open("/tmp/test_cobbler_kickstart","w+")
        fd.write("")
        fd.close()

        # find things we are going to test with
        distro = self.api.find_distro(name="testdistro0")
        profile = self.api.find_profile(name="testprofile0")
        system = self.api.find_system(name="testsystem0")
        repo = self.api.find_repo(name="testrepo0")

        # as we didn't specify an owner for objects, the default
        # ownership should be as specified in settings
        default_owner = self.api.settings().default_ownership
github cobbler / cobbler / cobbler / test_basic.py View on Github external
def test_system_name_is_an_IP(self):
        system = self.api.new_system()
        name = "192.168.1.54"
        self.assertTrue(system.set_name(name))
        self.assertTrue(system.set_profile("testprofile0"))
        self.assertTrue(self.api.add_system(system))
        self.assertTrue(self.api.find_system(name=name))

    def test_invalid_system_non_referenced_profile(self):
        system = self.api.new_system()
        self.assertTrue(system.set_name("testsystem0"))
        self.failUnlessRaises(CobblerException, system.set_profile, "profiledoesntexist")
        self.failUnlessRaises(CobblerException, self.api.add_system, system)

class SyncContents(BootTest):

    def test_blender_cache_works(self):

        distro = self.api.new_distro()
        self.assertTrue(distro.set_name("D1"))
        self.assertTrue(distro.set_kernel(self.fk_kernel))
        self.assertTrue(distro.set_initrd(self.fk_initrd))
        self.assertTrue(self.api.add_distro(distro))
        self.assertTrue(self.api.find_distro(name="D1"))

        profile = self.api.new_profile()
        self.assertTrue(profile.set_name("P1"))
        self.assertTrue(profile.set_distro("D1"))
        self.assertTrue(profile.set_kickstart("/var/lib/cobbler/kickstarts/sample.ks"))
        self.assertTrue(self.api.add_profile(profile))
        assert self.api.find_profile(name="P1") != None
github cobbler / cobbler / cobbler / test_basic.py View on Github external
def test_invalid_delete_distro_would_orphan_profile(self):
        self.failUnlessRaises(CobblerException, self.api.distros().remove, "testdistro0")

    #def test_working_deletes(self):
    #    self.api.clear()
    #    # self.make_basic_config()
    #    #self.assertTrue(self.api.systems().remove("testsystem0"))
    #    self.api.serialize()
    #    self.assertTrue(self.api.remove_profile("testprofile0"))
    #    self.assertTrue(self.api.remove_distro("testdistro0"))
    #    #self.assertFalse(self.api.find_system(name="testsystem0"))
    #    self.assertFalse(self.api.find_profile(name="testprofile0"))
    #    self.assertFalse(self.api.find_distro(name="testdistro0"))

class TestCheck(BootTest):

   def test_check(self):
       # we can't know if it's supposed to fail in advance
       # (ain't that the halting problem), but it shouldn't ever
       # throw exceptions.
       self.api.check()

class TestSync(BootTest):

   def test_real_run(self):
       # syncing a real test run in an automated environment would
       # break a valid cobbler configuration, so we're not going to
       # test this here.
       pass

class TestListings(BootTest):
github cobbler / cobbler / cobbler / test_basic.py View on Github external
def test_check(self):
       # we can't know if it's supposed to fail in advance
       # (ain't that the halting problem), but it shouldn't ever
       # throw exceptions.
       self.api.check()

class TestSync(BootTest):

   def test_real_run(self):
       # syncing a real test run in an automated environment would
       # break a valid cobbler configuration, so we're not going to
       # test this here.
       pass

class TestListings(BootTest):

   def test_listings(self):
       # check to see if the collection listings output something.
       # this is a minimal check, mainly for coverage, not validity
       # self.make_basic_config()
       self.assertTrue(len(self.api.systems().printable()) > 0)
       self.assertTrue(len(self.api.profiles().printable()) > 0)
       self.assertTrue(len(self.api.distros().printable()) > 0)

class TestImage(BootTest):

    def test_image_file(self):
        # ensure that only valid names are accepted and invalid ones are rejected
        image = self.api.new_image()
        self.assertTrue(image.set_file("nfs://hostname/path/to/filename.iso"))
        self.assertTrue(image.set_file("nfs://mcpierce@hostname:/path/to/filename.iso"))
github cobbler / cobbler / cobbler / test_basic.py View on Github external
# now check one interface to make sure it's exactly right
        # and we didn't accidentally fill in any other fields elsewhere

        self.assertTrue(system.interfaces.has_key("eth4"))
        self.assertTrue(system.gateway == "192.168.1.25")
        for (name,intf) in system.interfaces.iteritems():
            if name == "eth4": # xmlrpc dicts must have string keys, so we must also
                self.assertTrue(intf["virt_bridge"] == "zero")
                self.assertTrue(intf["netmask"] == "255.255.255.0")
                self.assertTrue(intf["mac_address"] == "AA:AA:BB:BB:CC:CC")
                self.assertTrue(intf["ip_address"] == "192.168.1.26")
                self.assertTrue(intf["dns_name"] == "fooserver")
                self.assertTrue(intf["dhcp_tag"] == "red")
 
class Utilities(BootTest):

    def _expeq(self, expected, actual):
        try:
            self.failUnlessEqual(expected, actual,
                "Expected: %s; actual: %s" % (expected, actual))
        except:
            self.fail("exception during failUnlessEqual")

    def test_kernel_scan(self):
        self.assertTrue(utils.find_kernel(self.fk_kernel))
        self.assertFalse(utils.find_kernel("filedoesnotexist"))
        self._expeq(self.fk_kernel, utils.find_kernel(self.topdir))

    def test_initrd_scan(self):
        self.assertTrue(utils.find_initrd(self.fk_initrd))
        self.assertFalse(utils.find_initrd("filedoesnotexist"))
github cobbler / cobbler / cobbler / test_basic.py View on Github external
# syncing a real test run in an automated environment would
       # break a valid cobbler configuration, so we're not going to
       # test this here.
       pass

class TestListings(BootTest):

   def test_listings(self):
       # check to see if the collection listings output something.
       # this is a minimal check, mainly for coverage, not validity
       # self.make_basic_config()
       self.assertTrue(len(self.api.systems().printable()) > 0)
       self.assertTrue(len(self.api.profiles().printable()) > 0)
       self.assertTrue(len(self.api.distros().printable()) > 0)

class TestImage(BootTest):

    def test_image_file(self):
        # ensure that only valid names are accepted and invalid ones are rejected
        image = self.api.new_image()
        self.assertTrue(image.set_file("nfs://hostname/path/to/filename.iso"))
        self.assertTrue(image.set_file("nfs://mcpierce@hostname:/path/to/filename.iso"))
        self.assertTrue(image.set_file("nfs://hostname:/path/to/filename.iso"))
        self.assertTrue(image.set_file("nfs://hostname/filename.iso"))
        self.assertTrue(image.set_file("hostname:/path/to/the/filename.iso"))
        self.failUnlessRaises(CX, image.set_file, "hostname:filename.iso")
        self.failUnlessRaises(CX, image.set_file, "path/to/filename.iso")
        self.failUnlessRaises(CX, image.set_file, "hostname:")
        # port is not allowed
        self.failUnlessRaises(CX, image.set_file, "nfs://hostname:1234/path/to/the/filename.iso")

#class TestCLIBasic(BootTest):
github cobbler / cobbler / cobbler / test_basic.py View on Github external
renamer(y, name1) 
        x = finder(name1)
        y = finder(name2)
        assert x is not None
        assert y is None 

    def test_renames(self):
        self.__tester(self.api.find_distro, self.api.rename_distro, "testdistro0", "testdistro1")
        self.__tester(self.api.find_profile, self.api.rename_profile, "testprofile0", "testprofile1")
        self.__tester(self.api.find_system, self.api.rename_system, "testsystem0", "testsystem1")
        self.__tester(self.api.find_repo, self.api.rename_repo, "testrepo0", "testrepo1")
        self.__tester(self.api.find_image, self.api.rename_image, "testimage0", "testimage1")


class DuplicateNamesAndIpPrevention(BootTest):

    """
    The command line (and WebUI) have checks to prevent new system
    additions from conflicting with existing systems and overwriting
    them inadvertantly. This class tests that code.  NOTE: General API
    users will /not/ encounter these checks.
    """

    def test_duplicate_prevention(self):

        # find things we are going to test with
        distro1 = self.api.find_distro(name="testdistro0")
        profile1 = self.api.find_profile(name="testprofile0")
        system1 = self.api.find_system(name="testsystem0")
        repo1 = self.api.find_repo(name="testrepo0")