fleet/server/datastore/datastore_password_reset.go

34 lines
699 B
Go
Raw Normal View History

package datastore
import (
"testing"
"time"
2021-06-26 04:46:51 +00:00
"github.com/fleetdm/fleet/v4/server/fleet"
"github.com/stretchr/testify/assert"
)
func testPasswordResetRequests(t *testing.T, db fleet.Datastore) {
createTestUsers(t, db)
now := time.Now().UTC()
tomorrow := now.Add(time.Hour * 24)
var passwordResetTests = []struct {
userID uint
expires time.Time
token string
}{
{userID: 1, expires: tomorrow, token: "abcd"},
}
for _, tt := range passwordResetTests {
r := &fleet.PasswordResetRequest{
UserID: tt.userID,
ExpiresAt: tt.expires,
Token: tt.token,
}
req, err := db.NewPasswordResetRequest(r)
assert.Nil(t, err)
assert.Equal(t, tt.userID, req.UserID)
}
}