Ejemplo n.º 1
0
    def test_positive_update_1(self, test_name):
        """@Test: Check if Subnet name can be updated

        @Feature: Subnet - Update

        @Assert: Subnet name is updated

        """

        try:
            new_subnet = make_subnet()
        except CLIFactoryError as err:
            self.fail(err)

        # Fetch it
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(result.return_code, 0, "Subnet was not found")
        self.assertEqual(len(result.stderr), 0, "No error was expected")

        # Update the name
        result = Subnet.update({'id': new_subnet['id'], 'new-name': test_name})
        self.assertEqual(result.return_code, 0, "Subnet was not updated")
        self.assertEqual(len(result.stderr), 0, "No error was expected")

        # Fetch it again
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(result.return_code, 0, "Subnet was not found")
        self.assertEqual(len(result.stderr), 0, "No error was expected")
        self.assertEqual(result.stdout['name'], test_name,
                         "Names should match")
        self.assertNotEqual(result.stdout['name'], new_subnet['name'],
                            "Names should not match")
Ejemplo n.º 2
0
    def test_positive_delete_1(self, test_name):
        """
        @Test: Check if Subnet can be deleted
        @Feature: Subnet - Delete
        @Assert: Subnet is deleted
        """

        new_subnet = make_subnet({'name': test_name['name']})

        # Fetch it
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not found")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Delete it
        result = Subnet.delete({'id': result.stdout['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not deleted")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Fetch it again
        result = Subnet.info({'id': new_subnet['id']})
        self.assertGreater(
            result.return_code,
            0,
            "Subnet should not be found")
        self.assertGreater(
            len(result.stderr), 0, "No error was expected")
Ejemplo n.º 3
0
    def test_positive_delete_1(self, test_name):
        """@Test: Check if Subnet can be deleted

        @Feature: Subnet - Delete

        @Assert: Subnet is deleted

        """

        try:
            new_subnet = make_subnet({'name': test_name})
        except CLIFactoryError as err:
            self.fail(err)

        # Fetch it
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(result.return_code, 0, "Subnet was not found")
        self.assertEqual(len(result.stderr), 0, "No error was expected")

        # Delete it
        result = Subnet.delete({'id': result.stdout['id']})
        self.assertEqual(result.return_code, 0, "Subnet was not deleted")
        self.assertEqual(len(result.stderr), 0, "No error was expected")

        # Fetch it again
        result = Subnet.info({'id': new_subnet['id']})
        self.assertGreater(result.return_code, 0, "Subnet should not be found")
        self.assertGreater(len(result.stderr), 0, "No error was expected")
Ejemplo n.º 4
0
    def test_positive_delete_1(self):
        """@Test: Check if Subnet can be deleted

        @Feature: Subnet - Delete

        @Assert: Subnet is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                subnet = make_subnet({'name': name})
                Subnet.delete({'id': subnet['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Subnet.info({'id': subnet['id']})
Ejemplo n.º 5
0
    def test_positive_delete_by_id(self):
        """Check if Subnet can be deleted

        @id: ad269df8-4bb2-46a5-9c82-010a80087408

        @Assert: Subnet is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                subnet = make_subnet({'name': name})
                Subnet.delete({'id': subnet['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Subnet.info({'id': subnet['id']})
Ejemplo n.º 6
0
    def test_positive_delete_by_id(self):
        """Check if Subnet can be deleted

        @id: ad269df8-4bb2-46a5-9c82-010a80087408

        @Assert: Subnet is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                subnet = make_subnet({"name": name})
                Subnet.delete({"id": subnet["id"]})
                with self.assertRaises(CLIReturnCodeError):
                    Subnet.info({"id": subnet["id"]})
Ejemplo n.º 7
0
    def test_positive_delete_by_id(self):
        """Check if Subnet can be deleted

        @Feature: Subnet - Delete

        @Assert: Subnet is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                subnet = make_subnet({'name': name})
                Subnet.delete({'id': subnet['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Subnet.info({'id': subnet['id']})
Ejemplo n.º 8
0
    def test_positive_delete_by_id(self):
        """Check if Subnet can be deleted

        :id: ad269df8-4bb2-46a5-9c82-010a80087408

        :expectedresults: Subnet is deleted

        :CaseImportance: Critical
        """
        for name in valid_data_list():
            with self.subTest(name):
                subnet = make_subnet({'name': name})
                Subnet.delete({'id': subnet['id']})
                with self.assertRaises(CLIReturnCodeError):
                    Subnet.info({'id': subnet['id']})
Ejemplo n.º 9
0
    def test_negative_update_1(self, options):
        """@Test: Update subnet with invalid or missing required attributes

        @Feature: Subnet - Update

        @Assert: Subnet is not updated

        """

        bug_id = options.pop('bz-bug', None)
        if bug_id is not None and bz_bug_is_open(bug_id):
            self.skipTest('Bugzilla bug {0} is open.'.format(bug_id))

        try:
            subnet = make_subnet()
        except CLIFactoryError as err:
            self.fail(err)
        options['id'] = subnet['id']
        result = Subnet.update(options)
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)

        # check - subnet is not updated
        result = Subnet.info({u'id': subnet['id']})
        for key in options.keys():
            self.assertEqual(subnet[key], result.stdout[key])
Ejemplo n.º 10
0
    def test_positive_update_2(self):
        """@Test: Check if Subnet network and mask can be updated

        @Feature: Subnet - Update

        @Assert: Subnet network and mask are updated

        """

        network = gen_ipaddr()
        mask = '255.255.255.0'
        try:
            subnet = make_subnet({
                u'network': network,
                u'mask': mask,
            })
        except CLIFactoryError as err:
            self.fail(err)
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        result = Subnet.update({
            u'id': subnet['id'],
            u'network': new_network,
            u'mask': new_mask,
        })
        self.assertEqual(result.return_code, 0)

        # check - subnet is updated
        result = Subnet.info({u'id': subnet['id']})
        self.assertEqual(result.stdout['network'], new_network)
        self.assertEqual(result.stdout['mask'], new_mask)
Ejemplo n.º 11
0
    def test_negative_update_1(self, options):
        """@Test: Update subnet with invalid or missing required attributes

        @Feature: Subnet - Update

        @Assert: Subnet is not updated

        """

        bug_id = options.pop('bz-bug', None)
        if bug_id is not None and bz_bug_is_open(bug_id):
            self.skipTest('Bugzilla bug {0} is open.'.format(bug_id))

        try:
            subnet = make_subnet()
        except CLIFactoryError as err:
            self.fail(err)
        options['id'] = subnet['id']
        result = Subnet.update(options)
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)

        # check - subnet is not updated
        result = Subnet.info({u'id': subnet['id']})
        for key in options.keys():
            self.assertEqual(subnet[key], result.stdout[key])
Ejemplo n.º 12
0
    def test_negative_update_address_pool(self):
        """Update subnet with invalid address pool

        :id: d0a857b4-be10-4b5d-86d4-43cf99c11619

        :expectedresults: Subnet is not updated

        :CaseImportance: Critical
        """
        subnet = make_subnet()
        for options in invalid_addr_pools():
            with self.subTest(options):
                opts = {u'id': subnet['id']}
                # generate pool range from network address
                for key, val in options.items():
                    opts[key] = re.sub(r'\d+$', str(val), subnet['network'])
                with self.assertRaisesRegex(
                    CLIReturnCodeError,
                    u'Could not update the subnet:'
                ):
                    Subnet.update(opts)
                # check - subnet is not updated
                result = Subnet.info({u'id': subnet['id']})
                for key in options.keys():
                    self.assertEqual(result[key], subnet[key])
Ejemplo n.º 13
0
    def test_positive_update_3(self, pool):
        """@Test: Check if Subnet address pool can be updated

        @Feature: Subnet - Update

        @Assert: Subnet address pool is updated

        """
        pool.sort()
        try:
            subnet = make_subnet({u'mask': '255.255.255.0'})
        except CLIFactoryError as err:
            self.fail(err)
        # generate pool range from network address
        ip_from = re.sub('\d+$', str(pool[0]), subnet['network'])
        ip_to = re.sub('\d+$', str(pool[1]), subnet['network'])
        result = Subnet.update({
            u'id': subnet['id'],
            u'from': ip_from,
            u'to': ip_to,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # check - subnet is updated
        result = Subnet.info({u'id': subnet['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(result.stdout['from'], ip_from)
        self.assertEqual(result.stdout['to'], ip_to)
Ejemplo n.º 14
0
    def test_positive_update_network_mask(self):
        """Check if Subnet network and mask can be updated

        :id: 6a8d7750-71f1-4cd8-bf90-f2eac457c3b4

        :expectedresults: Subnet network and mask are updated

        :CaseImportance: Critical
        """
        network = gen_ipaddr()
        mask = '255.255.255.0'
        subnet = make_subnet({
            u'mask': mask,
            u'network': network,
        })
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        Subnet.update({
            u'id': subnet['id'],
            u'mask': new_mask,
            u'network': new_network,
        })
        # check - subnet is updated
        subnet = Subnet.info({u'id': subnet['id']})
        self.assertEqual(subnet['network'], new_network)
        self.assertEqual(subnet['mask'], new_mask)
Ejemplo n.º 15
0
    def test_positive_update_network_mask(self):
        """Check if Subnet network and mask can be updated

        :id: 6a8d7750-71f1-4cd8-bf90-f2eac457c3b4

        :expectedresults: Subnet network and mask are updated

        :CaseImportance: Critical
        """
        network = gen_ipaddr()
        mask = '255.255.255.0'
        subnet = make_subnet({
            u'mask': mask,
            u'network': network,
        })
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        Subnet.update({
            u'id': subnet['id'],
            u'mask': new_mask,
            u'network': new_network,
        })
        # check - subnet is updated
        subnet = Subnet.info({u'id': subnet['id']})
        self.assertEqual(subnet['network-addr'], new_network)
        self.assertEqual(subnet['network-mask'], new_mask)
Ejemplo n.º 16
0
    def test_positive_update_2(self):
        """@Test: Check if Subnet network and mask can be updated

        @Feature: Subnet - Update

        @Assert: Subnet network and mask are updated

        """
        network = gen_ipaddr()
        mask = '255.255.255.0'
        subnet = make_subnet({
            u'mask': mask,
            u'network': network,
        })
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        Subnet.update({
            u'id': subnet['id'],
            u'mask': new_mask,
            u'network': new_network,
        })
        # check - subnet is updated
        subnet = Subnet.info({u'id': subnet['id']})
        self.assertEqual(subnet['network'], new_network)
        self.assertEqual(subnet['mask'], new_mask)
Ejemplo n.º 17
0
    def test_positive_update_2(self):
        """@Test: Check if Subnet network and mask can be updated

        @Feature: Subnet - Update

        @Assert: Subnet network and mask are updated

        """

        network = gen_ipaddr()
        mask = '255.255.255.0'
        try:
            subnet = make_subnet({
                u'network': network,
                u'mask': mask,
            })
        except CLIFactoryError as err:
            self.fail(err)
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        result = Subnet.update({
            u'id': subnet['id'],
            u'network': new_network,
            u'mask': new_mask,
        })
        self.assertEqual(result.return_code, 0)

        # check - subnet is updated
        result = Subnet.info({u'id': subnet['id']})
        self.assertEqual(result.stdout['network'], new_network)
        self.assertEqual(result.stdout['mask'], new_mask)
Ejemplo n.º 18
0
    def test_positive_update_3(self, pool):
        """@Test: Check if Subnet address pool can be updated

        @Feature: Subnet - Update

        @Assert: Subnet address pool is updated

        """
        pool.sort()
        try:
            subnet = make_subnet({u'mask': '255.255.255.0'})
        except CLIFactoryError as err:
            self.fail(err)
        # generate pool range from network address
        ip_from = re.sub('\d+$', str(pool[0]), subnet['network'])
        ip_to = re.sub('\d+$', str(pool[1]), subnet['network'])
        result = Subnet.update({
            u'id': subnet['id'],
            u'from': ip_from,
            u'to': ip_to,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # check - subnet is updated
        result = Subnet.info({u'id': subnet['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(result.stdout['from'], ip_from)
        self.assertEqual(result.stdout['to'], ip_to)
Ejemplo n.º 19
0
    def test_positive_update_1(self, test_name):
        """@Test: Check if Subnet name can be updated

        @Feature: Subnet - Update

        @Assert: Subnet name is updated

        """

        try:
            new_subnet = make_subnet()
        except CLIFactoryError as err:
            self.fail(err)

        # Fetch it
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not found")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Update the name
        result = Subnet.update(
            {'id': new_subnet['id'], 'new-name': test_name})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not updated")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Fetch it again
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not found")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")
        self.assertEqual(
            result.stdout['name'], test_name, "Names should match")
        self.assertNotEqual(
            result.stdout['name'], new_subnet['name'], "Names should not match"
        )
Ejemplo n.º 20
0
    def test_positive_update_name(self):
        """Check if Subnet name can be updated

        @id: 34533e6c-7081-4b13-99bd-bd57533e05c0

        @Assert: Subnet name is updated
        """
        new_subnet = make_subnet()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Subnet.update({'id': new_subnet['id'], 'new-name': new_name})
                result = Subnet.info({'id': new_subnet['id']})
                self.assertEqual(result['name'], new_name)
Ejemplo n.º 21
0
    def test_positive_update_name(self):
        """Check if Subnet name can be updated

        @id: 34533e6c-7081-4b13-99bd-bd57533e05c0

        @Assert: Subnet name is updated
        """
        new_subnet = make_subnet()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Subnet.update({"id": new_subnet["id"], "new-name": new_name})
                result = Subnet.info({"id": new_subnet["id"]})
                self.assertEqual(result["name"], new_name)
Ejemplo n.º 22
0
    def test_positive_update_name(self):
        """Check if Subnet name can be updated

        @Feature: Subnet - Update

        @Assert: Subnet name is updated
        """
        new_subnet = make_subnet()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Subnet.update({'id': new_subnet['id'], 'new-name': new_name})
                result = Subnet.info({'id': new_subnet['id']})
                self.assertEqual(result['name'], new_name)
Ejemplo n.º 23
0
    def test_positive_update_1(self):
        """@Test: Check if Subnet name can be updated

        @Feature: Subnet - Update

        @Assert: Subnet name is updated
        """
        new_subnet = make_subnet()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Subnet.update({'id': new_subnet['id'], 'new-name': new_name})
                result = Subnet.info({'id': new_subnet['id']})
                self.assertEqual(result['name'], new_name)
Ejemplo n.º 24
0
    def test_positive_update_name(self):
        """Check if Subnet name can be updated

        :id: 34533e6c-7081-4b13-99bd-bd57533e05c0

        :expectedresults: Subnet name is updated

        :CaseImportance: Critical
        """
        new_subnet = make_subnet()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                Subnet.update({'id': new_subnet['id'], 'new-name': new_name})
                result = Subnet.info({'id': new_subnet['id']})
                self.assertEqual(result['name'], new_name)
Ejemplo n.º 25
0
    def test_negative_update_1(self):
        """@Test: Update subnet with invalid or missing required attributes

        @Feature: Subnet - Update

        @Assert: Subnet is not updated
        """
        subnet = make_subnet()
        for options in invalid_missing_attributes():
            with self.subTest(options):
                options['id'] = subnet['id']
                with self.assertRaises(CLIReturnCodeError):
                    Subnet.update(options)
                    # check - subnet is not updated
                    result = Subnet.info({u'id': subnet['id']})
                    for key in options.keys():
                        self.assertEqual(subnet[key], result[key])
Ejemplo n.º 26
0
    def test_negative_update_attributes(self):
        """Update subnet with invalid or missing required attributes

        @Feature: Subnet - Update

        @Assert: Subnet is not updated
        """
        subnet = make_subnet()
        for options in invalid_missing_attributes():
            with self.subTest(options):
                options['id'] = subnet['id']
                with self.assertRaises(CLIReturnCodeError):
                    Subnet.update(options)
                    # check - subnet is not updated
                    result = Subnet.info({u'id': subnet['id']})
                    for key in options.keys():
                        self.assertEqual(subnet[key], result[key])
Ejemplo n.º 27
0
    def test_positive_update_network_mask(self):
        """Check if Subnet network and mask can be updated

        @id: 6a8d7750-71f1-4cd8-bf90-f2eac457c3b4

        @Assert: Subnet network and mask are updated
        """
        network = gen_ipaddr()
        mask = "255.255.255.0"
        subnet = make_subnet({u"mask": mask, u"network": network})
        new_network = gen_ipaddr()
        new_mask = "255.255.192.0"
        Subnet.update({u"id": subnet["id"], u"mask": new_mask, u"network": new_network})
        # check - subnet is updated
        subnet = Subnet.info({u"id": subnet["id"]})
        self.assertEqual(subnet["network"], new_network)
        self.assertEqual(subnet["mask"], new_mask)
Ejemplo n.º 28
0
    def test_negative_update_attributes(self):
        """Update subnet with invalid or missing required attributes

        @id: ab60372e-cef7-4495-bd66-68e7dbece475

        @Assert: Subnet is not updated
        """
        subnet = make_subnet()
        for options in invalid_missing_attributes():
            with self.subTest(options):
                options["id"] = subnet["id"]
                with self.assertRaisesRegex(CLIReturnCodeError, u"Could not update the subnet:"):
                    Subnet.update(options)
                    # check - subnet is not updated
                    result = Subnet.info({u"id": subnet["id"]})
                    for key in options.keys():
                        self.assertEqual(subnet[key], result[key])
Ejemplo n.º 29
0
    def test_positive_update_address_pool(self):
        """Check if Subnet address pool can be updated

        @id: 18ced88f-d62e-4e15-8b7b-0a08c4ef239b

        @Assert: Subnet address pool is updated
        """
        subnet = make_subnet({u"mask": "255.255.255.0"})
        for pool in valid_addr_pools():
            with self.subTest(pool):
                pool.sort()
                # generate pool range from network address
                ip_from = re.sub(r"\d+$", str(pool[0]), subnet["network"])
                ip_to = re.sub(r"\d+$", str(pool[1]), subnet["network"])
                Subnet.update({u"from": ip_from, u"id": subnet["id"], u"to": ip_to})
                subnet = Subnet.info({u"id": subnet["id"]})
                self.assertEqual(subnet["from"], ip_from)
                self.assertEqual(subnet["to"], ip_to)
Ejemplo n.º 30
0
    def test_negative_update_attributes(self):
        """Update subnet with invalid or missing required attributes

        @id: ab60372e-cef7-4495-bd66-68e7dbece475

        @Assert: Subnet is not updated
        """
        subnet = make_subnet()
        for options in invalid_missing_attributes():
            with self.subTest(options):
                options['id'] = subnet['id']
                with self.assertRaisesRegex(CLIReturnCodeError,
                                            u'Could not update the subnet:'):
                    Subnet.update(options)
                    # check - subnet is not updated
                    result = Subnet.info({u'id': subnet['id']})
                    for key in options.keys():
                        self.assertEqual(subnet[key], result[key])
Ejemplo n.º 31
0
    def test_positive_create_1(self, test_name):
        """
        @Test: Check if Subnet can be created with random names
        @Feature: Subnet - Create
        @Assert: Subnet is created and has random name
        """

        new_subnet = make_subnet({'name': test_name['name']})

        # Fetch it
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not found")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")
        self.assertEqual(
            result.stdout['name'], new_subnet['name'], "Names don't match")
Ejemplo n.º 32
0
def test_negative_update_attributes(options):
    """Update subnet with invalid or missing required attributes

    :parametrized: yes

    :id: ab60372e-cef7-4495-bd66-68e7dbece475

    :expectedresults: Subnet is not updated

    :CaseImportance: Medium
    """
    subnet = make_subnet()
    options['id'] = subnet['id']
    with pytest.raises(CLIReturnCodeError, match='Could not update the subnet:'):
        Subnet.update(options)
        # check - subnet is not updated
        result = Subnet.info({'id': subnet['id']})
        for key in options.keys():
            assert subnet[key] == result[key]
Ejemplo n.º 33
0
    def test_positive_create_1(self, test_name):
        """@Test: Check if Subnet can be created with random names

        @Feature: Subnet - Create

        @Assert: Subnet is created and has random name

        """
        try:
            new_subnet = make_subnet({'name': test_name})
        except CLIFactoryError as err:
            self.fail(err)

        # Fetch it
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(result.return_code, 0, "Subnet was not found")
        self.assertEqual(len(result.stderr), 0, "No error was expected")
        self.assertEqual(result.stdout['name'], new_subnet['name'],
                         "Names don't match")
Ejemplo n.º 34
0
    def test_info(self):
        """
        @Feature: Subnet - Info
        @Test: Check if Subnet Info is displayed
        @Assert: Subnet Info is displayed
        """
        options = {}
        options['name'] = generate_name(8, 8)
        options['network'] = generate_ipaddr(ip3=True)
        options['mask'] = '255.255.255.0'

        Subnet.create(options)
        sleep_for_seconds(5)

        result = Subnet.info({'name': options['name']})

        self.assertTrue(len(result.stdout) > 1,
                        "Subnet info - returns 1 record")
        self.assertEquals(result.stdout['name'], options['name'],
                          "Subnet info - check name")
Ejemplo n.º 35
0
    def test_negative_update_address_pool(self):
        """Update subnet with invalid address pool

        @id: d0a857b4-be10-4b5d-86d4-43cf99c11619

        @Assert: Subnet is not updated
        """
        subnet = make_subnet()
        for options in invalid_addr_pools():
            with self.subTest(options):
                opts = {u"id": subnet["id"]}
                # generate pool range from network address
                for key, val in options.iteritems():
                    opts[key] = re.sub(r"\d+$", str(val), subnet["network"])
                with self.assertRaisesRegex(CLIReturnCodeError, u"Could not update the subnet:"):
                    Subnet.update(opts)
                # check - subnet is not updated
                result = Subnet.info({u"id": subnet["id"]})
                for key in options.keys():
                    self.assertEqual(result[key], subnet[key])
Ejemplo n.º 36
0
    def test_negative_update_2(self):
        """@Test: Update subnet with invalid address pool

        @Feature: Subnet - Update

        @Assert: Subnet is not updated
        """
        subnet = make_subnet()
        for options in invalid_addr_pools():
            with self.subTest(options):
                opts = {u'id': subnet['id']}
                # generate pool range from network address
                for key, val in options.iteritems():
                    opts[key] = re.sub(r'\d+$', str(val), subnet['network'])
                with self.assertRaises(CLIReturnCodeError):
                    Subnet.update(opts)
                # check - subnet is not updated
                result = Subnet.info({u'id': subnet['id']})
                for key in options.keys():
                    self.assertEqual(result[key], subnet[key])
Ejemplo n.º 37
0
    def test_negative_update_address_pool(self):
        """Update subnet with invalid address pool

        @Feature: Subnet - Update

        @Assert: Subnet is not updated
        """
        subnet = make_subnet()
        for options in invalid_addr_pools():
            with self.subTest(options):
                opts = {u'id': subnet['id']}
                # generate pool range from network address
                for key, val in options.iteritems():
                    opts[key] = re.sub(r'\d+$', str(val), subnet['network'])
                with self.assertRaises(CLIReturnCodeError):
                    Subnet.update(opts)
                # check - subnet is not updated
                result = Subnet.info({u'id': subnet['id']})
                for key in options.keys():
                    self.assertEqual(result[key], subnet[key])
Ejemplo n.º 38
0
def test_negative_update_address_pool(options):
    """Update subnet with invalid address pool

    :parametrized: yes

    :id: d0a857b4-be10-4b5d-86d4-43cf99c11619

    :expectedresults: Subnet is not updated

    :CaseImportance: Medium
    """
    subnet = make_subnet()
    opts = {'id': subnet['id']}
    # generate pool range from network address
    for key, val in options.items():
        opts[key] = re.sub(r'\d+$', str(val), subnet['network-addr'])
    with pytest.raises(CLIReturnCodeError, match='Could not update the subnet:'):
        Subnet.update(opts)
    # check - subnet is not updated
    result = Subnet.info({'id': subnet['id']})
    for key in ['start-of-ip-range', 'end-of-ip-range']:
        assert result[key] == subnet[key]
Ejemplo n.º 39
0
    def test_positive_update_address_pool(self):
        """Check if Subnet address pool can be updated

        @Feature: Subnet - Update

        @Assert: Subnet address pool is updated
        """
        subnet = make_subnet({u'mask': '255.255.255.0'})
        for pool in valid_addr_pools():
            with self.subTest(pool):
                pool.sort()
                # generate pool range from network address
                ip_from = re.sub(r'\d+$', str(pool[0]), subnet['network'])
                ip_to = re.sub(r'\d+$', str(pool[1]), subnet['network'])
                Subnet.update({
                    u'from': ip_from,
                    u'id': subnet['id'],
                    u'to': ip_to,
                })
                subnet = Subnet.info({u'id': subnet['id']})
                self.assertEqual(subnet['from'], ip_from)
                self.assertEqual(subnet['to'], ip_to)
Ejemplo n.º 40
0
    def test_positive_update_3(self):
        """@Test: Check if Subnet address pool can be updated

        @Feature: Subnet - Update

        @Assert: Subnet address pool is updated
        """
        subnet = make_subnet({u'mask': '255.255.255.0'})
        for pool in valid_addr_pools():
            with self.subTest(pool):
                pool.sort()
                # generate pool range from network address
                ip_from = re.sub(r'\d+$', str(pool[0]), subnet['network'])
                ip_to = re.sub(r'\d+$', str(pool[1]), subnet['network'])
                Subnet.update({
                    u'from': ip_from,
                    u'id': subnet['id'],
                    u'to': ip_to,
                })
                subnet = Subnet.info({u'id': subnet['id']})
                self.assertEqual(subnet['from'], ip_from)
                self.assertEqual(subnet['to'], ip_to)
Ejemplo n.º 41
0
    def test_positive_delete_1(self, test_name):
        """@Test: Check if Subnet can be deleted

        @Feature: Subnet - Delete

        @Assert: Subnet is deleted

        """
        try:
            subnet = make_subnet({'name': test_name})
        except CLIFactoryError as err:
            self.fail(err)

        # Delete it
        result = Subnet.delete({'id': subnet['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Fetch it again
        result = Subnet.info({'id': subnet['id']})
        self.assertGreater(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Ejemplo n.º 42
0
    def test_positive_update_address_pool(self):
        """Check if Subnet address pool can be updated

        :id: 18ced88f-d62e-4e15-8b7b-0a08c4ef239b

        :expectedresults: Subnet address pool is updated
        """
        subnet = make_subnet({u'mask': '255.255.255.0'})
        for pool in valid_addr_pools():
            with self.subTest(pool):
                pool.sort()
                # generate pool range from network address
                ip_from = re.sub(r'\d+$', str(pool[0]), subnet['network-addr'])
                ip_to = re.sub(r'\d+$', str(pool[1]), subnet['network-addr'])
                Subnet.update({
                    u'from': ip_from,
                    u'id': subnet['id'],
                    u'to': ip_to,
                })
                subnet = Subnet.info({u'id': subnet['id']})
                self.assertEqual(subnet['start-of-ip-range'], ip_from)
                self.assertEqual(subnet['end-of-ip-range'], ip_to)
Ejemplo n.º 43
0
    def test_negative_update_attributes(self):
        """Update subnet with invalid or missing required attributes

        :id: ab60372e-cef7-4495-bd66-68e7dbece475

        :expectedresults: Subnet is not updated

        :CaseImportance: Critical
        """
        subnet = make_subnet()
        for options in invalid_missing_attributes():
            with self.subTest(options):
                options['id'] = subnet['id']
                with self.assertRaisesRegex(
                    CLIReturnCodeError,
                    u'Could not update the subnet:'
                ):
                    Subnet.update(options)
                    # check - subnet is not updated
                    result = Subnet.info({u'id': subnet['id']})
                    for key in options.keys():
                        self.assertEqual(subnet[key], result[key])
Ejemplo n.º 44
0
    def test_negative_update_2(self, options):
        """@Test: Update subnet with invalid address pool

        @Feature: Subnet - Update

        @Assert: Subnet is not updated

        """
        try:
            subnet = make_subnet()
        except CLIFactoryError as err:
            self.fail(err)

        opts = {u'id': subnet['id']}
        # generate pool range from network address
        for key, val in options.iteritems():
            opts[key] = re.sub('\d+$', str(val), subnet['network'])
        result = Subnet.update(opts)
        self.assertNotEqual(result.return_code, 0)

        # check - subnet is not updated
        result = Subnet.info({u'id': subnet['id']})
        for key in options.keys():
            self.assertEqual(result.stdout[key], subnet[key])
Ejemplo n.º 45
0
    def test_positive_update_network_mask(self):
        """Check if Subnet network and mask can be updated

        @Feature: Subnet - Update

        @Assert: Subnet network and mask are updated
        """
        network = gen_ipaddr()
        mask = '255.255.255.0'
        subnet = make_subnet({
            u'mask': mask,
            u'network': network,
        })
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        Subnet.update({
            u'id': subnet['id'],
            u'mask': new_mask,
            u'network': new_network,
        })
        # check - subnet is updated
        subnet = Subnet.info({u'id': subnet['id']})
        self.assertEqual(subnet['network'], new_network)
        self.assertEqual(subnet['mask'], new_mask)
Ejemplo n.º 46
0
    def test_positive_update_network_mask(self):
        """Check if Subnet network and mask can be updated

        @id: 6a8d7750-71f1-4cd8-bf90-f2eac457c3b4

        @Assert: Subnet network and mask are updated
        """
        network = gen_ipaddr()
        mask = '255.255.255.0'
        subnet = make_subnet({
            u'mask': mask,
            u'network': network,
        })
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        Subnet.update({
            u'id': subnet['id'],
            u'mask': new_mask,
            u'network': new_network,
        })
        # check - subnet is updated
        subnet = Subnet.info({u'id': subnet['id']})
        self.assertEqual(subnet['network'], new_network)
        self.assertEqual(subnet['mask'], new_mask)
Ejemplo n.º 47
0
    def test_negative_update_2(self, options):
        """@Test: Update subnet with invalid address pool

        @Feature: Subnet - Update

        @Assert: Subnet is not updated

        """
        try:
            subnet = make_subnet()
        except CLIFactoryError as err:
            self.fail(err)

        opts = {u'id': subnet['id']}
        # generate pool range from network address
        for key, val in options.iteritems():
            opts[key] = re.sub('\d+$', str(val), subnet['network'])
        result = Subnet.update(opts)
        self.assertNotEqual(result.return_code, 0)

        # check - subnet is not updated
        result = Subnet.info({u'id': subnet['id']})
        for key in options.keys():
            self.assertEqual(result.stdout[key], subnet[key])
Ejemplo n.º 48
0
    def test_positive_update_address_pool(self):
        """Check if Subnet address pool can be updated

        :id: 18ced88f-d62e-4e15-8b7b-0a08c4ef239b

        :expectedresults: Subnet address pool is updated

        :CaseImportance: Critical
        """
        subnet = make_subnet({u'mask': '255.255.255.0'})
        for pool in valid_addr_pools():
            with self.subTest(pool):
                pool.sort()
                # generate pool range from network address
                ip_from = re.sub(r'\d+$', str(pool[0]), subnet['network'])
                ip_to = re.sub(r'\d+$', str(pool[1]), subnet['network'])
                Subnet.update({
                    u'from': ip_from,
                    u'id': subnet['id'],
                    u'to': ip_to,
                })
                subnet = Subnet.info({u'id': subnet['id']})
                self.assertEqual(subnet['from'], ip_from)
                self.assertEqual(subnet['to'], ip_to)
Ejemplo n.º 49
0
    def test_positive_CRUD(self):
        """Create, update and delete subnet

        :id: d74a52a7-df56-44ef-89a3-081c14e81e43

        :expectedresults: Subnet is created, updated and deleted

        :CaseImportance: Critical
        """
        name = valid_data_list()[0]
        pool = sorted(valid_addr_pools()[0])
        mask = '255.255.255.0'
        # generate pool range from network address
        network = gen_ipaddr()
        from_ip = re.sub(r'\d+$', str(pool[0]), network)
        to_ip = re.sub(r'\d+$', str(pool[1]), network)
        domains_amount = random.randint(3, 5)
        domains = [make_domain() for _ in range(domains_amount)]
        gateway = gen_ipaddr(ip3=True)
        ipam_type = SUBNET_IPAM_TYPES['dhcp']
        subnet = make_subnet(
            {
                'name': name,
                'from': from_ip,
                'mask': mask,
                'network': network,
                'to': to_ip,
                'domain-ids': [domain['id'] for domain in domains],
                'gateway': gateway,
                'ipam': ipam_type,
            }
        )
        # Check if Subnet can be listed
        subnets_ids = [subnet_['id'] for subnet_ in Subnet.list()]
        self.assertIn(subnet['id'], subnets_ids)
        self.assertEqual(subnet['name'], name)
        self.assertEqual(subnet['start-of-ip-range'], from_ip)
        self.assertEqual(subnet['end-of-ip-range'], to_ip)
        self.assertEqual(len(subnet['domains']), domains_amount)
        for domain in domains:
            self.assertIn(domain['name'], subnet['domains'])
        self.assertIn(gateway, subnet['gateway-addr'])
        self.assertIn(ipam_type, subnet['ipam'])

        # update subnet
        new_name = valid_data_list()[0]
        pool = sorted(valid_addr_pools()[0])
        # generate pool range from network address
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        ip_from = re.sub(r'\d+$', str(pool[0]), new_network)
        ip_to = re.sub(r'\d+$', str(pool[1]), new_network)
        ipam_type = SUBNET_IPAM_TYPES['internal']
        Subnet.update(
            {
                'new-name': new_name,
                'from': ip_from,
                'id': subnet['id'],
                'to': ip_to,
                'mask': new_mask,
                'network': new_network,
                'ipam': ipam_type,
                'domain-ids': "",  # delete domains needed for subnet delete
            }
        )
        subnet = Subnet.info({'id': subnet['id']})
        self.assertEqual(subnet['name'], new_name)
        self.assertEqual(subnet['start-of-ip-range'], ip_from)
        self.assertEqual(subnet['end-of-ip-range'], ip_to)
        self.assertEqual(subnet['network-addr'], new_network)
        self.assertEqual(subnet['network-mask'], new_mask)
        self.assertIn(ipam_type, subnet['ipam'])

        # delete subnet
        Subnet.delete({'id': subnet['id']})
        with self.assertRaises(CLIReturnCodeError):
            Subnet.info({'id': subnet['id']})