-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
privilege,executor: update DBIsVisible() function for RBAC (#10261)
- Loading branch information
1 parent
e56a14b
commit 1690912
Showing
5 changed files
with
45 additions
and
13 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
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
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 |
---|---|---|
|
@@ -445,7 +445,7 @@ func (s *testPrivilegeSuite) TestCheckAuthenticate(c *C) { | |
mustExec(c, se1, "drop user '[email protected]'@'localhost'") | ||
} | ||
|
||
func (s *testPrivilegeSuite) TestUseDb(c *C) { | ||
func (s *testPrivilegeSuite) TestUseDB(c *C) { | ||
|
||
se := newSession(c, s.store, s.dbName) | ||
// high privileged user | ||
|
@@ -465,6 +465,21 @@ func (s *testPrivilegeSuite) TestUseDb(c *C) { | |
c.Assert(se.Auth(&auth.UserIdentity{Username: "usenobody", Hostname: "localhost", AuthUsername: "usenobody", AuthHostname: "%"}, nil, nil), IsTrue) | ||
_, err = se.Execute(context.Background(), "use mysql") | ||
c.Assert(err, IsNil) | ||
|
||
// test `use db` for role. | ||
c.Assert(se.Auth(&auth.UserIdentity{Username: "usesuper", Hostname: "localhost", AuthUsername: "usesuper", AuthHostname: "%"}, nil, nil), IsTrue) | ||
mustExec(c, se, `CREATE DATABASE app_db`) | ||
mustExec(c, se, `CREATE ROLE 'app_developer'`) | ||
mustExec(c, se, `GRANT ALL ON app_db.* TO 'app_developer'`) | ||
mustExec(c, se, `CREATE USER 'dev'@'localhost'`) | ||
mustExec(c, se, `GRANT 'app_developer' TO 'dev'@'localhost'`) | ||
mustExec(c, se, `SET DEFAULT ROLE 'app_developer' TO 'dev'@'localhost'`) | ||
mustExec(c, se, `FLUSH PRIVILEGES`) | ||
c.Assert(se.Auth(&auth.UserIdentity{Username: "dev", Hostname: "localhost", AuthUsername: "dev", AuthHostname: "localhost"}, nil, nil), IsTrue) | ||
_, err = se.Execute(context.Background(), "use app_db") | ||
c.Assert(err, IsNil) | ||
_, err = se.Execute(context.Background(), "use mysql") | ||
c.Assert(err, NotNil) | ||
} | ||
|
||
func (s *testPrivilegeSuite) TestSetGlobal(c *C) { | ||
|