Пример #1
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")
Пример #2
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")
Пример #3
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')
Пример #4
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')
Пример #5
0
def test_logout():
    s = _get_session(True)
    User.create_user("BillBixby", "hulkrulez", "*****@*****.**")
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/login/BillBixby", dict(password='******'))
    resp = app.get("/register/logout/")
    assert resp.cookies_set['auth_tkt'] == '""'
Пример #6
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)
Пример #7
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)
Пример #8
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
Пример #9
0
def test_logout():
    s = _get_session(True)
    User.create_user("BillBixby", "hulkrulez", "*****@*****.**")
    app = controllers.make_app()
    app = BespinTestApp(app)
    resp = app.post("/register/login/BillBixby", 
        dict(password='******'))
    resp = app.get("/register/logout/")
    assert resp.cookies_set['auth_tkt'] == '""'
Пример #10
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=[])
Пример #11
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
Пример #12
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=[])
Пример #13
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 == ""
Пример #14
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"
Пример #15
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 == ""
Пример #16
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"