| 315 | } |
| 316 | |
| 317 | TEST_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 | |
| 358 | TEST_F(ConnectionRemoteTest, TestSQLConnectInvalidUid) { |
| 359 | // Connect string |
nothing calls this directly
no test coverage detected