commit 7662410ce9e08e7a214dd4d93aa8fe5df708b3b2
parent ec4075a3a54d7e154b171ba248f57900f6622c9a
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Thu, 7 Jul 2022 11:20:07 +0200
more tests
Diffstat:
4 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/cmd/taldir-server/main_test.go b/cmd/taldir-server/main_test.go
@@ -103,3 +103,44 @@ func TestRegisterRequest(s *testing.T) {
s.Errorf("Expected response code %d. Got %d\n", http.StatusNoContent, response.Code)
}
}
+
+func TestRegisterRequestWrongPubkey(s *testing.T) {
+ t.ClearDatabase()
+
+ req, _ := http.NewRequest("POST", "/register/test", bytes.NewBuffer(validRegisterRequest))
+ response := executeRequest(req)
+
+ if http.StatusAccepted != response.Code {
+ s.Errorf("Expected response code %d. Got %d\n", http.StatusAccepted, response.Code)
+ }
+ file, err := os.Open("validation_code")
+ if err != nil {
+ s.Errorf("No validation code file found!\n")
+ }
+ code, err := ioutil.ReadAll(file)
+ if err != nil {
+ s.Errorf("Error reading validation code file contents!\n")
+ }
+ log.Printf("Got code: %s\n", code)
+ h_addr := getHAddress("abc@test")
+ trimCode := strings.Trim(string(code), " \r\n")
+ solution := util.GenerateSolution("000G006XE97PTWV3B7AJNCRQZA6BF26HPV3XZ07293FMY7KD4181946AA0", trimCode)
+ solutionJSON := "{\"solution\": \"" + solution + "\"}"
+ req, _ = http.NewRequest("POST", "/" + h_addr, bytes.NewBuffer([]byte(solutionJSON)))
+ response = executeRequest(req)
+ if http.StatusForbidden != response.Code {
+ s.Errorf("Expected response code %d. Got %d\n", http.StatusForbidden, response.Code)
+ }
+}
+
+
+func TestUnsupportedMethod(s *testing.T) {
+ t.ClearDatabase()
+
+ req, _ := http.NewRequest("POST", "/register/email", bytes.NewBuffer(validRegisterRequest))
+ response := executeRequest(req)
+
+ if http.StatusNotFound != response.Code {
+ s.Errorf("Expected response code %d. Got %d\n", http.StatusNotFound, response.Code)
+ }
+}
diff --git a/cmd/taldir-server/testdata/taldir-test.conf b/cmd/taldir-server/testdata/taldir-test.conf
@@ -8,23 +8,9 @@ monthly_fee = KUDOS:1
request_frequency = 3
validation_landing = testdata/templates/validation_landing.html
-[taldir-email]
-sender = "taldir@taler.net"
-challenge_fee = KUDOS:0.5
-command = validate_email.sh
-
-[taldir-phone]
-challenge_fee = KUDOS:5
-requires_payment = true
-command = validate_phone.sh
-
[taldir-test]
challenge_fee = KUDOS:23
-command = taldir-validate-test
-
-[taldir-twitter]
-challenge_fee = KUDOS:2
-command = taldir-validate-twitter
+command = testdata/taldir-validate-test
[taldir-pq]
host = "localhost"
diff --git a/scripts/taldir-validate-test b/cmd/taldir-server/testdata/taldir-validate-test
diff --git a/taldir.conf b/taldir.conf
@@ -1,6 +1,6 @@
[taldir]
production = false
-validators = "twitter test"
+validators = "twitter"
host = "https://taldir.net"
bind_to = "localhost:11000"
salt = "ChangeMe"
@@ -17,10 +17,6 @@ challenge_fee = KUDOS:5
requires_payment = true
command = validate_phone.sh
-[taldir-test]
-challenge_fee = KUDOS:23
-command = taldir-validate-test
-
[taldir-twitter]
challenge_fee = KUDOS:2
command = taldir-validate-twitter