Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions go/vt/tableacl/tableacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func (tacl *tableACL) init(configFile string, aclCB func()) error {
log.Infof("unable to read tableACL config file: %v Error: %v", configFile, err)
return err
}
if len(data) == 0 {
return errors.New("tableACL config file is empty")
}

config := &tableaclpb.Config{}
if err := config.UnmarshalVT(data); err != nil {
// try to parse tableacl as json file
Expand Down
14 changes: 14 additions & 0 deletions go/vt/tableacl/tableacl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"reflect"
"testing"

"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"

"vitess.io/vitess/go/vt/tableacl/acl"
Expand Down Expand Up @@ -74,6 +75,19 @@ func TestInitWithValidConfig(t *testing.T) {
}
}

func TestInitWithEmptyConfig(t *testing.T) {
tacl := tableACL{factory: &simpleacl.Factory{}}
f, err := os.CreateTemp("", "tableacl")
require.NoError(t, err)

defer os.Remove(f.Name())
err = f.Close()
require.NoError(t, err)

err = tacl.init(f.Name(), func() {})
require.Error(t, err)
}

func TestInitFromProto(t *testing.T) {
tacl := tableACL{factory: &simpleacl.Factory{}}
readerACL := tacl.Authorized("my_test_table", READER)
Expand Down
Loading