-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Gary Kim <[email protected]>
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
name: user1 | ||
full_name: User One | ||
email: [email protected] | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -22,6 +23,7 @@ | |
full_name: " < U<se>r Tw<o > >< " | ||
email: [email protected] | ||
keep_email_private: true | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -40,6 +42,7 @@ | |
name: user3 | ||
full_name: " <<<< >> >> > >> > >>> >> " | ||
email: [email protected] | ||
email_notifications_preference: onmention | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 1 # organization | ||
salt: ZogKvWdyEx | ||
|
@@ -56,6 +59,7 @@ | |
name: user4 | ||
full_name: " " | ||
email: [email protected] | ||
email_notifications_preference: onmention | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -72,6 +76,7 @@ | |
name: user5 | ||
full_name: User Five | ||
email: [email protected] | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -89,6 +94,7 @@ | |
name: user6 | ||
full_name: User Six | ||
email: [email protected] | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 1 # organization | ||
salt: ZogKvWdyEx | ||
|
@@ -105,6 +111,7 @@ | |
name: user7 | ||
full_name: User Seven | ||
email: [email protected] | ||
email_notifications_preference: disabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 1 # organization | ||
salt: ZogKvWdyEx | ||
|
@@ -121,6 +128,7 @@ | |
name: user8 | ||
full_name: User Eight | ||
email: [email protected] | ||
email_notifications_preference: enabled | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
@@ -138,6 +146,7 @@ | |
name: user9 | ||
full_name: User Nine | ||
email: [email protected] | ||
email_notifications_preference: onmention | ||
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password | ||
type: 0 # individual | ||
salt: ZogKvWdyEx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,8 @@ func TestGetUserEmailsByNames(t *testing.T) { | |
// ignore none active user email | ||
assert.Equal(t, []string{"[email protected]"}, GetUserEmailsByNames([]string{"user8", "user9"})) | ||
assert.Equal(t, []string{"[email protected]", "[email protected]"}, GetUserEmailsByNames([]string{"user8", "user5"})) | ||
|
||
assert.Equal(t, []string{"[email protected]"}, GetUserEmailsByNames([]string{"user8", "user7"})) | ||
} | ||
|
||
func TestUser_APIFormat(t *testing.T) { | ||
|
@@ -196,6 +198,37 @@ func TestDeleteUser(t *testing.T) { | |
test(11) | ||
} | ||
|
||
func TestEmailNotificationPreferences(t *testing.T) { | ||
assert.NoError(t, PrepareTestDatabase()) | ||
for _, test := range []struct { | ||
expected string | ||
userID int64 | ||
}{ | ||
{EmailNotificationsEnabled, 1}, | ||
{EmailNotificationsEnabled, 2}, | ||
{EmailNotificationsOnMention, 3}, | ||
{EmailNotificationsOnMention, 4}, | ||
{EmailNotificationsEnabled, 5}, | ||
{EmailNotificationsEnabled, 6}, | ||
{EmailNotificationsDisabled, 7}, | ||
{EmailNotificationsEnabled, 8}, | ||
{EmailNotificationsOnMention, 9}, | ||
} { | ||
user := AssertExistsAndLoadBean(t, &User{ID: test.userID}).(*User) | ||
assert.Equal(t, test.expected, user.EmailNotifications()) | ||
|
||
// Try all possible settings | ||
user.SetEmailNotifications(EmailNotificationsDisabled) | ||
assert.Equal(t, EmailNotificationsDisabled, user.EmailNotifications()) | ||
|
||
user.SetEmailNotifications(EmailNotificationsOnMention) | ||
assert.Equal(t, EmailNotificationsOnMention, user.EmailNotifications()) | ||
|
||
user.SetEmailNotifications(EmailNotificationsDisabled) | ||
assert.Equal(t, EmailNotificationsDisabled, user.EmailNotifications()) | ||
} | ||
} | ||
|
||
func TestHashPasswordDeterministic(t *testing.T) { | ||
b := make([]byte, 16) | ||
rand.Read(b) | ||
|