fix(bolt): test passes with uint64 IDs
parent
3ebc6548e3
commit
6ceb351759
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
15
bolt/user.go
15
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))
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue