Skip to content

Commit 1a616c1

Browse files
authored
Check for ALL PRIVILEGES with boundaries. Improve test case for MySQL 8 (petoju#155)
Co-authored-by: Victor Cabezas <[email protected]>
1 parent e094f30 commit 1a616c1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mysql/resource_grant.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ func normalizeColumnOrder(perm string) string {
10781078
return fmt.Sprintf("%s(%s)", precursor, partsTogether)
10791079
}
10801080

1081-
var kReAllPrivileges = regexp.MustCompile(`ALL ?(PRIVILEGES)?`)
1081+
var kReAllPrivileges = regexp.MustCompile(`\bALL ?(PRIVILEGES)?\b`)
10821082

10831083
func normalizePerms(perms []string) []string {
10841084
ret := []string{}

mysql/resource_grant_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ func TestAccGrantComplexMySQL8(t *testing.T) {
317317
Check: resource.ComposeTestCheckFunc(
318318
testAccPrivilege("mysql_grant.test", "SHOW DATABASES", true, false),
319319
testAccPrivilege("mysql_grant.test", "CONNECTION_ADMIN", true, false),
320+
testAccPrivilege("mysql_grant.test", "FIREWALL_EXEMPT", true, false),
320321
testAccPrivilege("mysql_grant.test", "SELECT", true, false),
322+
testAccPrivilege("mysql_grant.test", "ALL PRIVILEGES", false, false),
321323
),
322324
},
323325
},
@@ -616,7 +618,7 @@ resource "mysql_grant" "test" {
616618
host = "${mysql_user.test.host}"
617619
table = "*"
618620
database = "*"
619-
privileges = ["SHOW DATABASES", "CONNECTION_ADMIN", "SELECT"]
621+
privileges = ["SHOW DATABASES", "CONNECTION_ADMIN", "SELECT", "FIREWALL_EXEMPT"]
620622
}
621623
622624
`, dbName, dbName)

0 commit comments

Comments
 (0)