コード例 #1
0
 def setUp(self):
     CloudStackConnection.conn_classes = (None, CloudStackMockHttp)
     self.connection = CloudStackConnection('apikey',
                                            'secret',
                                            host=CloudStackMockDriver.host)
     self.connection.poll_interval = 0.0
     self.driver = self.connection.driver = CloudStackMockDriver()
コード例 #2
0
    def test_signature_algorithm(self):
        cases = [({
            'command': 'listVirtualMachines'
        }, 'z/a9Y7J52u48VpqIgiwaGUMCso0='),
                 ({
                     'command': 'deployVirtualMachine',
                     'name': 'fred',
                     'displayname': 'George',
                     'serviceofferingid': 5,
                     'templateid': 17,
                     'zoneid': 23,
                     'networkids': 42
                 }, 'gHTo7mYmadZ+zluKHzlEKb1i/QU='),
                 ({
                     'command': 'deployVirtualMachine',
                     'name': 'fred',
                     'displayname': 'George+Ringo',
                     'serviceofferingid': 5,
                     'templateid': 17,
                     'zoneid': 23,
                     'networkids': 42
                 }, 'tAgfrreI1ZvWlWLClD3gu4+aKv4=')]

        connection = CloudStackConnection('fnord', 'abracadabra')
        for case in cases:
            params = connection.add_default_params(case[0])
            self.assertEqual(connection._make_signature(params), b(case[1]))
コード例 #3
0
ファイル: test_cloudstack.py プロジェクト: racker/libcloud
    def test_signature_algorithm(self):
        cases = [
            (
                {
                    'command': 'listVirtualMachines'
                }, 'z/a9Y7J52u48VpqIgiwaGUMCso0='
            ), (
                {
                    'command': 'deployVirtualMachine',
                    'name': 'fred',
                    'displayname': 'George',
                    'serviceofferingid': 5,
                    'templateid': 17,
                    'zoneid': 23,
                    'networkids': 42
                 }, 'gHTo7mYmadZ+zluKHzlEKb1i/QU='
            ), (
                {
                    'command': 'deployVirtualMachine',
                    'name': 'fred',
                    'displayname': 'George+Ringo',
                    'serviceofferingid': 5,
                    'templateid': 17,
                    'zoneid': 23,
                    'networkids': 42
                 }, 'tAgfrreI1ZvWlWLClD3gu4+aKv4='
            )
        ]

        connection = CloudStackConnection('fnord', 'abracadabra')
        for case in cases:
            params = connection.add_default_params(case[0])
            self.assertEqual(connection._make_signature(params), b(case[1]))
コード例 #4
0
ファイル: test_cloudstack.py プロジェクト: wandera/libcloud
    def test_signature_algorithm(self):
        cases = [
            ({
                "command": "listVirtualMachines"
            }, "z/a9Y7J52u48VpqIgiwaGUMCso0="),
            (
                {
                    "command": "deployVirtualMachine",
                    "name": "fred",
                    "displayname": "George",
                    "serviceofferingid": 5,
                    "templateid": 17,
                    "zoneid": 23,
                    "networkids": 42,
                },
                "gHTo7mYmadZ+zluKHzlEKb1i/QU=",
            ),
            (
                {
                    "command": "deployVirtualMachine",
                    "name": "fred",
                    "displayname": "George+Ringo",
                    "serviceofferingid": 5,
                    "templateid": 17,
                    "zoneid": 23,
                    "networkids": 42,
                },
                "tAgfrreI1ZvWlWLClD3gu4+aKv4=",
            ),
        ]

        connection = CloudStackConnection("fnord", "abracadabra")
        for case in cases:
            params = connection.add_default_params(case[0])
            self.assertEqual(connection._make_signature(params), b(case[1]))
コード例 #5
0
ファイル: test_cloudstack.py プロジェクト: wandera/libcloud
 def setUp(self):
     CloudStackConnection.conn_class = CloudStackMockHttp
     self.connection = CloudStackConnection("apikey",
                                            "secret",
                                            host=CloudStackMockDriver.host)
     self.connection.poll_interval = 0.0
     self.driver = self.connection.driver = CloudStackMockDriver()
コード例 #6
0
ファイル: test_cloudstack.py プロジェクト: Keisuke69/libcloud
class CloudStackCommonTest(unittest.TestCase):
    def setUp(self):
        CloudStackConnection.conn_classes = (None, CloudStackMockHttp)
        self.connection = CloudStackConnection('apikey', 'secret',
                                               host=CloudStackMockDriver.host)
        self.driver = self.connection.driver = CloudStackMockDriver()

    def test_sync_request_bad_response(self):
        self.driver.path = '/bad/response'
        try:
            self.connection._sync_request('fake')
        except Exception, e:
            self.assertTrue(isinstance(e, MalformedResponseError))
            return
        self.assertTrue(False)
コード例 #7
0
ファイル: test_cloudstack.py プロジェクト: Keisuke69/libcloud
class CloudStackCommonTest(unittest.TestCase):
    def setUp(self):
        CloudStackConnection.conn_classes = (None, CloudStackMockHttp)
        self.connection = CloudStackConnection('apikey',
                                               'secret',
                                               host=CloudStackMockDriver.host)
        self.driver = self.connection.driver = CloudStackMockDriver()

    def test_sync_request_bad_response(self):
        self.driver.path = '/bad/response'
        try:
            self.connection._sync_request('fake')
        except Exception, e:
            self.assertTrue(isinstance(e, MalformedResponseError))
            return
        self.assertTrue(False)
コード例 #8
0
class CloudStackCommonTest(unittest.TestCase):
    def setUp(self):
        CloudStackConnection.conn_classes = (None, CloudStackMockHttp)
        self.connection = CloudStackConnection('apikey',
                                               'secret',
                                               host=CloudStackMockDriver.host)
        self.connection.poll_interval = 0.0
        self.driver = self.connection.driver = CloudStackMockDriver()

    def test_sync_request_bad_response(self):
        self.driver.path = '/bad/response'
        try:
            self.connection._sync_request('fake')
        except Exception:
            e = sys.exc_info()[1]
            self.assertTrue(isinstance(e, MalformedResponseError))
            return
        self.assertTrue(False)

    def test_sync_request(self):
        self.driver.path = '/sync'
        self.connection._sync_request('fake')

    def test_async_request_successful(self):
        self.driver.path = '/async/success'
        result = self.connection._async_request('fake')
        self.assertEqual(result, {'fake': 'result'})

    def test_async_request_unsuccessful(self):
        self.driver.path = '/async/fail'
        try:
            self.connection._async_request('fake')
        except Exception:
            e = sys.exc_info()[1]
            self.assertEquals(CloudStackMockHttp.ERROR_TEXT, str(e))
            return
        self.assertFalse(True)

    def test_async_request_delayed(self):
        global async_delay
        self.driver.path = '/async/delayed'
        async_delay = 2
        self.connection._async_request('fake')
        self.assertEqual(async_delay, 0)

    def test_signature_algorithm(self):
        cases = [({
            'command': 'listVirtualMachines'
        }, 'z/a9Y7J52u48VpqIgiwaGUMCso0='),
                 ({
                     'command': 'deployVirtualMachine',
                     'name': 'fred',
                     'displayname': 'George',
                     'serviceofferingid': 5,
                     'templateid': 17,
                     'zoneid': 23,
                     'networkids': 42
                 }, 'gHTo7mYmadZ+zluKHzlEKb1i/QU='),
                 ({
                     'command': 'deployVirtualMachine',
                     'name': 'fred',
                     'displayname': 'George+Ringo',
                     'serviceofferingid': 5,
                     'templateid': 17,
                     'zoneid': 23,
                     'networkids': 42
                 }, 'tAgfrreI1ZvWlWLClD3gu4+aKv4=')]

        connection = CloudStackConnection('fnord', 'abracadabra')
        for case in cases:
            params = connection.add_default_params(case[0])
            self.assertEqual(connection._make_signature(params), b(case[1]))
コード例 #9
0
ファイル: test_cloudstack.py プロジェクト: racker/libcloud
 def setUp(self):
     CloudStackConnection.conn_classes = (None, CloudStackMockHttp)
     self.connection = CloudStackConnection('apikey', 'secret',
                                            host=CloudStackMockDriver.host)
     self.connection.poll_interval = 0.0
     self.driver = self.connection.driver = CloudStackMockDriver()
コード例 #10
0
ファイル: test_cloudstack.py プロジェクト: racker/libcloud
class CloudStackCommonTest(unittest.TestCase):
    def setUp(self):
        CloudStackConnection.conn_classes = (None, CloudStackMockHttp)
        self.connection = CloudStackConnection('apikey', 'secret',
                                               host=CloudStackMockDriver.host)
        self.connection.poll_interval = 0.0
        self.driver = self.connection.driver = CloudStackMockDriver()

    def test_sync_request_bad_response(self):
        self.driver.path = '/bad/response'
        try:
            self.connection._sync_request('fake')
        except Exception:
            e = sys.exc_info()[1]
            self.assertTrue(isinstance(e, MalformedResponseError))
            return
        self.assertTrue(False)

    def test_sync_request(self):
        self.driver.path = '/sync'
        self.connection._sync_request('fake')

    def test_async_request_successful(self):
        self.driver.path = '/async/success'
        result = self.connection._async_request('fake')
        self.assertEqual(result, {'fake': 'result'})

    def test_async_request_unsuccessful(self):
        self.driver.path = '/async/fail'
        try:
            self.connection._async_request('fake')
        except Exception:
            e = sys.exc_info()[1]
            self.assertEquals(CloudStackMockHttp.ERROR_TEXT, str(e))
            return
        self.assertFalse(True)

    def test_async_request_delayed(self):
        global async_delay
        self.driver.path = '/async/delayed'
        async_delay = 2
        self.connection._async_request('fake')
        self.assertEqual(async_delay, 0)

    def test_signature_algorithm(self):
        cases = [
            (
                {
                    'command': 'listVirtualMachines'
                }, 'z/a9Y7J52u48VpqIgiwaGUMCso0='
            ), (
                {
                    'command': 'deployVirtualMachine',
                    'name': 'fred',
                    'displayname': 'George',
                    'serviceofferingid': 5,
                    'templateid': 17,
                    'zoneid': 23,
                    'networkids': 42
                 }, 'gHTo7mYmadZ+zluKHzlEKb1i/QU='
            ), (
                {
                    'command': 'deployVirtualMachine',
                    'name': 'fred',
                    'displayname': 'George+Ringo',
                    'serviceofferingid': 5,
                    'templateid': 17,
                    'zoneid': 23,
                    'networkids': 42
                 }, 'tAgfrreI1ZvWlWLClD3gu4+aKv4='
            )
        ]

        connection = CloudStackConnection('fnord', 'abracadabra')
        for case in cases:
            params = connection.add_default_params(case[0])
            self.assertEqual(connection._make_signature(params), b(case[1]))
コード例 #11
0
ファイル: test_cloudstack.py プロジェクト: wandera/libcloud
class CloudStackCommonTest(unittest.TestCase):
    def setUp(self):
        CloudStackConnection.conn_class = CloudStackMockHttp
        self.connection = CloudStackConnection("apikey",
                                               "secret",
                                               host=CloudStackMockDriver.host)
        self.connection.poll_interval = 0.0
        self.driver = self.connection.driver = CloudStackMockDriver()

    def test_sync_request_bad_response(self):
        self.driver.path = "/bad/response"
        try:
            self.connection._sync_request("fake")
        except Exception as e:
            self.assertTrue(isinstance(e, MalformedResponseError))
            return
        self.assertTrue(False)

    def test_sync_request(self):
        self.driver.path = "/sync"
        self.connection._sync_request("fake")

    def test_async_request_successful(self):
        self.driver.path = "/async/success"
        result = self.connection._async_request("fake")
        self.assertEqual(result, {"fake": "result"})

    def test_async_request_unsuccessful(self):
        self.driver.path = "/async/fail"
        try:
            self.connection._async_request("fake")
        except Exception as e:
            self.assertEqual(CloudStackMockHttp.ERROR_TEXT, str(e))
            return
        self.assertFalse(True)

    def test_async_request_delayed(self):
        global async_delay
        self.driver.path = "/async/delayed"
        async_delay = 2
        self.connection._async_request("fake")
        self.assertEqual(async_delay, 0)

    def test_signature_algorithm(self):
        cases = [
            ({
                "command": "listVirtualMachines"
            }, "z/a9Y7J52u48VpqIgiwaGUMCso0="),
            (
                {
                    "command": "deployVirtualMachine",
                    "name": "fred",
                    "displayname": "George",
                    "serviceofferingid": 5,
                    "templateid": 17,
                    "zoneid": 23,
                    "networkids": 42,
                },
                "gHTo7mYmadZ+zluKHzlEKb1i/QU=",
            ),
            (
                {
                    "command": "deployVirtualMachine",
                    "name": "fred",
                    "displayname": "George+Ringo",
                    "serviceofferingid": 5,
                    "templateid": 17,
                    "zoneid": 23,
                    "networkids": 42,
                },
                "tAgfrreI1ZvWlWLClD3gu4+aKv4=",
            ),
        ]

        connection = CloudStackConnection("fnord", "abracadabra")
        for case in cases:
            params = connection.add_default_params(case[0])
            self.assertEqual(connection._make_signature(params), b(case[1]))