def test_cookie_settings(self): # Ensure that if a user specifies a cookie domain which isn't a string, # an error is raised. self.app.config['STORMPATH_COOKIE_DOMAIN'] = 1 self.assertRaises(ConfigurationError, check_settings, self.app.config) # Now that we've configured things properly, it should work. self.app.config['STORMPATH_COOKIE_DOMAIN'] = 'test' check_settings(self.app.config) # Ensure that if a user specifies a cookie duration which isn't a # timedelta object, an error is raised. self.app.config['STORMPATH_COOKIE_DURATION'] = 1 self.assertRaises(ConfigurationError, check_settings, self.app.config) # Now that we've configured things properly, it should work. self.app.config['STORMPATH_COOKIE_DURATION'] = timedelta(minutes=1) check_settings(self.app.config)
def test_facebook_settings(self): # Ensure that if the user has Facebook login enabled, they've specified # the correct settings. self.app.config['STORMPATH_ENABLE_FACEBOOK'] = True self.assertRaises(ConfigurationError, check_settings, self.app.config) # Ensure that things don't work if not all social configs are specified. self.app.config['STORMPATH_SOCIAL'] = {} self.assertRaises(ConfigurationError, check_settings, self.app.config) self.app.config['STORMPATH_SOCIAL'] = {'FACEBOOK': {}} self.assertRaises(ConfigurationError, check_settings, self.app.config) self.app.config['STORMPATH_SOCIAL']['FACEBOOK']['app_id'] = 'xxx' self.assertRaises(ConfigurationError, check_settings, self.app.config) # Now that we've configured things properly, it should work. self.app.config['STORMPATH_SOCIAL']['FACEBOOK']['app_secret'] = 'xxx' check_settings(self.app.config)
def test_google_settings(self): # Ensure that if the user has Google login enabled, they've specified # the correct settings. self.app.config['STORMPATH_ENABLE_GOOGLE'] = True self.assertRaises(ConfigurationError, check_settings, self.app.config) # Ensure that things don't work if not all social configs are specified. self.app.config['STORMPATH_SOCIAL'] = {} self.assertRaises(ConfigurationError, check_settings, self.app.config) self.app.config['STORMPATH_SOCIAL'] = {'GOOGLE': {}} self.assertRaises(ConfigurationError, check_settings, self.app.config) self.app.config['STORMPATH_SOCIAL']['GOOGLE']['client_id'] = 'xxx' self.assertRaises(ConfigurationError, check_settings, self.app.config) # Now that we've configured things properly, it should work. self.app.config['STORMPATH_SOCIAL']['GOOGLE']['client_secret'] = 'xxx' check_settings(self.app.config)
def test_requires_api_credentials(self): # We'll remove our default API credentials, and ensure we get an # exception raised. self.app.config['STORMPATH_API_KEY_ID'] = None self.app.config['STORMPATH_API_KEY_SECRET'] = None self.app.config['STORMPATH_API_KEY_FILE'] = None self.assertRaises(ConfigurationError, check_settings, self.app.config) # Now we'll check to see that if we specify an API key ID and secret # things work. self.app.config['STORMPATH_API_KEY_ID'] = environ.get('STORMPATH_API_KEY_ID') self.app.config['STORMPATH_API_KEY_SECRET'] = environ.get('STORMPATH_API_KEY_SECRET') check_settings(self.app.config) # Now we'll check to see that if we specify an API key file things work. self.app.config['STORMPATH_API_KEY_ID'] = None self.app.config['STORMPATH_API_KEY_SECRET'] = None self.app.config['STORMPATH_API_KEY_FILE'] = self.file check_settings(self.app.config)
def test_requires_api_credentials(self): # We'll remove our default API credentials, and ensure we get an # exception raised. self.app.config['STORMPATH_API_KEY_ID'] = None self.app.config['STORMPATH_API_KEY_SECRET'] = None self.app.config['STORMPATH_API_KEY_FILE'] = None self.assertRaises(ConfigurationError, check_settings, self.app.config) # Now we'll check to see that if we specify an API key ID and secret # things work. self.app.config['STORMPATH_API_KEY_ID'] = environ.get( 'STORMPATH_API_KEY_ID') self.app.config['STORMPATH_API_KEY_SECRET'] = environ.get( 'STORMPATH_API_KEY_SECRET') check_settings(self.app.config) # Now we'll check to see that if we specify an API key file things work. self.app.config['STORMPATH_API_KEY_ID'] = None self.app.config['STORMPATH_API_KEY_SECRET'] = None self.app.config['STORMPATH_API_KEY_FILE'] = self.file check_settings(self.app.config)