mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-02 02:34:19 +00:00
Fixed some tests for pt-show-grants
This commit is contained in:
@@ -2012,7 +2012,7 @@ sub main {
|
||||
my $grant = $_;
|
||||
PTDEBUG && _d($grant);
|
||||
my ( $grants, $on_what, $user ) = $grant
|
||||
=~ m/GRANT (.*?) ON (.*?) TO ('[^']*'\@'[^']*')/;
|
||||
=~ m/GRANT (.*?) ON (.*?) TO ([`'][^'`]*[`']\@[`'][^'`]*[`'])/;
|
||||
PTDEBUG && _d('grants:', $grants, 'on_what:', $on_what,
|
||||
'user:', $user);
|
||||
|
||||
|
@@ -50,6 +50,21 @@ $output = output(
|
||||
sub { pt_show_grants::main('-F', $cnf, qw(--only bob --no-header)); }
|
||||
);
|
||||
|
||||
my $expected_80 = <<'END_OUTPUT_0';
|
||||
-- Grants for 'bob'@'%'
|
||||
CREATE USER IF NOT EXISTS 'bob'@'%';
|
||||
ALTER USER 'bob'@'%' IDENTIFIED WITH 'mysql_native_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT;
|
||||
GRANT USAGE ON *.* TO `bob`@`%`;
|
||||
-- Grants for 'bob'@'192.168.1.1'
|
||||
CREATE USER IF NOT EXISTS 'bob'@'192.168.1.1';
|
||||
ALTER USER 'bob'@'192.168.1.1' IDENTIFIED WITH 'mysql_native_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT;
|
||||
GRANT USAGE ON *.* TO `bob`@`192.168.1.1`;
|
||||
-- Grants for 'bob'@'localhost'
|
||||
CREATE USER IF NOT EXISTS 'bob'@'localhost';
|
||||
ALTER USER 'bob'@'localhost' IDENTIFIED WITH 'mysql_native_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT;
|
||||
GRANT USAGE ON *.* TO `bob`@`localhost`;
|
||||
END_OUTPUT_0
|
||||
|
||||
my $expected_57 = <<'END_OUTPUT_1';
|
||||
-- Grants for 'bob'@'%'
|
||||
CREATE USER IF NOT EXISTS 'bob'@'%';
|
||||
@@ -74,7 +89,7 @@ GRANT USAGE ON *.* TO 'bob'@'192.168.1.1';
|
||||
GRANT USAGE ON *.* TO 'bob'@'localhost';
|
||||
END_OUTPUT_2
|
||||
|
||||
my $expected = $sandbox_version < '5.7' ? $expected_56 : $expected_57;
|
||||
my $expected = $sandbox_version < '5.7' ? $expected_56 : $sandbox_version < '8.0' ? $expected_57 : $expected_80;
|
||||
|
||||
is(
|
||||
$output,
|
||||
@@ -86,6 +101,13 @@ $output = output(
|
||||
sub { pt_show_grants::main('-F', $cnf, qw(--only bob@192.168.1.1 --no-header)); }
|
||||
);
|
||||
|
||||
$expected_80 = <<'END_OUTPUT_5';
|
||||
-- Grants for 'bob'@'192.168.1.1'
|
||||
CREATE USER IF NOT EXISTS 'bob'@'192.168.1.1';
|
||||
ALTER USER 'bob'@'192.168.1.1' IDENTIFIED WITH 'mysql_native_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT;
|
||||
GRANT USAGE ON *.* TO `bob`@`192.168.1.1`;
|
||||
END_OUTPUT_5
|
||||
|
||||
$expected_57 = <<'END_OUTPUT_3';
|
||||
-- Grants for 'bob'@'192.168.1.1'
|
||||
CREATE USER IF NOT EXISTS 'bob'@'192.168.1.1';
|
||||
@@ -98,7 +120,7 @@ $expected_56 = <<'END_OUTPUT_4';
|
||||
GRANT USAGE ON *.* TO 'bob'@'192.168.1.1';
|
||||
END_OUTPUT_4
|
||||
|
||||
$expected = $sandbox_version < '5.7' ? $expected_56 : $expected_57;
|
||||
$expected = $sandbox_version < '5.7' ? $expected_56 : $sandbox_version < '8.0' ? $expected_57: $expected_80;
|
||||
|
||||
is(
|
||||
$output,
|
||||
|
@@ -63,11 +63,15 @@ like(
|
||||
qr/at \d{4}/,
|
||||
'It has a timestamp',
|
||||
);
|
||||
like(
|
||||
$output,
|
||||
qr/^REVOKE ALL PRIVILEGES/m,
|
||||
"Revoke statement is correct (bug 821709)"
|
||||
);
|
||||
|
||||
SKIP: {
|
||||
skip "MySQL 8.0+ doesn't have ALL PRIVILEGES", 1 if ($sandbox_version >= '8.0');
|
||||
like(
|
||||
$output,
|
||||
qr/^REVOKE ALL PRIVILEGES/m,
|
||||
"Revoke statement is correct (bug 821709)"
|
||||
);
|
||||
}
|
||||
|
||||
$output = output(
|
||||
sub { pt_show_grants::main('-F', $cnf, qw(--no-timestamp --drop --flush --revoke --separate)); }
|
||||
@@ -79,7 +83,7 @@ unlike(
|
||||
);
|
||||
|
||||
$output = output(
|
||||
sub { pt_show_grants::main('-F', $cnf, '--ignore', 'baron,msandbox,root,root@localhost,user'); }
|
||||
sub { pt_show_grants::main('-F', $cnf, '--ignore', 'baron,msandbox,root,root@localhost,user,mysql.session@localhost,mysql.sys@localhost,sys'); }
|
||||
);
|
||||
unlike(
|
||||
$output,
|
||||
@@ -103,7 +107,7 @@ diag(`/tmp/12345/use -u root -e "GRANT SELECT(DateCreated, PckPrice, PaymentStat
|
||||
diag(`/tmp/12345/use -u root -e "GRANT SELECT(city_id), INSERT(city) ON sakila.city TO 'sally'\@'%'"`);
|
||||
$modes->restore_original_modes();
|
||||
|
||||
my $postfix = $sandbox_version < '5.7' ? '' : '-57';
|
||||
my $postfix = $sandbox_version >= '8.0' ? '-80' : $sandbox_version < '5.7' ? '' : '-57';
|
||||
|
||||
# 11
|
||||
ok(
|
||||
|
6
t/pt-show-grants/samples/column-grants-80.txt
Normal file
6
t/pt-show-grants/samples/column-grants-80.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
-- Grants for 'sally'@'%'
|
||||
CREATE USER IF NOT EXISTS 'sally'@'%';
|
||||
ALTER USER 'sally'@'%' IDENTIFIED WITH 'mysql_native_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT;
|
||||
GRANT INSERT (`city`), SELECT (`city_id`) ON `sakila`.`city` TO `sally`@`%`;
|
||||
GRANT SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` TO `sally`@`%`;
|
||||
GRANT USAGE ON *.* TO `sally`@`%`;
|
6
t/pt-show-grants/samples/column-grants-combined-80.txt
Normal file
6
t/pt-show-grants/samples/column-grants-combined-80.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
-- Grants for 'sally'@'%'
|
||||
CREATE USER IF NOT EXISTS 'sally'@'%';
|
||||
ALTER USER 'sally'@'%' IDENTIFIED WITH 'mysql_native_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT;
|
||||
GRANT INSERT (`city`), SELECT, SELECT (`city_id`) ON `sakila`.`city` TO `sally`@`%`;
|
||||
GRANT SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` TO `sally`@`%`;
|
||||
GRANT USAGE ON *.* TO `sally`@`%`;
|
7
t/pt-show-grants/samples/column-grants-separate-80.txt
Normal file
7
t/pt-show-grants/samples/column-grants-separate-80.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
-- Grants for 'sally'@'%'
|
||||
CREATE USER IF NOT EXISTS 'sally'@'%';
|
||||
ALTER USER 'sally'@'%' IDENTIFIED WITH 'mysql_native_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT;
|
||||
GRANT INSERT (`city`) ON `sakila`.`city` TO `sally`@`%`;
|
||||
GRANT SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` TO `sally`@`%`;
|
||||
GRANT SELECT (`city_id`) ON `sakila`.`city` TO `sally`@`%`;
|
||||
GRANT USAGE ON *.* TO `sally`@`%`;
|
@@ -0,0 +1,12 @@
|
||||
-- Revoke statements for 'sally'@'%'
|
||||
REVOKE INSERT (`city`) ON `sakila`.`city` FROM `sally`@`%`;
|
||||
REVOKE SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` FROM `sally`@`%`;
|
||||
REVOKE SELECT (`city_id`) ON `sakila`.`city` FROM `sally`@`%`;
|
||||
REVOKE USAGE ON *.* FROM `sally`@`%`;
|
||||
-- Grants for 'sally'@'%'
|
||||
CREATE USER IF NOT EXISTS 'sally'@'%';
|
||||
ALTER USER 'sally'@'%' IDENTIFIED WITH 'mysql_native_password' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT;
|
||||
GRANT INSERT (`city`) ON `sakila`.`city` TO `sally`@`%`;
|
||||
GRANT SELECT (`DateCreated`, `PaymentStat`, `PckPrice`, `SANumber`) ON `test`.`t` TO `sally`@`%`;
|
||||
GRANT SELECT (`city_id`) ON `sakila`.`city` TO `sally`@`%`;
|
||||
GRANT USAGE ON *.* TO `sally`@`%`;
|
Reference in New Issue
Block a user