aboutsummaryrefslogtreecommitdiff
path: root/src/guff/api
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-04-01 20:08:00 -0400
committerPaul Duncan <pabs@pablotron.org>2016-04-01 20:08:00 -0400
commitf6a068fdcef8b7650f010e4bb52f52a3b566e4bd (patch)
tree7d6042a88f0fb0fa35b642d484888777a7d3eb22 /src/guff/api
parent6b9ca27c67d043a8737da652bf7915645628db4c (diff)
downloadold-guff-f6a068fdcef8b7650f010e4bb52f52a3b566e4bd.tar.bz2
old-guff-f6a068fdcef8b7650f010e4bb52f52a3b566e4bd.zip
add login test
Diffstat (limited to 'src/guff/api')
-rw-r--r--src/guff/api/methods.cr20
-rw-r--r--src/guff/api/test.cr10
2 files changed, 28 insertions, 2 deletions
diff --git a/src/guff/api/methods.cr b/src/guff/api/methods.cr
index 970e41f..fce6911 100644
--- a/src/guff/api/methods.cr
+++ b/src/guff/api/methods.cr
@@ -368,7 +368,7 @@ module Guff
},
"add_user": {
- text: "Add new user",
+ text: "Test add new user",
args: {
"name": {
@@ -402,6 +402,24 @@ module Guff
},
},
},
+
+ "login": {
+ text: "Test user login.",
+
+ args: {
+ "email": {
+ text: "Email address of user",
+ type: :text,
+ required: true,
+ },
+
+ "password": {
+ text: "Password of user",
+ type: :text,
+ required: true,
+ },
+ },
+ },
}
}
diff --git a/src/guff/api/test.cr b/src/guff/api/test.cr
index 059f670..448cadf 100644
--- a/src/guff/api/test.cr
+++ b/src/guff/api/test.cr
@@ -82,7 +82,7 @@ module Guff::API::TestAPI
user_id = @models.user.add_user(args["name"].not_nil!,
active: args["active"]? ? args["active"] == "t" : nil,
role: args["role"]?,
- email: args["name"]?,
+ email: args["email"]?,
password: args["password"]?,
)
{ "ok": true, "user_id": user_id }
@@ -120,4 +120,12 @@ module Guff::API::TestAPI
@models.user.remove_login(args["user_id"].to_i)
{ "ok": true }
end
+
+ private def do_test_login(
+ context : HTTP::Server::Context,
+ args : Hash(String, String)
+ )
+ user_id = @models.user.login(args["email"], args["password"]).to_i
+ { "ok": true, "user_id": user_id }
+ end
end