Example #1
0
 def test_init_success(self, mock_rules, mock_enforcer, mock_open):
     policy_file = 'a'
     token_conf = 'b'
     mock_rules.load_json.return_value = 'c'
     policy.init(policy_file, token_conf)
     self.assertEqual(policy._POLICY_FILE, 'a')
     self.assertEqual(policy._TOKEN_CONF, 'b')
Example #2
0
def setup_app(config):
    wsme.init_model()
    token_conf = authentication.get_token_conf(config)
    policy.init(config.authentication.policy_file, token_conf)
    app_conf = dict(config.app)

    app = make_app(app_conf.pop('root'),
                   logging=getattr(config, 'logging', {}),
                   **app_conf)
    logger.info('Starting FMS...')
    return app
Example #3
0
def setup_app(config):
    model.init_model()
    token_conf = authentication._get_token_conf(config)
    policy.init(config.authentication.policy_file, token_conf)
    app_conf = dict(config.app)

    # setting configurations for utils to be used from now and on
    utils.set_utils_conf(config)

    app = make_app(app_conf.pop('root'),
                   logging=getattr(config, 'logging', {}),
                   **app_conf)
    logger.info('Starting CMS...')
    return app
Example #4
0
    def test_init_enforcer_already_exists(self):
        policy._ENFORCER = mock.MagicMock()

        # Nothing should happen when the enforcer already exists, so make sure
        # that no exception is raised
        policy.init('a', 'b')