Repository: EFForg/starttls-policy-cli

Issue:
policy.py: Deprecation Warning
Run of testsuite showed to me following warning:

```
starttls_policy_cli/policy.py:220
  /home/user/starttls-policy-cli/starttls_policy_cli/policy.py:220: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    class Config(MergableConfig, collections.Mapping):
```

This issue should be addressed ASAP because Python 3.8.0 has already reached alpha 2 release.

Comments:

Patch:
diff --git a/starttls_policy_cli/policy.py b/starttls_policy_cli/policy.py
index b4ab17a..1cb0212 100644
--- a/starttls_policy_cli/policy.py
+++ b/starttls_policy_cli/policy.py
@@ -1,5 +1,4 @@
 """ Policy config wrapper """
-import collections
 import logging
 import datetime
 import io
@@ -8,6 +7,12 @@ import six
 from starttls_policy_cli import util
 from starttls_policy_cli import constants
 
+try:
+    # Python 3.3+
+    from collections.abc import Mapping
+except ImportError:
+    from collections import Mapping
+
 logger = logging.getLogger(__name__)
 logger.addHandler(logging.StreamHandler())
 
@@ -210,7 +215,6 @@ class PolicyNoAlias(Policy):
     @property
     def policy_alias(self):
         """ This type of policy can't be aliased. Returns None."""
-        pass
 
     @policy_alias.setter
     def policy_alias(self, value):
@@ -218,7 +222,7 @@ class PolicyNoAlias(Policy):
         # pylint: disable=unused-argument
         raise util.ConfigError('PolicyNoAlias object cannot have policy-alias field!')
 
-class Config(MergableConfig, collections.Mapping):
+class Config(MergableConfig, Mapping):
     """Class for retrieving properties in TLS Policy config.
     If `policy_aliases` is specified, they must be set before `policies`,
     so policy format validation can work properly.
@@ -238,6 +242,7 @@ class Config(MergableConfig, collections.Mapping):
             yield domain
 
     def keys(self):
+        """ Returns iterable over policies even if this attribute is not set """
         if self.policies is None:
             return set([])
         return self.policies.keys()
diff --git a/starttls_policy_cli/util.py b/starttls_policy_cli/util.py
index 8f7da53..6b703a7 100644
--- a/starttls_policy_cli/util.py
+++ b/starttls_policy_cli/util.py
@@ -103,20 +103,14 @@ TLS_VERSIONS = ('TLSv1', 'TLSv1.1', 'TLSv1.2', 'TLSv1.3')
 ENFORCE_MODES = ('testing', 'enforce')
 
 POLICY_SCHEMA = {
-        'min-tls-version': {
-            'enforce': partial(enforce_in, TLS_VERSIONS),
-            'default': 'TLSv1.2',
-            },
         'mode': {
             'enforce': partial(enforce_in, ENFORCE_MODES),
             'default': 'testing',
             },
-        # TODO (#50) Validate mxs as FQDNs (using public suffix list)
         'mxs': {
             'enforce': partial(enforce_list, partial(enforce_type, six.string_types)),
             'default': [],
             },
-        # TODO (#50) Validate reporting endpoint as https: or mailto:
         'policy-alias': partial(enforce_type, six.string_types),
 }
 


Test patch:
diff --git a/starttls_policy_cli/tests/policy_test.py b/starttls_policy_cli/tests/policy_test.py
index 81a8fb1..994c7bd 100644
--- a/starttls_policy_cli/tests/policy_test.py
+++ b/starttls_policy_cli/tests/policy_test.py
@@ -16,7 +16,6 @@ test_json = '{\
         "timestamp": "2014-05-26T01:35:33+0000",\
         "policies": {\
             ".valid.example-recipient.com": {\
-                "min-tls-version": "TLSv1.1",\
                     "mode": "enforce",\
                     "mxs": [".valid.example-recipient.com"]\
             }\
@@ -166,8 +165,8 @@ class TestConfig(unittest.TestCase):
         with self.assertRaises(util.ConfigError):
             policy.Config().policies = {'invalid': invalid_policy}
         conf = policy.Config()
-        conf.policies = {'valid': {}}
-        self.assertEqual(conf.get_policy_for('valid').min_tls_version, 'TLSv1.2')
+        conf.policies = {'valid': {'mxs': ['example.com']}}
+        self.assertEqual(conf.get_policy_for('valid').mxs, ['example.com'])
 
     def test_set_aliased_policy(self):
         conf = policy.Config()
@@ -175,7 +174,7 @@ class TestConfig(unittest.TestCase):
         with self.assertRaises(util.ConfigError):
             conf.policies = {'invalid': {'policy-alias': 'invalid'}}
         conf.policies = {'valid': {'policy-alias': 'valid'}}
-        self.assertEqual(conf.get_policy_for('valid').min_tls_version, 'TLSv1.2')
+        self.assertEqual(conf.get_policy_for('valid').mode, 'testing')
 
     def test_iter_policies_aliased(self):
         conf = policy.Config()
@@ -226,23 +225,10 @@ class TestPolicy(unittest.TestCase):
         self.assertFalse('eff.org' in new_conf.mxs)
         self.assertTrue('example.com' in new_conf.mxs)
 
-    def test_tls_version_default(self):
-        p = policy.Policy({})
-        self.assertEqual(p.min_tls_version, 'TLSv1.2')
-
     def test_mode_default(self):
         p = policy.Policy({})
         self.assertEqual(p.mode, 'testing')
 
-    def test_tls_version_valid(self):
-        with self.assertRaises(util.ConfigError):
-            policy.Policy({'min-tls-version': 'SSLv3'})
-        p = policy.Policy({})
-        with self.assertRaises(util.ConfigError):
-            p.min_tls_version = 'SSLv3'
-        p.min_tls_version = 'TLSv1.1'
-        self.assertEqual(p.min_tls_version, 'TLSv1.1')
-
     def test_mode_valid(self):
         p = policy.Policy({})
         with self.assertRaises(util.ConfigError):