-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PT-2247 - pt-show-grants does not CREATE USER
- Removed option print_identified_with_as_hex, because it was already implemented in the PT-2190 fix - Simplified patch - Kept CREATE USER/ALTER USER sequence and extra DELETE from mysql.user table - Added test case
- Loading branch information
1 parent
bc23d08
commit f3f4943
Showing
2 changed files
with
106 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env perl | ||
|
||
BEGIN { | ||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n" | ||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH}; | ||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib"; | ||
}; | ||
|
||
use strict; | ||
use warnings FATAL => 'all'; | ||
use English qw(-no_match_vars); | ||
use Test::More; | ||
|
||
use PerconaTest; | ||
use Sandbox; | ||
use SqlModes; | ||
use VersionParser; | ||
require "$trunk/bin/pt-show-grants"; | ||
|
||
my $dp = new DSNParser(opts=>$dsn_opts); | ||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); | ||
my $dbh = $sb->get_dbh_for('master'); | ||
|
||
if ( !$dbh ) { | ||
plan skip_all => 'Cannot connect to sandbox master'; | ||
} | ||
|
||
if ( VersionParser->new($dbh)->flavor !~ m/maria/i ) { | ||
plan skip_all => "This test requires MariaDB"; | ||
} | ||
|
||
$sb->wipe_clean($dbh); | ||
|
||
my $output; | ||
my $cnf = '/tmp/12345/my.sandbox.cnf'; | ||
|
||
diag(`/tmp/12345/use -u root -e "CREATE USER 'sally'\@'%' IDENTIFIED BY 'A005?>6LZe1'"`); | ||
|
||
ok( | ||
`/tmp/12345/use -s -u sally -p'A005?>6LZe1' -e "SELECT 1" 2>/dev/null`, | ||
'User sally can log in before tests' | ||
); | ||
|
||
$output = output( | ||
sub { pt_show_grants::main('-F', $cnf, qw(--only sally)); } | ||
); | ||
|
||
like( | ||
$output, | ||
qr/CREATE USER IF NOT EXISTS `sally`@`%`;/, | ||
'CREATE USER printed' | ||
) or diag($output); | ||
|
||
like( | ||
$output, | ||
qr/ALTER USER `sally`@`%` IDENTIFIED BY PASSWORD '\*A5C09B5E9542E3C716E3E0A711336D9ABB48D89F';/, | ||
'ALTER USER printed' | ||
) or diag($output); | ||
|
||
diag(`/tmp/12345/use -u root -e "DROP USER 'sally'\@'%'"`); | ||
open(my $pipe, '|-', '/tmp/12345/use -u root'); | ||
print $pipe $output; | ||
close($pipe); | ||
|
||
ok( | ||
`/tmp/12345/use -s -u sally -p'A005?>6LZe1' -e "SELECT 1" 2>/dev/null`, | ||
'User sally can log in' | ||
) or diag($output); | ||
|
||
diag(`/tmp/12345/use -u root -e "DROP USER 'sally'\@'%'"`); | ||
|
||
# ############################################################################# | ||
# Done. | ||
# ############################################################################# | ||
$sb->wipe_clean($dbh); | ||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); | ||
done_testing; |