Skip to content

Commit

Permalink
Remove Timestream authentication methods (#2)
Browse files Browse the repository at this point in the history
* Replaced aws-profile, iam, aad and okta with default authentication.

* Delete aad_credentials_provider(h,cpp) source files.

* Delete okta_credentials_provider(h,cpp) source files.

* Delete saml_credentials_provider(h,cpp) source files.

* Remove commented out code from test_conn.cpp.

* Remove commented out code from dlg_specific.h.

* Remove commented out code from dlg_wingui.c.

* Remove commented out code from drvconn.c.

* Remove commented out code from odbc.h.

* Remove commented out code from odbc_communication.cpp

* Remove commented out code from odbc_communication.h

* Remove commented out code from resource.h.

* Remove commented out code from setup.c.

* Change 'AUTHMODE_CNT' for 4 to 1.

* Remove extra line with 4 trailing white spaces.

* Set DEFAULT_AUTHTYPE to equal AUTHTYPE_DEFAULT.

* Remove 'IDC_TOKEN_STATIC' and 'IDC_TOKEN'.

* Bug fix: declare pwdp variable inside hide_password function.

* Implement SetDlgStuff and GetDlgStuff for default authentication method.

* In dconn_FDriverConnectProc function, for default authentication set focus to user item.

* In SetDlgStuff function wrap pwd in SAFE_NAME macro.

* Remove remaining commented out code.
  • Loading branch information
garya-bitquill authored Oct 26, 2021
1 parent 37a4562 commit 20d95e8
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 1,666 deletions.
41 changes: 3 additions & 38 deletions src/Tests/Tests/odbc-linux32.ini
Original file line number Diff line number Diff line change
@@ -1,43 +1,8 @@
[ODBC Data Sources]
timestream-iam = Amazon Timestream ODBC Driver 32
timestream-aws-profile = Amazon Timestream ODBC Driver 32
timestream-aad = Amazon Timestream ODBC Driver 32
timestream-okta = Amazon Timestream ODBC Driver 32
timestream-default = Amazon Timestream ODBC Driver 32

[timestream-aws-profile]
[timestream-default]
Driver = Amazon Timestream ODBC Driver 32
Region = us-east-1
Auth = AWS_PROFILE

[timestream-iam]
Driver = Amazon Timestream ODBC Driver 32
Region = us-east-1
Auth = IAM
Auth = DEFAULT
UID =
PWD =
SessionToken =

[timestream-aad]
Driver = Amazon Timestream ODBC Driver 32
Region = us-east-1
Auth = AAD
IdpName = AzureAD
AADApplicationID =
AADClientSecret =
RoleARN =
AADTenant =
IdpARN =
IdpUserName =
IdpPassword =

[timestream-okta]
Driver = Amazon Timestream ODBC Driver 32
Region = us-east-1
Auth = OKTA
IdpName = Okta
IdpHost =
OktaApplicationID =
RoleARN =
IdpARN =
IdpUserName =
IdpPassword =
41 changes: 3 additions & 38 deletions src/Tests/Tests/odbc-linux64.ini
Original file line number Diff line number Diff line change
@@ -1,43 +1,8 @@
[ODBC Data Sources]
timestream-iam = Amazon Timestream ODBC Driver
timestream-aws-profile = Amazon Timestream ODBC Driver
timestream-aad = Amazon Timestream ODBC Driver
timestream-okta = Amazon Timestream ODBC Driver
timestream-default = Amazon Timestream ODBC Driver

[timestream-aws-profile]
[timestream-default]
Driver = Amazon Timestream ODBC Driver
Region = us-east-1
Auth = AWS_PROFILE

[timestream-iam]
Driver = Amazon Timestream ODBC Driver
Region = us-east-1
Auth = IAM
Auth = DEFAULT
UID =
PWD =
SessionToken =

[timestream-aad]
Driver = Amazon Timestream ODBC Driver
Region = us-east-1
Auth = AAD
IdpName = AzureAD
AADApplicationID =
AADClientSecret =
RoleARN =
AADTenant =
IdpARN =
IdpUserName =
IdpPassword =

[timestream-okta]
Driver = Amazon Timestream ODBC Driver
Region = us-east-1
Auth = OKTA
IdpName = Okta
IdpHost =
OktaApplicationID =
RoleARN =
IdpARN =
IdpUserName =
IdpPassword =
41 changes: 3 additions & 38 deletions src/Tests/Tests/odbc-mac.ini
Original file line number Diff line number Diff line change
@@ -1,43 +1,8 @@
[ODBC Data Sources]
timestream-iam = Amazon Timestream ODBC Driver
timestream-aws-profile = Amazon Timestream ODBC Driver
timestream-aad = Amazon Timestream ODBC Driver
timestream-okta = Amazon Timestream ODBC Driver
timestream-default = Amazon Timestream ODBC Driver

[timestream-aws-profile]
[timestream-default]
Driver = Amazon Timestream ODBC Driver
Region = us-east-1
Auth = AWS_PROFILE

[timestream-iam]
Driver = Amazon Timestream ODBC Driver
Region = us-east-1
Auth = IAM
Auth = DEFAULT
UID =
PWD =
SessionToken =

[timestream-aad]
Driver = Amazon Timestream ODBC Driver
Region = us-east-1
Auth = AAD
IdpName = AzureAD
AADApplicationID =
AADClientSecret =
RoleARN =
AADTenant =
IdpARN =
IdpUserName =
IdpPassword =

[timestream-okta]
Driver = Amazon Timestream ODBC Driver
Region = us-east-1
Auth = OKTA
IdpName = Okta
IdpHost =
OktaApplicationID =
RoleARN =
IdpARN =
IdpUserName =
IdpPassword =
73 changes: 3 additions & 70 deletions src/Tests/Tests/test_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#endif

#include "odbc_communication.h"
#include "okta_credentials_provider.h"
#include "pch.h"
#include "unit_test_helper.h"
// clang-format on
Expand All @@ -31,8 +30,7 @@ TEST(TestConnectionOptions, Good) {
runtime_options options;
options.auth.uid = "UID";
options.auth.pwd = "PWD";
options.auth.region = "Region";
options.auth.auth_type = AUTHTYPE_IAM;
options.auth.auth_type = AUTHTYPE_DEFAULT;
TSCommunication conn;
EXPECT_NO_THROW(conn.Validate(options));
EXPECT_TRUE(conn.Validate(options));
Expand All @@ -42,8 +40,7 @@ TEST(TestConnectionOptions, UID_is_empty) {
runtime_options options;
options.auth.uid = "";
options.auth.pwd = "PWD";
options.auth.region = "Region";
options.auth.auth_type = AUTHTYPE_IAM;
options.auth.auth_type = AUTHTYPE_DEFAULT;
TSCommunication conn;
EXPECT_THROW(conn.Validate(options), std::invalid_argument);
}
Expand All @@ -52,18 +49,7 @@ TEST(TestConnectionOptions, PWD_is_empty) {
runtime_options options;
options.auth.uid = "UID";
options.auth.pwd = "";
options.auth.region = "Region";
options.auth.auth_type = AUTHTYPE_IAM;
TSCommunication conn;
EXPECT_THROW(conn.Validate(options), std::invalid_argument);
}

TEST(TestConnectionOptions, Region_is_empty) {
runtime_options options;
options.auth.uid = "UID";
options.auth.pwd = "PWD";
options.auth.region = "";
options.auth.auth_type = AUTHTYPE_IAM;
options.auth.auth_type = AUTHTYPE_DEFAULT;
TSCommunication conn;
EXPECT_THROW(conn.Validate(options), std::invalid_argument);
}
Expand All @@ -72,7 +58,6 @@ TEST(TestConnectionOptions, Auth_type_is_empty) {
runtime_options options;
options.auth.uid = "UID";
options.auth.pwd = "PWD";
options.auth.region = "Region";
options.auth.auth_type = "";
TSCommunication conn;
EXPECT_THROW(conn.Validate(options), std::invalid_argument);
Expand All @@ -82,64 +67,12 @@ TEST(TestConnectionOptions, Timeout_is_alpha) {
runtime_options options;
options.auth.uid = "UID";
options.auth.pwd = "PWD";
options.auth.region = "Region";
options.auth.auth_type = "";
options.conn.timeout = "timeout";
TSCommunication conn;
EXPECT_THROW(conn.Validate(options), std::invalid_argument);
}

TEST(TestConnectionOptions, IdP_host_is_empty) {
runtime_options options;
options.auth.uid = "UID";
options.auth.pwd = "PWD";
options.auth.region = "Region";
options.auth.auth_type = AUTHTYPE_OKTA;
options.auth.idp_host = "";
TSCommunication conn;
EXPECT_THROW(conn.Validate(options), std::invalid_argument);
}

TEST(TestDecodeHex, Single_hex) {
const std::string hex_encoded = "=";
const std::string expected = "=";
EXPECT_EQ(expected, OktaCredentialsProvider::DecodeHex(hex_encoded));
}

TEST(TestDecodeHex, Invalid_single_hex) {
const std::string hex_encoded = "&#x3d";
EXPECT_EQ(hex_encoded, OktaCredentialsProvider::DecodeHex(hex_encoded));
}

TEST(TestDecodeHex, Double_ampersand) {
const std::string hex_encoded = "&=";
const std::string expected = "&=";
EXPECT_EQ(expected, OktaCredentialsProvider::DecodeHex(hex_encoded));
}

TEST(TestDecodeHex, Hex_with_numbers) {
const std::string hex_encoded = "12345=+12345";
const std::string expected = "12345=+12345";
EXPECT_EQ(expected, OktaCredentialsProvider::DecodeHex(hex_encoded));
}

TEST(TestDecodeHex, Empty) {
const std::string hex_encoded = "";
const std::string expected = "";
EXPECT_EQ(expected, OktaCredentialsProvider::DecodeHex(hex_encoded));
}

TEST(TestDecodeHex, No_hex) {
const std::string hex_encoded = "12345abc";
EXPECT_EQ(hex_encoded, OktaCredentialsProvider::DecodeHex(hex_encoded));
}

TEST(TestDecodeHex, All_possible_hex) {
const std::string hex_encoded = "+/=,-_";
const std::string expected = "+/=,-_";
EXPECT_EQ(expected, OktaCredentialsProvider::DecodeHex(hex_encoded));
}

TEST(TestGetUserAgent, Success) {
TSCommunication conn;
std::string expected = "ts-odbc." TIMESTREAMDRIVERVERSION " [tests]";
Expand Down
Loading

0 comments on commit 20d95e8

Please sign in to comment.