Commit 508be503 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Bootstrap tests use SQL test user without password and log level set to ERROR.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@374 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 9203c883
...@@ -35,13 +35,12 @@ from neo.protocol import ANSWER_PRIMARY_MASTER ...@@ -35,13 +35,12 @@ from neo.protocol import ANSWER_PRIMARY_MASTER
SQL_ADMIN_USER = 'root' SQL_ADMIN_USER = 'root'
SQL_ADMIN_PASSWORD = None SQL_ADMIN_PASSWORD = None
NEO_SQL_USER = 'test' NEO_SQL_USER = 'test'
NEO_SQL_PASSWORD = 'test'
NEO_SQL_DATABASE = 'test_neo1' NEO_SQL_DATABASE = 'test_neo1'
class StorageBootstrapTests(unittest.TestCase): class StorageBootstrapTests(unittest.TestCase):
def setUp(self): def setUp(self):
#logging.basicConfig(level = logging.DEBUG) logging.basicConfig(level = logging.ERROR)
# create an application object # create an application object
config_file_text = """# Default parameters. config_file_text = """# Default parameters.
[DEFAULT] [DEFAULT]
...@@ -55,8 +54,6 @@ partitions: 1009 ...@@ -55,8 +54,6 @@ partitions: 1009
name: main name: main
# The user name for the database. # The user name for the database.
user: %(user)s user: %(user)s
# The password for the database.
password: %(password)s
connector : SocketConnector connector : SocketConnector
# The first master. # The first master.
[mastertest] [mastertest]
...@@ -68,7 +65,6 @@ server: 127.0.0.1:10020 ...@@ -68,7 +65,6 @@ server: 127.0.0.1:10020
""" % { """ % {
'database': NEO_SQL_DATABASE, 'database': NEO_SQL_DATABASE,
'user': NEO_SQL_USER, 'user': NEO_SQL_USER,
'password': NEO_SQL_PASSWORD,
} }
# SQL connection # SQL connection
connect_arg_dict = {'user': SQL_ADMIN_USER} connect_arg_dict = {'user': SQL_ADMIN_USER}
...@@ -79,8 +75,8 @@ server: 127.0.0.1:10020 ...@@ -79,8 +75,8 @@ server: 127.0.0.1:10020
# new database # new database
cursor.execute('DROP DATABASE IF EXISTS %s' % (NEO_SQL_DATABASE, )) cursor.execute('DROP DATABASE IF EXISTS %s' % (NEO_SQL_DATABASE, ))
cursor.execute('CREATE DATABASE %s' % (NEO_SQL_DATABASE, )) cursor.execute('CREATE DATABASE %s' % (NEO_SQL_DATABASE, ))
cursor.execute('GRANT ALL ON %s.* TO "%s"@"localhost" IDENTIFIED BY "%s"' % cursor.execute('GRANT ALL ON %s.* TO "%s"@"localhost" IDENTIFIED BY ""' %
(NEO_SQL_DATABASE, NEO_SQL_USER, NEO_SQL_PASSWORD)) (NEO_SQL_DATABASE, NEO_SQL_USER))
cursor.close() cursor.close()
# config file # config file
tmp_id, self.tmp_path = mkstemp() tmp_id, self.tmp_path = mkstemp()
......
...@@ -27,13 +27,11 @@ from neo.storage.mysqldb import MySQLDatabaseManager, p64, u64 ...@@ -27,13 +27,11 @@ from neo.storage.mysqldb import MySQLDatabaseManager, p64, u64
SQL_ADMIN_USER = 'root' SQL_ADMIN_USER = 'root'
SQL_ADMIN_PASSWORD = None SQL_ADMIN_PASSWORD = None
NEO_SQL_USER = 'test' NEO_SQL_USER = 'test'
NEO_SQL_PASSWORD = 'test'
NEO_SQL_DATABASE = 'test_neo1' NEO_SQL_DATABASE = 'test_neo1'
class StorageMySQSLdbTests(unittest.TestCase): class StorageMySQSLdbTests(unittest.TestCase):
def setUp(self): def setUp(self):
#logging.basicConfig(level = logging.DEBUG)
logging.basicConfig(level = logging.ERROR) logging.basicConfig(level = logging.ERROR)
# SQL connection # SQL connection
connect_arg_dict = {'user': SQL_ADMIN_USER} connect_arg_dict = {'user': SQL_ADMIN_USER}
...@@ -44,13 +42,12 @@ class StorageMySQSLdbTests(unittest.TestCase): ...@@ -44,13 +42,12 @@ class StorageMySQSLdbTests(unittest.TestCase):
# new database # new database
cursor.execute('DROP DATABASE IF EXISTS %s' % (NEO_SQL_DATABASE, )) cursor.execute('DROP DATABASE IF EXISTS %s' % (NEO_SQL_DATABASE, ))
cursor.execute('CREATE DATABASE %s' % (NEO_SQL_DATABASE, )) cursor.execute('CREATE DATABASE %s' % (NEO_SQL_DATABASE, ))
cursor.execute('GRANT ALL ON %s.* TO "%s"@"localhost" IDENTIFIED BY "%s"' % cursor.execute('GRANT ALL ON %s.* TO "%s"@"localhost" IDENTIFIED BY ""' %
(NEO_SQL_DATABASE, NEO_SQL_USER, NEO_SQL_PASSWORD)) (NEO_SQL_DATABASE, NEO_SQL_USER))
# db manager # db manager
self.db = MySQLDatabaseManager( self.db = MySQLDatabaseManager(
database=NEO_SQL_DATABASE, database=NEO_SQL_DATABASE,
user=NEO_SQL_USER, user=NEO_SQL_USER,
password=NEO_SQL_PASSWORD,
) )
def tearDown(self): def tearDown(self):
...@@ -73,12 +70,10 @@ class StorageMySQSLdbTests(unittest.TestCase): ...@@ -73,12 +70,10 @@ class StorageMySQSLdbTests(unittest.TestCase):
db = MySQLDatabaseManager( db = MySQLDatabaseManager(
database=NEO_SQL_DATABASE, database=NEO_SQL_DATABASE,
user=NEO_SQL_USER, user=NEO_SQL_USER,
password=NEO_SQL_PASSWORD,
) )
# init # init
self.assertEquals(db.db, NEO_SQL_DATABASE) self.assertEquals(db.db, NEO_SQL_DATABASE)
self.assertEquals(db.user, NEO_SQL_USER) self.assertEquals(db.user, NEO_SQL_USER)
self.assertEquals(db.passwd, NEO_SQL_PASSWORD)
# & connect # & connect
import MySQLdb import MySQLdb
self.assertTrue(isinstance(db.conn, MySQLdb.connection)) self.assertTrue(isinstance(db.conn, MySQLdb.connection))
......
...@@ -32,7 +32,6 @@ from neo.protocol import * ...@@ -32,7 +32,6 @@ from neo.protocol import *
SQL_ADMIN_USER = 'root' SQL_ADMIN_USER = 'root'
SQL_ADMIN_PASSWORD = None SQL_ADMIN_PASSWORD = None
NEO_SQL_USER = 'test' NEO_SQL_USER = 'test'
NEO_SQL_PASSWORD = 'test'
NEO_SQL_DATABASE = 'test_neo1' NEO_SQL_DATABASE = 'test_neo1'
class StorageOperationTests(unittest.TestCase): class StorageOperationTests(unittest.TestCase):
...@@ -84,7 +83,6 @@ class StorageOperationTests(unittest.TestCase): ...@@ -84,7 +83,6 @@ class StorageOperationTests(unittest.TestCase):
self.assertEquals(len(conn.mockGetNamedCalls('addPacket')), 0) self.assertEquals(len(conn.mockGetNamedCalls('addPacket')), 0)
def setUp(self): def setUp(self):
#logging.basicConfig(level = logging.DEBUG)
logging.basicConfig(level = logging.ERROR) logging.basicConfig(level = logging.ERROR)
# create an application object # create an application object
config_file_text = """# Default parameters. config_file_text = """# Default parameters.
...@@ -99,8 +97,6 @@ partitions: 1009 ...@@ -99,8 +97,6 @@ partitions: 1009
name: main name: main
# The user name for the database. # The user name for the database.
user: %(user)s user: %(user)s
# The password for the database.
password: %(password)s
connector : SocketConnector connector : SocketConnector
# The first master. # The first master.
[mastertest] [mastertest]
...@@ -112,7 +108,6 @@ server: 127.0.0.1:10020 ...@@ -112,7 +108,6 @@ server: 127.0.0.1:10020
""" % { """ % {
'database': NEO_SQL_DATABASE, 'database': NEO_SQL_DATABASE,
'user': NEO_SQL_USER, 'user': NEO_SQL_USER,
'password': NEO_SQL_PASSWORD,
} }
# SQL connection # SQL connection
connect_arg_dict = {'user': SQL_ADMIN_USER} connect_arg_dict = {'user': SQL_ADMIN_USER}
...@@ -123,8 +118,8 @@ server: 127.0.0.1:10020 ...@@ -123,8 +118,8 @@ server: 127.0.0.1:10020
# new database # new database
cursor.execute('DROP DATABASE IF EXISTS %s' % (NEO_SQL_DATABASE, )) cursor.execute('DROP DATABASE IF EXISTS %s' % (NEO_SQL_DATABASE, ))
cursor.execute('CREATE DATABASE %s' % (NEO_SQL_DATABASE, )) cursor.execute('CREATE DATABASE %s' % (NEO_SQL_DATABASE, ))
cursor.execute('GRANT ALL ON %s.* TO "%s"@"localhost" IDENTIFIED BY "%s"' % cursor.execute('GRANT ALL ON %s.* TO "%s"@"localhost" IDENTIFIED BY ""' %
(NEO_SQL_DATABASE, NEO_SQL_USER, NEO_SQL_PASSWORD)) (NEO_SQL_DATABASE, NEO_SQL_USER))
# config file # config file
tmp_id, self.tmp_path = mkstemp() tmp_id, self.tmp_path = mkstemp()
tmp_file = os.fdopen(tmp_id, "w+b") tmp_file = os.fdopen(tmp_id, "w+b")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment