Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
@ametaireau review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Sep 24, 2015
1 parent 16e3b82 commit 04c1a7b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion syncto/__init__.py
Expand Up @@ -18,14 +18,18 @@
CLIENT_STATE_HEADER = 'X-Client-State'

DEFAULT_SETTINGS = {
'syncto.cache_hmac_secret': 'This is not a secret',
'syncto.cache_hmac_secret': None,
'syncto.cache_credentials_ttl_seconds': 300
}


def main(global_config, **settings):
config = Configurator(settings=settings)

if 'syncto.cache_hmac_secret' not in settings:
raise ValueError(
"Please configure the `syncto.cache_hmac_secret` settings.")

cliquet.initialize(config, __version__, default_settings=DEFAULT_SETTINGS)
config.scan("syncto.views")
return config.make_wsgi_app()
1 change: 1 addition & 0 deletions syncto/tests/support.py
Expand Up @@ -28,6 +28,7 @@ def get_app_settings(self, additional_settings=None):
settings['cliquet.storage_backend'] = 'cliquet.storage.memory'
settings['cliquet.permission_backend'] = 'cliquet.permission.memory'
settings['cliquet.userid_hmac_secret'] = "this is not a secret"
settings['syncto.cache_hmac_secret'] = 'This is not a secret'

if additional_settings is not None:
settings.update(additional_settings)
Expand Down
12 changes: 12 additions & 0 deletions syncto/tests/test_functional.py
Expand Up @@ -6,6 +6,7 @@
from cliquet.tests.support import FormattedErrorMixin
from requests.exceptions import HTTPError
from syncto import AUTHORIZATION_HEADER, CLIENT_STATE_HEADER
from syncto import main as testapp

from .support import BaseWebTest, unittest

Expand All @@ -20,6 +21,17 @@
}


class SettingsMissingTest(BaseWebTest, unittest.TestCase):
def __init__(self, *args, **kwargs):
super(unittest.TestCase, self).__init__(*args, **kwargs)

def test_syncto_cache_hmac_secret_missing(self):
settings = self.get_app_settings()
# Remove the mandatory settings we want to test

This comment has been minimized.

Copy link
@almet

almet Sep 24, 2015

Contributor

Remove the mandatory setting.

del settings['syncto.cache_hmac_secret']
self.assertRaises(ValueError, testapp, {}, **settings)


class FunctionalTest(FormattedErrorMixin, BaseWebTest, unittest.TestCase):

def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit 04c1a7b

Please sign in to comment.