Change auth-token
endpoint from GET
to POST
.
This commit is contained in:
@ -8,9 +8,9 @@ import ../../main/nim/strawbosspkg/server
|
||||
import ../../main/nim/strawbosspkg/private/util
|
||||
|
||||
# test helpers
|
||||
proc newAuthenticatedHttpClient(apiBase, uname, pwd: string): HttpClient =
|
||||
proc newAuthenticatedHttpClient(apiBase, uname, pwd: string): HttpClient =
|
||||
result = newHttpClient()
|
||||
let authResp = result.get(apiBase & "/auth-token?username=" & uname & "&password=" & pwd)
|
||||
let authResp = result.post(apiBase & "/auth-token", $(%*{"username": uname, "password": pwd}))
|
||||
assert authResp.status.startsWith("200")
|
||||
result.headers = newHttpHeaders({"Authorization": "Bearer " & parseJson(authResp.body).getStr})
|
||||
|
||||
@ -54,11 +54,13 @@ suite "strawboss server":
|
||||
resp.body == "\"pong\""
|
||||
|
||||
test "fail auth":
|
||||
let resp = http.get(apiBase & "/auth-token?username=bob@builder.com&password=notpassword")
|
||||
let resp = http.post(apiBase & "/auth-token",
|
||||
$(%*{"username": "bob@builder.com", "password": "notpassword"}))
|
||||
check resp.status.startsWith("401")
|
||||
|
||||
test "auth":
|
||||
let resp = http.get(apiBase & "/auth-token?username=bob@builder.com&password=password")
|
||||
let resp = http.post(apiBase & "/auth-token",
|
||||
$(%*{"username": "bob@builder.com", "password": "password"}))
|
||||
check resp.status.startsWith("200")
|
||||
|
||||
test "verify valid auth token":
|
||||
|
Reference in New Issue
Block a user