Fixed formatting and test
authorSyldexia <syldexia@ofthewi.red>
Sun, 13 May 2018 13:56:59 +0000 (14:56 +0100)
committerSyldexia <syldexia@ofthewi.red>
Sun, 13 May 2018 14:43:42 +0000 (15:43 +0100)
lib/pleroma/web/common_api/utils.ex
test/web/common_api/common_api_utils_test.exs

index d9f80ee0fd9060605518d90d6049763f376f0df6..e774743a2736c41d1410e1ada51088b296237506 100644 (file)
@@ -189,7 +189,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
 
   def confirm_current_password(user, params) do
     with %User{local: true} = db_user <- Repo.get(User, user.id),
-          true <- Pbkdf2.checkpw(params["password"], db_user.password_hash) do
+         true <- Pbkdf2.checkpw(params["password"], db_user.password_hash) do
       {:ok, db_user}
     else
       _ -> {:error, "Invalid password."}
index d59864c4352152246a280016ee38865e28c8794a..23cce471f4cfb622444c9d1e13d72f180dcdd151 100644 (file)
@@ -18,19 +18,14 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
   end
 
   describe "it confirms the password given is the current users password" do
-    test "with no credentials" do
-      assert Utils.confirm_current_password(nil, %{"password" => "test"}) ==
-               {:error, "Invalid credentials."}
-    end
-
-    test "with incorrect password given" do
+    test "incorrect password given" do
       {:ok, user} = UserBuilder.insert()
 
       assert Utils.confirm_current_password(user, %{"password" => ""}) ==
                {:error, "Invalid password."}
     end
 
-    test "with correct password given" do
+    test "correct password given" do
       {:ok, user} = UserBuilder.insert()
       assert Utils.confirm_current_password(user, %{"password" => "test"}) == {:ok, user}
     end