From b293abaa52bffa705f4012d9726296c21db482c8 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Thu, 12 May 2016 22:28:35 +0200 Subject: [bug] check if 'enabled' field exist in the Identity document - Related: #7961 --- src/leap/mx/couchdbhelper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/leap/mx/couchdbhelper.py b/src/leap/mx/couchdbhelper.py index e9cf4a4..f17466d 100644 --- a/src/leap/mx/couchdbhelper.py +++ b/src/leap/mx/couchdbhelper.py @@ -100,13 +100,14 @@ class ConnectedCouchDB(client.CouchDB): pubkey = None if result["rows"]: doc = result["rows"][0]["doc"] - if doc["enabled"]: + if "enabled" not in doc or doc["enabled"]: uuid = doc["user_id"] if "keys" in doc: pubkey = doc["keys"]["pgp"] return uuid, pubkey d.addCallback(_get_uuid_and_pubkey_cbk) + d.addErrback(lambda _: (None, None)) return d def getPubkey(self, uuid): -- cgit v1.2.3 From 43f670bec64cf52ff2ecc9f548735b25f6c14076 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Fri, 13 May 2016 09:14:13 -0400 Subject: [pkg] remove old changes notes --- changes/bug_6937_remove-syslog-option | 2 -- changes/feature_6942_use_syslog | 1 - changes/feature_7272-msg-key-not-found | 1 - changes/feature_7435_unit_testing | 1 - changes/feature_7439_remove_provenance | 1 - changes/feature_7565_couchdb_refactor | 1 - 6 files changed, 7 deletions(-) delete mode 100644 changes/bug_6937_remove-syslog-option delete mode 100644 changes/feature_6942_use_syslog delete mode 100644 changes/feature_7272-msg-key-not-found delete mode 100644 changes/feature_7435_unit_testing delete mode 100644 changes/feature_7439_remove_provenance delete mode 100644 changes/feature_7565_couchdb_refactor diff --git a/changes/bug_6937_remove-syslog-option b/changes/bug_6937_remove-syslog-option deleted file mode 100644 index d3a65c3..0000000 --- a/changes/bug_6937_remove-syslog-option +++ /dev/null @@ -1,2 +0,0 @@ - o Remove logging to syslog for now. We should only do this in the future, - when the platform is ready for it. Closes #6937. diff --git a/changes/feature_6942_use_syslog b/changes/feature_6942_use_syslog deleted file mode 100644 index ffa8f62..0000000 --- a/changes/feature_6942_use_syslog +++ /dev/null @@ -1 +0,0 @@ -- Use syslog for logging (Closes: #6859) diff --git a/changes/feature_7272-msg-key-not-found b/changes/feature_7272-msg-key-not-found deleted file mode 100644 index 2d82df8..0000000 --- a/changes/feature_7272-msg-key-not-found +++ /dev/null @@ -1 +0,0 @@ -- return a more meaningful msg if user exists but has no key (Closes: #7272) diff --git a/changes/feature_7435_unit_testing b/changes/feature_7435_unit_testing deleted file mode 100644 index 32778b7..0000000 --- a/changes/feature_7435_unit_testing +++ /dev/null @@ -1 +0,0 @@ -- set up unit testing infrastructure (Closes: #7435) diff --git a/changes/feature_7439_remove_provenance b/changes/feature_7439_remove_provenance deleted file mode 100644 index 188b9a2..0000000 --- a/changes/feature_7439_remove_provenance +++ /dev/null @@ -1 +0,0 @@ -- Don't add X-Leap-Provenance header (Closes: #7439) diff --git a/changes/feature_7565_couchdb_refactor b/changes/feature_7565_couchdb_refactor deleted file mode 100644 index dc6ac0b..0000000 --- a/changes/feature_7565_couchdb_refactor +++ /dev/null @@ -1 +0,0 @@ -- Update code to the new CouchDatabase soledad code -- cgit v1.2.3 From ab8d10520a6ecb01ac0357a397697df3ed50d331 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Fri, 13 May 2016 09:16:59 -0400 Subject: [pkg] add changelog for 0.8.1 --- CHANGELOG.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 31fba49..b1824a7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,10 @@ +0.8.1 - 13 May, 2016 ++++++++++++++++++++++++++++++++ + +Bugfixes +~~~~~~~~ +- `#7961 `_: Deleted account crashes leap-mx + 0.8.0 - 18 Apr, 2016 +++++++++++++++++++++++++++++++ -- cgit v1.2.3 From 800c2167ca332e7b59072a1c928cbb9ba996f369 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 12 May 2016 18:59:24 -0400 Subject: [style] improve readability --- src/leap/mx/couchdbhelper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/leap/mx/couchdbhelper.py b/src/leap/mx/couchdbhelper.py index f17466d..50275ca 100644 --- a/src/leap/mx/couchdbhelper.py +++ b/src/leap/mx/couchdbhelper.py @@ -100,7 +100,8 @@ class ConnectedCouchDB(client.CouchDB): pubkey = None if result["rows"]: doc = result["rows"][0]["doc"] - if "enabled" not in doc or doc["enabled"]: + user_enabled = doc.get('enabled', True) + if user_enabled: uuid = doc["user_id"] if "keys" in doc: pubkey = doc["keys"]["pgp"] -- cgit v1.2.3 From eec79703d4f09580b20b06f1c8ca16d4068e128f Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Wed, 18 May 2016 12:19:35 -0400 Subject: [pkg] update to new versioneer json format --- setup.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 7523222..dee8c0b 100644 --- a/setup.py +++ b/setup.py @@ -72,14 +72,20 @@ class freeze_debianver(Command): # unpacked source archive. Distribution tarballs contain a pre-generated copy # of this file. -version_version = '{version}' -full_revisionid = '{full_revisionid}' -""" - templatefun = r""" - -def get_versions(default={}, verbose=False): - return {'version': version_version, - 'full-revisionid': full_revisionid} +import json +import sys + +version_json = ''' +{ + "dirty": false, + "error": null, + "full-revisionid": "FULL_REVISIONID", + "version": "VERSION_STRING" +} +''' # END VERSION_JSON + +def get_versions(): + return json.loads(version_json) """ def initialize_options(self): @@ -94,9 +100,9 @@ def get_versions(default={}, verbose=False): if proceed != "y": print("He. You scared. Aborting.") return - subst_template = self.template.format( - version=VERSION_SHORT, - full_revisionid=VERSION_REVISION) + self.templatefun + subst_template = self.template.replace( + 'VERSION_STRING', VERSION_SHORT).replace( + 'FULL_REVISIONID', VERSION_REVISION) versioneer_cfg = versioneer.get_config_from_root('.') with open(versioneer_cfg.versionfile_source, 'w') as f: f.write(subst_template) -- cgit v1.2.3 From cb3128966983c26d747bee1e6a79242e9512c21f Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Thu, 26 Jan 2017 20:09:04 +0100 Subject: [test] run the tests with tox and py.test - Resolves: #14 --- .gitignore | 3 ++- README.md | 14 ++++++++++++++ pkg/requirements-testing.pip | 6 ++++++ setup.cfg | 20 ++++++++++++++++---- tox.ini | 14 ++++++++++++++ 5 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 173cac5..dc8af53 100644 --- a/.gitignore +++ b/.gitignore @@ -25,9 +25,10 @@ PKG-INFO pip-log.txt # Unit test / coverage reports +docs/cov_html/ .coverage .tox -nosetests.xml +.cache # Translations *.mo diff --git a/README.md b/README.md index c78b14b..cd55f6d 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,20 @@ Please use that for bug reports and feature requests instead of github's tracker. We're using github for code commenting and review between collaborators. +### Running Tests + +You need tox to run the tests. If you don't have it in your system yet:: + +~~~ +$ pip install tox +~~~ + +And then run all the tests:: + +~~~ +$ tox +~~~ + ## Issues * see the [Changelog](./CHANGELOG) for details of all major changes in the different versions diff --git a/pkg/requirements-testing.pip b/pkg/requirements-testing.pip index 94b8e9c..322f1e8 100644 --- a/pkg/requirements-testing.pip +++ b/pkg/requirements-testing.pip @@ -1,2 +1,8 @@ pep8 +flake8 +coverage +pytest +pytest-pep8 +pytest-cov +pytest-pdb setuptools-trial diff --git a/setup.cfg b/setup.cfg index d8a5cc1..b58cc41 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,6 @@ -[aliases] -test = trial - [pep8] exclude = versioneer.py,_version.py,*.egg,build,dist,docs -ignore = E731 +ignore = E731 E402 [flake8] exclude = versioneer.py,_version.py,*.egg,build,dist,docs @@ -15,3 +12,18 @@ style = pep440 versionfile_source = src/leap/mx/_version.py versionfile_build = leap/mx/_version.py tag_prefix = + +[tool:pytest] +pep8ignore = + * E731 E402 + docs/conf.py ALL + versioneer.py ALL + _version.py ALL + *.egg ALL + *_rc.py ALL + +[coverage:run] +branch = True + +[coverage:html] +directory = doc/cov_html diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..417bd18 --- /dev/null +++ b/tox.ini @@ -0,0 +1,14 @@ +[tox] +envlist = py27 +skipsdist=True + +[testenv] +commands = py.test --cov-report=html \ + --cov-report=term \ + --cov=leap.mx \ + --pep8 {posargs} +usedevelop = True +deps = + -r{toxinidir}/pkg/requirements-testing.pip +setenv = + HOME=/tmp -- cgit v1.2.3 From 0e8d052856be24aaffc5dee738de8f07e2322d02 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Thu, 26 Jan 2017 22:51:45 +0100 Subject: [test] add gitlab CI --- .gitlab-ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..49844b4 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,8 @@ +stages: + - test + +test: + image: leapcode/soledad:latest + stage: test + script: + - tox --recreate -- cgit v1.2.3 From 7a870fdc4471702146fc4ff8a6acae1d560b2984 Mon Sep 17 00:00:00 2001 From: Thais Siqueira Date: Thu, 12 Jan 2017 15:31:08 -0200 Subject: [pkg] Configure systemd to auto-restart. --- pkg/leap-mx.service | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/leap-mx.service b/pkg/leap-mx.service index 5852ee8..d5a18a7 100644 --- a/pkg/leap-mx.service +++ b/pkg/leap-mx.service @@ -5,6 +5,7 @@ Before=postfix.service [Service] ExecStart=/usr/bin/python /usr/bin/twistd -n --rundir=/var/lib/leap_mx/ --python=/usr/share/app/mx.tac --syslog --prefix=leap-mx --pidfile=/tmp/leap-mx.pid User=leap-mx +Restart=always [Install] WantedBy=multi-user.target -- cgit v1.2.3 From c02c73fea4901edd4002c3a317295c252ae426ca Mon Sep 17 00:00:00 2001 From: Thais Siqueira Date: Tue, 24 Jan 2017 18:48:08 -0200 Subject: Returns doc as None if we have some error during the encryption When we had an error during encryption, the doc property "_enc_json" was empty and we were saving this empty data on CouchDb. Then it was causing the [GNUPG:] NODATA 2 error during decryption. Related with: https://github.com/pixelated/pixelated-user-agent/issues/908 with @tayanefernandes --- src/leap/mx/mail_receiver.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py index 7c5a368..b8eb2ae 100644 --- a/src/leap/mx/mail_receiver.py +++ b/src/leap/mx/mail_receiver.py @@ -202,14 +202,22 @@ class MailReceiver(Service): with openpgp.TempGPGWrapper(gpgbinary='/usr/bin/gpg') as gpg: gpg.import_keys(pubkey) key = gpg.list_keys().pop() + + encryption_result = gpg.encrypt( + json.dumps(data, ensure_ascii=False), + key["fingerprint"], + symmetric=False) + + if encryption_result.ok == False: + log.msg("_encrypt_message: Encryption Failed" + "Status: %r" % (encryption_result.status,)) + return None + doc.content = { self.INCOMING_KEY: True, self.ERROR_DECRYPTING_KEY: False, ENC_SCHEME_KEY: EncryptionSchemes.PUBKEY, - ENC_JSON_KEY: str(gpg.encrypt( - json.dumps(data, ensure_ascii=False), - key["fingerprint"], - symmetric=False)) + ENC_JSON_KEY: str(encryption_result) } return doc -- cgit v1.2.3 From 28936b276cc2fa8f3572c9248ed4bc5bef4ea7c4 Mon Sep 17 00:00:00 2001 From: drebs Date: Fri, 27 Jan 2017 11:25:46 -0200 Subject: [style] pep8 fixes --- src/leap/mx/mail_receiver.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py index b8eb2ae..b200772 100644 --- a/src/leap/mx/mail_receiver.py +++ b/src/leap/mx/mail_receiver.py @@ -204,13 +204,13 @@ class MailReceiver(Service): key = gpg.list_keys().pop() encryption_result = gpg.encrypt( - json.dumps(data, ensure_ascii=False), - key["fingerprint"], - symmetric=False) + json.dumps(data, ensure_ascii=False), + key["fingerprint"], + symmetric=False) - if encryption_result.ok == False: - log.msg("_encrypt_message: Encryption Failed" - "Status: %r" % (encryption_result.status,)) + if not encryption_result.ok: + log.msg("_encrypt_message: Encryption failed with status: %r" + % (encryption_result.status,)) return None doc.content = { -- cgit v1.2.3