Ejemplo n.º 1
0
    def setUp(self):
        self.blade01_key = None
        with open('tests/resources/blade01.pgp') as f:
            self.blade01_key = f.read()

        self.interface = DebileMasterInterface(
            pgp_keyring=u'tests/resources/keyring')
        NAMESPACE.session = self.session
Ejemplo n.º 2
0
    def test_create_builder(self):
        interface = DebileMasterInterface(pgp_keyring=u'tests/resources/keyring')
        NAMESPACE.session = self.session
        interface.create_builder('blade01', self.blade01_key, ip='10.0.0.1')

        b = self.session.query(Builder).filter_by(name='blade01').one()

        assert b.ssl is None
        assert b.ip == '10.0.0.1'
        assert b.pgp == '7C367D02AF6D20DCF2BFB686E8D62122F818733D'
Ejemplo n.º 3
0
    def setUp(self):
        self.blade01_key = None
        with open('tests/resources/blade01.pgp') as f:
            self.blade01_key = f.read()

        self.interface = DebileMasterInterface(pgp_keyring=u'tests/resources/keyring')
        NAMESPACE.session = self.session
Ejemplo n.º 4
0
def serve(server_addr,
          port,
          auth_method,
          keyfile=None,
          certfile=None,
          ssl_keyring=None,
          pgp_keyring=None):
    logger = logging.getLogger('debile')
    logger.info(
        "Serving on `{server_addr}' on port `{port}'".format(**locals()))
    logger.info("Authentication method: {0}".format(auth_method))
    if auth_method == 'ssl':
        logger.info("Using keyfile=`{keyfile}', certfile=`{certfile}', "
                    "ssl_keyring=`{ssl_keyring}'".format(**locals()))
    logger.info("Using pgp_keyring=`{pgp_keyring}'".format(**locals()))

    server = None
    if auth_method == 'simple':
        server = SimpleAuthXMLRPCServer((server_addr, port),
                                        requestHandler=SimpleAsyncXMLRPCServer,
                                        allow_none=True)

    else:
        server = SecureXMLRPCServer((server_addr, port),
                                    keyfile,
                                    certfile,
                                    ca_certs=ssl_keyring,
                                    requestHandler=AsyncXMLRPCServer,
                                    allow_none=True)

    server.register_introspection_functions()
    server.register_instance(DebileMasterInterface(ssl_keyring, pgp_keyring))
    server.serve_forever()
Ejemplo n.º 5
0
def serve(server, port):
    # Don't move the stuff below above; it would cause a circular
    # import; since it needs some of our kruft. I know it's bad form
    # but I'm tired of it.
    from debile.master.interface import DebileMasterInterface
    logger = logging.getLogger('debile')
    logger.info("Serving on `{server}' on port `{port}'".format(**locals()))
    server = SimpleXMLRPCServer((server, port),
                                requestHandler=AsyncXMLRPCServer,
                                allow_none=True)
    server.register_introspection_functions()
    server.register_instance(DebileMasterInterface())
    server.serve_forever()
Ejemplo n.º 6
0
class DebileInterfaceTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        # setup the database
        if 'DATABASE_URI' in os.environ:
            db_URI = os.environ['DATABASE_URI']
        else:
            # See README.md for the doc
            db_URI = 'postgres://*****:*****@127.0.0.1:5432/debile_tests'
        engine = create_engine(db_URI,
                                implicit_returning=False)

        Session = sessionmaker()
        Session.configure(bind=engine)
        self.session = Session()
        Base.metadata.drop_all(self.session.bind)

        # feed database
        class Args:
            pass
        args = Args()
        args.file = 'tests/resources/debile.yaml'
        args.force = False
        dimport(args, self.session)

        # some more setting up
        u = self.session.query(Person).filter_by(
            email='*****@*****.**'
        ).first()
        NAMESPACE.user = u


    def setUp(self):
        self.blade01_key = None
        with open('tests/resources/blade01.pgp') as f:
            self.blade01_key = f.read()

        self.interface = DebileMasterInterface(pgp_keyring=u'tests/resources/keyring')
        NAMESPACE.session = self.session


    def tearDown(self):
        for f in ('tests/resources/keyring', 'tests/resources/secret-keyring'):
            if os.path.exists(f):
                os.remove(f)


    def test_create_builder(self):
        self.interface.create_builder('blade01', self.blade01_key, ip='10.0.0.1')

        b = self.session.query(Builder).filter_by(name='blade01').one()

        assert b.ssl is None
        assert b.ip == '10.0.0.1'
        assert b.pgp == '7C367D02AF6D20DCF2BFB686E8D62122F818733D'


    def test_create_user_with_simple_auth(self):
        self.interface.create_user('John', '*****@*****.**', self.blade01_key,
                ssl=None, ip='10.0.0.1')

        p = self.session.query(Person).filter_by(name='John').first()

        self.assertEquals(p.name, 'John')
        self.assertEquals(p.email, '*****@*****.**')
        self.assertEquals(p.pgp, '7C367D02AF6D20DCF2BFB686E8D62122F818733D')
        self.assertEquals(p.ip, '10.0.0.1')
        self.assertIsNone(p.ssl)
Ejemplo n.º 7
0
class DebileInterfaceTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        # setup the database
        if 'DATABASE_URI' in os.environ:
            db_URI = os.environ['DATABASE_URI']
        else:
            # See README.md for the doc
            db_URI = 'postgres://*****:*****@127.0.0.1:5432/debile_tests'
        engine = create_engine(db_URI, implicit_returning=False)

        Session = sessionmaker()
        Session.configure(bind=engine)
        self.session = Session()
        Base.metadata.drop_all(self.session.bind)

        # feed database
        class Args:
            pass

        args = Args()
        args.file = 'tests/resources/debile.yaml'
        args.force = False
        dimport(args, self.session)

        # some more setting up
        u = self.session.query(Person).filter_by(
            email='*****@*****.**').first()
        NAMESPACE.user = u

    def setUp(self):
        self.blade01_key = None
        with open('tests/resources/blade01.pgp') as f:
            self.blade01_key = f.read()

        self.interface = DebileMasterInterface(
            pgp_keyring=u'tests/resources/keyring')
        NAMESPACE.session = self.session

    def tearDown(self):
        for f in ('tests/resources/keyring', 'tests/resources/secret-keyring'):
            if os.path.exists(f):
                os.remove(f)

    def test_create_builder(self):
        self.interface.create_builder('blade01',
                                      self.blade01_key,
                                      ip='10.0.0.1')

        b = self.session.query(Builder).filter_by(name='blade01').one()

        assert b.ssl is None
        assert b.ip == '10.0.0.1'
        assert b.pgp == '7C367D02AF6D20DCF2BFB686E8D62122F818733D'

    def test_create_user_with_simple_auth(self):
        self.interface.create_user('John',
                                   '*****@*****.**',
                                   self.blade01_key,
                                   ssl=None,
                                   ip='10.0.0.1')

        p = self.session.query(Person).filter_by(name='John').first()

        self.assertEquals(p.name, 'John')
        self.assertEquals(p.email, '*****@*****.**')
        self.assertEquals(p.pgp, '7C367D02AF6D20DCF2BFB686E8D62122F818733D')
        self.assertEquals(p.ip, '10.0.0.1')
        self.assertIsNone(p.ssl)