Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
imtbkcat committed Dec 4, 2019
1 parent 84d6033 commit c8c448e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions executor/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,28 @@ func (s *testSuite3) TestRole(c *C) {
tk.MustExec("SET ROLE NONE")
}

func (s *testSuite3) TestRoleAdmin(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("CREATE USER 'testRoleAdmin';")
tk.MustExec("CREATE ROLE 'targetRole';")
tk.MustExec("GRANT SUPER ON *.* TO `testRoleAdmin`;")

// Create a new session.
se, err := session.CreateSession4Test(s.store)
c.Check(err, IsNil)
defer se.Close()
c.Assert(se.Auth(&auth.UserIdentity{Username: "testRoleAdmin", Hostname: "localhost"}, nil, nil), IsTrue)

ctx := context.Background()
_, err = se.Execute(ctx, "GRANT `targetRole` TO `testRoleAdmin`;")
c.Assert(err, IsNil)
_, err = se.Execute(ctx, "REVOKE `targetRole` FROM `testRoleAdmin`;")
c.Assert(err, IsNil)

tk.MustExec("DROP USER 'testRoleAdmin';")
tk.MustExec("DROP ROLE 'targetRole';")
}

func (s *testSuite3) TestDefaultRole(c *C) {
tk := testkit.NewTestKit(c, s.store)

Expand Down

0 comments on commit c8c448e

Please sign in to comment.