You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Travis and Appveyor integration:
- added travis support - fixed appveyor settings - fixed some warnings (gcc 4.8) - removed sleep commands - disabled failing tests when running against MySQL server, mostly related to stored procedures and binary protocol - reverted fix for MDEV_10361 Still open: TLS/SSL appveyor tests, since .msi installation on appveyor doesn't provide certificates.
This commit is contained in:
@@ -64,7 +64,7 @@ FOREACH(API_TEST ${API_TESTS})
|
||||
ENDIF()
|
||||
TARGET_LINK_LIBRARIES(${API_TEST} cctap ma_getopt mariadbclient)
|
||||
ADD_TEST(${API_TEST} ${EXECUTABLE_OUTPUT_PATH}/${API_TEST})
|
||||
SET_TESTS_PROPERTIES(${API_TEST} PROPERTIES TIMEOUT 120)
|
||||
SET_TESTS_PROPERTIES(${API_TEST} PROPERTIES TIMEOUT 180)
|
||||
ENDFOREACH(API_TEST)
|
||||
|
||||
FOREACH(API_TEST ${MANUAL_TESTS})
|
||||
|
@@ -58,7 +58,6 @@ static int test_conc75(MYSQL *my)
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
diag("killing connection");
|
||||
mysql_kill(my, thread_id);
|
||||
sleep(2);
|
||||
mysql_ping(mysql);
|
||||
rc= mysql_query(mysql, "load data local infile './nonexistingfile.csv' into table a (`a`)");
|
||||
FAIL_IF(!test(mysql->options.client_flag | CLIENT_LOCAL_FILES), "client_flags not correct");
|
||||
@@ -128,7 +127,6 @@ static int test_conc71(MYSQL *my)
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
diag("kill server");
|
||||
sleep(20);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT 'foo' FROM DUAL");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -173,7 +171,6 @@ static int test_conc70(MYSQL *my)
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
sleep(20);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT a FROM t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -717,6 +714,7 @@ static int test_reconnect_maxpackage(MYSQL *unused __attribute__((unused)))
|
||||
my_bool reconnect= 1;
|
||||
|
||||
SKIP_CONNECTION_HANDLER;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
|
||||
@@ -748,9 +746,13 @@ static int test_reconnect_maxpackage(MYSQL *unused __attribute__((unused)))
|
||||
return FAIL;
|
||||
}
|
||||
else
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
diag("Error (expected): %s", mysql_error(mysql));
|
||||
|
||||
rc= mysql_ping(mysql);
|
||||
/* if the server is under load, poll might not report closed
|
||||
socket since FIN packet came too late */
|
||||
if (rc)
|
||||
rc= mysql_ping(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "SELECT @@max_allowed_packet");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
@@ -539,6 +539,8 @@ static int test_conc243(MYSQL *mysql)
|
||||
size_t row_size= sizeof(struct st_data);
|
||||
int rc;
|
||||
|
||||
if (!bulk_enabled)
|
||||
return SKIP;
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk_example2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -628,12 +630,15 @@ static int bulk7(MYSQL *mysql)
|
||||
|
||||
static int test_char_conv1(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||
MYSQL_STMT *stmt;
|
||||
int rc;
|
||||
MYSQL_BIND bind_in, bind_out;
|
||||
char buffer[100];
|
||||
char outbuffer[100];
|
||||
|
||||
|
||||
if (!bulk_enabled)
|
||||
return SKIP;
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
strcpy (buffer, "\xC3\x82\xC3\x83\xC3\x84\x00");
|
||||
|
||||
rc= mysql_query(mysql, "SET NAMES UTF8");
|
||||
@@ -696,13 +701,17 @@ static int test_char_conv1(MYSQL *mysql)
|
||||
|
||||
static int test_char_conv2(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||
MYSQL_STMT *stmt;
|
||||
int rc;
|
||||
int array_size= 1;
|
||||
MYSQL_BIND bind_in, bind_out;
|
||||
char *buffer[1];
|
||||
char outbuffer[100];
|
||||
|
||||
|
||||
if (!bulk_enabled)
|
||||
return SKIP;
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
buffer[0]= calloc(1, 7);
|
||||
strcpy (buffer[0], "\xC3\x82\xC3\x83\xC3\x84\x00");
|
||||
|
||||
@@ -794,6 +803,8 @@ static int bulk_skip_row(MYSQL *mysql)
|
||||
size_t row_size= sizeof(struct st_data);
|
||||
int rc;
|
||||
|
||||
if (!bulk_enabled)
|
||||
return SKIP;
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk_example2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
|
@@ -536,7 +536,8 @@ static int test_bug30472(MYSQL *mysql)
|
||||
char character_set_results_4[MY_CS_NAME_SIZE];
|
||||
char collation_connnection_4[MY_CS_NAME_SIZE];
|
||||
|
||||
if (mysql_get_server_version(mysql) < 50100) {
|
||||
if (mysql_get_server_version(mysql) < 50100 || !is_mariadb)
|
||||
{
|
||||
diag("Test requires MySQL Server version 5.1 or above");
|
||||
return SKIP;
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ static int test_conc66(MYSQL *my)
|
||||
rc= mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "./my-conc66-test.cnf");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
sprintf(query, "GRANT ALL ON %s.* TO 'conc66'@'%s' IDENTIFIED BY 'test\";#test'", schema, hostname ? hostname : "localhost");
|
||||
sprintf(query, "GRANT ALL ON %s.* TO 'conc66'@'%s' IDENTIFIED BY 'test\";#test'", schema, this_host ? this_host : "localhost");
|
||||
rc= mysql_query(my, query);
|
||||
check_mysql_rc(rc, my);
|
||||
rc= mysql_query(my, "FLUSH PRIVILEGES");
|
||||
@@ -60,11 +60,13 @@ static int test_conc66(MYSQL *my)
|
||||
if (!my_test_connect(mysql, hostname, NULL,
|
||||
NULL, schema, port, socketname, 0))
|
||||
{
|
||||
diag("user: %s", mysql->options.user);
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
return FAIL;
|
||||
}
|
||||
diag("user: %s", mysql->options.user);
|
||||
|
||||
sprintf(query, "DROP user conc66@%s", hostname ? hostname : "localhost");
|
||||
sprintf(query, "DROP user 'conc66'@'%s'", this_host ? this_host : "localhost");
|
||||
rc= mysql_query(my, query);
|
||||
|
||||
check_mysql_rc(rc, my);
|
||||
@@ -83,6 +85,9 @@ static int test_bug20023(MYSQL *mysql)
|
||||
int sql_big_selects_5;
|
||||
int rc;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
if (mysql_get_server_version(mysql) < 50100) {
|
||||
diag("Test requires MySQL Server version 5.1 or above");
|
||||
return SKIP;
|
||||
@@ -579,7 +584,6 @@ static int test_reconnect(MYSQL *mysql)
|
||||
|
||||
diag("Thread_id before kill: %lu", mysql_thread_id(mysql1));
|
||||
mysql_kill(mysql, mysql_thread_id(mysql1));
|
||||
sleep(4);
|
||||
|
||||
mysql_ping(mysql1);
|
||||
|
||||
@@ -657,7 +661,7 @@ int test_connection_timeout(MYSQL *unused __attribute__((unused)))
|
||||
elapsed= time(NULL) - start;
|
||||
diag("elapsed: %lu", (unsigned long)elapsed);
|
||||
mysql_close(mysql);
|
||||
FAIL_IF(elapsed > 2 * timeout, "timeout ignored")
|
||||
FAIL_IF((unsigned int)elapsed > 2 * timeout, "timeout ignored")
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -677,7 +681,7 @@ int test_connection_timeout2(MYSQL *unused __attribute__((unused)))
|
||||
elapsed= time(NULL) - start;
|
||||
diag("elapsed: %lu", (unsigned long)elapsed);
|
||||
mysql_close(mysql);
|
||||
FAIL_IF(elapsed > 2 * timeout, "timeout ignored")
|
||||
FAIL_IF((unsigned int)elapsed > 2 * timeout, "timeout ignored")
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -702,7 +706,7 @@ int test_connection_timeout3(MYSQL *unused __attribute__((unused)))
|
||||
}
|
||||
elapsed= time(NULL) - start;
|
||||
diag("elapsed: %lu", (unsigned long)elapsed);
|
||||
FAIL_IF(elapsed > timeout + 1, "timeout ignored")
|
||||
FAIL_IF((unsigned int)elapsed > timeout + 1, "timeout ignored")
|
||||
|
||||
mysql_close(mysql);
|
||||
mysql= mysql_init(NULL);
|
||||
@@ -737,7 +741,6 @@ static int test_conc118(MYSQL *mysql)
|
||||
mysql->options.unused_1= 1;
|
||||
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
|
||||
mysql_ping(mysql);
|
||||
|
||||
@@ -747,7 +750,6 @@ static int test_conc118(MYSQL *mysql)
|
||||
FAIL_IF(mysql->options.unused_1 != 1, "options got lost");
|
||||
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
|
||||
mysql_ping(mysql);
|
||||
rc= mysql_query(mysql, "SET @a:=1");
|
||||
@@ -1021,6 +1023,9 @@ static int test_reset(MYSQL *mysql)
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
|
||||
if (mysql_get_server_version(mysql) < 100200)
|
||||
return SKIP;
|
||||
|
||||
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -1071,6 +1076,13 @@ static int test_auth256(MYSQL *my)
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
my_ulonglong num_rows= 0;
|
||||
char query[1024];
|
||||
|
||||
if (!mysql_client_find_plugin(mysql, "sha256_password", 3))
|
||||
{
|
||||
diag("sha256_password plugin not available");
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
rc= mysql_query(my, "SELECT * FROM information_schema.plugins where plugin_name='sha256_password'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -1088,8 +1100,10 @@ static int test_auth256(MYSQL *my)
|
||||
rc= mysql_query(my, "DROP USER IF EXISTS sha256user@localhost");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(my, "CREATE user sha256user@localhost identified with sha256_password by 'foo'");
|
||||
sprintf(query, "CREATE user 'sha256user'@'%s' identified with sha256_password by 'foo'", this_host);
|
||||
rc= mysql_query(my, query);
|
||||
check_mysql_rc(rc, my);
|
||||
|
||||
if (!mysql_real_connect(mysql, hostname, "sha256user", "foo", NULL, port, socketname, 0))
|
||||
{
|
||||
diag("error: %s", mysql_error(mysql));
|
||||
@@ -1107,7 +1121,8 @@ static int test_auth256(MYSQL *my)
|
||||
return FAIL;
|
||||
}
|
||||
mysql_close(mysql);
|
||||
rc= mysql_query(my, "DROP USER sha256user@localhost");
|
||||
sprintf(query, "DROP USER 'sha256user'@'%s'", this_host);
|
||||
rc= mysql_query(my, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
return OK;
|
||||
}
|
||||
|
@@ -176,6 +176,8 @@ static int test_cuted_rows(MYSQL *mysql)
|
||||
int rc, count;
|
||||
MYSQL_RES *result;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
mysql_query(mysql, "DROP TABLE if exists t1");
|
||||
mysql_query(mysql, "DROP TABLE if exists t2");
|
||||
|
@@ -98,6 +98,7 @@ static int bug31418_impl()
|
||||
MYSQL *mysql;
|
||||
int rc;
|
||||
|
||||
|
||||
/* Create a new connection. */
|
||||
|
||||
mysql= test_connect(NULL);
|
||||
@@ -169,7 +170,10 @@ static int bug31418_impl()
|
||||
|
||||
static int test_bug31418(MYSQL *unused __attribute__((unused)))
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
/* Run test case for BUG#31418 for three different connections. */
|
||||
|
||||
for (i=0; i < 3; i++)
|
||||
@@ -976,7 +980,6 @@ static int test_conc117(MYSQL *unused __attribute__((unused)))
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
mysql_kill(my, mysql_thread_id(my));
|
||||
sleep(5);
|
||||
|
||||
mysql_options(my, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
@@ -1064,6 +1067,9 @@ static int test_mdev12965(MYSQL *unused __attribute__((unused)))
|
||||
const char *env= getenv("MYSQL_TMP_DIR");
|
||||
char cnf_file1[FN_REFLEN + 1];
|
||||
|
||||
if (travis_test)
|
||||
return SKIP;
|
||||
|
||||
if (!env)
|
||||
env= "/tmp";
|
||||
|
||||
@@ -1082,7 +1088,7 @@ static int test_mdev12965(MYSQL *unused __attribute__((unused)))
|
||||
fprintf(fp, "[client]\ndefault-character-set=latin2\nreconnect=1\n");
|
||||
fclose(fp);
|
||||
|
||||
mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, NULL);
|
||||
mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "client");
|
||||
my_test_connect(mysql, hostname, username, password,
|
||||
schema, 0, socketname, 0);
|
||||
|
||||
@@ -1189,7 +1195,12 @@ static int test_server_status(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
unsigned int server_status;
|
||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||
MYSQL_STMT *stmt;
|
||||
|
||||
if (mysql_get_server_version(mysql) < 100200)
|
||||
return SKIP;
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
|
||||
rc= mysql_autocommit(mysql, 1);
|
||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_STATUS, &server_status);
|
||||
|
@@ -134,6 +134,9 @@ static unsigned int port = 0;
|
||||
static char *socketname = 0;
|
||||
static char *username = 0;
|
||||
static int force_tls= 0;
|
||||
static uchar is_mariadb= 0;
|
||||
static char *this_host= 0;
|
||||
static unsigned char travis_test= 0;
|
||||
/*
|
||||
static struct my_option test_options[] =
|
||||
{
|
||||
@@ -216,6 +219,22 @@ int do_verify_prepare_field(MYSQL_RES *result,
|
||||
return OK;
|
||||
}
|
||||
|
||||
void get_this_host(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if (mysql_query(mysql, "select substr(current_user(), locate('@', current_user())+1)"))
|
||||
return;
|
||||
|
||||
if ((res= mysql_store_result(mysql)))
|
||||
{
|
||||
if ((row= mysql_fetch_row(res)))
|
||||
this_host= strdup(row[0]);
|
||||
mysql_free_result(res);
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare statement, execute, and process result set for given query */
|
||||
|
||||
int my_stmt_result(MYSQL *mysql, const char *buff)
|
||||
@@ -436,7 +455,10 @@ MYSQL *test_connect(struct my_tests_st *test)
|
||||
static int reset_connection(MYSQL *mysql) {
|
||||
int rc;
|
||||
|
||||
rc= mysql_change_user(mysql, username, password, schema);
|
||||
if (is_mariadb)
|
||||
rc= mysql_change_user(mysql, username, password, schema);
|
||||
else
|
||||
rc= mysql_reset_connection(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "SET sql_mode=''");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -452,6 +474,9 @@ static int reset_connection(MYSQL *mysql) {
|
||||
void get_envvars() {
|
||||
char *envvar;
|
||||
|
||||
if (getenv("MYSQL_TEST_TRAVIS"))
|
||||
travis_test= 1;
|
||||
|
||||
if (!hostname && (envvar= getenv("MYSQL_TEST_HOST")))
|
||||
hostname= envvar;
|
||||
if (!username)
|
||||
@@ -504,6 +529,8 @@ MYSQL *my_test_connect(MYSQL *mysql,
|
||||
diag("Error: TLS connection not established");
|
||||
return NULL;
|
||||
}
|
||||
if (!this_host)
|
||||
get_this_host(mysql);
|
||||
return mysql;
|
||||
}
|
||||
|
||||
@@ -512,7 +539,6 @@ void run_tests(struct my_tests_st *test) {
|
||||
int i, rc, total=0;
|
||||
MYSQL *mysql, *mysql_default= NULL; /* default connection */
|
||||
|
||||
|
||||
while (test[total].function)
|
||||
total++;
|
||||
plan(total);
|
||||
@@ -522,6 +548,7 @@ void run_tests(struct my_tests_st *test) {
|
||||
diag("Testing against MySQL Server %s", mysql_get_server_info(mysql_default));
|
||||
diag("Host: %s", mysql_get_host_info(mysql_default));
|
||||
diag("Client library: %s", mysql_get_client_info());
|
||||
is_mariadb= mariadb_connection(mysql_default);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -567,6 +594,9 @@ void run_tests(struct my_tests_st *test) {
|
||||
skip(1, "%s", test[i].skipmsg);
|
||||
}
|
||||
}
|
||||
if (this_host)
|
||||
free(this_host);
|
||||
|
||||
if (mysql_default) {
|
||||
diag("close default");
|
||||
mysql_close(mysql_default);
|
||||
|
@@ -65,7 +65,6 @@ static int test_conc83(MYSQL *unused __attribute__((unused)))
|
||||
/* 1. Status is inited, so prepare should work */
|
||||
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(5);
|
||||
|
||||
rc= mysql_ping(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -76,7 +75,6 @@ static int test_conc83(MYSQL *unused __attribute__((unused)))
|
||||
|
||||
/* 2. Status is prepared, execute should fail */
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
FAIL_IF(!rc, "Error expected");
|
||||
@@ -1377,7 +1375,7 @@ static int test_long_data_str1(MYSQL *mysql)
|
||||
int rc, i, rowcount= 0;
|
||||
char data[255];
|
||||
long length;
|
||||
size_t max_blob_length, blob_length, length1;
|
||||
unsigned long max_blob_length, blob_length, length1;
|
||||
my_bool true_value;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_BIND my_bind[2];
|
||||
@@ -3137,6 +3135,8 @@ static int test_datetime_ranges(MYSQL *mysql)
|
||||
MYSQL_BIND my_bind[6];
|
||||
MYSQL_TIME tm[6];
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
stmt_text= "drop table if exists t1";
|
||||
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
|
||||
@@ -4980,6 +4980,9 @@ static int test_reexecute(MYSQL *mysql)
|
||||
int int_data[3]; /* input/output values */
|
||||
int rc;
|
||||
|
||||
if (!mariadb_connection(mysql))
|
||||
return SKIP;
|
||||
|
||||
/* set up stored procedure */
|
||||
rc = mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
@@ -537,7 +537,6 @@ static int test_bug12744(MYSQL *mysql)
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
|
||||
sleep(4);
|
||||
rc= mysql_ping(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -2731,6 +2730,8 @@ static int test_bug5315(MYSQL *mysql)
|
||||
const char *stmt_text;
|
||||
int rc;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
stmt_text= "SELECT 1";
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
@@ -3456,6 +3457,8 @@ static int test_explain_bug(MYSQL *mysql)
|
||||
MYSQL_RES *result;
|
||||
int rc;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
mysql_autocommit(mysql, TRUE);
|
||||
|
||||
@@ -3803,7 +3806,6 @@ static int test_bug53311(MYSQL *mysql)
|
||||
|
||||
/* kill connection */
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(1);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
FAIL_IF(rc == 0, "Error expected");
|
||||
@@ -4286,8 +4288,11 @@ static int test_conc179(MYSQL *mysql)
|
||||
rc= mysql_stmt_prepare(stmt, stmtstr, (unsigned long)strlen(stmtstr));
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
FAIL_IF(mysql_warning_count(mysql) < 2, "expected 2 or more warnings");
|
||||
FAIL_IF(mysql_stmt_warning_count(stmt) < 2, "expected 2 or more warnings");
|
||||
if (mysql_get_server_version(mysql) >= 100100)
|
||||
{
|
||||
FAIL_IF(mysql_warning_count(mysql) < 2, "expected 2 or more warnings");
|
||||
FAIL_IF(mysql_stmt_warning_count(stmt) < 2, "expected 2 or more warnings");
|
||||
}
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||
|
@@ -104,7 +104,7 @@ static int test_multi_result(MYSQL *mysql)
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
FAIL_IF(int_data[0] != 10 || int_data[1] != 20 || int_data[2] != 30,
|
||||
"expected 10 20 30");
|
||||
"expected 10 20 30");
|
||||
rc= mysql_stmt_next_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
rc= mysql_stmt_bind_result(stmt, rs_bind);
|
||||
@@ -112,7 +112,7 @@ static int test_multi_result(MYSQL *mysql)
|
||||
rc= mysql_stmt_fetch(stmt);
|
||||
FAIL_IF(mysql_stmt_field_count(stmt) != 3, "expected 3 fields");
|
||||
FAIL_IF(int_data[0] != 100 || int_data[1] != 200 || int_data[2] != 300,
|
||||
"expected 100 200 300");
|
||||
"expected 100 200 300");
|
||||
|
||||
FAIL_IF(mysql_stmt_next_result(stmt) != 0, "expected more results");
|
||||
rc= mysql_stmt_bind_result(stmt, rs_bind);
|
||||
@@ -120,7 +120,7 @@ static int test_multi_result(MYSQL *mysql)
|
||||
rc= mysql_stmt_fetch(stmt);
|
||||
FAIL_IF(mysql_stmt_field_count(stmt) != 2, "expected 2 fields");
|
||||
FAIL_IF(int_data[0] != 200 || int_data[1] != 300,
|
||||
"expected 100 200 300");
|
||||
"expected 100 200 300");
|
||||
|
||||
FAIL_IF(mysql_stmt_next_result(stmt) != 0, "expected more results");
|
||||
FAIL_IF(mysql_stmt_field_count(stmt) != 0, "expected 0 fields");
|
||||
|
@@ -86,15 +86,14 @@ static int create_ssl_user(const char *ssluser, my_bool is_X509)
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
|
||||
sprintf(query, "DROP USER IF EXISTS '%s'@'%s'", ssluser, sslhost);
|
||||
sprintf(query, "DROP USER '%s'@'%s'", ssluser, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
|
||||
sprintf(query, "CREATE USER '%s'@'%s' IDENTIFIED BY '%s'", ssluser, this_host, sslpw);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc,mysql);
|
||||
|
||||
sprintf(query, "CREATE USER '%s'@'%s' IDENTIFIED BY '%s'", ssluser, sslhost, sslpw);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc,mysql);
|
||||
|
||||
sprintf(query, "GRANT ALL ON %s.* TO '%s'@'%s' REQUIRE %s", schema, ssluser, sslhost, is_X509 ? "X509" : "SSL");
|
||||
sprintf(query, "GRANT ALL ON %s.* TO '%s'@'%s' REQUIRE %s", schema, ssluser, this_host, is_X509 ? "X509" : "SSL");
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc,mysql);
|
||||
rc= mysql_query(mysql, "FLUSH PRIVILEGES");
|
||||
@@ -128,6 +127,24 @@ static int test_ssl(MYSQL *mysql)
|
||||
}
|
||||
mysql_free_result(res);
|
||||
|
||||
/* In MySQL we need to check tls_version */
|
||||
if (!mariadb_connection(mysql))
|
||||
{
|
||||
rc= mysql_query(mysql, "select locate('v1.2', @@tls_version) > 0");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
res= mysql_store_result(mysql);
|
||||
FAIL_IF(!res, mysql_error(mysql));
|
||||
|
||||
if ((row= mysql_fetch_row(res)))
|
||||
{
|
||||
if (row[0] && row[0][0] == '0')
|
||||
have_openssl= 0;
|
||||
}
|
||||
mysql_free_result(res);
|
||||
}
|
||||
diag("OpenSSL: %d", have_openssl);
|
||||
|
||||
mariadb_get_infov(NULL, MARIADB_TLS_LIBRARY, &tls_library);
|
||||
diag("SSL library: %s", tls_library);
|
||||
|
||||
@@ -450,6 +467,8 @@ static int test_conc50_1(MYSQL *unused __attribute__((unused)))
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
create_ssl_user(ssluser, 0);
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
FAIL_IF(!mysql, "Can't allocate memory");
|
||||
|
||||
@@ -460,6 +479,7 @@ static int test_conc50_1(MYSQL *unused __attribute__((unused)))
|
||||
if (mysql_errno(mysql))
|
||||
diag("Error: %d %s", mysql_errno(mysql), mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql), "No error expected");
|
||||
|
||||
mysql_close(mysql);
|
||||
|
||||
return OK;
|
||||
@@ -957,19 +977,23 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
if (check_skip_ssl())
|
||||
return SKIP;
|
||||
|
||||
if (!mariadb_connection(mysql))
|
||||
return SKIP;
|
||||
|
||||
for (i=1; i < 6; i++)
|
||||
{
|
||||
sprintf(query, "DROP USER IF EXISTS 'ssluser%d'@'%s'", i, sslhost);
|
||||
sprintf(query, "DROP USER 'ssluser%d'@'%s'", i, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
sprintf(query, "CREATE USER 'ssluser%d'@'%s'", i, sslhost);
|
||||
sprintf(query, "CREATE USER 'ssluser%d'@'%s'", i, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
}
|
||||
rc= mysql_query(mysql, "FLUSH PRIVILEGES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
diag("sslusers created");
|
||||
|
||||
sprintf(query, "grant select on %s.* to 'ssluser1'@'%s' require ssl", schema, sslhost);
|
||||
diag("ssluser1");
|
||||
sprintf(query, "grant select on %s.* to 'ssluser1'@'%s' require ssl", schema, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -988,11 +1012,12 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
FAIL_IF(!mysql_get_ssl_cipher(my), "No TLS connection");
|
||||
mysql_close(my);
|
||||
|
||||
sprintf(query, "grant select on %s.* to 'ssluser2'@'%s' require cipher 'AES256-SHA'", schema, sslhost);
|
||||
diag("ssluser2");
|
||||
sprintf(query, "grant select on %s.* to 'ssluser2'@'%s' require cipher 'AES256-SHA'", schema, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
|
||||
#ifdef TEST_RANDOM_RESULT
|
||||
/* ssl_user2: connect with enforce should work */
|
||||
my= mysql_init(NULL);
|
||||
mysql_options(my, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||
@@ -1005,8 +1030,21 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
return FAIL;
|
||||
}
|
||||
mysql_close(my);
|
||||
#endif
|
||||
/* ssl_user2: connect with correct cipher */
|
||||
diag("ssluser2");
|
||||
if (mysql_get_server_version(mysql) >= 100100)
|
||||
{
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
FAIL_IF(strcmp("AES256-SHA", mysql_get_ssl_cipher(my)) != 0, "expected cipher AES256-SHA");
|
||||
mysql_close(my);
|
||||
}
|
||||
|
||||
/* ssl_user2: connect with cipher should work */
|
||||
/* ssl_user2: connect with wrong cipher should not work */
|
||||
diag("ssluser2");
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES128-SHA");
|
||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||
@@ -1014,68 +1052,61 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
mysql_close(my);
|
||||
|
||||
|
||||
/* ssl_user2: connect with correct cipher */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
FAIL_IF(strcmp("AES256-SHA", mysql_get_ssl_cipher(my)) != 0, "expected cipher AES256-SHA");
|
||||
mysql_close(my);
|
||||
|
||||
|
||||
sprintf(query, "grant select on %s.* to 'ssluser3'@'%s' require cipher 'AES256-SHA' AND "
|
||||
" SUBJECT '/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB/CN=client'", schema, sslhost);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
/* ssluser3: connect with cipher only */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
||||
port, socketname, 0), "Error expected");
|
||||
mysql_close(my);
|
||||
|
||||
/* ssluser3 connect with cipher and certs */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, sslkey,
|
||||
sslcert,
|
||||
sslca,
|
||||
NULL,
|
||||
"AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
mysql_close(my);
|
||||
|
||||
sprintf(query, "grant select on %s.* to 'ssluser4'@'%s' require cipher 'AES256-SHA' AND "
|
||||
" ISSUER '/CN=cacert/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'", schema, sslhost);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
/* ssluser4: connect with cipher only */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
||||
port, socketname, 0), "Error expected");
|
||||
mysql_close(my);
|
||||
|
||||
/* ssluser4 connect with cipher and certs */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, sslkey,
|
||||
sslcert,
|
||||
sslca,
|
||||
NULL,
|
||||
"AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
for (i=1; i < 6; i++)
|
||||
if (!travis_test)
|
||||
{
|
||||
sprintf(query, "DROP USER IF EXISTS 'ssluser%d'@'%s'", i, sslhost);
|
||||
sprintf(query, "grant select on %s.* to 'ssluser3'@'%s' require cipher 'AES256-SHA' AND "
|
||||
" SUBJECT '/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB/CN=client'", schema, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
/* ssluser3: connect with cipher only */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
||||
port, socketname, 0), "Error expected");
|
||||
mysql_close(my);
|
||||
|
||||
/* ssluser3 connect with cipher and certs */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, sslkey,
|
||||
sslcert,
|
||||
sslca,
|
||||
NULL,
|
||||
"AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
mysql_close(my);
|
||||
|
||||
sprintf(query, "grant select on %s.* to 'ssluser4'@'%s' require cipher 'AES256-SHA' AND "
|
||||
" ISSUER '/CN=cacert/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'", schema, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
/* ssluser4: connect with cipher only */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
||||
port, socketname, 0), "Error expected");
|
||||
mysql_close(my);
|
||||
|
||||
/* ssluser4 connect with cipher and certs */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, sslkey,
|
||||
sslcert,
|
||||
sslca,
|
||||
NULL,
|
||||
"AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
mysql_close(my);
|
||||
}
|
||||
diag("drop users");
|
||||
for (i=1; i < 6; i++)
|
||||
{
|
||||
sprintf(query, "DROP USER 'ssluser%d'@'%s'", i, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
}
|
||||
mysql_close(my);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -1195,8 +1226,6 @@ static int test_mdev14101(MYSQL *my __attribute__((unused)))
|
||||
bool skip_tlsv12= !have_openssl;
|
||||
#endif
|
||||
|
||||
diag("%d %d", skip_tlsv12, have_openssl);
|
||||
|
||||
for (i=0; combinations[i].expected; i++)
|
||||
{
|
||||
MYSQL *mysql;
|
||||
@@ -1205,7 +1234,9 @@ static int test_mdev14101(MYSQL *my __attribute__((unused)))
|
||||
|
||||
if (!combinations[i].do_yassl && skip_tlsv12)
|
||||
break;
|
||||
|
||||
|
||||
diag("combination: %s", combinations[i].opt_tls_version);
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||
mysql_options(mysql, MARIADB_OPT_TLS_VERSION, combinations[i].opt_tls_version);
|
||||
|
Reference in New Issue
Block a user