def test_connection_uri(self): uri = build_uri(user=self.connect_kwargs["user"], password=self.connect_kwargs["password"], host=self.connect_kwargs["host"], port=self.connect_kwargs["port"], schema=self.connect_kwargs["schema"], use_pure=False) session = mysqlx.get_session(uri) self.assertIsInstance(session, mysqlx.Session) # Test URI parser function for uri, res in _URI_TEST_RESULTS: try: settings = mysqlx._get_connection_settings(uri) self.assertEqual(res, settings) except mysqlx.Error: self.assertEqual(res, None) # Test URI parser function for uri, res in _ROUTER_LIST_RESULTS: try: settings = mysqlx._get_connection_settings(uri) self.assertEqual(res, settings) except mysqlx.Error: self.assertEqual(res, None)
def test_mysqlx_socket(self): # Connect with unix socket uri = "mysqlx://{user}:{password}@({socket})".format( user=self.connect_kwargs["user"], password=self.connect_kwargs["password"], socket=self.connect_kwargs["socket"]) session = mysqlx.get_session(uri) # No SSL with Unix Sockets res = mysqlx.statement.SqlStatement( session._connection, "SHOW STATUS LIKE 'Mysqlx_ssl_active'").execute().fetch_all() self.assertEqual("OFF", res[0][1]) session.close() # Socket parsing tests conn = mysqlx._get_connection_settings("root:@(/path/to/sock)") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@(/path/to/sock)/schema") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@/path%2Fto%2Fsock") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings( "root:@/path%2Fto%2Fsock/schema") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@.%2Fpath%2Fto%2Fsock") self.assertEqual("./path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@.%2Fpath%2Fto%2Fsock" "/schema") self.assertEqual("./path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@..%2Fpath%2Fto%2Fsock") self.assertEqual("../path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@..%2Fpath%2Fto%2Fsock" "/schema") self.assertEqual("../path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"])
def test_mysqlx_socket(self): # Connect with unix socket uri = "mysqlx://{user}:{password}@({socket})".format( user=self.connect_kwargs["user"], password=self.connect_kwargs["password"], socket=self.connect_kwargs["socket"]) session = mysqlx.get_session(uri) # No SSL with Unix Sockets res = mysqlx.statement.SqlStatement(session._connection, "SHOW STATUS LIKE 'Mysqlx_ssl_active'").execute().fetch_all() self.assertEqual("OFF", res[0][1]) session.close() # Socket parsing tests conn = mysqlx._get_connection_settings("root:@(/path/to/sock)") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@(/path/to/sock)/schema") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@/path%2Fto%2Fsock") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@/path%2Fto%2Fsock/schema") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@.%2Fpath%2Fto%2Fsock") self.assertEqual("./path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@.%2Fpath%2Fto%2Fsock" "/schema") self.assertEqual("./path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@..%2Fpath%2Fto%2Fsock") self.assertEqual("../path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@..%2Fpath%2Fto%2Fsock" "/schema") self.assertEqual("../path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"])
def test_connection_uri(self): uri = ("mysqlx://{user}:{password}@{host}:{port}/{schema}" "".format(user=self.connect_kwargs["user"], password=self.connect_kwargs["password"], host=self.connect_kwargs["host"], port=self.connect_kwargs["port"], schema=self.connect_kwargs["schema"])) session = mysqlx.get_node_session(uri) self.assertIsInstance(session, mysqlx.NodeSession) # Test URI parser function for uri, res in _URI_TEST_RESULTS: try: settings = mysqlx._get_connection_settings(uri) self.assertEqual(res, settings) except mysqlx.Error: self.assertEqual(res, None)
def test_connection_uri(self): uri = ("mysqlx://{user}:{password}@{host}:{port}/{schema}" "".format(user=self.connect_kwargs["user"], password=self.connect_kwargs["password"], host=self.connect_kwargs["host"], port=self.connect_kwargs["port"], schema=self.connect_kwargs["schema"])) session = mysqlx.get_node_session(uri) self.assertIsInstance(session, mysqlx.NodeSession) # Test URI parser function for uri, res in _URI_TEST_RESULTS: try: settings = mysqlx._get_connection_settings(uri) self.assertEqual(res, settings) except mysqlx.Error: self.assertEqual(res, None)
def test_mysqlx_socket(self): # Connect with unix socket uri = "mysqlx://{user}:{password}@({socket})".format( user=self.connect_kwargs["user"], password=self.connect_kwargs["password"], socket=self.connect_kwargs["socket"]) session = mysqlx.get_session(uri) conn = mysqlx._get_connection_settings("root:@(/path/to/sock)") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@(/path/to/sock)/schema") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@/path%2Fto%2Fsock") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings( "root:@/path%2Fto%2Fsock/schema") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@.%2Fpath%2Fto%2Fsock") self.assertEqual("./path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@.%2Fpath%2Fto%2Fsock" "/schema") self.assertEqual("./path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@..%2Fpath%2Fto%2Fsock") self.assertEqual("../path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@..%2Fpath%2Fto%2Fsock" "/schema") self.assertEqual("../path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"])
def test_mysqlx_socket(self): # Connect with unix socket uri = "mysqlx://{user}:{password}@({socket})".format( user=self.connect_kwargs["user"], password=self.connect_kwargs["password"], socket=self.connect_kwargs["socket"]) session = mysqlx.get_session(uri) conn = mysqlx._get_connection_settings("root:@(/path/to/sock)") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@(/path/to/sock)/schema") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@/path%2Fto%2Fsock") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@/path%2Fto%2Fsock/schema") self.assertEqual("/path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@.%2Fpath%2Fto%2Fsock") self.assertEqual("./path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@.%2Fpath%2Fto%2Fsock" "/schema") self.assertEqual("./path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"]) conn = mysqlx._get_connection_settings("root:@..%2Fpath%2Fto%2Fsock") self.assertEqual("../path/to/sock", conn["socket"]) self.assertEqual("", conn["schema"]) conn = mysqlx._get_connection_settings("root:@..%2Fpath%2Fto%2Fsock" "/schema") self.assertEqual("../path/to/sock", conn["socket"]) self.assertEqual("schema", conn["schema"])