@@ -69,22 +69,29 @@ def _runner_test_various_file_slash(client, file_uri):
69
69
wait_for_all_checks (client )
70
70
res = client .get (url_for ("index" ))
71
71
72
+ substrings = [b"URLs with hostname components are not permitted" , b"No connection adapters were found for" ]
73
+
74
+
72
75
# If it is enabled at test time
73
76
if strtobool (os .getenv ('ALLOW_FILE_URI' , 'false' )):
74
- # So it should permit it, but it should fall back to the 'requests' library giving an error
75
- # (but means it gets passed to playwright etc)
76
- assert b"URLs with hostname components are not permitted" in res .data
77
- assert b"_runner_test_various_file_slash" in res .data # Can read this file OK
78
- else :
79
- # Default should be here
80
- assert b'file:// type access is denied for security reasons.' in res .data
77
+ if file_uri .startswith ('file:///' ):
78
+ # This one should be the full qualified path to the file and should get the contents of this file
79
+ res = client .get (
80
+ url_for ("preview_page" , uuid = "first" ),
81
+ follow_redirects = True
82
+ )
83
+ assert b'_runner_test_various_file_slash' in res .data
84
+ else :
85
+ # This will give some error from requests or if it went to chrome, will give some other error :-)
86
+ assert any (s in res .data for s in substrings )
81
87
82
88
res = client .get (url_for ("form_delete" , uuid = "all" ), follow_redirects = True )
83
89
assert b'Deleted' in res .data
84
90
85
91
def test_file_slash_access (client , live_server , measure_memory_usage ):
86
92
#live_server_setup(live_server)
87
- # file: is permitted by default, but it will be caught by ALLOW_FILE_URI
93
+
94
+ # file: is NOT permitted by default, so it will be caught by ALLOW_FILE_URI check
88
95
89
96
test_file_path = os .path .abspath (__file__ )
90
97
_runner_test_various_file_slash (client , file_uri = f"file://{ test_file_path } " )
0 commit comments