gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taldir] branch master updated: more tests


From: gnunet
Subject: [taler-taldir] branch master updated: more tests
Date: Thu, 07 Jul 2022 00:13:48 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository taldir.

The following commit(s) were added to refs/heads/master by this push:
     new ec4075a  more tests
ec4075a is described below

commit ec4075a3a54d7e154b171ba248f57900f6622c9a
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Thu Jul 7 00:13:45 2022 +0200

    more tests
---
 .gitignore                     |  6 ++++++
 cmd/taldir-server/main_test.go | 35 +++++++++++++++++++++++++++--------
 test.sh                        | 15 ---------------
 3 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..94016dc
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.gitignore
+go.sum
+**/validation_code
+taldir-server
+taldir-cli
+gana
diff --git a/cmd/taldir-server/main_test.go b/cmd/taldir-server/main_test.go
index 3d4b434..90729c2 100644
--- a/cmd/taldir-server/main_test.go
+++ b/cmd/taldir-server/main_test.go
@@ -26,6 +26,9 @@ import (
   "net/http/httptest"
   "crypto/sha512"
   "bytes"
+  "strings"
+  "io/ioutil"
+  "log"
   "taler.net/taldir/cmd/taldir-server"
   "taler.net/taldir/util"
 )
@@ -73,14 +76,30 @@ func executeRequest(req *http.Request) 
*httptest.ResponseRecorder {
 }
 
 func TestRegisterRequest(s *testing.T) {
-    t.ClearDatabase()
+  t.ClearDatabase()
 
-    req, _ := http.NewRequest("POST", "/register/test", 
bytes.NewBuffer(validRegisterRequest))
-    response := executeRequest(req)
+  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)
-    }
+  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("000G006XE97PTWV3B7AJNCRQZA6BF26HPV3XZ07293FMY7KD4181946A90",
 trimCode)
+  solutionJSON := "{\"solution\": \"" + solution + "\"}"
+  req, _ = http.NewRequest("POST", "/" + h_addr, 
bytes.NewBuffer([]byte(solutionJSON)))
+  response = executeRequest(req)
+  if http.StatusNoContent != response.Code {
+    s.Errorf("Expected response code %d. Got %d\n", http.StatusNoContent, 
response.Code)
+  }
 }
-
-
diff --git a/test.sh b/test.sh
deleted file mode 100755
index e6aeaef..0000000
--- a/test.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-# New request
-PUBKEY="000G006XE97PTWV3B7AJNCRQZA6BF26HPV3XZ07293FMY7KD4181946A90"
-curl -v localhost:11000/register/test --data "{\"address\": \"abc@test\", 
\"public_key\": \"${PUBKEY}\", \"inbox_url\": \"myinbox@xyz\", \"duration\": 
23}"
-# Read validation code from tempfile
-CODE=`cat validation_code`
-H_ADDRESS=`echo -n abc@test | openssl dgst -binary -sha512 | gnunet-base32`
-echo "Code: $CODE; Address: $H_ADDRESS"
-# Validate
-# echo localhost:11000/register/$H_ADDRESS/$CODE
-SOLUTION=$(./taldir-cli -s -c ${CODE} -p ${PUBKEY})
-echo "Solution: $SOLUTION"
-curl -v localhost:11000/$H_ADDRESS --data "{\"solution\": \"${SOLUTION}\"}"
-# Get mapping
-curl -v localhost:11000/$H_ADDRESS

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]