Example #1
0
def test():
    from custodia.compat import configparser
    from custodia.log import setup_logging
    from .interface import IPA_SECTIONNAME

    parser = configparser.ConfigParser(
        interpolation=configparser.ExtendedInterpolation()
    )
    parser.read_string(u"""
    [auth:ipa]
    handler = IPAInterface
    [store:ipa_vault]
    handler = IPAVault
    """)

    setup_logging(debug=True, auditfile=None)
    config = {
        'authenticators': {
            'ipa': IPAInterface(parser, IPA_SECTIONNAME)
        }
    }
    v = IPAVault(parser, 'store:ipa_vault')
    v.finalize_init(config, parser, None)
    v.set('foo', 'bar', replace=True)
    print(v.get('foo'))
    print(v.list())
    v.cut('foo')
    print(v.list())
Example #2
0
def main():
    args = argparser.parse_args()
    config = parse_config(args)
    log.setup_logging(config['debug'], config['auditlog'])
    logger.debug('Config file %s loaded', args.configfile)
    httpd = HTTPServer(config['server_url'], config)
    httpd.serve()
Example #3
0
def test():
    from custodia.compat import configparser
    from custodia.log import setup_logging
    from .interface import IPA_SECTIONNAME
    from .vault import IPAVault

    parser = configparser.ConfigParser(
        interpolation=configparser.ExtendedInterpolation())
    parser.read_string(u"""
    [auth:ipa]
    handler = IPAInterface
    [store:ipa_vault]
    handler = IPAVault
    [store:ipa_certreq]
    handler = IPAVault
    backing_store = ipa_vault
    """)

    setup_logging(debug=True, auditfile=None)
    config = {'authenticators': {'ipa': IPAInterface(parser, IPA_SECTIONNAME)}}
    vault = IPAVault(parser, 'store:ipa_vault')
    vault.finalize_init(config, parser, None)
    s = IPACertRequest(parser, 'store:ipa_certreq')
    s.store = vault
    s.finalize_init(config, parser, None)
    print(s.get('keys/HTTP/client1.ipa.example'))
    print(s.get('keys/HTTP/client1.ipa.example'))
    print(s.cut('keys/HTTP/client1.ipa.example'))
Example #4
0
def main(argparser=None):
    if argparser is None:
        argparser = default_argparser
    args = argparser.parse_args()
    config = parse_config(args)
    log.setup_logging(config['debug'], config['auditlog'])
    logger.debug('Config file %s loaded', args.configfile)
    httpd = HTTPServer(config['server_url'], config)
    httpd.serve()
Example #5
0
def main(argparser=None):
    args = _parse_args(argparser=argparser)
    # parse arguments and populate config with basic settings
    cfgparser, config = _parse_config(args)
    # initialize logging
    log.setup_logging(config['debug'], config['auditlog'])
    logger.info('Custodia instance %s', args.instance or '<main>')
    logger.debug('Config file(s) %s loaded', config['configfiles'])
    # load plugins after logging
    _load_plugins(config, cfgparser)
    # create and run server
    httpd = HTTPServer(config['server_url'], config)
    httpd.serve()
Example #6
0
def main(argparser=None):
    if argparser is None:
        argparser = default_argparser
    args = argparser.parse_args()
    # parse arguments and populate config with basic settings
    config = {}
    cfgparser = _parse_config(args, config)
    # initialize logging
    log.setup_logging(config['debug'], config['auditlog'])
    logger.debug('Config file %s loaded', args.configfile)
    # load plugins after logging
    _load_plugins(config, cfgparser)
    # create and run server
    httpd = HTTPServer(config['server_url'], config)
    httpd.serve()
Example #7
0
def main():
    args = parse_args()

    log.setup_logging(debug=args.debug, auditfile=None)

    try:
        result = args.func(args)
    except BaseException as e:  # pylint: disable=broad-except
        errcode, msg = error_message(args, e)
        main_parser.exit(errcode, msg)
    else:
        if result is not None:
            if isinstance(result, list):
                print('\n'.join(result))
            else:
                print(result)
Example #8
0
                    revocation_reason=self.revocation_reason,
                )
            return certs


if __name__ == '__main__':
    from custodia.compat import configparser
    from custodia.log import setup_logging
    from custodia.store.sqlite import SqliteStore

    parser = configparser.ConfigParser(
        interpolation=configparser.ExtendedInterpolation())
    parser.read_string(u"""
    [auth:ipa]
    handler = IPAInterface
    [store:sqlite]
    handler = SqliteStore
    dburi = /tmp/test.sqlite
    [store:ipa_certreq]
    handler = IPAVault
    backing_store = sqlite
    """)

    setup_logging(debug=True, auditfile=None)
    IPAInterface(parser, 'auth:ipa')
    s = IPACertRequest(parser, 'store:ipa_certreq')
    s.store = SqliteStore(parser, 'store:sqlite')
    print(s.get('HTTP/client1.ipa.example'))
    print(s.get('HTTP/client1.ipa.example'))
    print(s.cut('HTTP/client1.ipa.example'))
Example #9
0
import pytest

from custodia.log import ProvisionalWarning, setup_logging

# deprecated APIs raise an exception
warnings.simplefilter('error', category=DeprecationWarning)
# ignore pytest warnings
warnings.filterwarnings('ignore',
                        category=DeprecationWarning,
                        module='_pytest\..*')
# silence our own warnings about provisional APIs
warnings.simplefilter('ignore', category=ProvisionalWarning)

# don't spam stderr with log messages
logging.getLogger().handlers[:] = []
setup_logging(debug=False, auditfile=None, handler=logging.NullHandler())

SKIP_SERVERTEST = "--skip-servertests"


def pytest_addoption(parser):
    parser.addoption(SKIP_SERVERTEST,
                     action="store_true",
                     help="Skip integration tests")


def pytest_runtest_setup(item):
    skip_servertest = item.config.getoption(SKIP_SERVERTEST)
    if skip_servertest and item.get_marker("servertest") is not None:
        # args has --skip-servertests and test is marked as servertest
        pytest.skip("Skip integration test")
Example #10
0
def loghandler(request):
    orig_handlers = logging.getLogger().handlers[:]
    handler = logging.handlers.BufferingHandler(10240)
    log.setup_logging(debug=False, auditfile=None, handler=handler)
    yield handler
    logging.getLogger().handlers = orig_handlers