Skip to content

Commit

Permalink
merged two manual tests in one file
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jy committed Sep 12, 2024
1 parent 23d5f75 commit 85eb163
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 71 deletions.
4 changes: 1 addition & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ SET(TESTS_C
# test_lob
# test_stats
# This test needs the Oauth token, so it should be run manually
# test_oauth
# MFA connection is only able to run testing manually.
test_mfa_connect
# test_manual_connect
)

SET(TESTS_CXX
Expand Down
73 changes: 54 additions & 19 deletions tests/test_mfa_connect.c → tests/test_manual_connect.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,53 @@
/*
* Copyright (c) 2018-2024 Snowflake Computing, Inc. All rights reserved.
*/
//
// Copyright (c) 2018-2024 Snowflake Computing, Inc. All rights reserved.
//

#include "utils/test_setup.h"

void test_connect_with_duo_push(void **unused)
{
/**
* Test connection with OAuth authentication.
*/
void test_oauth_connect(void **unused) {
SF_CONNECT *sf = snowflake_init();
snowflake_set_attribute(sf, SF_CON_ACCOUNT,
getenv("SNOWFLAKE_TEST_ACCOUNT"));
snowflake_set_attribute(sf, SF_CON_USER, getenv("SNOWFLAKE_TEST_USER"));
snowflake_set_attribute(sf, SF_CON_PASSWORD,
getenv("SNOWFLAKE_TEST_PASSWORD"));

char *host, *port, *protocol;
host = getenv("SNOWFLAKE_TEST_HOST");
if (host) {
snowflake_set_attribute(sf, SF_CON_HOST, host);
}
port = getenv("SNOWFLAKE_TEST_PORT");
if (port) {
snowflake_set_attribute(sf, SF_CON_PORT, port);
}
protocol = getenv("SNOWFLAKE_TEST_PROTOCOL");
if (protocol) {
snowflake_set_attribute(sf, SF_CON_PROTOCOL, protocol);
}
char* token = "<Pass your token here>";
snowflake_set_attribute(sf, SF_CON_AUTHENTICATOR, "oauth");
snowflake_set_attribute(sf, SF_CON_OAUTH_TOKEN, token);

SF_STATUS status = snowflake_connect(sf);
if (status != SF_STATUS_SUCCESS) {
dump_error(&(sf->error));
}
assert_int_equal(status, SF_STATUS_SUCCESS);
snowflake_term(sf);
}

void test_mfa_connect_with_duo_push(void** unused)
{
SF_CONNECT* sf = snowflake_init();
snowflake_set_attribute(sf, SF_CON_ACCOUNT,
getenv("SNOWFLAKE_TEST_ACCOUNT"));
snowflake_set_attribute(sf, SF_CON_USER, getenv("SNOWFLAKE_TEST_USER"));
snowflake_set_attribute(sf, SF_CON_PASSWORD,
getenv("SNOWFLAKE_TEST_PASSWORD"));
char* host, * port, * protocol;
host = getenv("SNOWFLAKE_TEST_HOST");
if (host)
{
snowflake_set_attribute(sf, SF_CON_HOST, host);
Expand All @@ -38,15 +72,15 @@ void test_connect_with_duo_push(void **unused)
snowflake_term(sf);
}

void test_connect_with_duo_passcode(void **unused)
void test_mfa_connect_with_duo_passcode(void** unused)
{
SF_CONNECT *sf = snowflake_init();
SF_CONNECT* sf = snowflake_init();
snowflake_set_attribute(sf, SF_CON_ACCOUNT,
getenv("SNOWFLAKE_TEST_ACCOUNT"));
getenv("SNOWFLAKE_TEST_ACCOUNT"));
snowflake_set_attribute(sf, SF_CON_USER, getenv("SNOWFLAKE_TEST_USER"));
snowflake_set_attribute(sf, SF_CON_PASSWORD,
getenv("SNOWFLAKE_TEST_PASSWORD"));
char *host, *port, *protocol, *passcode;
getenv("SNOWFLAKE_TEST_PASSWORD"));
char* host, * port, * protocol, * passcode;
host = getenv("SNOWFLAKE_TEST_HOST");
if (host)
{
Expand Down Expand Up @@ -80,7 +114,7 @@ void test_connect_with_duo_passcode(void **unused)
snowflake_term(sf);
}

void test_connect_with_duo_passcodeInPassword(void** unused)
void test_mfa_connect_with_duo_passcodeInPassword(void** unused)
{
SF_CONNECT* sf = snowflake_init();
snowflake_set_attribute(sf, SF_CON_ACCOUNT,
Expand Down Expand Up @@ -117,14 +151,15 @@ void test_connect_with_duo_passcodeInPassword(void** unused)
snowflake_term(sf);
}

int main(void)
{

int main(void) {
initialize_test(SF_BOOLEAN_FALSE);
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_connect_with_duo_push),
cmocka_unit_test(test_connect_with_duo_passcode),
//Need to run this testing separately.
//cmocka_unit_test(test_connect_with_duo_passcodeInPassword),
cmocka_unit_test(test_oauth_connect),
cmocka_unit_test(test_mfa_connect_with_duo_push),
cmocka_unit_test(test_mfa_connect_with_duo_passcode),
//Need to run this testing separately.
//cmocka_unit_test(test_mfa_connect_with_duo_passcodeInPassword),
};
int ret = cmocka_run_group_tests(tests, NULL, NULL);
snowflake_global_term();
Expand Down
49 changes: 0 additions & 49 deletions tests/test_oauth.c

This file was deleted.

0 comments on commit 85eb163

Please sign in to comment.