From 20c61a76e4315a7d238f8ab3d59b16bec0c857f3 Mon Sep 17 00:00:00 2001 From: Michael Desa Date: Mon, 30 Oct 2017 12:28:57 -0400 Subject: [PATCH] Change OrganizationID to Organization in Roles Fix formatting of proto file --- bolt/internal/internal.go | 14 +-- bolt/internal/internal.pb.go | 160 +++++++++++++++++--------------- bolt/internal/internal.proto | 6 +- bolt/organization_users.go | 18 ++-- bolt/organization_users_test.go | 150 +++++++++++++++--------------- chronograf.go | 8 +- 6 files changed, 185 insertions(+), 171 deletions(-) diff --git a/bolt/internal/internal.go b/bolt/internal/internal.go index 4c639f149..c69177fbf 100644 --- a/bolt/internal/internal.go +++ b/bolt/internal/internal.go @@ -420,8 +420,8 @@ func MarshalUser(u *chronograf.User) ([]byte, error) { roles := make([]*Role, len(u.Roles)) for i, role := range u.Roles { roles[i] = &Role{ - OrganizationID: role.OrganizationID, - Name: role.Name, + Organization: role.Organization, + Name: role.Name, } } return MarshalUserPB(&User{ @@ -449,8 +449,8 @@ func UnmarshalUser(data []byte, u *chronograf.User) error { roles := make([]chronograf.Role, len(pb.Roles)) for i, role := range pb.Roles { roles[i] = chronograf.Role{ - OrganizationID: role.OrganizationID, - Name: role.Name, + Organization: role.Organization, + Name: role.Name, } } u.ID = pb.ID @@ -474,8 +474,8 @@ func UnmarshalUserPB(data []byte, u *User) error { // MarshalOrganization encodes a organization to binary protobuf format. func MarshalRole(r *chronograf.Role) ([]byte, error) { return MarshalRolePB(&Role{ - OrganizationID: r.OrganizationID, - Name: r.Name, + Organization: r.Organization, + Name: r.Name, }) } @@ -490,7 +490,7 @@ func UnmarshalRole(data []byte, r *chronograf.Role) error { if err := UnmarshalRolePB(data, &pb); err != nil { return err } - r.OrganizationID = pb.OrganizationID + r.Organization = pb.Organization r.Name = pb.Name return nil diff --git a/bolt/internal/internal.pb.go b/bolt/internal/internal.pb.go index 17dc8c64d..6e9625db1 100644 --- a/bolt/internal/internal.pb.go +++ b/bolt/internal/internal.pb.go @@ -325,8 +325,8 @@ func (m *User) GetRoles() []*Role { } type Role struct { - OrganizationID string `protobuf:"bytes,1,opt,name=OrganizationID,proto3" json:"OrganizationID,omitempty"` - Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` + Organization string `protobuf:"bytes,1,opt,name=Organization,proto3" json:"Organization,omitempty"` + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` } func (m *Role) Reset() { *m = Role{} } @@ -334,6 +334,20 @@ func (m *Role) String() string { return proto.CompactTextString(m) } func (*Role) ProtoMessage() {} func (*Role) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{14} } +func (m *Role) GetOrganization() string { + if m != nil { + return m.Organization + } + return "" +} + +func (m *Role) GetName() string { + if m != nil { + return m.Name + } + return "" +} + type Organization struct { ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` @@ -366,75 +380,75 @@ func init() { func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) } var fileDescriptorInternal = []byte{ - // 1111 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x8f, 0xdb, 0x44, - 0x14, 0x96, 0x63, 0x3b, 0x89, 0x5f, 0xb6, 0x0b, 0x1a, 0x55, 0xd4, 0x94, 0x4b, 0xb0, 0x00, 0x05, - 0x89, 0x2e, 0xa8, 0x15, 0x12, 0xe2, 0x96, 0xdd, 0xa0, 0x6a, 0xd9, 0x6d, 0xbb, 0x4c, 0x76, 0x97, - 0x13, 0xaa, 0x26, 0xce, 0x4b, 0x62, 0xd5, 0x89, 0xcd, 0xd8, 0xde, 0x8d, 0x39, 0xf3, 0x8f, 0x70, - 0xe5, 0x88, 0xb8, 0x23, 0x71, 0x42, 0x3d, 0xf2, 0x17, 0xa1, 0x37, 0x33, 0x76, 0x9c, 0x26, 0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0x83, 0xe0, 0x07, - 0xf0, 0x86, 0x31, 0xca, 0x9c, 0x17, 0xf1, 0xae, 0x36, 0x33, 0x70, 0xbe, 0x1d, 0xbf, 0x78, 0x5e, - 0x2d, 0x38, 0x9d, 0x37, 0x6b, 0x69, 0xbf, 0xb1, 0x96, 0x67, 0x22, 0x15, 0xa7, 0x23, 0xc5, 0x33, - 0x9b, 0x1b, 0x14, 0xfc, 0x6c, 0x81, 0x43, 0xfb, 0xdf, 0x08, 0xed, 0xbc, 0x4d, 0x3b, 0x2e, 0x64, - 0x72, 0x13, 0x4d, 0x51, 0x56, 0xda, 0x51, 0x61, 0x55, 0x74, 0xb8, 0xc0, 0xfa, 0x67, 0xcf, 0x20, - 0x9a, 0x35, 0x4f, 0xe2, 0x9a, 0xcb, 0x8d, 0x59, 0x93, 0x99, 0x6b, 0x67, 0x70, 0x0c, 0x0e, 0x1d, - 0xd8, 0x27, 0x70, 0xd8, 0x5c, 0xa6, 0xba, 0xd8, 0x37, 0xac, 0xfb, 0xb2, 0x0b, 0x1e, 0x6f, 0x2f, - 0xe7, 0x5d, 0x2a, 0x9a, 0xb4, 0xd5, 0x8f, 0xef, 0x93, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc3, - 0xf4, 0xb2, 0x6a, 0x0a, 0x0b, 0x00, 0x00, + // 1109 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x6f, 0xe3, 0xc4, + 0x17, 0x97, 0x63, 0x3b, 0x89, 0x5f, 0xba, 0xfd, 0x7e, 0x35, 0x5a, 0xb1, 0x66, 0xb9, 0x04, 0x0b, + 0xa4, 0x20, 0xb1, 0x05, 0x75, 0x85, 0x84, 0x38, 0x20, 0xa5, 0x0d, 0x5a, 0x95, 0x76, 0x77, 0xcb, + 0xa4, 0x2d, 0x27, 0xb4, 0x9a, 0x38, 0x2f, 0x89, 0xb5, 0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b9, 0x41, 0xc1, 0x53, 0xf3, 0x39, 0x45, + 0xbf, 0x4e, 0x53, 0x94, 0x86, 0xaa, 0x1a, 0xa8, 0x37, 0x93, 0x3b, 0xd4, 0x2a, 0x6b, 0x73, 0x0d, + 0x82, 0xef, 0xc0, 0x1b, 0xc6, 0x28, 0x73, 0x5e, 0xc4, 0xbb, 0xda, 0xcc, 0xc0, 0xf9, 0x7a, 0xfc, + 0xf2, 0x45, 0x45, 0x70, 0x3a, 0x6f, 0x68, 0x69, 0xff, 0x8d, 0x96, 0xe7, 0x22, 0x15, 0x67, 0x23, + 0xb5, 0x67, 0x36, 0x37, 0x28, 0xf8, 0xd1, 0x02, 0x87, 0xf8, 0xdf, 0x08, 0xed, 0xbc, 0x4d, 0x3b, + 0x2e, 0x65, 0x72, 0x1b, 0x4d, 0x51, 0x56, 0xda, 0x51, 0x61, 0x55, 0x74, 0xb8, 0xc0, 0xfa, 0x67, + 0xcf, 0x20, 0x9a, 0x35, 0x4f, 0xe2, 0x7a, 0x97, 0x1b, 0xb3, 0x26, 0x33, 0xd7, 0xce, 0xe0, 0x4b, + 0x70, 0xe8, 0xb0, 0x43, 0x30, 0x6b, 0x97, 0x60, 0xfb, 0x32, 0x0b, 0x8e, 0xb7, 0xbf, 0xbb, 0x4f, + 0x35, 0x93, 0xb6, 0xfa, 0xe9, 0x7d, 0xfa, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0c, 0xe0, 0x82, + 0xca, 0x06, 0x0b, 0x00, 0x00, } diff --git a/bolt/internal/internal.proto b/bolt/internal/internal.proto index ec760640c..f4c56de5f 100644 --- a/bolt/internal/internal.proto +++ b/bolt/internal/internal.proto @@ -87,7 +87,7 @@ message Layout { string Measurement = 3; // Measurement is the descriptive name of the time series data. repeated Cell Cells = 4; // Cells are the individual visualization elements. bool Autoflow = 5; // Autoflow indicates whether the frontend should layout the cells automatically. - string Organization = 7; // Organization is the organization ID that resource belongs to + string Organization = 6; // Organization is the organization ID that resource belongs to } message Cell { @@ -136,8 +136,8 @@ message User { } message Role { - string OrganizationID = 1; // OrganizationID is the ID of the organization that this user has a role in - string Name = 2; // Name is the name of the role of this user in the respective organization + string Organization = 1; // Organization is the ID of the organization that this user has a role in + string Name = 2; // Name is the name of the role of this user in the respective organization } message Organization { diff --git a/bolt/organization_users.go b/bolt/organization_users.go index 96e313563..7c2ab9379 100644 --- a/bolt/organization_users.go +++ b/bolt/organization_users.go @@ -33,17 +33,17 @@ func validOrganization(ctx context.Context) (string, error) { return orgID, nil } -// validOrganizationRoles ensures that each User Role has both an associated OrganizationID and a Name +// validOrganizationRoles ensures that each User Role has both an associated Organization and a Name func validOrganizationRoles(orgID string, u *chronograf.User) error { if u == nil || u.Roles == nil { return nil } for _, r := range u.Roles { - if r.OrganizationID == "" { - return fmt.Errorf("user role must have an OrganizationID") + if r.Organization == "" { + return fmt.Errorf("user role must have an Organization") } - if r.OrganizationID != orgID { - return fmt.Errorf("organizationID %s does not match %s", r.OrganizationID, orgID) + if r.Organization != orgID { + return fmt.Errorf("organizationID %s does not match %s", r.Organization, orgID) } if r.Name == "" { return fmt.Errorf("user role must have a Name") @@ -66,7 +66,7 @@ func (s *OrganizationUsersStore) Get(ctx context.Context, q chronograf.UserQuery // filter Roles that are not scoped to this Organization roles := usr.Roles[:0] for _, r := range usr.Roles { - if r.OrganizationID == orgID { + if r.Organization == orgID { roles = append(roles, r) } } @@ -120,7 +120,7 @@ func (s *OrganizationUsersStore) Delete(ctx context.Context, usr *chronograf.Use // delete Roles that are not scoped to this Organization roles := u.Roles[:0] for _, r := range u.Roles { - if r.OrganizationID != orgID { + if r.Organization != orgID { roles = append(roles, r) } } @@ -144,7 +144,7 @@ func (s *OrganizationUsersStore) Update(ctx context.Context, usr *chronograf.Use // filter Roles that are not scoped to this Organization roles := u.Roles[:0] for _, r := range u.Roles { - if r.OrganizationID != orgID { + if r.Organization != orgID { roles = append(roles, r) } } @@ -172,7 +172,7 @@ func (s *OrganizationUsersStore) All(ctx context.Context) ([]chronograf.User, er for _, usr := range usrs { roles := usr.Roles[:0] for _, r := range usr.Roles { - if r.OrganizationID == orgID { + if r.Organization == orgID { roles = append(roles, r) } } diff --git a/bolt/organization_users_test.go b/bolt/organization_users_test.go index 75e5a9023..97cf5e237 100644 --- a/bolt/organization_users_test.go +++ b/bolt/organization_users_test.go @@ -31,8 +31,8 @@ func TestOrganizationUsersStore_Get(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "The HillBilliettas", + Organization: "1338", + Name: "The HillBilliettas", }, }, }, @@ -51,8 +51,8 @@ func TestOrganizationUsersStore_Get(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "The HillBilliettas", + Organization: "1338", + Name: "The HillBilliettas", }, }, }, @@ -70,12 +70,12 @@ func TestOrganizationUsersStore_Get(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "The HillBilliettas", + Organization: "1338", + Name: "The HillBilliettas", }, { - OrganizationID: "1336", - Name: "The BillHilliettos", + Organization: "1336", + Name: "The BillHilliettos", }, }, }, @@ -87,8 +87,8 @@ func TestOrganizationUsersStore_Get(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1336", - Name: "The BillHilliettos", + Organization: "1336", + Name: "The BillHilliettos", }, }, }, @@ -148,8 +148,8 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1336", - Name: "editor", + Organization: "1336", + Name: "editor", }, }, }, @@ -166,8 +166,8 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1336", - Name: "editor", + Organization: "1336", + Name: "editor", }, }, }, @@ -179,8 +179,8 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1336", - Name: "editor", + Organization: "1336", + Name: "editor", }, }, }, @@ -221,8 +221,8 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1336", - Name: "admin", + Organization: "1336", + Name: "admin", }, }, }, @@ -233,8 +233,8 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", - Name: "editor", + Organization: "1337", + Name: "editor", }, }, }, @@ -246,18 +246,18 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", - Name: "editor", + Organization: "1337", + Name: "editor", }, { - OrganizationID: "1336", - Name: "admin", + Organization: "1336", + Name: "admin", }, }, }, }, { - name: "Has invalid Role: missing OrganizationID", + name: "Has invalid Role: missing Organization", args: args{ ctx: context.Background(), u: &chronograf.User{ @@ -283,7 +283,7 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", + Organization: "1337", }, }, }, @@ -304,7 +304,7 @@ func TestOrganizationUsersStore_Add(t *testing.T) { wantErr: true, }, { - name: "Has invalid OrganizationID", + name: "Has invalid Organization", args: args{ ctx: context.Background(), u: &chronograf.User{ @@ -322,8 +322,8 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", - Name: "editor", + Organization: "1337", + Name: "editor", }, }, }, @@ -332,7 +332,7 @@ func TestOrganizationUsersStore_Add(t *testing.T) { wantErr: true, }, { - name: "OrganizationID does not match orgID", + name: "Organization does not match orgID", args: args{ ctx: context.Background(), u: &chronograf.User{ @@ -341,8 +341,8 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "editor", + Organization: "1338", + Name: "editor", }, }, }, @@ -353,8 +353,8 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", - Name: "editor", + Organization: "1337", + Name: "editor", }, }, }, @@ -372,7 +372,7 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", + Organization: "1337", }, }, }, @@ -383,8 +383,8 @@ func TestOrganizationUsersStore_Add(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", - Name: "editor", + Organization: "1337", + Name: "editor", }, }, }, @@ -460,12 +460,12 @@ func TestOrganizationUsersStore_Delete(t *testing.T) { Name: "noone", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "The BillHilliettas", + Organization: "1338", + Name: "The BillHilliettas", }, { - OrganizationID: "1336", - Name: "The HillBilliettas", + Organization: "1336", + Name: "The HillBilliettas", }, }, }, @@ -476,8 +476,8 @@ func TestOrganizationUsersStore_Delete(t *testing.T) { Name: "noone", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "The BillHilliettas", + Organization: "1338", + Name: "The BillHilliettas", }, }, }, @@ -547,19 +547,19 @@ func TestOrganizationUsersStore_Update(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "viewer", + Organization: "1338", + Name: "viewer", }, { - OrganizationID: "1337", - Name: "viewer", + Organization: "1337", + Name: "viewer", }, }, }, roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "editor", + Organization: "1338", + Name: "editor", }, }, orgID: "1338", @@ -570,8 +570,8 @@ func TestOrganizationUsersStore_Update(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "editor", + Organization: "1338", + Name: "editor", }, }, }, @@ -581,12 +581,12 @@ func TestOrganizationUsersStore_Update(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", - Name: "viewer", + Organization: "1337", + Name: "viewer", }, { - OrganizationID: "1338", - Name: "editor", + Organization: "1338", + Name: "editor", }, }, }, @@ -662,12 +662,12 @@ func TestOrganizationUsersStore_All(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "viewer", + Organization: "1338", + Name: "viewer", }, { - OrganizationID: "1336", - Name: "viewer", + Organization: "1336", + Name: "viewer", }, }, }, @@ -677,8 +677,8 @@ func TestOrganizationUsersStore_All(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", - Name: "editor", + Organization: "1337", + Name: "editor", }, }, }, @@ -688,8 +688,8 @@ func TestOrganizationUsersStore_All(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "editor", + Organization: "1338", + Name: "editor", }, }, }, @@ -707,8 +707,8 @@ func TestOrganizationUsersStore_All(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "viewer", + Organization: "1338", + Name: "viewer", }, }, }, @@ -718,8 +718,8 @@ func TestOrganizationUsersStore_All(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "editor", + Organization: "1338", + Name: "editor", }, }, }, @@ -731,12 +731,12 @@ func TestOrganizationUsersStore_All(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "viewer", + Organization: "1338", + Name: "viewer", }, { - OrganizationID: "1336", - Name: "viewer", + Organization: "1336", + Name: "viewer", }, }, }, @@ -746,8 +746,8 @@ func TestOrganizationUsersStore_All(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1337", - Name: "editor", + Organization: "1337", + Name: "editor", }, }, }, @@ -757,8 +757,8 @@ func TestOrganizationUsersStore_All(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - OrganizationID: "1338", - Name: "editor", + Organization: "1338", + Name: "editor", }, }, }, diff --git a/chronograf.go b/chronograf.go index 2bc78ae00..c8ec2506b 100644 --- a/chronograf.go +++ b/chronograf.go @@ -112,10 +112,10 @@ type TimeSeries interface { // Role is a restricted set of permissions assigned to a set of users. type Role struct { - Name string `json:"name"` - Permissions Permissions `json:"permissions,omitempty"` - Users []User `json:"users,omitempty"` - OrganizationID string `json:"organization,string,omitempty"` + Name string `json:"name"` + Permissions Permissions `json:"permissions,omitempty"` + Users []User `json:"users,omitempty"` + Organization string `json:"organization,string,omitempty"` } // RolesStore is the Storage and retrieval of authentication information