summaryrefslogtreecommitdiffstats
path: root/tester.sh
diff options
context:
space:
mode:
authorYigit Sever2021-04-11 21:39:18 +0300
committerYigit Sever2021-04-12 00:03:23 +0300
commit518a99a132707ba0e2572b24ca18f6b9606d7334 (patch)
treec7cbe183f088b286903389f58743b1e5688119c5 /tester.sh
parent217398c52c68b3b73454d3e9f66c85b5a1638f3f (diff)
downloadgradecoin-518a99a132707ba0e2572b24ca18f6b9606d7334.tar.gz
gradecoin-518a99a132707ba0e2572b24ca18f6b9606d7334.tar.bz2
gradecoin-518a99a132707ba0e2572b24ca18f6b9606d7334.zip
Implement User handling and authentication
New struct: User, corresponds to a student Blocks and users are persistent (written to a text file) PostgreSQL would've been overkill, we have 30 students AuthRequest is the representation for incoming register requests and User is the inner representation Students who are enrolled to the class are hardcoded, only they can register new accounts There are two new tests, one checks if a priviliged (=enrolled) user can create an account and the other checks if a unpriviliged one cannot There are quick verbose error messages that I'm not married to, might move on to something better honestly There's nothing stopping a malicious user to pre-register everyone with mock public keys and effectively lock everyone out, what's a good secret we can use?
Diffstat (limited to 'tester.sh')
-rwxr-xr-xtester.sh21
1 files changed, 20 insertions, 1 deletions
diff --git a/tester.sh b/tester.sh
index e6bb007..71e6ae6 100755
--- a/tester.sh
+++ b/tester.sh
@@ -2,6 +2,26 @@
2 2
3## When in doubt just write a shell script 3## When in doubt just write a shell script
4 4
5## new registration request
6## should fail because foobar is not a student
7curl --request POST \
8 --header 'Content-Type: application/json' \
9 --data '{
10 "student_id": "foobar",
11 "public_key": "not_implemented_yet"
12}' \
13 http://localhost:8080/register
14
15## new registration request
16## should fail because foobar is not a student
17curl --request POST \
18 --header 'Content-Type: application/json' \
19 --data '{
20 "student_id": "e254275",
21 "public_key": "not_implemented_yet"
22 }' \
23 http://localhost:8080/register
24
5## new transaction 25## new transaction
6curl --request POST \ 26curl --request POST \
7 --header 'Content-Type: application/json' \ 27 --header 'Content-Type: application/json' \
@@ -72,4 +92,3 @@ curl localhost:8080/transaction
72 92
73printf "\n\nShould have only one block\n\n" 93printf "\n\nShould have only one block\n\n"
74curl localhost:8080/block 94curl localhost:8080/block
75