summaryrefslogtreecommitdiff
path: root/domain_test.go
diff options
context:
space:
mode:
authorHorus32015-03-20 14:26:08 +0100
committerHorus32015-03-20 14:26:08 +0100
commit9ab1f49c4c4aa5dcaa0dd50ec606ca06ca071c71 (patch)
tree378bdbab80905a53c1193bfe28e22d1df0fbbcd3 /domain_test.go
parent039fb0ce71d132a1dfe93b516bc5953dcb61285e (diff)
downloadfreemail-9ab1f49c4c4aa5dcaa0dd50ec606ca06ca071c71.tar.gz
Validate MX from domain. Improve Makefile. Add schema.txt
Diffstat (limited to 'domain_test.go')
-rw-r--r--domain_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/domain_test.go b/domain_test.go
index 6f90ede..456d301 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -1,9 +1,13 @@
package main
import (
+ "flag"
+ "os"
"testing"
)
+var testExternal = flag.Bool("external", false, "allow use of external networks during long test")
+
func TestCreateDomain(t *testing.T) {
d := VirtualDomain{Name: "example.org"}
if !d.CreateDomain() {
@@ -41,6 +45,20 @@ func TestValidateDomain(t *testing.T) {
}
}
+func TestValidateDomainMX(t *testing.T) {
+ if testing.Short() || !*testExternal {
+ t.Skip("Skipping test to avoid external network.")
+ }
+ d := VirtualDomain{Name: "heise.de"}
+ if d.ValidateDomainMX(os.Getenv("FREEMAIL_SMTP_MAILER_MX")) {
+ t.Fatal("heise.de MX record doesn't point to this server.")
+ }
+ d.Name = "iamfabulous.de"
+ if !d.ValidateDomainMX(os.Getenv("FREEMAIL_SMTP_MAILER_MX")) {
+ t.Fatal(os.Getenv("FREEMAIL_SMTP_MAILER_MX") + " MX should point to this server.")
+ }
+}
+
func TestGetDomain(t *testing.T) {
domain := GetDomain("foo@example.org")
if domain != "example.org" {