Merge branch 'flake-random-worker-id' into 'develop'
[akkoma] / test / web / oauth / oauth_controller_test.exs
index 26505bab7035cef3a1fdb1f036862b45d85a92eb..ccd55225859fa699fda02cdf41426ace62155fe9 100644 (file)
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Pleroma.Web.OAuth.OAuthControllerTest do
   use Pleroma.Web.ConnCase
   import Pleroma.Factory
@@ -113,10 +117,17 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
     refute Map.has_key?(resp, "access_token")
   end
 
-  test "rejects token exchange for valid credentials belonging to unconfirmed user" do
+  test "rejects token exchange for valid credentials belonging to unconfirmed user and confirmation is required" do
+    setting = Pleroma.Config.get([:instance, :account_activation_required])
+
+    unless setting do
+      Pleroma.Config.put([:instance, :account_activation_required], true)
+      on_exit(fn -> Pleroma.Config.put([:instance, :account_activation_required], setting) end)
+    end
+
     password = "testpassword"
     user = insert(:user, password_hash: Comeonin.Pbkdf2.hashpwsalt(password))
-    info_change = Pleroma.User.Info.confirmation_change(user.info, :unconfirmed)
+    info_change = Pleroma.User.Info.confirmation_changeset(user.info, :unconfirmed)
 
     {:ok, user} =
       user