ripgrep

Options:

For example *.py or **/templates/**/*.html or datasette/** or !setup.py

datasette/tests/test_auth.py

32      """A valid actor cookie sets request.scope['actor']"""
33      cookie = app_client.actor_cookie({"id": "test"})
34      response = app_client.get("/", cookies={"ds_actor": cookie})
35      assert {"id": "test"} == app_client.ds._last_request.scope["actor"]
36  
39      cookie = app_client.actor_cookie({"id": "test"})
40      # Break the signature
41      response = app_client.get("/", cookies={"ds_actor": cookie[:-1] + "."})
42      assert None == app_client.ds._last_request.scope["actor"]
43      # Break the cookie format
44      cookie = app_client.ds.sign({"b": {"id": "test"}}, "actor")
45      response = app_client.get("/", cookies={"ds_actor": cookie})
46      assert None == app_client.ds._last_request.scope["actor"]
47  
59          {"a": {"id": "test"}, "e": baseconv.base62.encode(expires_at)}, "actor"
60      )
61      response = app_client.get("/", cookies={"ds_actor": cookie})
62      assert expected == app_client.ds._last_request.scope["actor"]
63  

datasette/tests/test_canned_queries.py

246     assert 200 == canned_write_client.get("/data/update_name").status
247     cookies = {"ds_actor": canned_write_client.actor_cookie({"id": "root"})}
248     assert 200 == canned_write_client.get("/data/delete_name", cookies=cookies).status
249     assert 200 == canned_write_client.get("/data/update_name", cookies=cookies).status
250 
251 

datasette/tests/test_internal_db.py

6       cookie = app_client.actor_cookie({"id": "root"})
7       assert app_client.get("/_internal").status == 403
8       assert app_client.get("/_internal", cookies={"ds_actor": cookie}).status == 200
9   
10  

datasette/tests/test_html.py

1591    if actor_id:
1592        cookies = {"ds_actor": app_client.actor_cookie({"id": actor_id})}
1593    html = app_client.get("/", cookies=cookies).text
1594    soup = Soup(html, "html.parser")
1595    details = soup.find("nav").find("details")

datasette/tests/test_messages.py

22      set_msg_response = app_client.get("/fixtures.message?add_msg=xmessagex")
23      # Now access a page that displays messages
24      response = app_client.get("/", cookies=set_msg_response.cookies)
25      # Messages should be in that HTML
26      assert "xmessagex" in response.text

datasette/tests/test_permissions.py

230         # But for logged in user all of these should work:
231         cookies = {"ds_actor": client.actor_cookie({"id": "root"})}
232         response_text = client.get("/fixtures", cookies=cookies).text
233         assert form_fragment in response_text
234         assert 200 == client.get("/fixtures?sql=select+1", cookies=cookies).status
235         assert (
236             200
237             == client.get("/fixtures/facet_cities?_where=id=3", cookies=cookies).status
238         )
239 
314     # With the cookie it should work
315     cookie = app_client.actor_cookie({"id": "root"})
316     response = app_client.get("/-/permissions", cookies={"ds_actor": cookie})
317     assert response.status == 200
318     # Should show one failure and one success

datasette/tests/test_plugins.py

686     with make_app_client(template_dir=templates) as client:
687         response1 = client.get("/add-message/")
688         response2 = client.get("/render-message/", cookies=response1.cookies)
689         assert 200 == response2.status
690         assert "Hello from messages" in response2.text

datasette-auth-github/tests/test_datasette_auth_github.py

187         )
188         cookies = {"ds_actor": auth_response.cookies["ds_actor"]}
189     databases = await ds.client.get("/.json", cookies=cookies)
190     assert set(databases.json().keys()) == expected_databases

datasette-configure-fts/tests/test_configure_fts.py

226         if authenticate:
227             cookies = {"ds_actor": ds.sign({"a": {"id": "root"}}, "actor")}
228         response = await client.get("http://localhost/data/creatures", cookies=cookies)
229         assert response.status_code == 200
230         fragment = '<li><a href="/-/configure-fts/data?table=creatures">Configure full-text search</a></li>'

datasette-edit-schema/tests/test_edit_schema.py

45          if authenticate:
46              cookies = {"ds_actor": ds.sign({"a": {"id": "root"}}, "actor")}
47          response = await client.get("http://localhost/data/creatures", cookies=cookies)
48          assert response.status_code == 200
49          fragment = (
274         assert response.status_code == 403
275         # Should deny with someuser cookie
276         response = await client.get("http://localhost" + path, cookies=someuser_cookies)
277         assert response.status_code == 403
278         # Should allow with root cookies

datasette-import-table/tests/test_import_table.py

40      cookies = {"ds_actor": datasette.sign({"a": {"id": "root"}}, "actor")}
41      async with httpx.AsyncClient(app=datasette.app()) as client:
42          response = await client.get("http://localhost/-/import-table", cookies=cookies)
43          assert 200 == response.status_code
44          csrftoken = response.cookies["ds_csrftoken"]

datasette-ripgrep/tests/test_ripgrep.py

223         if authenticated:
224             cookies["ds_actor"] = datasette.sign({"a": {"id": "user"}}, "actor")
225         response = await datasette.client.get(path, cookies=cookies)
226         assert response.status_code == expected_status
227     finally:

datasette-upload-csvs/tests/test_datasette_upload_csvs.py

40              if auth:
41                  cookies = {"ds_actor": ds.sign({"a": {"id": "root"}}, "actor")}
42              response = await client.get("http://localhost/", cookies=cookies)
43              assert 200 == response.status_code
44              if auth:
61      # First test the upload page exists
62      async with httpx.AsyncClient(app=datasette.app()) as client:
63          response = await client.get("http://localhost/-/upload-csvs", cookies=cookies)
64          assert 200 == response.status_code
65          assert b'<form action="/-/upload-csvs" method="post"' in response.content