Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix queryservice integration tests related to tableacl #937

Merged
merged 1 commit into from
Jul 29, 2015
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
2 changes: 1 addition & 1 deletion go/vt/tableacl/tableacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func Authorized(table string, role Role) acl.ACL {
start = mid + 1
}
}
return acl.AcceptAllACL{}
return acl.DenyAllACL{}
}

// GetCurrentConfig returns a copy of current tableacl configuration.
Expand Down
8 changes: 4 additions & 4 deletions go/vt/tableacl/tableacl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func TestInitWithValidConfig(t *testing.T) {
func TestInitFromProto(t *testing.T) {
setUpTableACL(&simpleacl.Factory{})
readerACL := Authorized("my_test_table", READER)
if !reflect.DeepEqual(readerACL, acl.AcceptAllACL{}) {
t.Fatalf("tableacl has not been initialized, got: %v, want: %v", readerACL, acl.AcceptAllACL{})
if !reflect.DeepEqual(readerACL, acl.DenyAllACL{}) {
t.Fatalf("tableacl has not been initialized, got: %v, want: %v", readerACL, acl.DenyAllACL{})
}
config := &tableaclpb.Config{
TableGroups: []*tableaclpb.TableGroupSpec{{
Expand All @@ -67,8 +67,8 @@ func TestInitFromProto(t *testing.T) {
}

readerACL = Authorized("unknown_table", READER)
if !reflect.DeepEqual(acl.AcceptAllACL{}, readerACL) {
t.Fatalf("there is no config for unknown_table, should grand all permissions")
if !reflect.DeepEqual(acl.DenyAllACL{}, readerACL) {
t.Fatalf("there is no config for unknown_table, should deny by default")
}

readerACL = Authorized("test_table", READER)
Expand Down
4 changes: 2 additions & 2 deletions go/vt/tabletserver/query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ func (qre *QueryExecutor) checkPermissions() error {
qre.qe.tableaclPseudoDenied.Add(tableACLStatsKey, 1)
return nil
}
errStr := fmt.Sprintf("table acl error: %q cannot run %v on table %q", username, qre.plan.PlanId, qre.plan.TableName)
// raise error if in strictTableAcl mode, else just log an error.
if qre.qe.strictTableAcl {
errStr := fmt.Sprintf("table acl error: %q cannot run %v on table %q", username, qre.plan.PlanId, qre.plan.TableName)
qre.qe.tableaclDenied.Add(tableACLStatsKey, 1)
qre.qe.accessCheckerLogger.Errorf("%s", errStr)
return NewTabletError(ErrFail, "%s", errStr)
}
qre.qe.accessCheckerLogger.Errorf("%s", errStr)
return nil
}
qre.qe.tableaclAllowed.Add(tableACLStatsKey, 1)
Expand Down
49 changes: 49 additions & 0 deletions test/test_data/table_acl_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
{
"table_groups": [
{
"name": "mysql",
"table_names_or_prefixes": [""],
"readers": ["youtube-dev-dedicated"],
"writers": ["youtube-dev-dedicated"],
"admins": ["youtube-dev-dedicated"]
},
{
"name": "vtocc_cached",
"table_names_or_prefixes": ["vtocc_nocache", "vtocc_cached%"],
"readers": ["youtube-dev-dedicated"],
"writers": ["youtube-dev-dedicated"],
"admins": ["youtube-dev-dedicated"]
},
{
"name": "vtocc_renamed",
"table_names_or_prefixes": ["vtocc_renamed%"],
"readers": ["youtube-dev-dedicated"],
"writers": ["youtube-dev-dedicated"],
"admins": ["youtube-dev-dedicated"]
},
{
"name": "vtocc_part",
"table_names_or_prefixes": ["vtocc_part%"],
"readers": ["youtube-dev-dedicated"],
"writers": ["youtube-dev-dedicated"],
"admins": ["youtube-dev-dedicated"]
},
{
"name": "vtocc",
"table_names_or_prefixes": ["vtocc_a", "vtocc_b", "vtocc_c", "dual", "vtocc_d", "vtocc_temp", "vtocc_e", "vtocc_f", "vtocc_strings", "vtocc_fracts", "vtocc_ints", "vtocc_misc", "vtocc_big", "vtocc_view"],
"readers": ["youtube-dev-dedicated"],
"writers": ["youtube-dev-dedicated"],
"admins": ["youtube-dev-dedicated"]
},
{
"name": "vtocc_test",
"table_names_or_prefixes": ["vtocc_test"],
"readers": ["youtube-dev-dedicated"],
"writers": ["youtube-dev-dedicated"],
"admins": ["youtube-dev-dedicated"]
},
{
"name": "vtocc_acl_unmatched",
"table_names_or_prefixes": ["vtocc_acl_unmatched"],
"readers": ["youtube-dev-dedicated"],
"writers": ["youtube-dev-dedicated"],
"admins": ["youtube-dev-dedicated"]
},
{
"name": "vtocc_acl_no_access",
"table_names_or_prefixes": ["vtocc_acl_no_access"]
Expand Down