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")
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')
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'] == '""'
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)
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
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=[])
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
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=[])
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 == ""
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"