@@ -33,7 +33,7 @@ async def test_restrict_access():
33
33
},
34
34
)
35
35
app = datasette .app ()
36
- paths = ("/-/actor.json" , "/" , "/:memory: " , "/-/metadata" )
36
+ paths = ("/-/actor.json" , "/" , "/_memory " , "/-/metadata" )
37
37
async with httpx .AsyncClient (app = app ) as client :
38
38
# All pages should 403 and show login form
39
39
for path in paths :
@@ -144,26 +144,26 @@ async def test_indieauth_flow(
144
144
expected_error ,
145
145
):
146
146
httpx_mock .add_response (
147
- url = me . rstrip ( "/" ) ,
148
- data = b '<link rel="authorization_endpoint" href="https://indieauth.simonwillison.net/auth">' ,
147
+ url = me ,
148
+ text = '<link rel="authorization_endpoint" href="https://indieauth.simonwillison.net/auth">' ,
149
149
)
150
150
httpx_mock .add_response (
151
151
url = "https://indieauth.simonwillison.net/auth" ,
152
152
method = "POST" ,
153
- data = auth_response_body . encode ( "utf-8" ) ,
153
+ text = auth_response_body ,
154
154
status_code = auth_response_status ,
155
155
)
156
156
if not expected_error :
157
157
httpx_mock .add_response (
158
158
url = "https://indieauth.simonwillison.net/index.php/author/simonw/" ,
159
159
method = "GET" ,
160
- data = b '<link rel="authorization_endpoint" href="https://indieauth.simonwillison.net/auth">' ,
160
+ text = '<link rel="authorization_endpoint" href="https://indieauth.simonwillison.net/auth">' ,
161
161
)
162
162
if "indieauth.simonwillison.com" in auth_response_body :
163
163
httpx_mock .add_response (
164
- url = "https://indieauth.simonwillison.com" ,
164
+ url = "https://indieauth.simonwillison.com/ " ,
165
165
method = "GET" ,
166
- data = b '<link rel="authorization_endpoint" href="https://indieauth.simonwillison.net/auth">' ,
166
+ text = '<link rel="authorization_endpoint" href="https://indieauth.simonwillison.net/auth">' ,
167
167
)
168
168
datasette = Datasette ([], memory = True )
169
169
app = datasette .app ()
@@ -251,7 +251,7 @@ async def test_indieauth_done_no_params_error():
251
251
(
252
252
"https://simonwillison.net/" ,
253
253
{
254
- "https://simonwillison.net" : "No link here" ,
254
+ "https://simonwillison.net/ " : "No link here" ,
255
255
# "https://indieauth.simonwillison.net/auth": "me=https%3A%2F%2Findieauth.simonwillison.net%2Findex.php%2Fauthor%2Fsimonw%2F&scope",
256
256
},
257
257
"Invalid IndieAuth identifier - no authorization_endpoint found" ,
@@ -267,7 +267,7 @@ async def test_indieauth_errors(httpx_mock, me, bodies, expected_error):
267
267
for url , body in bodies .items ():
268
268
httpx_mock .add_response (
269
269
url = url ,
270
- data = body . encode ( "utf-8" ) ,
270
+ text = body ,
271
271
)
272
272
datasette = Datasette ([], memory = True )
273
273
app = datasette .app ()
@@ -310,10 +310,10 @@ async def test_invalid_ds_indieauth_cookie(bad_cookie):
310
310
311
311
@pytest .mark .asyncio
312
312
async def test_invalid_url (httpx_mock ):
313
- def raise_timeout (request , ext ):
313
+ def raise_timeout (request ):
314
314
raise httpx .ReadTimeout (f"HTTP error occurred" , request = request )
315
315
316
- httpx_mock .add_callback (raise_timeout , url = "http://invalid" )
316
+ httpx_mock .add_callback (raise_timeout , url = "http://invalid/ " )
317
317
318
318
datasette = Datasette ([], memory = True )
319
319
app = datasette .app ()
@@ -332,17 +332,17 @@ def raise_timeout(request, ext):
332
332
async def test_non_matching_authorization_endpoint (httpx_mock ):
333
333
# See https://github.com/simonw/datasette-indieauth/issues/22
334
334
httpx_mock .add_response (
335
- url = "https://simonwillison.net" ,
336
- data = b '<link rel="authorization_endpoint" href="https://indieauth.simonwillison.net/auth">' ,
335
+ url = "https://simonwillison.net/ " ,
336
+ text = '<link rel="authorization_endpoint" href="https://indieauth.simonwillison.net/auth">' ,
337
337
)
338
338
httpx_mock .add_response (
339
339
url = "https://indieauth.simonwillison.net/auth" ,
340
340
method = "POST" ,
341
- data = "me=https%3A%2F%2Fsimonwillison.net%2Fme" . encode ( "utf-8" ) ,
341
+ text = "me=https%3A%2F%2Fsimonwillison.net%2Fme" ,
342
342
)
343
343
httpx_mock .add_response (
344
344
url = "https://simonwillison.net/me" ,
345
- data = b '<link rel="authorization_endpoint" href="https://example.com">' ,
345
+ text = '<link rel="authorization_endpoint" href="https://example.com">' ,
346
346
)
347
347
datasette = Datasette ([], memory = True )
348
348
app = datasette .app ()
0 commit comments