MCPcopy Create free account
hub / github.com/apache/arrow / TEST_F

Function TEST_F

cpp/src/arrow/flight/sql/odbc/tests/connection_test.cc:317–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317TEST_F(ConnectionRemoteTest, TestSQLConnectInputUidPwd) {
318 // Connect string
319 std::string connect_str = GetConnectionString();
320
321 // Retrieve valid uid and pwd, assumes TEST_CONNECT_STR contains uid and pwd
322 Connection::ConnPropertyMap properties;
323 ODBC::ODBCConnection::GetPropertiesFromConnString(connect_str, properties);
324 std::string uid_key("uid");
325 std::string pwd_key("pwd");
326 std::string uid = properties[uid_key];
327 std::string pwd = properties[pwd_key];
328
329 // Write connection string content without uid and pwd into a DSN,
330 // must succeed before continuing
331 properties.erase(uid_key);
332 properties.erase(pwd_key);
333 ASSERT_TRUE(WriteDSN(properties));
334
335 std::string dsn(kTestDsn);
336 ASSERT_OK_AND_ASSIGN(std::wstring wdsn, arrow::util::UTF8ToWideString(dsn));
337 ASSERT_OK_AND_ASSIGN(std::wstring wuid, arrow::util::UTF8ToWideString(uid));
338 ASSERT_OK_AND_ASSIGN(std::wstring wpwd, arrow::util::UTF8ToWideString(pwd));
339 std::vector<SQLWCHAR> dsn0(wdsn.begin(), wdsn.end());
340 std::vector<SQLWCHAR> uid0(wuid.begin(), wuid.end());
341 std::vector<SQLWCHAR> pwd0(wpwd.begin(), wpwd.end());
342
343 // Connecting to ODBC server.
344 ASSERT_EQ(SQL_SUCCESS,
345 SQLConnect(conn, dsn0.data(), static_cast<SQLSMALLINT>(dsn0.size()),
346 uid0.data(), static_cast<SQLSMALLINT>(uid0.size()), pwd0.data(),
347 static_cast<SQLSMALLINT>(pwd0.size())))
348 << GetOdbcErrorMessage(SQL_HANDLE_DBC, conn);
349
350 // Remove DSN
351 ASSERT_TRUE(UnregisterDsn(wdsn));
352
353 // Disconnect from ODBC
354 ASSERT_EQ(SQL_SUCCESS, SQLDisconnect(conn))
355 << GetOdbcErrorMessage(SQL_HANDLE_DBC, conn);
356}
357
358TEST_F(ConnectionRemoteTest, TestSQLConnectInvalidUid) {
359 // Connect string

Callers

nothing calls this directly

Calls 13

WriteDSNFunction · 0.85
GetOdbcErrorMessageFunction · 0.85
UnregisterDsnFunction · 0.85
VerifyOdbcErrorStateFunction · 0.85
SqlWcharToStringFunction · 0.85
SQLConnectFunction · 0.50
SQLDisconnectFunction · 0.50
SQLDriverConnectFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected