Skip to content

Commit e0c7fc1

Browse files
committed
Test that invalid ssl option combinations are checked
1 parent 8bec278 commit e0c7fc1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

t/92ssl_optional.t

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ my $have_ssl = eval { $dbh->selectrow_hashref("SHOW VARIABLES WHERE Variable_nam
1313
$dbh->disconnect();
1414
plan skip_all => 'Server supports SSL connections, cannot test fallback to plain text' if $have_ssl and $have_ssl->{Value} eq 'YES';
1515

16-
plan tests => 2;
16+
plan tests => 3;
1717

1818
$dbh = DBI->connect($test_dsn, $test_user, $test_password, { PrintError => 0, RaiseError => 0, mariadb_ssl => 1, mariadb_ssl_optional => 1 });
1919
ok(defined $dbh, 'DBD::MariaDB supports mariadb_ssl_optional=1 and connect via plain text protocol when SSL is not supported by server') or diag('Error code: ' . ($DBI::err || 'none') . "\n" . 'Error message: ' . ($DBI::errstr || 'unknown'));
2020

2121
$dbh = DBI->connect($test_dsn, $test_user, $test_password, { PrintError => 0, RaiseError => 0, mariadb_ssl => 1, mariadb_ssl_optional => 1, mariadb_ssl_ca_file => "" });
2222
ok(defined $dbh, 'DBD::MariaDB supports mariadb_ssl_optional=1 and connect via plain text protocol when SSL is not supported by server even with mariadb_ssl_ca_file') or diag('Error code: ' . ($DBI::err || 'none') . "\n" . 'Error message: ' . ($DBI::errstr || 'unknown'));
23+
24+
$dbh = DBI->connect($test_dsn, $test_user, $test_password, { PrintError => 0, RaiseError => 0, mariadb_ssl => 0, mariadb_ssl_verify_server_cert => 1 });
25+
ok(! defined $dbh && $DBI::errstr =~ /but SSL encryption was not enabled/,
26+
'DBD::MariaDB cannot use other ssl options if ssl is not enabled'
27+
) or diag(defined $dbh ? 'Connection succeeded' : "Unexpected error: $DBI::errstr");

0 commit comments

Comments
 (0)