def setup_module():
    global app, app_murdoc
    config.set_profile('test')
    app = controllers.make_app()
    app = BespinTestApp(app)
    app_murdoc = controllers.make_app()
    app_murdoc = BespinTestApp(app_murdoc)
    
    _install_test_plugin_path()
    config.activate_profile()
def _reset():
    Base.metadata.drop_all(bind=config.c.dbengine)
    Base.metadata.create_all(bind=config.c.dbengine)
    fsroot = config.c.fsroot
    if fsroot.exists() and fsroot.basename() == "testfiles":
        fsroot.rmtree()
    fsroot.makedirs()

    global session
    session = config.c.session_factory()
    num_users = session.query(User).count()
    assert_equals(num_users, 0)
    session.commit()

    global mattb, zuck, tom, ev, joe
    mattb = User.create_user("mattb", "mattb", "mattb")
    zuck = User.create_user("zuck", "zuck", "zuck")
    tom = User.create_user("tom", "tom", "tom")
    ev = User.create_user("ev", "ev", "ev")
    joe = User.create_user("joe", "joe", "joe")
    group = joe.add_group("group")
    group.add_member(mattb)
    group.add_member(zuck)
    group.add_member(tom)
    group.add_member(ev)

    global app
    app = controllers.make_app()
    app = BespinTestApp(app)
    app.post("/register/login/joe", dict(password="******"))
Ejemplo n.º 3
0
def start():
    """Starts the BespinServer on localhost port 8080 for development.
    
    You can change the port and allow remote connections by setting
    server.port or server.address on the command line.
    
    paver server.address=your.ip.address server.port=8000 start
    
    will allow remote connections (assuming you don't have a firewall
    blocking the connection) and start the server on port 8000.
    """
    # automatically install Dojo if it's not there already
    if not (options.dojo.destination / "dojo").exists():
        dojo()
    
    from bespin import config, controllers
    from paste.httpserver import serve
    
    options.order('server')
    
    config.set_profile('dev')
    
    if options.server.try_build:
        config.c.static_dir = (options.build_dir / "frontend").abspath()
    
    if options.server.dburl:
        config.c.dburl = options.server.dburl
    
    if options.server.async:
        config.c.async_jobs = True
        config.c.queue_path = path.getcwd() / "queue.db"
    
    config.activate_profile()
    port = int(options.port)
    serve(controllers.make_app(), options.address, port, use_threadpool=True)
Ejemplo n.º 4
0
def _reset():
    Base.metadata.drop_all(bind=config.c.dbengine)
    Base.metadata.create_all(bind=config.c.dbengine)
    fsroot = config.c.fsroot
    if fsroot.exists() and fsroot.basename() == "testfiles":
        fsroot.rmtree()
    fsroot.makedirs()

    global session
    session = config.c.session_factory()
    num_users = session.query(User).count()
    assert_equals(num_users, 0)
    session.commit()

    global mattb, zuck, tom, ev, joe
    mattb = User.create_user("mattb", "mattb", "mattb")
    zuck = User.create_user("zuck", "zuck", "zuck")
    tom = User.create_user("tom", "tom", "tom")
    ev = User.create_user("ev", "ev", "ev")
    joe = User.create_user("joe", "joe", "joe")
    group = joe.add_group("group")
    group.add_member(mattb)
    group.add_member(zuck)
    group.add_member(tom)
    group.add_member(ev)

    global app
    app = controllers.make_app()
    app = BespinTestApp(app)
    app.post("/register/login/joe", dict(password="******"))
Ejemplo n.º 5
0
def test_login_without_cookie():
    s = _get_session(True)
    User.create_user("BillBixby", "hulkrulez", "*****@*****.**")
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/login/BillBixby", dict(password="******"))
    assert resp.cookies_set['auth_tkt']
Ejemplo n.º 6
0
def test_bad_login_yields_401():
    s = _get_session(True)
    User.create_user("BillBixby", "hulkrulez", "*****@*****.**")
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/login/BillBixby",
        dict(password="******"), status=401)
Ejemplo n.º 7
0
def test_register_and_verify_user():
    config.activate_profile()
    _clear_db()
    s = _get_session()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    assert resp.content_type == "application/json"
    data = simplejson.loads(resp.body)
    assert data == {}
    assert resp.cookies_set['auth_tkt']
    assert app.cookies
    billbixby = User.find_user("BillBixby")
    sample_project = get_project(billbixby, billbixby, "SampleProject")
    files = [file.name for file in sample_project.list_files()]
    assert "readme.txt" in files

    # should be able to run again without an exception appearing
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"),
                    status=409)

    # with the cookie set, we should be able to retrieve the
    # logged in name
    resp = app.get('/register/userinfo/')
    assert resp.content_type == 'application/json'
    data = simplejson.loads(resp.body)
    assert data['username'] == 'BillBixby'
    assert 'quota' in data
    assert data['quota'] == 15728640
    assert 'amountUsed' in data

    resp = app.get("/file/at/BespinSettings/config")
    app.post("/file/close/BespinSettings/config")
Ejemplo n.º 8
0
def test_register_and_verify_user():
    config.activate_profile()
    _clear_db()
    s = _get_session()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    assert resp.content_type == "application/json"
    data = simplejson.loads(resp.body)
    assert data == {}
    assert resp.cookies_set['auth_tkt']
    assert app.cookies
    billbixby = User.find_user("BillBixby")
    sample_project = get_project(billbixby, billbixby, "SampleProject")
    files = [file.name for file in sample_project.list_files()]
    assert "readme.txt" in files
    
    # should be able to run again without an exception appearing
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"),
                    status=409)
    
    # with the cookie set, we should be able to retrieve the 
    # logged in name
    resp = app.get('/register/userinfo/')
    assert resp.content_type == 'application/json'
    data = simplejson.loads(resp.body)
    assert data['username'] == 'BillBixby'
    assert 'quota' in data
    assert data['quota'] == 15728640
    assert 'amountUsed' in data
    
    resp = app.get("/file/at/BespinSettings/config")
    app.post("/file/close/BespinSettings/config")
Ejemplo n.º 9
0
def test_bad_login_yields_401():
    s = _get_session(True)
    User.create_user("BillBixby", "hulkrulez", "*****@*****.**")
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/login/BillBixby",
                    dict(password="******"),
                    status=401)
Ejemplo n.º 10
0
def test_bad_ticket_is_ignored():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/Aldus", dict(password="******", 
                                        email="*****@*****.**"))
    app.cookies['auth_tkt'] = app.cookies['auth_tkt'][:-1]
    resp = app.get("/preview/at/SampleProjectFor%3AAldus/index.html", status=401)
Ejemplo n.º 11
0
def test_login_without_cookie():
    s = _get_session(True)
    User.create_user("BillBixby", "hulkrulez", "*****@*****.**")
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/login/BillBixby",
        dict(password="******"))
    assert resp.cookies_set['auth_tkt']
Ejemplo n.º 12
0
def test_userinfo_also_returns_capabilities():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/BillBixby", dict(email="*****@*****.**", password="******"))
    resp = app.get("/register/userinfo/")
    data = simplejson.loads(resp.body)
    print data
    assert "serverCapabilities" in data
Ejemplo n.º 13
0
def test_bad_ticket_is_ignored():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/Aldus", dict(password="******",
                                                email="*****@*****.**"))
    app.cookies['auth_tkt'] = app.cookies['auth_tkt'][:-1]
    resp = app.get("/preview/at/SampleProjectFor%3AAldus/index.html",
                   status=401)
Ejemplo n.º 14
0
def test_static_files_with_auth():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.get('/editor.html', status=302)
    assert resp.location == "http://localhost/"
    resp = app.post('/register/new/Aldus', dict(password="******", 
                                                email="*****@*****.**"))
    resp = app.get('/editor.html')
Ejemplo n.º 15
0
def test_logout():
    s, user_manager = _get_user_manager(True)
    user_manager.create_user("BillBixby", "hulkrulez", "*****@*****.**")
    app = controllers.make_app()
    app = TestApp(app)
    resp = app.post("/register/login/BillBixby", 
        dict(password='******'))
    resp = app.get("/register/logout/")
    assert resp.cookies_set['auth_tkt'] == '""'
Ejemplo n.º 16
0
def test_static_files_with_auth():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.get('/editor.html', status=302)
    assert resp.location == "http://localhost/"
    resp = app.post('/register/new/Aldus', dict(password="******",
                                                email="*****@*****.**"))
    resp = app.get('/editor.html')
Ejemplo n.º 17
0
def test_server_capabilities():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/BillBixby", dict(email="*****@*****.**", password="******"))
    resp = app.get("/capabilities/")
    assert resp.content_type == "application/json"
    data = simplejson.loads(resp.body)
    print data
    assert data == dict(capabilities=["vcs"], dojoModulePath={}, javaScriptPlugins=[])
Ejemplo n.º 18
0
def test_userinfo_also_returns_capabilities():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    resp = app.get('/register/userinfo/')
    data = simplejson.loads(resp.body)
    print data
    assert 'serverCapabilities' in data
Ejemplo n.º 19
0
def setup_module(module):
    global app, session
    config.set_profile('test')
    config.activate_profile()
    Base.metadata.drop_all(bind=config.c.dbengine)
    Base.metadata.create_all(bind=config.c.dbengine)
    session = config.c.session_factory()
    User.create_user("BillBixby", "", "*****@*****.**")
    app = controllers.make_app()
    app = BespinTestApp(app)
    app.post("/register/login/BillBixby", dict(password=""))
Ejemplo n.º 20
0
def test_username_with_bad_characters():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/Thinga%20Majig",
            dict(password="******", email="thinga@majig"), status=400)
    resp = app.post("/register/new/Thinga<majig>",
            dict(password="******", email="thinga@majig"), status=400)
    resp = app.post("/register/new/Thing/", 
                    dict(password="******", email="thinga@majig"), status=400)
    resp = app.post("/register/new/..", 
                    dict(password="******", email="thinga@majig"), status=400)
Ejemplo n.º 21
0
def setup_module(module):
    global user_manager, app, session
    config.set_profile('test')
    config.activate_profile()
    model.Base.metadata.drop_all(bind=config.c.dbengine)
    model.Base.metadata.create_all(bind=config.c.dbengine)
    session = config.c.sessionmaker(bind=config.c.dbengine)
    user_manager = model.UserManager(session)
    user_manager.create_user("BillBixby", "", "*****@*****.**")
    app = controllers.make_app()
    app = TestApp(app)
    app.post("/register/login/BillBixby", dict(password=""))
Ejemplo n.º 22
0
def test_server_capabilities():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    resp = app.get("/capabilities/")
    assert resp.content_type == "application/json"
    data = simplejson.loads(resp.body)
    print data
    assert data == dict(capabilities=["vcs"],
                        dojoModulePath={},
                        javaScriptPlugins=[])
Ejemplo n.º 23
0
def test_register_existing_user_should_not_authenticate():
    s = _get_session(True)
    app_orig = controllers.make_app()
    app = BespinTestApp(app_orig)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    app = BespinTestApp(app_orig)
    resp = app.post("/register/new/BillBixby",
                    dict(email="*****@*****.**", password="******"),
                    status=409)
    assert not resp.cookies_set
    user = User.find_user("BillBixby", 'notangry')
    assert user is not None
Ejemplo n.º 24
0
def test_register_existing_user_should_not_authenticate():
    s, user_manager = _get_user_manager(True)
    app_orig = controllers.make_app()
    app = TestApp(app_orig)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    app = TestApp(app_orig)
    resp = app.post("/register/new/BillBixby", dict(email="*****@*****.**",
                                                    password="******"),
                    status=409)
    assert not resp.cookies_set
    user = user_manager.get_user("BillBixby")
    assert user.password == 'notangry'
Ejemplo n.º 25
0
def test_register_existing_user_should_not_authenticate():
    s = _get_session(True)
    app_orig = controllers.make_app()
    app = BespinTestApp(app_orig)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    app = BespinTestApp(app_orig)
    resp = app.post("/register/new/BillBixby", dict(email="*****@*****.**",
                                                    password="******"),
                    status=409)
    assert not resp.cookies_set
    user = User.find_user("BillBixby", 'notangry')
    assert user is not None
Ejemplo n.º 26
0
def test_password_change_bad_code():
    config.set_profile("test")
    config.activate_profile()
    _clear_db()

    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    app.reset()

    resp = app.post('/register/password/BillBixby',
                    dict(code="42", newPassword="******"),
                    status=400)
Ejemplo n.º 27
0
def test_get_users_settings():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/macgyver",
                    dict(password="******", email="*****@*****.**"))
    resp = app.put("/file/at/BespinSettings/settings", """
vcsuser Mack Gyver <*****@*****.**>

""")
    s = _get_session()
    macgyver = User.find_user("macgyver")
    settings = macgyver.get_settings()
    assert settings == dict(vcsuser="******")
Ejemplo n.º 28
0
def test_get_users_settings():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/macgyver",
        dict(password="******", email="*****@*****.**"))
    resp = app.put("/file/at/BespinSettings/settings", """
vcsuser Mack Gyver <*****@*****.**>

""")
    s = _get_session()
    macgyver = User.find_user("macgyver")
    settings = macgyver.get_settings()
    assert settings == dict(vcsuser="******")
Ejemplo n.º 29
0
def test_username_with_bad_characters():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/Thinga%20Majig",
                    dict(password="******", email="thinga@majig"),
                    status=400)
    resp = app.post("/register/new/Thinga<majig>",
                    dict(password="******", email="thinga@majig"),
                    status=400)
    resp = app.post("/register/new/Thing/",
                    dict(password="******", email="thinga@majig"),
                    status=400)
    resp = app.post("/register/new/..",
                    dict(password="******", email="thinga@majig"),
                    status=400)
Ejemplo n.º 30
0
def test_password_change_bad_code():
    config.set_profile("test")
    config.activate_profile()
    _clear_db()
    
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    app.reset()
    
    resp = app.post('/register/password/BillBixby', dict( 
                                            code="42",
                                            newPassword="******"),
                    status=400)
    
Ejemplo n.º 31
0
def test_lost_username(send_text_email):
    config.set_profile("test")
    config.activate_profile()
    _clear_db()

    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))

    resp = app.post('/register/lost/', dict(email='*****@*****.**'))
    assert send_text_email.called
    args = send_text_email.call_args[0]
    assert args[0] == '*****@*****.**'
    assert args[1].startswith("Your username for ")
    assert "Your username is:" in args[2]
    assert "BillBixby" in args[2]
Ejemplo n.º 32
0
def test_lost_username(send_text_email):
    config.set_profile("test")
    config.activate_profile()
    _clear_db()
    
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    
    resp = app.post('/register/lost/', dict(email='*****@*****.**'))
    assert send_text_email.called
    args = send_text_email.call_args[0]
    assert args[0] == '*****@*****.**'
    assert args[1].startswith("Your username for ")
    assert "Your username is:" in args[2]
    assert "BillBixby" in args[2]
Ejemplo n.º 33
0
def test_password_change_with_confirmation_code():
    config.set_profile("test")
    config.activate_profile()
    _clear_db()

    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    app.reset()

    user = User.find_user("BillBixby")
    verify_code = controllers._get_password_verify_code(user)
    resp = app.post('/register/password/BillBixby',
                    dict(code=verify_code, newPassword="******"))

    user = User.find_user('BillBixby', 'hatetraffic')
    assert user
Ejemplo n.º 34
0
def test_users_can_be_locked_out():
    config.set_profile("test")
    config.c.login_failure_tracking = "memory"
    config.c.login_attempts = "1"
    config.c.lockout_period = "1"
    config.activate_profile()
    app = controllers.make_app()
    app = BespinTestApp(app)
    _clear_db()
    
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    resp = app.post("/register/login/BillBixby",
        dict(password="******"), status=401)
    
    # fail with good password now, because we're locked out
    resp = app.post("/register/login/BillBixby",
        dict(password="******"), status=401)
Ejemplo n.º 35
0
def test_password_change_with_confirmation_code():
    config.set_profile("test")
    config.activate_profile()
    _clear_db()
    
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    app.reset()
    
    user = User.find_user("BillBixby")
    verify_code = controllers._get_password_verify_code(user)
    resp = app.post('/register/password/BillBixby', dict( 
                                            code=verify_code,
                                            newPassword="******"))
    
    user = User.find_user('BillBixby', 'hatetraffic')
    assert user
Ejemplo n.º 36
0
def test_lost_password_request(send_text_email):
    config.set_profile("test")
    config.activate_profile()
    _clear_db()
    
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby', dict(email="*****@*****.**",
                                                    password="******"))
    
    app.reset()
    resp = app.post('/register/lost/', dict(username='******'))
    assert send_text_email.called
    args = send_text_email.call_args[0]
    assert args[0] == '*****@*****.**'
    assert args[1].startswith("Requested password change for ")
    user = User.find_user("BillBixby")
    verify_code = controllers._get_password_verify_code(user)
    assert verify_code in args[2]
Ejemplo n.º 37
0
def test_lost_password_request(send_text_email):
    config.set_profile("test")
    config.activate_profile()
    _clear_db()

    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))

    app.reset()
    resp = app.post('/register/lost/', dict(username='******'))
    assert send_text_email.called
    args = send_text_email.call_args[0]
    assert args[0] == '*****@*****.**'
    assert args[1].startswith("Requested password change for ")
    user = User.find_user("BillBixby")
    verify_code = controllers._get_password_verify_code(user)
    assert verify_code in args[2]
Ejemplo n.º 38
0
def test_users_can_be_locked_out():
    config.set_profile("test")
    config.c.login_failure_tracking = "memory"
    config.c.login_attempts = "1"
    config.c.lockout_period = "1"
    config.activate_profile()
    app = controllers.make_app()
    app = BespinTestApp(app)
    _clear_db()

    resp = app.post('/register/new/BillBixby',
                    dict(email="*****@*****.**", password="******"))
    resp = app.post("/register/login/BillBixby",
                    dict(password="******"),
                    status=401)

    # fail with good password now, because we're locked out
    resp = app.post("/register/login/BillBixby",
                    dict(password="******"),
                    status=401)
Ejemplo n.º 39
0
def test_messages_sent_from_server_to_user():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/macgyver",
        dict(password="******", email="*****@*****.**"))
    s = _get_session()
    macgyver = User.find_user("macgyver")
    assert len(macgyver.messages) == 0
    macgyver.publish(dict(my="message"))
    s.commit()
    resp = app.post("/messages/")
    assert resp.content_type == "application/json"
    data = simplejson.loads(resp.body)
    assert len(data) == 1
    assert data[0] == dict(my="message")
    
    # the message should be consumed
    resp = app.post("/messages/")
    data = simplejson.loads(resp.body)
    assert len(data) == 0
Ejemplo n.º 40
0
def test_messages_sent_from_server_to_user():
    _clear_db()
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/new/macgyver",
                    dict(password="******", email="*****@*****.**"))
    s = _get_session()
    macgyver = User.find_user("macgyver")
    assert len(macgyver.messages) == 0
    macgyver.publish(dict(my="message"))
    s.commit()
    resp = app.post("/messages/")
    assert resp.content_type == "application/json"
    data = simplejson.loads(resp.body)
    assert len(data) == 1
    assert data[0] == dict(my="message")

    # the message should be consumed
    resp = app.post("/messages/")
    data = simplejson.loads(resp.body)
    assert len(data) == 0
Ejemplo n.º 41
0
def start():
    """Starts the BespinServer on localhost port 8080 for development.
    
    You can change the port and allow remote connections by setting
    server.port or server.address on the command line.
    
    paver server.address=your.ip.address server.port=8000 start
    
    will allow remote connections (assuming you don't have a firewall
    blocking the connection) and start the server on port 8000.
    """
    # automatically install Dojo if it's not there already
    if not (options.dojo.destination / "dojo").exists():
        dojo()

    from bespin import config, controllers
    from paste.httpserver import serve

    options.order('server')

    config.set_profile('dev')

    if options.server.try_build:
        config.c.static_dir = (options.build_dir / "frontend").abspath()

    if options.server.dburl:
        config.c.dburl = options.server.dburl

    if options.server. async:
        config.c.async_jobs = True

    config_file = options.server.config_file
    if config_file.exists():
        info("Loading config: %s", config_file)
        code = compile(config_file.bytes(), config_file, "exec")
        exec code in {}

    config.activate_profile()
    port = int(options.port)
    serve(controllers.make_app(), options.address, port, use_threadpool=True)
def start():
    """Starts the BespinServer on localhost port 8080 for development.
    
    You can change the port and allow remote connections by setting
    server.port or server.address on the command line.
    
    paver server.address=your.ip.address server.port=8000 start
    
    will allow remote connections (assuming you don't have a firewall
    blocking the connection) and start the server on port 8000.
    """
    from bespin import config, controllers
    from paste.httpserver import serve

    options.order('server')

    config.set_profile('dev')

    if options.staticdir:
        config.c.static_dir = path(options.clientdir) / options.staticdir

    if options.server.dburl:
        config.c.dburl = options.server.dburl

    if options.server. async:
        config.c.async_jobs = True

    config.c.server_base_url = options.server_base_url

    config_file = options.server.config_file
    if config_file.exists():
        info("Loading config: %s", config_file)
        code = compile(config_file.bytes(), config_file, "exec")
        exec code in {}

    config.activate_profile()
    port = int(options.port)
    serve(controllers.make_app(), options.address, port, use_threadpool=True)
Ejemplo n.º 43
0
def start():
    """Starts the BespinServer on localhost port 8080 for development.
    
    You can change the port and allow remote connections by setting
    server.port or server.address on the command line.
    
    paver server.address=your.ip.address server.port=8000 start
    
    will allow remote connections (assuming you don't have a firewall
    blocking the connection) and start the server on port 8000.
    """
    from bespin import config, controllers
    from paste.httpserver import serve
    
    options.order('server')
    
    config.set_profile('dev')
    
    if options.staticdir:
        config.c.static_dir = path(options.clientdir) / options.staticdir
    
    if options.server.dburl:
        config.c.dburl = options.server.dburl
    
    if options.server.async:
        config.c.async_jobs = True
    
    config.c.server_base_url = options.server_base_url
    
    config_file = options.server.config_file
    if config_file.exists():
        info("Loading config: %s", config_file)
        code = compile(config_file.bytes(), config_file, "exec")
        exec code in {}
    
    config.activate_profile()
    port = int(options.port)
    serve(controllers.make_app(), options.address, port, use_threadpool=True)
def setup_module(module):
    global app
    config.set_profile('test')
    app = controllers.make_app()
    app = BespinTestApp(app)
    logging.basicConfig(level=logging.DEBUG)
Ejemplo n.º 45
0
def dev_factory(config):
    from bespin.controllers import make_app
    return make_app()
Ejemplo n.º 46
0
def test_auth_required():
    app = controllers.make_app()
    app = BespinTestApp(app)
    app.post('/settings/', {'foo' : 'bar'}, status=401)
    app.get('/settings/', status=401)
    app.get('/settings/foo', status=401)
Ejemplo n.º 47
0
def test_api_version_header():
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.get("/register/userinfo/", status=401)
    assert resp.headers.get("X-Bespin-API") == "dev"
Ejemplo n.º 48
0
def setup_module(module):
    global app
    config.set_profile('test')
    app = controllers.make_app()
    app = TestApp(app)
Ejemplo n.º 49
0
def setup_module(module):
    global app
    config.set_profile('test')
    app = controllers.make_app()
    app = BespinTestApp(app)
Ejemplo n.º 50
0
def test_api_version_header():
    app = controllers.make_app()
    app = BespinTestApp(app)    
    resp = app.get("/register/userinfo/", status=401)
    assert resp.headers.get("X-Bespin-API") == "dev"
Ejemplo n.º 51
0
def test_register_returns_empty_when_not_logged_in():
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.get('/register/userinfo/', status=401)
    assert resp.body == ""
Ejemplo n.º 52
0
def setup_module(module):
    global app
    config.set_profile("test")
    app = controllers.make_app()
    app = BespinTestApp(app)
Ejemplo n.º 53
0
def test_register_returns_empty_when_not_logged_in():
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.get('/register/userinfo/', status=401)
    assert resp.body == ""
Ejemplo n.º 54
0
def dev_factory(config):
    from bespin.controllers import make_app
    return make_app()