Merge pull request #50 from poanetwork/ferigis.49.improve_tests
Ferigis.49.improve tests
This commit is contained in:
commit
0d53f92fea
|
@ -81,6 +81,7 @@ defmodule POABackend.Auth do
|
|||
alias Comeonin.Bcrypt
|
||||
|
||||
with user <- get_user(user_name),
|
||||
true <- user != nil,
|
||||
true <- Bcrypt.checkpw(password, user.password_hash),
|
||||
true <- user_active?(user)
|
||||
do
|
||||
|
|
|
@ -94,6 +94,38 @@ defmodule Auth.APITest do
|
|||
assert {401, :nobody} == result
|
||||
end
|
||||
|
||||
test "try with a user who doesn't exist [JSON]" do
|
||||
url = @base_url <> "/session"
|
||||
mime_type = "application/json"
|
||||
headers = [
|
||||
{"Content-Type", mime_type},
|
||||
{"authorization", "Basic " <> Base.encode64("nonexistinguser" <> ":" <> "password")}
|
||||
]
|
||||
|
||||
result =
|
||||
%{:'agent-id' => "agentID"}
|
||||
|> Poison.encode!()
|
||||
|> post(url, headers)
|
||||
|
||||
assert {401, :nobody} == result
|
||||
end
|
||||
|
||||
test "try with a user who doesn't exist [MSGPACK]" do
|
||||
url = @base_url <> "/session"
|
||||
mime_type = "application/msgpack"
|
||||
headers = [
|
||||
{"Content-Type", mime_type},
|
||||
{"authorization", "Basic " <> Base.encode64("nonexistinguser" <> ":" <> "password")}
|
||||
]
|
||||
|
||||
result =
|
||||
%{:'agent-id' => "agentID"}
|
||||
|> Msgpax.pack!()
|
||||
|> post(url, headers)
|
||||
|
||||
assert {401, :nobody} == result
|
||||
end
|
||||
|
||||
test "testing an unnexisting endpoint" do
|
||||
url = @base_url <> "/thisdoesntexist"
|
||||
mime_type = "application/json"
|
||||
|
|
Loading…
Reference in New Issue