예제 #1
0
 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)
예제 #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.")
예제 #3
0
 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)
예제 #4
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.")
예제 #5
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())
예제 #6
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())
예제 #7
0
 def setUp(self):
     self.options = MockOptions("osksadm")
     self.extensions_reader = ExtensionsReader(self.options,
         EXTENSION_ADMIN_PREFIX)
예제 #8
0
 def setUp(self):
     self.options = MockOptions("osksadm")
     self.extensions_reader = ExtensionsReader(self.options,
                                               EXTENSION_ADMIN_PREFIX)
예제 #9
0
 def setUp(self):
     self.original_extensions = CONF.extensions
     CONF.set_override(CONFIG_EXTENSION_PROPERTY, ["osksadm"])
     self.extensions_reader = ExtensionsReader(EXTENSION_ADMIN_PREFIX)
예제 #10
0
 def setUp(self):
     self.original_extensions = CONF.extensions
     CONF.set_override(CONFIG_EXTENSION_PROPERTY, ["osksadm"])
     self.extensions_reader = ExtensionsReader(EXTENSION_ADMIN_PREFIX)