libcloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pque...@apache.org
Subject svn commit: r908756 - in /incubator/libcloud/trunk: libcloud/drivers/voxel.py test/test_voxel.py
Date Wed, 10 Feb 2010 23:42:50 GMT
Author: pquerna
Date: Wed Feb 10 23:42:39 2010
New Revision: 908756

URL: http://svn.apache.org/viewvc?rev=908756&view=rev
Log:
Add an extremely simple test_voxel, which just detects failed authentication

Added:
    incubator/libcloud/trunk/test/test_voxel.py   (with props)
Modified:
    incubator/libcloud/trunk/libcloud/drivers/voxel.py

Modified: incubator/libcloud/trunk/libcloud/drivers/voxel.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/voxel.py?rev=908756&r1=908755&r2=908756&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/voxel.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/voxel.py Wed Feb 10 23:42:39 2010
@@ -22,7 +22,6 @@
 import datetime
 import hashlib
 from xml.etree import ElementTree as ET
-from xml.parsers.expat import ExpatError
 
 VOXEL_API_HOST = "api.voxel.net"
 

Added: incubator/libcloud/trunk/test/test_voxel.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_voxel.py?rev=908756&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/test_voxel.py (added)
+++ incubator/libcloud/trunk/test/test_voxel.py Wed Feb 10 23:42:39 2010
@@ -0,0 +1,50 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# libcloud.org licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import unittest
+
+from libcloud.drivers.voxel import VoxelNodeDriver as Voxel
+from libcloud.types import Provider, NodeState, InvalidCredsException
+from libcloud.base import Node, NodeImage, NodeSize
+
+import httplib
+
+from test import MockHttp, multipleresponse, TestCaseMixin
+from secrets import VOXEL_USER, VOXEL_SECRET
+from xml.etree import ElementTree as ET
+
+class VoxelTest(unittest.TestCase):
+
+    def setUp(self):
+
+        Voxel.connectionCls.conn_classes = (None, VoxelMockHttp)
+        VoxelMockHttp.type = None
+        self.driver = Voxel('foo', 'bar')
+
+    def test_auth_failed(self):
+        VoxelMockHttp.type = 'UNAUTHORIZED'
+        try:
+            ret = self.driver.list_nodes()
+        except Exception, e:
+            self.assertTrue(isinstance(e, InvalidCredsException))
+        else:
+            self.fail('test should have thrown')
+
+class VoxelMockHttp(MockHttp):
+
+    def _UNAUTHORIZED(self, method, url, body, headers):
+        body = """<?xml version="1.0"?>
+<rsp stat="fail"><err code="1" msg="Invalid login or password"/><method>voxel.devices.list</method><parameters><param
name="timestamp">2010-02-10T23:39:25.808107+0000</param><param name="key">authshouldfail</param><param
name="api_sig">ae069bb835e998622caaddaeff8c98e0</param></parameters><string_to_sign>YOUR_SECRETtimestamp2010-02-10T23:39:25.808107+0000methodvoxel.devices.listkeyauthshouldfail</string_to_sign></rsp>
+"""
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])

Propchange: incubator/libcloud/trunk/test/test_voxel.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/libcloud/trunk/test/test_voxel.py
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: incubator/libcloud/trunk/test/test_voxel.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message