Skip to content

Commit

Permalink
reslove conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Lloyd-Pottiger <[email protected]>
  • Loading branch information
Lloyd-Pottiger committed Nov 1, 2024
1 parent 54c8ee3 commit ac81c09
Showing 1 changed file with 0 additions and 86 deletions.
86 changes: 0 additions & 86 deletions server/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ type tidbTestSuite struct {
}

func createTidbTestSuite(t *testing.T) *tidbTestSuite {
<<<<<<< HEAD
=======
cfg := newTestConfig()
cfg.Port = 0
cfg.Status.ReportStatus = true
Expand All @@ -106,7 +104,6 @@ func parseDuration(lease string) (time.Duration, error) {
}

func createTidbTestSuiteWithCfg(t *testing.T, cfg *config.Config) *tidbTestSuite {
>>>>>>> 996098ec4ae (*: fix a bug that update statement uses point get and update plan with different tblInfo (#54183) (#54259))
ts := &tidbTestSuite{testServerClient: newTestServerClient()}

// setup tidbTestSuite
Expand All @@ -120,11 +117,6 @@ func createTidbTestSuiteWithCfg(t *testing.T, cfg *config.Config) *tidbTestSuite
ts.domain, err = session.BootstrapSession(ts.store)
require.NoError(t, err)
ts.tidbdrv = NewTiDBDriver(ts.store)
cfg := newTestConfig()
cfg.Port = ts.port
cfg.Status.ReportStatus = true
cfg.Status.StatusPort = ts.statusPort
cfg.Performance.TCPKeepAlive = true
RunInGoTestChan = make(chan struct{})
server, err := NewServer(cfg, ts.tidbdrv)
require.NoError(t, err)
Expand Down Expand Up @@ -3256,83 +3248,6 @@ func TestLoadData(t *testing.T) {
ts.runTestLoadDataReplace(t)
ts.runTestLoadDataReplaceNonclusteredPK(t)
}
<<<<<<< HEAD
=======

func TestAuthSocket(t *testing.T) {
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/server/MockOSUserForAuthSocket", "return(true)"))
defer func() {
mockOSUserForAuthSocketTest.Store(nil)
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/server/MockOSUserForAuthSocket"))
}()

cfg := newTestConfig()
cfg.Socket = filepath.Join(t.TempDir(), "authsock.sock")
cfg.Port = 0
cfg.Status.StatusPort = 0
ts := createTidbTestSuiteWithCfg(t, cfg)
ts.waitUntilServerCanConnect()

ts.runTests(t, nil, func(dbt *testkit.DBTestKit) {
dbt.MustExec("CREATE USER 'u1'@'%' IDENTIFIED WITH auth_socket;")
dbt.MustExec("CREATE USER 'u2'@'%' IDENTIFIED WITH auth_socket AS 'sockuser'")
dbt.MustExec("CREATE USER 'sockuser'@'%' IDENTIFIED WITH auth_socket;")
})

// network login should be denied
for _, uname := range []string{"u1", "u2", "u3"} {
mockOSUserForAuthSocketTest.Store(&uname)
db, err := sql.Open("mysql", ts.getDSN(func(config *mysql.Config) {
config.User = uname
}))
require.NoError(t, err)
_, err = db.Conn(context.TODO())
require.EqualError(t,
err,
fmt.Sprintf("Error 1045: Access denied for user '%s'@'127.0.0.1' (using password: NO)", uname),
)
require.NoError(t, db.Close())
}

socketAuthConf := func(user string) func(*mysql.Config) {
return func(config *mysql.Config) {
config.User = user
config.Net = "unix"
config.Addr = cfg.Socket
config.DBName = ""
}
}

mockOSUser := "sockuser"
mockOSUserForAuthSocketTest.Store(&mockOSUser)

// mysql username that is different with the OS user should be rejected.
db, err := sql.Open("mysql", ts.getDSN(socketAuthConf("u1")))
require.NoError(t, err)
_, err = db.Conn(context.TODO())
require.EqualError(t, err, "Error 1045: Access denied for user 'u1'@'localhost' (using password: YES)")
require.NoError(t, db.Close())

// mysql username that is the same with the OS user should be accepted.
ts.runTests(t, socketAuthConf("sockuser"), func(dbt *testkit.DBTestKit) {
rows := dbt.MustQuery("select current_user();")
ts.checkRows(t, rows, "sockuser@%")
})

// When a user is created with `IDENTIFIED WITH auth_socket AS ...`.
// It should be accepted when username or as string is the same with OS user.
ts.runTests(t, socketAuthConf("u2"), func(dbt *testkit.DBTestKit) {
rows := dbt.MustQuery("select current_user();")
ts.checkRows(t, rows, "u2@%")
})

mockOSUser = "u2"
mockOSUserForAuthSocketTest.Store(&mockOSUser)
ts.runTests(t, socketAuthConf("u2"), func(dbt *testkit.DBTestKit) {
rows := dbt.MustQuery("select current_user();")
ts.checkRows(t, rows, "u2@%")
})
}

func TestIssue53634(t *testing.T) {
if !variable.DefTiDBEnableConcurrentDDL {
Expand All @@ -3347,4 +3262,3 @@ func TestIssue53634(t *testing.T) {

ts.runTestIssue53634(t, ts, ts.domain)
}
>>>>>>> 996098ec4ae (*: fix a bug that update statement uses point get and update plan with different tblInfo (#54183) (#54259))

0 comments on commit ac81c09

Please sign in to comment.