Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(719)

Unified Diff: tools/telemetry/third_party/gsutil/third_party/boto/tests/db/test_password.py

Issue 1260493004: Revert "Add gsutil 4.13 to telemetry/third_party" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/third_party/gsutil/third_party/boto/tests/db/test_password.py
diff --git a/tools/telemetry/third_party/gsutil/third_party/boto/tests/db/test_password.py b/tools/telemetry/third_party/gsutil/third_party/boto/tests/db/test_password.py
deleted file mode 100644
index 74c340952619067c3cba68149ce827ab119d514e..0000000000000000000000000000000000000000
--- a/tools/telemetry/third_party/gsutil/third_party/boto/tests/db/test_password.py
+++ /dev/null
@@ -1,128 +0,0 @@
-# Copyright (c) 2010 Robert Mela
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish, dis-
-# tribute, sublicense, and/or sell copies of the Software, and to permit
-# persons to whom the Software is furnished to do so, subject to the fol-
-# lowing conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
-# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-
-
-import unittest
-import logging
-import time
-
-log= logging.getLogger('password_property_test')
-log.setLevel(logging.DEBUG)
-
-class PasswordPropertyTest(unittest.TestCase):
- """Test the PasswordProperty"""
-
- def tearDown(self):
- cls=self.test_model()
- for obj in cls.all(): obj.delete()
-
- def hmac_hashfunc(self):
- import hmac
- def hashfunc(msg):
- return hmac.new('mysecret', msg)
- return hashfunc
-
- def test_model(self,hashfunc=None):
- from boto.utils import Password
- from boto.sdb.db.model import Model
- from boto.sdb.db.property import PasswordProperty
- import hashlib
- class MyModel(Model):
- password=PasswordProperty(hashfunc=hashfunc)
- return MyModel
-
- def test_custom_password_class(self):
- from boto.utils import Password
- from boto.sdb.db.model import Model
- from boto.sdb.db.property import PasswordProperty
- import hmac, hashlib
-
-
- myhashfunc = hashlib.md5
- ## Define a new Password class
- class MyPassword(Password):
- hashfunc = myhashfunc #hashlib.md5 #lambda cls,msg: hmac.new('mysecret',msg)
-
- ## Define a custom password property using the new Password class
-
- class MyPasswordProperty(PasswordProperty):
- data_type=MyPassword
- type_name=MyPassword.__name__
-
- ## Define a model using the new password property
-
- class MyModel(Model):
- password=MyPasswordProperty()#hashfunc=hashlib.md5)
-
- obj = MyModel()
- obj.password = 'bar'
- expected = myhashfunc('bar').hexdigest() #hmac.new('mysecret','bar').hexdigest()
- log.debug("\npassword=%s\nexpected=%s" % (obj.password, expected))
- self.assertTrue(obj.password == 'bar' )
- obj.save()
- id= obj.id
- time.sleep(5)
- obj = MyModel.get_by_id(id)
- self.assertEquals(obj.password, 'bar')
- self.assertEquals(str(obj.password), expected)
- #hmac.new('mysecret','bar').hexdigest())
-
-
- def test_aaa_default_password_property(self):
- cls = self.test_model()
- obj = cls(id='passwordtest')
- obj.password = 'foo'
- self.assertEquals('foo', obj.password)
- obj.save()
- time.sleep(5)
- obj = cls.get_by_id('passwordtest')
- self.assertEquals('foo', obj.password)
-
- def test_password_constructor_hashfunc(self):
- import hmac
- myhashfunc=lambda msg: hmac.new('mysecret', msg)
- cls = self.test_model(hashfunc=myhashfunc)
- obj = cls()
- obj.password='hello'
- expected = myhashfunc('hello').hexdigest()
- self.assertEquals(obj.password, 'hello')
- self.assertEquals(str(obj.password), expected)
- obj.save()
- id = obj.id
- time.sleep(5)
- obj = cls.get_by_id(id)
- log.debug("\npassword=%s" % obj.password)
- self.assertTrue(obj.password == 'hello')
-
-
-
-if __name__ == '__main__':
- import sys, os
- curdir = os.path.dirname( os.path.abspath(__file__) )
- srcroot = curdir + "/../.."
- sys.path = [ srcroot ] + sys.path
- logging.basicConfig()
- log.setLevel(logging.INFO)
- suite = unittest.TestLoader().loadTestsFromTestCase(PasswordPropertyTest)
- unittest.TextTestRunner(verbosity=2).run(suite)
-
- import boto
-

Powered by Google App Engine
This is Rietveld 408576698