Exemplo n.º 1
0
class TestExtensionReader(unittest.TestCase):
    """Unit tests for ExtensionsReader.These
    tests check whether the returned extensions vary
    when they are configured differently."""

    def setUp(self):
        self.original_extensions = CONF.extensions
        CONF.set_override(CONFIG_EXTENSION_PROPERTY, ["osksadm"])
        self.extensions_reader = ExtensionsReader(EXTENSION_ADMIN_PREFIX)

    def tearDown(self):
        CONF.set_override(CONFIG_EXTENSION_PROPERTY, self.original_extensions)

    def test_extensions_reader_getsupportedoptions(self):
        self.assertIn('osksadm', get_supported_extensions())

    def test_extensions_with_only_osksadm_json(self):
        r = self.extensions_reader.get_extensions().to_json()
        content = json.loads(r)
        self.assertIsNotNone(content['extensions'])
        self.assertIsNotNone(content['extensions']['values'])
        found_osksadm = False
        found_oskscatalog = False
        for value in content['extensions']['values']:
            if value['extension']['alias'] == 'OS-KSADM':
                found_osksadm = True
            if value['extension']['alias'] == 'OS-KSCATALOG':
                found_oskscatalog = True
        self.assertTrue(found_osksadm,
            "Missing OS-KSADM extension.")
        self.assertFalse(found_oskscatalog,
            "Non configured OS-KSCATALOG extension returned.")

    def test_extensions_with_only_osksadm_xml(self):
        r = self.extensions_reader.get_extensions().to_xml()
        content = ElementTree.XML(r)
        extensions = content.findall(
            "{http://docs.openstack.org/common/api/v1.0}extension")
        found_osksadm = False
        found_oskscatalog = False
        for extension in extensions:
            if extension.get("alias") == 'OS-KSADM':
                found_osksadm = True
            if extension.get("alias") == 'OS-KSCATALOG':
                found_oskscatalog = True
        self.assertTrue(found_osksadm,
            "Missing OS-KSADM extension.")
        self.assertFalse(found_oskscatalog,
            "Non configured OS-KSCATALOG extension returned.")
Exemplo n.º 2
0
class TestExtensionReader(unittest.TestCase):
    """Unit tests for ExtensionsReader.These
    tests check whether the returned extensions vary
    when they are configured differently."""
    def setUp(self):
        self.original_extensions = CONF.extensions
        CONF.set_override(CONFIG_EXTENSION_PROPERTY, ["osksadm"])
        self.extensions_reader = ExtensionsReader(EXTENSION_ADMIN_PREFIX)

    def tearDown(self):
        CONF.set_override(CONFIG_EXTENSION_PROPERTY, self.original_extensions)

    def test_extensions_reader_getsupportedoptions(self):
        self.assertIn('osksadm', get_supported_extensions())

    def test_extensions_with_only_osksadm_json(self):
        r = self.extensions_reader.get_extensions().to_json()
        content = json.loads(r)
        self.assertIsNotNone(content['extensions'])
        self.assertIsNotNone(content['extensions']['values'])
        found_osksadm = False
        found_oskscatalog = False
        for value in content['extensions']['values']:
            if value['extension']['alias'] == 'OS-KSADM':
                found_osksadm = True
            if value['extension']['alias'] == 'OS-KSCATALOG':
                found_oskscatalog = True
        self.assertTrue(found_osksadm, "Missing OS-KSADM extension.")
        self.assertFalse(found_oskscatalog,
                         "Non configured OS-KSCATALOG extension returned.")

    def test_extensions_with_only_osksadm_xml(self):
        r = self.extensions_reader.get_extensions().to_xml()
        content = ElementTree.XML(r)
        extensions = content.findall(
            "{http://docs.openstack.org/common/api/v1.0}extension")
        found_osksadm = False
        found_oskscatalog = False
        for extension in extensions:
            if extension.get("alias") == 'OS-KSADM':
                found_osksadm = True
            if extension.get("alias") == 'OS-KSCATALOG':
                found_oskscatalog = True
        self.assertTrue(found_osksadm, "Missing OS-KSADM extension.")
        self.assertFalse(found_oskscatalog,
                         "Non configured OS-KSCATALOG extension returned.")
Exemplo n.º 3
0
class ExtensionsController(BaseController):
    """Controller for extensions related methods"""
    def __init__(self, is_service_operation=None):
        super(ExtensionsController, self).__init__()
        if is_service_operation:
            self.extension_prefix = EXTENSION_SERVICE_PREFIX
        else:
            self.extension_prefix = EXTENSION_ADMIN_PREFIX
        self.extension_reader = ExtensionsReader(self.extension_prefix)

    @utils.wrap_error
    def get_extensions_info(self, req):
        return utils.send_result(200, req,
                                 self.extension_reader.get_extensions())
Exemplo n.º 4
0
class ExtensionsController(BaseController):
    """Controller for extensions related methods"""

    def __init__(self, is_service_operation=None):
        super(ExtensionsController, self).__init__()
        if is_service_operation:
            self.extension_prefix = EXTENSION_SERVICE_PREFIX
        else:
            self.extension_prefix = EXTENSION_ADMIN_PREFIX
        self.extension_reader = ExtensionsReader(self.extension_prefix)

    @utils.wrap_error
    def get_extensions_info(self, req):
        return utils.send_result(200, req,
            self.extension_reader.get_extensions())