aboutsummaryrefslogtreecommitdiff
path: root/test_api
diff options
context:
space:
mode:
authorGuillaume Pasquet <dev@etenil.net>2022-03-26 06:22:34 +0000
committerGuillaume Pasquet <dev@etenil.net>2022-03-26 06:22:34 +0000
commit08339229db6da6e76726162ba325a625b558cfb6 (patch)
treeca4b87529858d9d9cf3f15dbd42f2ff5ccabc1b8 /test_api
parent4d76e3d4c852967430b30cff4f6567cb8d7e9235 (diff)
Feature/16 dependencies
Diffstat (limited to 'test_api')
-rw-r--r--test_api/test_api.py14
-rw-r--r--test_api/test_api_auth.barb7
-rw-r--r--test_api/test_api_get_profile.barb3
-rw-r--r--test_api/test_api_get_profile_wrong_dep.barb3
4 files changed, 26 insertions, 1 deletions
diff --git a/test_api/test_api.py b/test_api/test_api.py
index cce55f4..02eb491 100644
--- a/test_api/test_api.py
+++ b/test_api/test_api.py
@@ -1,4 +1,4 @@
-from bottle import get, post, run, HTTPError
+from bottle import get, post, run, HTTPError, request
@get("/")
def get_root():
@@ -24,4 +24,16 @@ def error_404():
def error_500():
raise HTTPError(500, body={"error": "server error"})
+@post("/auth")
+def post_auth():
+ return {"token": "blah1234"}
+
+@get("/profile")
+def get_profile():
+ if request.headers.get("TOKEN") != "blah1234":
+ raise HTTPError(401, body={"error": "Not Authorized"})
+ return {
+ "user": "John Doe"
+ }
+
run(host="localhost", port=8080)
diff --git a/test_api/test_api_auth.barb b/test_api/test_api_auth.barb
new file mode 100644
index 0000000..40da734
--- /dev/null
+++ b/test_api/test_api_auth.barb
@@ -0,0 +1,7 @@
+#POST^http://localhost:8080/auth
+#TOKEN$$.token
+
+{
+ "username": "john.doe",
+ "password": "foobar123"
+} \ No newline at end of file
diff --git a/test_api/test_api_get_profile.barb b/test_api/test_api_get_profile.barb
new file mode 100644
index 0000000..9c0811a
--- /dev/null
+++ b/test_api/test_api_get_profile.barb
@@ -0,0 +1,3 @@
+#GET^http://localhost:8080/profile
+#>test_api_auth.barb
+#TOKEN: {TOKEN}
diff --git a/test_api/test_api_get_profile_wrong_dep.barb b/test_api/test_api_get_profile_wrong_dep.barb
new file mode 100644
index 0000000..f7ec2e7
--- /dev/null
+++ b/test_api/test_api_get_profile_wrong_dep.barb
@@ -0,0 +1,3 @@
+#GET^http://localhost:8080/profile
+#>test_api_aut.barb
+#TOKEN: {TOKEN}