core: fixed unit test.

see #1198
This commit is contained in:
Antoine Nguyen
2017-07-28 10:34:34 +02:00
parent c613ad4572
commit 9e90632878
2 changed files with 56 additions and 0 deletions
+54
View File
@@ -400,3 +400,57 @@ Finally, configure the ``sieve`` plugin by editing the
Restart Dovecot.
Now, you can go to the :ref:`postfix` section to finish the installation.
Last-login tracking
===================
To update the ``last_login`` attribute of an account after a succesful
IMAP or POP3 login, you can configure a `post-login script
<https://wiki.dovecot.org/PostLoginScripting>`_.
Open :file:`conf.d/10-master.conf` add the following configuration
(``imap`` and ``pop3`` services are already defined, you just need to
update them)::
service imap {
executable = imap postlogin
}
service pop3 {
executable = pop3 postlogin
}
service postlogin {
executable = script-login /usr/local/bin/postlogin.sh
user = modoboa
unix_listener postlogin {
}
}
Then, you must create a script named
:file:`/usr/local/bin/postlogin.sh`. According to your database
engine, the content will differ.
PostgreSQL
----------
::
#!/bin/sh
psql -c "UPDATE core_user SET last_login=now() WHERE username='$USER'" > /dev/null
exec "$@"
MySQL
-----
::
#!/bin/sh
DBNAME=XXX
DBUSER=XXX
DBPASSWORD=XXX
echo "UPDATE core_user SET last_login=now() WHERE username='$USER'" | mysql -u $DBUSER -p$DBPASSWORD $DBNAME
exec "$@"
+2
View File
@@ -156,6 +156,7 @@ class SettingsTestCase(ModoTestCase):
"core-default_password": "Toto1000",
"limits-deflt_user_quota_limit": "0",
"core-hide_features_widget": "False",
"core-inactive_account_threshold": "30",
}
def test_get_settings(self):
@@ -169,6 +170,7 @@ class SettingsTestCase(ModoTestCase):
"""Test settings save."""
url = reverse("core:parameters")
response = self.client.post(url, self.settings_sample, format="json")
print response.content
self.assertEqual(response.status_code, 200)
self.settings_sample["core-rounds_number"] = ""
response = self.client.post(url, self.settings_sample, format="json")