예제 #1
0
파일: base.py 프로젝트: peterbe/balrog
    def setUp(self):
        app.config['SECRET_KEY'] = 'abc123'
        app.config['DEBUG'] = True
        app.config['CSRF_ENABLED'] = False
        db.setDburi('sqlite:///:memory:')
        db.create()
        db.permissions.t.insert().execute(permission='admin', username='******', data_version=1)
        db.permissions.t.insert().execute(permission='/users/:id/permissions/:permission', username='******', data_version=1)
        db.permissions.t.insert().execute(permission='/releases/:name', username='******', options=json.dumps(dict(product='fake')), data_version=1)
        db.releases.t.insert().execute(name='a', product='a', version='a', data=json.dumps(dict(name='a')), data_version=1)
        db.releases.t.insert().execute(name='ab', product='a', version='a', data=json.dumps(dict(name='ab')), data_version=1)
        db.releases.t.insert().execute(name='b', product='b', version='b', data=json.dumps(dict(name='b')), data_version=1)
        db.releases.t.insert().execute(name='c', product='c', version='c', data=json.dumps(dict(name='c')), data_version=1)
        db.releases.t.insert().execute(name='d', product='d', version='d', data_version=1, data="""
{
    "name": "d",
    "platforms": {
        "p": {
            "locales": {
                "d": {
                    "complete": {
                        "filesize": 1234
                    }
                }
            }
        }
    }
}
""")
        db.rules.t.insert().execute(id=1, priority=100, version='3.5', buildTarget='d', throttle=100, mapping='c', update_type='minor', data_version=1)
        db.rules.t.insert().execute(id=2, priority=100, version='3.3', buildTarget='d', throttle=100, mapping='b', update_type='minor', data_version=1)
        db.rules.t.insert().execute(id=3, priority=100, version='3.5', buildTarget='a', throttle=100, mapping='a', update_type='minor', data_version=1)
        db.rules.t.insert().execute(id=4, priority=80, buildTarget='d', throttle=100, mapping='a', update_type='minor', data_version=1)
        db.rules.t.insert().execute(id=5, priority=80, buildTarget='d', version='3.3', throttle=0, mapping='c', update_type='minor', data_version=1)
        self.client = app.test_client()
예제 #2
0
파일: admin.py 프로젝트: peterbe/balrog
    from optparse import OptionParser
    parser = OptionParser()
    parser.set_defaults(
        db='sqlite:///update.db',
        port=9000,
    )

    parser.add_option("-d", "--db", dest="db", help="database to use, relative to inputdir")
    parser.add_option("-p", "--port", dest="port", type="int", help="port for server")
    parser.add_option("--host", dest="host", default='127.0.0.1', help="host to listen on. for example, 0.0.0.0 binds on all interfaces.")
    parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
        help="Verbose output")
    options, args = parser.parse_args()

    from auslib import log_format
    from auslib.admin.base import app, db

    log_level = logging.INFO
    if options.verbose:
        log_level = logging.DEBUG
    logging.basicConfig(level=log_level, format=log_format)

    db.setDburi(options.db)

    app.config['SECRET_KEY'] = 'abc123'
    app.config['DEBUG'] = True
    def auth(environ, username, password):
        return username == password
    app.wsgi_app = AuthBasicHandler(app.wsgi_app, "Balrog standalone auth", auth)
    app.run(port=options.port, host=options.host)