Repository: fedora-infra/bodhi

Issue:
Rename the prefer_ssl setting
Bodhi has a ```prefer_ssl``` setting, which doesn't do what it sounds like it does at all because it's only used when ```libravatar_dns``` is ```True```, and is only used by ```libravatar``` and not generally all of Bodhi. We should rename it to something that makes that clearer, like ```libravatar_prefer_tls```.

This is a backwards incompatible change and should be done in an X release.


Discussion:
Well, you could make a new setting and make it override the `prefer_ssl` setting if that's not set?

Resolving patch:
diff --git a/bodhi/server/config.py b/bodhi/server/config.py
--- a/bodhi/server/config.py
+++ b/bodhi/server/config.py
@@ -477,6 +477,9 @@ class BodhiConfig(dict):
         'libravatar_enabled': {
             'value': True,
             'validator': _validate_bool},
+        'libravatar_prefer_tls': {
+            'value': True,
+            'validator': bool},
         'mail.templates_basepath': {
             'value': 'bodhi:server/email/templates/',
             'validator': str},
@@ -534,9 +537,6 @@ class BodhiConfig(dict):
         'pdc_url': {
             'value': 'https://pdc.fedoraproject.org/',
             'validator': _validate_tls_url},
-        'prefer_ssl': {
-            'value': None,
-            'validator': _validate_none_or(bool)},
         'privacy_link': {
             'value': '',
             'validator': str},
diff --git a/bodhi/server/util.py b/bodhi/server/util.py
--- a/bodhi/server/util.py
+++ b/bodhi/server/util.py
@@ -347,7 +347,7 @@ def avatar(context, username, size):
 
     # context is a mako context object
     request = context['request']
-    https = request.registry.settings.get('prefer_ssl')
+    https = request.registry.settings.get('libravatar_prefer_tls')
 
     @request.cache.cache_on_arguments()
     def get_libravatar_url(openid, https, size):


Test patch:
diff --git a/bodhi/tests/server/test_util.py b/bodhi/tests/server/test_util.py
--- a/bodhi/tests/server/test_util.py
+++ b/bodhi/tests/server/test_util.py
@@ -45,8 +45,9 @@ def cache_on_arguments():
 
         self.assertEqual(util.avatar(context, 'bowlofeggs', 50), 'libravatar.org')
 
-    @mock.patch.dict(config,
-                     {'libravatar_enabled': True, 'libravatar_dns': True, 'prefer_ssl': False})
+    @mock.patch.dict(
+        config,
+        {'libravatar_enabled': True, 'libravatar_dns': True, 'libravatar_prefer_tls': False})
     @mock.patch('bodhi.server.util.libravatar.libravatar_url', return_value='cool url')
     def test_libravatar_dns_set_ssl_false(self, libravatar_url):
         """Test the correct return value when libravatar_dns is set in config."""
@@ -63,8 +64,9 @@ def cache_on_arguments():
         libravatar_url.assert_called_once_with(openid='http://bowlofeggs.id.fedoraproject.org/',
                                                https=False, size=50, default='retro')
 
-    @mock.patch.dict(config,
-                     {'libravatar_enabled': True, 'libravatar_dns': True, 'prefer_ssl': True})
+    @mock.patch.dict(
+        config,
+        {'libravatar_enabled': True, 'libravatar_dns': True, 'libravatar_prefer_tls': True})
     @mock.patch('bodhi.server.util.libravatar.libravatar_url', return_value='cool url')
     def test_libravatar_dns_set_ssl_true(self, libravatar_url):
         """Test the correct return value when libravatar_dns is set in config."""