diff --git a/plugin/auth/mysql/mysql.go b/plugin/auth/mysql/mysql.go index 6e18e7e..1c6d694 100644 --- a/plugin/auth/mysql/mysql.go +++ b/plugin/auth/mysql/mysql.go @@ -96,8 +96,16 @@ func (a *Auth) Init(config any) error { a.config.Auth.PasswordColumn, a.config.Auth.AllowColumn, a.config.Auth.Table, a.config.Auth.UserColumn) aclSql := fmt.Sprintf("select %s, %s from %s where %s=?", a.config.Acl.TopicColumn, a.config.Acl.AccessColumn, a.config.Acl.Table, a.config.Acl.UserColumn) - a.authStmt, _ = sqlxDB.Preparex(authSql) - a.aclStmt, _ = sqlxDB.Preparex(aclSql) + a.authStmt, err = sqlxDB.Preparex(authSql) + if err != nil { + a.Log.Error("Unable to create prepared statement for auth-sql", "authSql", authSql) + return err + } + a.aclStmt, err = sqlxDB.Preparex(aclSql) + if err != nil { + a.Log.Error("Unable to create prepared statement for acl-sql", "aclStmt", aclSql) + return err + } a.db = sqlxDB return nil } diff --git a/plugin/auth/mysql/mysql_test.go b/plugin/auth/mysql/mysql_test.go index 2b93c8e..fb9fe86 100644 --- a/plugin/auth/mysql/mysql_test.go +++ b/plugin/auth/mysql/mysql_test.go @@ -38,7 +38,7 @@ var ( pkc = packets.Packet{Connect: packets.ConnectParams{Password: []byte("123456")}} ) -func teardown(a *Auth, t *testing.T) { +func teardown(a *Auth) { if a.db != nil { a.Stop() } @@ -106,7 +106,7 @@ func TestOnConnectAuthenticate(t *testing.T) { t.SkipNow() } a := newAuth(t) - defer teardown(a, t) + defer teardown(a) result := a.OnConnectAuthenticate(client, pkc) require.Equal(t, true, result) } @@ -116,7 +116,7 @@ func TestOnACLCheck(t *testing.T) { t.SkipNow() } a := newAuth(t) - defer teardown(a, t) + defer teardown(a) topic := "topictest/1" topic2 := "topictest/2" result := a.OnACLCheck(client, topic, true) //publish