summaryrefslogtreecommitdiff
path: root/handler_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'handler_test.go')
-rw-r--r--handler_test.go29
1 files changed, 20 insertions, 9 deletions
diff --git a/handler_test.go b/handler_test.go
index 2ea7494..8bbf36a 100644
--- a/handler_test.go
+++ b/handler_test.go
@@ -4,6 +4,7 @@ import (
"net/http"
"net/http/httptest"
"net/url"
+ "os"
"strings"
"testing"
)
@@ -92,10 +93,15 @@ func BenchmarkRegisterHandler(b *testing.B) {
}
func TestCreateNewEntryHandler(t *testing.T) {
+ if testing.Short() || !*testExternal {
+ t.Skip("Skipping test to avoid external network.")
+ }
+
+ domain := os.Getenv("FREEMAIL_SMTP_MAILER_MX")
form := url.Values{}
- form.Set("Email", "createNewEntry@localhost")
- form.Set("ConfirmEmail", "createNewEntry@localhost")
+ form.Set("Email", "createNewEntry@"+domain)
+ form.Set("ConfirmEmail", "createNewEntry@"+domain)
form.Set("Password", "Password")
form.Set("ConfirmPassword", "Password")
@@ -342,15 +348,20 @@ func BenchmarkPasswordHandler(b *testing.B) {
func TestChangePasswordHandler(t *testing.T) {
+ if testing.Short() || !*testExternal {
+ t.Skip("Skipping test to avoid external network.")
+ }
+
// Test with the correct form
form := url.Values{}
- if err := CreateNewEntry("test@localhost", Md5Hash("Password")); err != nil {
+ domain := os.Getenv("FREEMAIL_SMTP_MAILER_MX")
+ if err := CreateNewEntry("test@"+domain, Md5Hash("Password")); err != nil {
t.Fatal(err)
}
- form.Set("Email", "test@localhost")
+ form.Set("Email", "test@"+domain)
form.Set("Password", "Password")
form.Set("ConfirmPassword", "password")
form.Set("NewPassword", "password")
@@ -395,11 +406,11 @@ func TestChangePasswordHandler(t *testing.T) {
form = url.Values{}
- if err = CreateNewEntry("test1@localhost", Md5Hash("Password")); err != nil {
+ if err = CreateNewEntry("test1@"+domain, Md5Hash("Password")); err != nil {
t.Fatal(err)
}
- form.Set("Email", "test1@localhost")
+ form.Set("Email", "test1@"+domain)
form.Set("Password", "Password")
form.Set("ConfirmPassword", "Password")
form.Set("NewPassword", "password")
@@ -439,11 +450,11 @@ func TestChangePasswordHandler(t *testing.T) {
form = url.Values{}
- if err = CreateNewEntry("test2@localhost", Md5Hash("Password")); err != nil {
+ if err = CreateNewEntry("test2@"+domain, Md5Hash("Password")); err != nil {
t.Fatal(err)
}
- form.Set("Email", "test2@localhost")
+ form.Set("Email", "test2@"+domain)
form.Set("Password", "password")
form.Set("ConfirmPassword", "Password")
form.Set("NewPassword", "Password")
@@ -483,7 +494,7 @@ func TestChangePasswordHandler(t *testing.T) {
form = url.Values{}
- form.Set("Email", "nonexistent@localhost")
+ form.Set("Email", "nonexistent@"+domain)
form.Set("Password", "password")
form.Set("ConfirmPassword", "Password")
form.Set("NewPassword", "Password")