create real user with a password to test authentication code

This commit is contained in:
Daniel Black 2015-08-27 00:10:51 +10:00
parent 7a80e4e041
commit 010c6438c4
4 changed files with 13 additions and 7 deletions

View File

@ -1,4 +1,4 @@
[
{"host": "localhost", "unix_socket": "/var/run/mysqld/mysqld.sock", "user": "root", "passwd": "", "db": "test_pymysql", "use_unicode": true, "local_infile": true},
{"host": "localhost", "port": 3306, "user": "root", "passwd": "", "db": "test_pymysql2" }
{"host": "127.0.0.1", "port": 3306, "user": "travis_pymysql2", "password": "some password", "db": "test_pymysql2" }
]

View File

@ -6,6 +6,9 @@ set -x
set -v
if [ ! -z "${DB}" ]; then
# disable existing database server in case of accidential connection
mysql -u root -e 'drop user travis@localhost; drop user root@localhost; drop user travis; create user super@localhost; grant all on super@localhost'
mysql -u super -e 'drop user root'
F=mysql-${DB}-linux-glibc2.5-x86_64
mkdir -p ${HOME}/mysql
P=${HOME}/mysql/${F}
@ -37,7 +40,7 @@ if [ ! -z "${DB}" ]; then
fi
mysql -S /tmp/mysql.sock -u root -e "create user ${USER}@localhost; create user ${USER}@'%'; grant all on *.* to ${USER}@localhost WITH GRANT OPTION;grant all on *.* to ${USER}@'%' WITH GRANT OPTION;"
sed -e 's/3306/3307/g' -e 's:/var/run/mysqld/mysqld.sock:/tmp/mysql.sock:g' .travis.databases.json > pymysql/tests/databases.json
echo -e "[client]\nsocket = /tmp/mysql.sock\n" > "${HOME}"/.my.cnf
echo -e "[client]\nsocket = /tmp/mysql.sock\n" > "${HOME}"/.my.cnf
else
cp .travis.databases.json pymysql/tests/databases.json
fi

View File

@ -59,7 +59,10 @@ before_script:
fi
- "mysql -e 'create database test_pymysql DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
- "mysql -e 'create database test_pymysql2 DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;'"
- mysql -u root -e "create user travis_pymysql2 identified by 'some password'; grant all on test_pymysql2.* to travis_pymysql2;"
- mysql -u root -e "create user travis_pymysql2@localhost identified by 'some password'; grant all on test_pymysql2.* to travis_pymysql2@localhost;"
- "mysql -e 'select VERSION();'"
- rm -f ~/.my.cnf # set in package downloads for the above commands - we should be using database.json however
script:
- tox -e $TOX_ENV

View File

@ -199,9 +199,9 @@ class TestNewIssues(base.PyMySQLTestCase):
self.assertEqual(2013, e.args[0])
def test_issue_36(self):
conn = self.connections[0]
# connection 0 is super user, connection 1 isn't
conn = self.connections[1]
c = conn.cursor()
# kill connections[0]
c.execute("show processlist")
kill_id = None
for row in c.fetchall():
@ -212,7 +212,7 @@ class TestNewIssues(base.PyMySQLTestCase):
break
self.assertEqual(kill_id, conn.thread_id())
# now nuke the connection
self.connections[1].kill(kill_id)
self.connections[0].kill(kill_id)
# make sure this connection has broken
try:
c.execute("show tables")
@ -227,12 +227,12 @@ class TestNewIssues(base.PyMySQLTestCase):
# Wait since Travis-CI sometimes fail this test.
time.sleep(0.1)
c = self.connections[1].cursor()
c = self.connections[0].cursor()
c.execute("show processlist")
ids = [row[0] for row in c.fetchall()]
self.assertFalse(kill_id in ids)
finally:
del self.connections[0]
del self.connections[1]
def test_issue_37(self):
conn = self.connections[0]