Skip to content

Commit

Permalink
Merge pull request #4 from Bit-Quill/main
Browse files Browse the repository at this point in the history
Re-sync develop to main branch
  • Loading branch information
garya-bitquill authored Oct 26, 2021
2 parents 4de96cd + 313353e commit dbbfbc6
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 1,674 deletions.
13 changes: 5 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@
<!--- Link to issue where this is tracked -->

### Additional Reviewers
@kylepbit
@raymond-lum
@yanw-bq
@lyndonb-bq
@csolonynka
@justing-bq
@leszek-bq
@jduo
@affonsoBQ
@alexey-temnikov
@andiem-bq
@birschick-bq
@garya-bitquill
<!-- Any additional reviewers -->
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 = "&#x3d;";
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 = "&&#x3d;";
const std::string expected = "&=";
EXPECT_EQ(expected, OktaCredentialsProvider::DecodeHex(hex_encoded));
}

TEST(TestDecodeHex, Hex_with_numbers) {
const std::string hex_encoded = "12345&#x3d;&#x2b;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 = "&#x2b;&#x2f;&#x3d;&#x2c;&#x2d;&#x5f;";
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 dbbfbc6

Please sign in to comment.