Merge "Fix user-list failed if host uses host_ip/netmask"
This commit is contained in:
commit
378af0ef06
@ -145,8 +145,8 @@ class MySQLUser(models.DatastoreUser):
|
||||
if CONF.hostname_require_valid_ip:
|
||||
try:
|
||||
# '%' works as a MySQL wildcard, but it is not a valid
|
||||
# part of an IPAddress
|
||||
netaddr.IPAddress(value.replace('%', '1'))
|
||||
# part of an IPNetwork
|
||||
netaddr.IPNetwork(value.replace('%', '1'))
|
||||
except (ValueError, netaddr.AddrFormatError):
|
||||
return False
|
||||
else:
|
||||
|
@ -20,6 +20,7 @@ from mock import patch
|
||||
from proboscis.asserts import assert_equal
|
||||
from testtools.matchers import Is, Equals, Not
|
||||
|
||||
from trove.common.db.mysql import models
|
||||
from trove.common.exception import InsufficientSpaceForReplica
|
||||
from trove.common.exception import ProcessExecutionError
|
||||
from trove.common import instance as rd_instance
|
||||
@ -103,6 +104,15 @@ class GuestAgentManagerTest(DatastoreManagerTest):
|
||||
dbaas.MySqlAppStatus.get.assert_any_call()
|
||||
mock_status.update.assert_any_call()
|
||||
|
||||
def _empty_user(self):
|
||||
return models.MySQLUser(deserializing=True)
|
||||
|
||||
def test_valid_host_name(self):
|
||||
test_host = "192.58.197.0/255.255.255.0"
|
||||
user = self._empty_user()
|
||||
user.host = test_host
|
||||
self.assertEqual(test_host, user.host)
|
||||
|
||||
@patch.object(dbaas.MySqlAdmin, 'create_database')
|
||||
def test_create_database(self, create_db_mock):
|
||||
self.manager.create_database(self.context, ['db1'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user