diff --git a/bolt/dashboard.go b/bolt/dashboard.go index 8dd88e8545..67f22b2b30 100644 --- a/bolt/dashboard.go +++ b/bolt/dashboard.go @@ -225,7 +225,7 @@ func (c *Client) ReplaceDashboardCells(ctx context.Context, id platform.ID, cs [ return fmt.Errorf("cannot replace cells that were not already present") } - if cl.ViewID == cell.ViewID { + if cl.ViewID != cell.ViewID { return fmt.Errorf("cannot update view id in replace") } } diff --git a/bolt/source.go b/bolt/source.go index 3c3c8417cf..8b056e8b7a 100644 --- a/bolt/source.go +++ b/bolt/source.go @@ -164,6 +164,7 @@ func (c *Client) CreateSource(ctx context.Context, s *platform.Source) error { return c.db.Update(func(tx *bolt.Tx) error { s.ID = c.IDGenerator.ID() // fixme > what if s does not contain a valid OrganizationID ? or contains an empty, thus invaid, OrganizationID ? + // throw an error? generate one? if !s.OrganizationID.Valid() { s.OrganizationID = c.IDGenerator.ID() } diff --git a/bolt/user.go b/bolt/user.go index d00e137835..0496d742cd 100644 --- a/bolt/user.go +++ b/bolt/user.go @@ -351,7 +351,12 @@ func (c *Client) setPassword(ctx context.Context, tx *bolt.Tx, name string, pass return err } - return tx.Bucket(userpasswordBucket).Put(u.ID, hash) + encodedID, err := u.ID.Encode() + if err != nil { + return err + } + + return tx.Bucket(userpasswordBucket).Put(encodedID, hash) } // ComparePassword compares a provided password with the stored password hash. @@ -365,7 +370,13 @@ func (c *Client) comparePassword(ctx context.Context, tx *bolt.Tx, name string, if err != nil { return err } - hash := tx.Bucket(userpasswordBucket).Get(u.ID) + + encodedID, err := u.ID.Encode() + if err != nil { + return err + } + + hash := tx.Bucket(userpasswordBucket).Get(encodedID) return bcrypt.CompareHashAndPassword(hash, []byte(password)) } diff --git a/bolt/user_test.go b/bolt/user_test.go index 0822d395f5..2e3e63e0b0 100644 --- a/bolt/user_test.go +++ b/bolt/user_test.go @@ -79,7 +79,7 @@ func TestBasicAuth(t *testing.T) { users: []*platform.User{ { Name: "user1", - ID: platform.ID("0"), + ID: platformtesting.MustIDFromString("aaaaaaaaaaaaaaaa"), }, }, }, @@ -96,7 +96,7 @@ func TestBasicAuth(t *testing.T) { users: []*platform.User{ { Name: "user1", - ID: platform.ID("0"), + ID: platformtesting.MustIDFromString("aaaaaaaaaaaaaaaa"), }, }, }, @@ -184,7 +184,7 @@ func TestBasicAuth_CompareAndSet(t *testing.T) { users: []*platform.User{ { Name: "user1", - ID: platform.ID("0"), + ID: platformtesting.MustIDFromString("aaaaaaaaaaaaaaaa"), }, }, }, diff --git a/testing/dashboards.go b/testing/dashboards.go index db673c953c..8c53ff088b 100644 --- a/testing/dashboards.go +++ b/testing/dashboards.go @@ -688,7 +688,8 @@ func RemoveDashboardCell( ViewID: MustIDFromString(dashTwoID), }, { - ID: MustIDFromString(dashOneID), + ID: MustIDFromString(dashOneID), + ViewID: MustIDFromString(dashOneID), }, }, }, @@ -712,7 +713,8 @@ func RemoveDashboardCell( Name: "dashboard1", Cells: []*platform.Cell{ { - ID: MustIDFromString(dashOneID), + ID: MustIDFromString(dashOneID), + ViewID: MustIDFromString(dashOneID), }, }, }, @@ -787,10 +789,12 @@ func UpdateDashboardCell( Name: "dashboard1", Cells: []*platform.Cell{ { - ID: MustIDFromString(dashTwoID), + ID: MustIDFromString(dashTwoID), + ViewID: MustIDFromString(dashTwoID), }, { - ID: MustIDFromString(dashOneID), + ID: MustIDFromString(dashOneID), + ViewID: MustIDFromString(dashOneID), }, }, }, @@ -808,11 +812,13 @@ func UpdateDashboardCell( Name: "dashboard1", Cells: []*platform.Cell{ { - ID: MustIDFromString(dashTwoID), - X: 10, + ID: MustIDFromString(dashTwoID), + ViewID: MustIDFromString(dashTwoID), + X: 10, }, { - ID: MustIDFromString(dashOneID), + ID: MustIDFromString(dashOneID), + ViewID: MustIDFromString(dashOneID), }, }, },