@@ -0,0 +1,40 @@
1+package main
2+
3+import (
4+ "io/ioutil"
5+ "os"
6+ "strings"
7+ "testing"
8+)
9+
10+func TestValidatorComparisonsAreCaseInsensitive(t *testing.T) {
11+ auth_email_file, err := ioutil.TempFile("", "test_auth_emails_")
12+ if err != nil {
13+ t.Fatal("failed to create temp file: " + err.Error())
14+ }
15+ defer os.Remove(auth_email_file.Name())
16+
17+ auth_email_file.WriteString(
18+ strings.Join([]string{"Foo.Bar@Example.Com"}, "\n"))
19+ err = auth_email_file.Close()
20+ if err != nil {
21+ t.Fatal("failed to close temp file " + auth_email_file.Name() +
22+ ": " + err.Error())
23+ }
24+
25+ domains := []string{"Frobozz.Com"}
26+ validator := NewValidator(domains, auth_email_file.Name())
27+
28+ if !validator("foo.bar@example.com") {
29+ t.Error("loaded email addresses are not lower-cased")
30+ }
31+ if !validator("Foo.Bar@Example.Com") {
32+ t.Error("validated email addresses are not lower-cased")
33+ }
34+ if !validator("foo.bar@frobozz.com") {
35+ t.Error("loaded domains are not lower-cased")
36+ }
37+ if !validator("foo.bar@Frobozz.Com") {
38+ t.Error("validated domains are not lower-cased")
39+ }
40+}