Skip to content

Commit

Permalink
Fixed test case for expired password
Browse files Browse the repository at this point in the history
Added test case for ODBC-138
  • Loading branch information
9EOR9 committed Apr 20, 2018
1 parent 60e5dee commit 3f43953
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
8 changes: 1 addition & 7 deletions unittest/libmariadb/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,21 +1340,15 @@ static int test_expired_pw(MYSQL *my)
my_test_connect(mysql, hostname, "foo", "foo", schema,
port, socketname, 0);

rc= mysql_query(mysql, "CREATE TEMPORARY TABLE t1 (a int)");

diag("error: %d %s", mysql_errno(mysql), mysql_error(mysql));
FAIL_IF(mysql_errno(mysql) != ER_MUST_CHANGE_PASSWORD, "Error 1820 expected");

rc= mysql_query(mysql, "SET PASSWORD=PASSWORD('foobar')");
check_mysql_rc(rc, mysql);
rc= mysql_query(mysql, "CREATE TEMPORARY TABLE t1 (a int)");
check_mysql_rc(rc, mysql);
mysql_close(mysql);

sprintf(query, "DROP USER 'foo'@'%s'", this_host);
rc= mysql_query(my, query);
check_mysql_rc(rc, my);

mysql_close(mysql);
return OK;
}

Expand Down
40 changes: 40 additions & 0 deletions unittest/libmariadb/ps_bugs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4651,8 +4651,48 @@ static int test_compress(MYSQL *mysql)
return OK;
}

static int test_codbc138(MYSQL *mysql)
{
int rc;
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
MYSQL_BIND bind[1];
MYSQL_TIME tm;

rc= mysql_stmt_prepare(stmt, SL("SELECT DATE_ADD('2018-02-01', INTERVAL -188 DAY)"));
check_stmt_rc(rc, stmt);

rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);

memset(bind, 0, sizeof(MYSQL_BIND));
bind[0].buffer_type= MYSQL_TYPE_DATETIME;
bind[0].buffer= &tm;
bind[0].buffer_length= sizeof(MYSQL_TIME);

rc= mysql_stmt_bind_result(stmt, bind);
check_stmt_rc(rc, stmt);

rc= mysql_stmt_fetch(stmt);
check_stmt_rc(rc, stmt);

if (tm.year != 2017 && tm.day != 28 && tm.month != 7)
{
diag("Error: Expected 2017-07-02");
return FAIL;
}
if (tm.minute | tm.second || tm.second_part)
{
diag("Error: minute, second or second_part is not zero");
return FAIL;
}

mysql_stmt_close(stmt);
return OK;
}

struct my_tests_st my_tests[] = {
{"test_compress", test_compress, TEST_CONNECTION_NEW, CLIENT_COMPRESS, NULL, NULL},
{"test_codbc138", test_codbc138, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc208", test_conc208, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_mdev14165", test_mdev14165, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc208", test_conc208, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
Expand Down

0 comments on commit 3f43953

Please sign in to comment.