diff --git a/ckanext/switzerland/tests/test_logic.py b/ckanext/switzerland/tests/test_logic.py index 862cf56c..f336cef3 100644 --- a/ckanext/switzerland/tests/test_logic.py +++ b/ckanext/switzerland/tests/test_logic.py @@ -17,6 +17,8 @@ class TestForceResetPasswords(OgdchFunctionalTestBase, SmtpServerHarness): + site_user = "" + @classmethod def setup_class(cls): super(TestForceResetPasswords, cls).setup_class() @@ -29,6 +31,8 @@ def setup_class(cls): def setup(self): super(TestForceResetPasswords, self).setup() + self.site_user = self._get_context()["user"] + for n in range(3): user = { "name": "user{}".format(str(n)), @@ -49,7 +53,7 @@ def test_reset_single_user_password(self): ) initial_other_user_passwords = {} - for user in ["user1", "user2", "default"]: + for user in ["user1", "user2", self.site_user]: initial_other_user_passwords[user] = tk.get_action("user_show")( self._get_context(), {"id": user, "include_password_hash": True} @@ -66,7 +70,7 @@ def test_reset_single_user_password(self): {"id": "user1", "include_password_hash": True} ) other_user_passwords_after_reset = {} - for user in ["user1", "user2", "default"]: + for user in ["user1", "user2", self.site_user]: other_user_passwords_after_reset[user] = tk.get_action("user_show")( self._get_context(), {"id": user, "include_password_hash": True} @@ -120,8 +124,8 @@ def test_reset_multiple_user_passwords(self): )["password_hash"] assert_equal( - initial_user_passwords["default"], - user_passwords_after_update["default"], + initial_user_passwords[self.site_user], + user_passwords_after_update[self.site_user], "The user at position 0 in the list should not have been updated", ) assert_not_equal( @@ -143,8 +147,10 @@ def test_reset_multiple_user_passwords(self): def test_own_password_is_not_reset_single_user_password(self): context = self._get_context() context["ignore_auth"] = False + site_user = context["user"] + result = tk.get_action("ogdch_force_reset_passwords")( - context, {"user": "default"} + context, {"user": self.site_user} ) assert_equal( @@ -154,7 +160,7 @@ def test_own_password_is_not_reset_single_user_password(self): ) assert_equal( "Not resetting password for the signed-in user default", - result["errors"]["default"], + result["errors"][self.site_user], "Expected error when resetting password for the user we are using to call the action" ) @@ -172,7 +178,7 @@ def test_own_password_is_not_reset_multiple_user_passwords(self): "Password should have been reset for the user we are not using to call the action" ) assert_equal( - {"default": "Not resetting password for the signed-in user default"}, + {self.site_user: "Not resetting password for the signed-in user default"}, result["errors"], "Expected error when resetting password for the user we are using to call the action" )