From 274937feeeb570c17f8d8e6d4a852490d180063d Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 3 Nov 2019 18:36:33 -0400 Subject: [PATCH 1/6] Move remaining mocked objects to mocks.py module Signed-off-by: Roberto Rosario --- mayan/apps/sources/tests/mocks.py | 29 ++++++++++++++++++++++++ mayan/apps/sources/tests/test_classes.py | 5 ++-- mayan/apps/sources/tests/test_models.py | 28 ++--------------------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/mayan/apps/sources/tests/mocks.py b/mayan/apps/sources/tests/mocks.py index 3e3c4b43eb..f66e9a0cfd 100644 --- a/mayan/apps/sources/tests/mocks.py +++ b/mayan/apps/sources/tests/mocks.py @@ -34,3 +34,32 @@ class MockIMAPServer(object): def logout(self): return ('BYE', ['LOGOUT Requested']) + + +class MockMailbox(object): + def dele(self, which): + return + + def getwelcome(self): + return + + def list(self, which=None): + return (None, ['1 test']) + + def user(self, user): + return + + def pass_(self, pswd): + return + + def quit(self): + return + + def retr(self, which=None): + return ( + 1, [TEST_EMAIL_BASE64_FILENAME] + ) + + +class MockStagingFolder(object): + """Mock of a StagingFolder model""" diff --git a/mayan/apps/sources/tests/test_classes.py b/mayan/apps/sources/tests/test_classes.py index 319c3eeb37..b20e63aa62 100644 --- a/mayan/apps/sources/tests/test_classes.py +++ b/mayan/apps/sources/tests/test_classes.py @@ -9,6 +9,8 @@ from mayan.apps.storage.utils import mkdtemp from ..classes import StagingFile +from .mocks import MockStagingFolder + class StagingFileTestCase(BaseTestCase): def test_unicode_staging_file(self): @@ -17,9 +19,6 @@ class StagingFileTestCase(BaseTestCase): filename = os.path.basename(TEST_NON_ASCII_DOCUMENT_PATH) - class MockStagingFolder(object): - self.folder_path = temporary_directory - staging_file_1 = StagingFile( staging_folder=MockStagingFolder(), filename=filename diff --git a/mayan/apps/sources/tests/test_models.py b/mayan/apps/sources/tests/test_models.py index 0fbc61ce05..8121566f10 100644 --- a/mayan/apps/sources/tests/test_models.py +++ b/mayan/apps/sources/tests/test_models.py @@ -29,7 +29,7 @@ from ..literals import SOURCE_UNCOMPRESS_CHOICE_Y from ..models.email_sources import EmailBaseModel, IMAPEmail, POP3Email from ..models.watch_folder_sources import WatchFolderSource -from .mocks import MockIMAPServer +from .mocks import MockIMAPServer, MockMailbox from .literals import ( @@ -288,33 +288,9 @@ class IMAPSourceTestCase(GenericDocumentTestCase): class POP3SourceTestCase(GenericDocumentTestCase): auto_upload_document = False - class MockMailbox(object): - def dele(self, which): - return - - def getwelcome(self): - return - - def list(self, which=None): - return (None, ['1 test']) - - def user(self, user): - return - - def pass_(self, pswd): - return - - def quit(self): - return - - def retr(self, which=None): - return ( - 1, [TEST_EMAIL_BASE64_FILENAME] - ) - @mock.patch('poplib.POP3_SSL', autospec=True) def test_download_document(self, mock_poplib): - mock_poplib.return_value = POP3SourceTestCase.MockMailbox() + mock_poplib.return_value = MockMailbox() self.source = POP3Email.objects.create( document_type=self.test_document_type, label='', host='', password='', username='' From 31b1f72b95c4886e4a15345b85d8d9eab0bf52c8 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 3 Nov 2019 18:42:00 -0400 Subject: [PATCH 2/6] Move django_gpg app mock objects to mocks.py Signed-off-by: Roberto Rosario --- mayan/apps/django_gpg/tests/literals.py | 12 +++++++++ mayan/apps/django_gpg/tests/mocks.py | 25 ++++++++++++++++++ mayan/apps/django_gpg/tests/test_models.py | 30 ++++------------------ 3 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 mayan/apps/django_gpg/tests/mocks.py diff --git a/mayan/apps/django_gpg/tests/literals.py b/mayan/apps/django_gpg/tests/literals.py index 3bcbe01ab3..c7dca32a6a 100644 --- a/mayan/apps/django_gpg/tests/literals.py +++ b/mayan/apps/django_gpg/tests/literals.py @@ -4,6 +4,18 @@ import os from django.conf import settings +MOCK_SEARCH_KEYS_RESPONSE = [ + { + 'algo': u'1', + 'date': u'1311475606', + 'expires': u'1643601600', + 'keyid': u'607138F1AECC5A5CA31CB7715F3F7F75D210724D', + 'length': u'2048', + 'type': u'pub', + 'uids': [u'Roberto Rosario '] + } +] + TEST_DETACHED_SIGNATURE = os.path.join( settings.BASE_DIR, 'apps', 'django_gpg', 'tests', 'contrib', 'test_files', 'test_file.txt.asc' diff --git a/mayan/apps/django_gpg/tests/mocks.py b/mayan/apps/django_gpg/tests/mocks.py new file mode 100644 index 0000000000..66c3ba5ac6 --- /dev/null +++ b/mayan/apps/django_gpg/tests/mocks.py @@ -0,0 +1,25 @@ +from __future__ import unicode_literals + +from .literals import TEST_RECEIVE_KEY, TEST_SEARCH_FINGERPRINT + +MOCK_SEARCH_KEYS_RESPONSE = [ + { + 'algo': u'1', + 'date': u'1311475606', + 'expires': u'1643601600', + 'keyid': u'607138F1AECC5A5CA31CB7715F3F7F75D210724D', + 'length': u'2048', + 'type': u'pub', + 'uids': [u'Roberto Rosario '] + } +] + + +def mock_recv_keys(self, keyserver, *keyids): + class ImportResult(object): + count = 1 + fingerprints = [TEST_SEARCH_FINGERPRINT] + + self.import_keys(TEST_RECEIVE_KEY) + + return ImportResult() diff --git a/mayan/apps/django_gpg/tests/test_models.py b/mayan/apps/django_gpg/tests/test_models.py index 5b805e5468..fe02e338b2 100644 --- a/mayan/apps/django_gpg/tests/test_models.py +++ b/mayan/apps/django_gpg/tests/test_models.py @@ -17,32 +17,12 @@ from ..exceptions import ( from ..models import Key from .literals import ( - TEST_DETACHED_SIGNATURE, TEST_FILE, TEST_KEY_DATA, TEST_KEY_FINGERPRINT, - TEST_KEY_PASSPHRASE, TEST_RECEIVE_KEY, TEST_SEARCH_FINGERPRINT, - TEST_SEARCH_UID, TEST_SIGNED_FILE, TEST_SIGNED_FILE_CONTENT + MOCK_SEARCH_KEYS_RESPONSE, TEST_DETACHED_SIGNATURE, TEST_FILE, + TEST_KEY_DATA, TEST_KEY_FINGERPRINT, TEST_KEY_PASSPHRASE, + TEST_SEARCH_FINGERPRINT, TEST_SEARCH_UID, TEST_SIGNED_FILE, + TEST_SIGNED_FILE_CONTENT ) - -MOCK_SEARCH_KEYS_RESPONSE = [ - { - 'algo': u'1', - 'date': u'1311475606', - 'expires': u'1643601600', - 'keyid': u'607138F1AECC5A5CA31CB7715F3F7F75D210724D', - 'length': u'2048', - 'type': u'pub', - 'uids': [u'Roberto Rosario '] - } -] - - -def mock_recv_keys(self, keyserver, *keyids): - class ImportResult(object): - count = 1 - fingerprints = [TEST_SEARCH_FINGERPRINT] - - self.import_keys(TEST_RECEIVE_KEY) - - return ImportResult() +from .mocks import mock_recv_keys class KeyTestCase(BaseTestCase): From ac0e74572ec0ad2da830c7b3ae6cb1868c71a2d6 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 3 Nov 2019 19:06:44 -0400 Subject: [PATCH 3/6] Prepare release notes Signed-off-by: Roberto Rosario --- HISTORY.rst | 8 +-- docs/releases/3.2.9.rst | 124 ++++++++++++++++++++++++++++++++++------ 2 files changed, 109 insertions(+), 23 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index f5f1e1292e..29860aa690 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,4 +1,4 @@ -3.2.9 (2019-XX-XX) +3.2.9 (2019-11-03) ================== - Move IMAPMockServer to its own module. - Display feedback message when testing a mailing profile. @@ -28,17 +28,17 @@ - Fix MAYAN_GUNICORN_TIMEOUT Docker image setting. GitLab issue #671. Thanks to Lennart Sauerbeck (@lennart_s) for the report. - Add makefile target to launch a production staging Docker image. -- Improve duplicated document list view logic to not show +- Improve duplicated document list view logic to not show documents with trashed duplicates. - Backport Docker composer makefile targets. - Add PermissionTestCaseMixin and SmartSettingTestCaseMixin to better organize cache invalidation of both apps for tests. -- Add a version attribute to setting namespace. These are dumped +- Add a version attribute to setting namespace. These are dumped as SMART_SETTINGS_NAMESPACES. - Add savesettings command. - Add extra logging to the IMAP email source. GitLab issue #682. Thanks to Patrick Hütter (@PatrickHuetter) for the report. -- Rename all instances of the IMAP server from mailbox to +- Rename all instances of the IMAP server from mailbox to server for clarity. - Add book link in the about menu. - Add unknown exception handling when checking for the latest diff --git a/docs/releases/3.2.9.rst b/docs/releases/3.2.9.rst index 1fc92c6e77..343ea7d804 100644 --- a/docs/releases/3.2.9.rst +++ b/docs/releases/3.2.9.rst @@ -1,25 +1,30 @@ Version 3.2.9 ============= -Released: October XX, 2019 +Released: November 3, 2019 Changes ------- -- Move IMAPMockServer to its own module. -- Display feedback message when testing a mailing profile. -- Add tests to the platform app. -- Fix platformtemplate command --context option help message. -- Language translations update. -- Add target to run all translations targets. -- Backport color log formatter from branch version/next. -- Don't raise error checking AnonymousUser for permissions. - Instead return always False. -- Enable the main menu workflow runtime link when the workflow view - permission is granted to at least one workflow. -- Make Postgres container wait delay configurable. GitLab issue #677. - Thanks to Antenore Gatta (@antenore) for the report. + +Debugging +^^^^^^^^^ + +The colored log formatter was ported from the versions/next branch. The +color of the log output will be determined by the log level. + +Extra logging was added to the IMAP source to help with import issues. +This relates to GitLab issue #682. + + +Dependencies +^^^^^^^^^^^^ + +The help message of the ``--context`` option of the ``platformtemplate`` +command was fixed to say "YAML" instead of "JSON". + + - Update Django to version 1.11.25. - Update PyYAML to version 5.1.2. - Update celery to version 3.1.26.post2. @@ -29,12 +34,93 @@ Changes - Update Pillow to version 6.2.1. - Move Celery and Django Celery dependencies to the task manager app. -- Improve dependecies app tests. -- Return st_nlink of 1 files in mirrored indexes. GitLab issue #676. - Thanks to Ezio Vernacotola (@eziove) for the report and solution. -- Fix MAYAN_GUNICORN_TIMEOUT Docker image setting. GitLab issue #671. - Thanks to Lennart Sauerbeck (@lennart_s) for the report. + + +Docker +^^^^^^ + +The Mayan EDMS launcher script at get.mayan-edms.com was updated to allow +configuring the wait delay after the PostgreSQL container is launched. The +environment variable for this is called ``DOCKER_POSTGRES_DELAY`` and +defaults to 10 seconds to preserve the existing behavior. This closes +GitLab issue #677. + +A formatting error was fixed enabling again the use of the +MAYAN_GUNICORN_TIMEOUT Docker image setting. Closes GitLab issue #671. + + +Duplicates +^^^^^^^^^^ + +The duplicated document list view logic was improved and will not show +documents with trashed duplicates. + + +Mirroring +^^^^^^^^^ + +Mirrored document entries will now return 1 on their ``st_nlink`` attribute, +fixing access errors in some operating systems. Fixes GitLab issue #676. + + +Permissions +^^^^^^^^^^^ + +Instead of adding check to every API endpoint for authentication, the +permission was updated to return False to any permission check for +anonymous users. This change centralizes this check in a single place +and lowers the probability of error on non authenticated API access. + + +Settings +^^^^^^^^ + +To reduce config file incompatibilities between versions, the setting +namespaces will now include a version attribute. This attribute is +saved along with all the other settings when the ``config.yml`` is saved. +This version attribute will allow apps to read entries in older formats +instead of raising an error. + +A new management command was added, this is the ``savesettings`` command. +This command does the same things as saving a setting from the user interface, +it will update the ``config.yml`` file or create it, if it doesn't exists. + + +Testing +^^^^^^^ + +Several improvements to the test system were ported from unreleased branches. +All the mocked object were moved to their own module called mocks.py for each +respective app. + +Test were added to the platform app and improved for the dependencies app. + +The mixins PermissionTestCaseMixin and SmartSettingTestCaseMixin were added +to better organize cache invalidation of both apps for tests. + + +User interface +^^^^^^^^^^^^^^ + +A message is now displayed when testing a mailing profile. + +Granting the workflow view permission to at least on workflow will now enable +the workflow main menu workflow link. + + +Other changes +^^^^^^^^^^^^^ + +- Language translations update. +- Add makefile target to run all translations targets. - Add makefile target to launch a production staging Docker image. +- Backport Docker composer makefile targets. +- Rename all instances of the IMAP server variable from mailbox to + server for clarity. +- Add book link in the about menu. +- Add unknown exception handling when checking for the latest + version. + Removals From 3bd1fb4e906090ea3d225aac3ed426f47d25d162 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 3 Nov 2019 19:11:09 -0400 Subject: [PATCH 4/6] Bump version to 3.2.9 Signed-off-by: Roberto Rosario --- docs/chapters/development.rst | 1 + mayan/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/chapters/development.rst b/docs/chapters/development.rst index ddca8b1b10..30b0c16f3b 100644 --- a/docs/chapters/development.rst +++ b/docs/chapters/development.rst @@ -502,6 +502,7 @@ Release checklist make generate-setup +#. Commit as version bump. #. Build source package and test: :: diff --git a/mayan/__init__.py b/mayan/__init__.py index c74a4eb196..077fbf891a 100644 --- a/mayan/__init__.py +++ b/mayan/__init__.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals __title__ = 'Mayan EDMS' __version__ = '3.2.9' __build__ = 0x030209 -__build_string__ = 'v3.2.8-28-gda7feed2ef_Tue Oct 29 04:57:27 2019 -0400' +__build_string__ = 'v3.2.8-49-gac0e74572e_Sun Nov 3 19:06:44 2019 -0400' __django_version__ = '1.11' __author__ = 'Roberto Rosario' __author_email__ = 'roberto.rosario@mayan-edms.com' From 7df930ae4c7f21f668d50a7621e2cd60e55b9302 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 3 Nov 2019 19:12:09 -0400 Subject: [PATCH 5/6] Update build string Signed-off-by: Roberto Rosario --- mayan/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mayan/__init__.py b/mayan/__init__.py index 077fbf891a..9da525a2ca 100644 --- a/mayan/__init__.py +++ b/mayan/__init__.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals __title__ = 'Mayan EDMS' __version__ = '3.2.9' __build__ = 0x030209 -__build_string__ = 'v3.2.8-49-gac0e74572e_Sun Nov 3 19:06:44 2019 -0400' +__build_string__ = 'v3.2.9_Sun Nov 3 19:11:09 2019 -0400' __django_version__ = '1.11' __author__ = 'Roberto Rosario' __author_email__ = 'roberto.rosario@mayan-edms.com' From 2f9062f31a337a3811916e6fbcab739413d5e663 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 3 Nov 2019 19:18:45 -0400 Subject: [PATCH 6/6] Update releases chapter of documentation Signed-off-by: Roberto Rosario --- docs/chapters/development.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/chapters/development.rst b/docs/chapters/development.rst index 30b0c16f3b..7ef7b76583 100644 --- a/docs/chapters/development.rst +++ b/docs/chapters/development.rst @@ -530,18 +530,18 @@ Release checklist Release using GitLab CI ----------------------- -#. Switch to the ``releases/all`` branch and merge the latest changes: +#. Delete the corresponding ``releases/`` branch: :: - git checkout releases/all - git merge + git push origin :releases/ -#. Push code to trigger builds: +#. Push the current branch to the corresponding origin ``releases/`` branch: :: - git push + git push origin releases/ -#. Push tag upstream: + +#. Push the new tags: :: git push --tags