5cfa7ca460
There are multiple entries in the users table with the same email address. This is because in the past users were able to register multiple times if the email was not verified. This is no longer the case. If a user tries to register with an unverified email already in the DB, we send a verification email instead of creating another entry. However, since these old entries in the table with duplicate emails were never cleaned up, the email reminder chore will send out email verification reminders to them. A single person will get one separate email per entry in the DB with their email and where status = 0. Since the multiple entries with the same email problem was solved a while ago, just add a constraint to GetUnverifiedNeedingReminder to only select users created after a cutoff. Once the DB is migrated to remove the duplicate emails, we can remove the cutoff. github issue: https://github.com/storj/storj/issues/4853 Change-Id: I07d77d43109bcacc8909df61d4fb49165a99527c
41 lines
860 B
Go
41 lines
860 B
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package satellitedb
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"storj.io/storj/satellite/satellitedb/dbx"
|
|
)
|
|
|
|
func TestUserFromDbx(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
t.Run("can't create dbo from nil dbx model", func(t *testing.T) {
|
|
user, err := userFromDBX(ctx, nil)
|
|
assert.Nil(t, user)
|
|
assert.Error(t, err)
|
|
})
|
|
|
|
t.Run("can't create dbo from dbx model with invalid ID", func(t *testing.T) {
|
|
dbxUser := dbx.User{
|
|
Id: []byte("qweqwe"),
|
|
FullName: "Very long full name",
|
|
ShortName: nil,
|
|
Email: "some@mail.test",
|
|
PasswordHash: []byte("ihqerfgnu238723huagsd"),
|
|
CreatedAt: time.Now(),
|
|
}
|
|
|
|
user, err := userFromDBX(ctx, &dbxUser)
|
|
|
|
assert.Nil(t, user)
|
|
assert.Error(t, err)
|
|
})
|
|
}
|