-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconnection.h
More file actions
98 lines (77 loc) · 3.98 KB
/
Copy pathconnection.h
File metadata and controls
98 lines (77 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CPP_BIGQUERY_ODBC_GOOGLE_CLOUD_ODBC_TESTING_ODBC_UTILS_CONNECTION_H
#define CPP_BIGQUERY_ODBC_GOOGLE_CLOUD_ODBC_TESTING_ODBC_UTILS_CONNECTION_H
#include "google/cloud/odbc/testing/odbc_utils/commons.h"
namespace google::cloud::odbc_tests {
void SetAttributes(std::shared_ptr<ODBCHandles> const& conn, int timeout,
bool use_ansi = false);
// Returns the default DSN name after checking if ODBC_TESTS_DSN env is defined
inline std::string GetDefaultDSN() {
return google::cloud::internal::GetEnv("ODBC_TESTS_DSN")
.value_or("ODBCTestsDSN");
}
// Returns the default Transactions DSN name after checking if
// ODBC_TRANSACTIONS_TESTS_DSN env is defined
inline std::string GetDefaultTransactionsTestDSN() {
return google::cloud::internal::GetEnv("ODBC_TRANSACTIONS_TESTS_DSN")
.value_or("ODBCTransactionsTestsDSN");
}
std::string const kDefaultDataSource = GetDefaultDSN();
auto const kDefaultConnectionString = "DSN=" + GetDefaultDSN();
auto const kSessionEnabledConnectionString =
"DSN=" + GetDefaultTransactionsTestDSN();
// used for DSNLess SQLConnect. If we change BQ service account credentials
// email it will need to be changed here as well other DSNLess connect tests
// would fail.
std::string const kServiceAccountEmail =
"bq-devtools-simba-drivers-test@bigquery-devtools-drivers.iam."
"gserviceaccount.com";
std::string const kImpersonatedAccountEmail =
"odbc-impersonation-test@bigquery-devtools-drivers.iam."
"gserviceaccount.com";
// Connect using a <conn_str> and populate the ODBCHandles
SQLRETURN
Connect(std::string const& conn_str, std::shared_ptr<ODBCHandles> const& conn,
bool use_ansi = false, int timeout = 30);
// To validate SQLDriverConnect and SQLDriverConnectW with NULL output
// parameters.
SQLRETURN
ConnectWithNullOutputParams(std::string const& conn_str, std::wstring dsn,
std::shared_ptr<ODBCHandles> const& conn,
bool use_wide = false);
SQLRETURN Connect(std::wstring dsn, std::shared_ptr<ODBCHandles> const& conn,
int timeout = 30, bool is_driver_connect = false);
// Connect using a <conn_str> with <window_handle>, <driver_completion>
// and populate ODBCHandles
SQLRETURN
ConnectWithPromptWindows(std::string const& conn_str,
std::shared_ptr<ODBCHandles> const& conn,
SQLHWND window_handle, SQLUSMALLINT driver_completion,
int timeout = 30, bool use_ansi = false);
// Connect using a datasource name directly and populate the ODBCHandles
SQLRETURN ConnectDsn(std::string const& dsn,
std::shared_ptr<ODBCHandles> const& conn, int timeout = 30,
bool use_ansi = false);
SQLRETURN ConnectDsnLess(std::string const& username, std::string const& auth,
std::shared_ptr<ODBCHandles> const& conn,
int timeout = 30, bool use_ansi = false);
SQLRETURN Disconnect(std::shared_ptr<ODBCHandles> const& conn);
SQLRETURN GetDriverInfo(std::shared_ptr<ODBCHandles> const& conn,
bool use_ansi = false);
SQLRETURN GetEnvInfo(std::shared_ptr<ODBCHandles> const& conn);
SQLRETURN PrintDriverVerName(std::shared_ptr<ODBCHandles> const& conn,
bool use_ansi = false);
} // namespace google::cloud::odbc_tests
#endif // CPP_BIGQUERY_ODBC_GOOGLE_CLOUD_ODBC_TESTING_ODBC_UTILS_CONNECTION_H