mirror of https://github.com/gophish/gophish
Properly returning 404 error if the requested sending profile isn't found.
parent
10aa98b760
commit
81da804761
|
@ -146,6 +146,7 @@ func GetSMTP(id int64, uid int64) (SMTP, error) {
|
||||||
err := db.Where("user_id=? and id=?", uid, id).Find(&s).Error
|
err := db.Where("user_id=? and id=?", uid, id).Find(&s).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
return s, err
|
||||||
}
|
}
|
||||||
err = db.Where("smtp_id=?", s.Id).Find(&s.Headers).Error
|
err = db.Where("smtp_id=?", s.Id).Find(&s.Headers).Error
|
||||||
if err != nil && err != gorm.ErrRecordNotFound {
|
if err != nil && err != gorm.ErrRecordNotFound {
|
||||||
|
|
|
@ -3,6 +3,8 @@ package models
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jinzhu/gorm"
|
||||||
|
|
||||||
check "gopkg.in/check.v1"
|
check "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -74,3 +76,8 @@ func (s *ModelsSuite) TestSMTPGetDialer(ch *check.C) {
|
||||||
ch.Assert(dialer.TLSConfig.ServerName, check.Equals, smtp.Host)
|
ch.Assert(dialer.TLSConfig.ServerName, check.Equals, smtp.Host)
|
||||||
ch.Assert(dialer.TLSConfig.InsecureSkipVerify, check.Equals, smtp.IgnoreCertErrors)
|
ch.Assert(dialer.TLSConfig.InsecureSkipVerify, check.Equals, smtp.IgnoreCertErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ModelsSuite) TestGetInvalidSMTP(ch *check.C) {
|
||||||
|
_, err := GetSMTP(-1, 1)
|
||||||
|
ch.Assert(err, check.Equals, gorm.ErrRecordNotFound)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue