diff options
| author | Horus3 | 2015-05-15 20:19:01 +0200 |
|---|---|---|
| committer | Horus3 | 2015-05-15 20:19:01 +0200 |
| commit | 5d48193b6988f20b4ed94331350262d07754bd4d (patch) | |
| tree | ee9914f39f095a995967031c14fb7779914df908 | |
| parent | 8532a24f6bc2069eff755d7174021a1ae5bc09c9 (diff) | |
| parent | 53b71a44c901b4630d247604b82a221e19a7d01d (diff) | |
| download | freemail-5d48193b6988f20b4ed94331350262d07754bd4d.tar.gz | |
Merge branch 'master' of git.iamfabulous.de:freemail
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | handler_test.go | 133 | ||||
| -rw-r--r-- | views/about.html | 2 | ||||
| -rw-r--r-- | views/server.html | 2 | ||||
| -rw-r--r-- | views/server_de.html | 10 |
5 files changed, 142 insertions, 9 deletions
@@ -100,7 +100,9 @@ pack: gen_config echo "\n/$(APP).tar.gz is ready." || \ (echo "Run \"make build\" first." && exit 1) -test: import _info_test _run_test +test: test_all + +test_new: import _info_test _run_test _info_test: @echo "Please note: We are testing only changes." diff --git a/handler_test.go b/handler_test.go index 92088bf..2ea7494 100644 --- a/handler_test.go +++ b/handler_test.go @@ -341,6 +341,9 @@ func BenchmarkPasswordHandler(b *testing.B) { } func TestChangePasswordHandler(t *testing.T) { + + // Test with the correct form + form := url.Values{} if err := CreateNewEntry("test@localhost", Md5Hash("Password")); err != nil { @@ -385,7 +388,135 @@ func TestChangePasswordHandler(t *testing.T) { t.Fatal("Expected success message.") } - t.Log(flash.Success) + t.Log("Success message:", flash.Success[0]) + + // Test with incorrect form to check validation + // Check Password and ConfirmPassword validation + + form = url.Values{} + + if err = CreateNewEntry("test1@localhost", Md5Hash("Password")); err != nil { + t.Fatal(err) + } + + form.Set("Email", "test1@localhost") + form.Set("Password", "Password") + form.Set("ConfirmPassword", "Password") + form.Set("NewPassword", "password") + + request, err = http.NewRequest("POST", "/changePassword", strings.NewReader(form.Encode())) + if err != nil { + t.Log("Error creating new http request. (/changePassword)", err) + } + request.Header.Add("Content-Type", "application/x-www-form-urlencoded") + response = httptest.NewRecorder() + + ChangePasswordHandler(response, request) + + if response.Code != 302 { + t.Log(response.Code) + t.Fatal("Expected 302 as status code.") + } + + flash = Flash{} + session, err = store.Get(request, "_SID") + if err != nil { + t.Log(err) + } + flash.Error = session.Flashes("error") + flash.Success = session.Flashes("success") + + if len(flash.Success) > 0 { + t.Fatal("Got success message, expected failure.") + } + + for _, v := range flash.Error { + t.Log(v) + } + + // Test with incorrect form to check validation + // Check password validation + + form = url.Values{} + + if err = CreateNewEntry("test2@localhost", Md5Hash("Password")); err != nil { + t.Fatal(err) + } + + form.Set("Email", "test2@localhost") + form.Set("Password", "password") + form.Set("ConfirmPassword", "Password") + form.Set("NewPassword", "Password") + + request, err = http.NewRequest("POST", "/changePassword", strings.NewReader(form.Encode())) + if err != nil { + t.Log("Error creating new http request. (/changePassword)", err) + } + request.Header.Add("Content-Type", "application/x-www-form-urlencoded") + response = httptest.NewRecorder() + + ChangePasswordHandler(response, request) + + if response.Code != 302 { + t.Log(response.Code) + t.Fatal("Expected 302 as status code.") + } + + flash = Flash{} + session, err = store.Get(request, "_SID") + if err != nil { + t.Log(err) + } + flash.Error = session.Flashes("error") + flash.Success = session.Flashes("success") + + if len(flash.Success) > 0 { + t.Fatal("Got success message, expected failure.") + } + + for _, v := range flash.Error { + t.Log(v) + } + + // Test with incorrect form to check validation + // Check non-existent e-mail + + form = url.Values{} + + form.Set("Email", "nonexistent@localhost") + form.Set("Password", "password") + form.Set("ConfirmPassword", "Password") + form.Set("NewPassword", "Password") + + request, err = http.NewRequest("POST", "/changePassword", strings.NewReader(form.Encode())) + if err != nil { + t.Log("Error creating new http request. (/changePassword)", err) + } + request.Header.Add("Content-Type", "application/x-www-form-urlencoded") + response = httptest.NewRecorder() + + ChangePasswordHandler(response, request) + + if response.Code != 302 { + t.Log(response.Code) + t.Fatal("Expected 302 as status code.") + } + + flash = Flash{} + session, err = store.Get(request, "_SID") + if err != nil { + t.Log(err) + } + flash.Error = session.Flashes("error") + flash.Success = session.Flashes("success") + + if len(flash.Success) > 0 { + t.Fatal("Got success message, expected failure.") + } + + for _, v := range flash.Error { + t.Log(v) + } } func TestChangeLocaleHandler(t *testing.T) { diff --git a/views/about.html b/views/about.html index 44c837d..8992d8c 100644 --- a/views/about.html +++ b/views/about.html @@ -55,7 +55,7 @@ <br> <h2 id="warranty">Warranty</h2> <p> - THERE IS ABSOLUT NO WARRANTY IN ANY WAY, BE IT UPTIME, BACKUP OR ABUSE. THE USER IS RESPONSIBLE FOR HER OWN DOING. + THERE IS ABSOLUT NO WARRANTY IN ANY WAY, BE IT UPTIME, BACKUP OR ABUSE. THE USER IS RESPONSIBLE FOR HIS OWN DOING. </p> </div> </div> diff --git a/views/server.html b/views/server.html index 9326b5c..5fb17de 100644 --- a/views/server.html +++ b/views/server.html @@ -56,7 +56,7 @@ </li> <li> <h2>POP3</h2> - <p>POP3 is used to pull the mails from the server to the cliente.g. your phone or thunderbird. Dovecot also handles your POP3 connections. + <p>POP3 is used to pull the mails from the server to the client e.g. your phone or thunderbird. Dovecot also handles your POP3 connections. <br> The TLS certificate is signed to 'mx.iamfabulous.de'</p> <p><strong>Ports:</strong></p> diff --git a/views/server_de.html b/views/server_de.html index c4d2f6f..997a78c 100644 --- a/views/server_de.html +++ b/views/server_de.html @@ -5,14 +5,14 @@ <div class="container"> <div class="row"> <div class="col-md-12"> - <h1>Server Details</h1> + <h1>Server-Details</h1> <br> <div class="well well-lg"> - <p>Alles was Sie wissen müssen um Libremail zu benutzen.</p> + <p>Alles was Sie wissen müssen, um Libremail zu benutzen.</p> <ul class="list-unstyled"> <li> <h2>Webmail</h2> - <p>Nutzen Sie ihren Browser um ihre E-Mails zu lesen. Unser Webmail finden sie unter <a href="https://iamfabulous.de/webmail" title="Webmail">diesem Link <span class="fa fa-external-link-square"></a>. + <p>Nutzen Sie ihren Browser, um ihre E-Mails zu lesen. Unser Webmail finden sie unter <a href="https://iamfabulous.de/webmail" title="Webmail">diesem Link <span class="fa fa-external-link-square"></a>. <br> <strong>Loggen Sie sich mit Ihrer kompletten E-Mail Adresse und ihrem Passwort ein.</strong> <br> @@ -23,7 +23,7 @@ </li> <li> <h2>SMTP</h2> - <p>Wir benutzen Postfix als unseren SMTP Server um E-Mails zu versenden oder zu empfangen. + <p>Wir benutzen Postfix als unseren SMTP Server, um E-Mails zu versenden oder zu empfangen. <br> Das TLS Zertifikat ist auf 'mx.iamfabulous.de' signiert. </p> @@ -42,7 +42,7 @@ </li> <li> <h2>IMAP</h2> - <p>IMAP wird benutzt um Ihre E-Mails auf dem Server zu verwalten. So gut wie alle Klienten (zum Beispiel Ihr Smartphone oder Thunderbird) sprechen IMAP. Bei uns ist Dovecot dafür verantwortlich das alles reibungslos klappt. + <p>IMAP wird benutzt, um Ihre E-Mails auf dem Server zu verwalten. So gut wie alle Klienten (zum Beispiel Ihr Smartphone oder Thunderbird) sprechen IMAP. Bei uns ist Dovecot dafür verantwortlich, dass alles reibungslos klappt. <br> Das TLS Zertifikat ist auf 'mx.iamfabulous.de' signiert. </p> |
