mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Lots of work on user password reset, #1456
This commit is contained in:
35
pkg/services/notifications/codes_test.go
Normal file
35
pkg/services/notifications/codes_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package notifications
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestEmailCodes(t *testing.T) {
|
||||
|
||||
Convey("When generating code", t, func() {
|
||||
setting.EmailCodeValidMinutes = 120
|
||||
|
||||
user := &m.User{Id: 10, Email: "t@a.com", Login: "asd", Password: "1", Rands: "2"}
|
||||
code := createUserEmailCode(user, nil)
|
||||
|
||||
Convey("getLoginForCode should return login", func() {
|
||||
login := getLoginForEmailCode(code)
|
||||
So(login, ShouldEqual, "asd")
|
||||
})
|
||||
|
||||
Convey("Can verify valid code", func() {
|
||||
So(validateUserEmailCode(user, code), ShouldBeTrue)
|
||||
})
|
||||
|
||||
Convey("Cannot verify in-valid code", func() {
|
||||
code = "ASD"
|
||||
So(validateUserEmailCode(user, code), ShouldBeFalse)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user