Repository: EFForg/starttls-policy-cli

Issue:
Config parser schema contains field not present in format spec
[Field Enforcer](https://github.com/EFForg/starttls-policy-cli/blob/687dbbf99b683eebceb524fb93286d5ebfe57204/starttls_policy_cli/util.py#L102-L105) ∉ [Format Spec](https://github.com/EFForg/starttls-everywhere/blob/master/RULES.md)

Discussion:

Patch:
diff --git a/starttls_policy_cli/policy.py b/starttls_policy_cli/policy.py
index b4ab17a..8b5aedb 100644
--- a/starttls_policy_cli/policy.py
+++ b/starttls_policy_cli/policy.py
@@ -210,7 +210,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):
@@ -238,6 +237,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):