summaryrefslogtreecommitdiff
path: root/test/web/catalog.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/web/catalog.py')
-rw-r--r--test/web/catalog.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/web/catalog.py b/test/web/catalog.py
index e1b153e..87773d8 100644
--- a/test/web/catalog.py
+++ b/test/web/catalog.py
@@ -6,6 +6,7 @@ import json
import os
from pathlib import Path
import socket
+import shutil
import struct
import subprocess
import sys
@@ -145,8 +146,14 @@ def main():
assert http(site_port, '/nested/')[2] == b'nested page'
assert http(site_port, '/', 'HEAD')[2] == b''
assert http(site_port, '/style.css', headers={'Range':'bytes=0-3'})[2] == b'body'
+ assert http(dashboard, '/sites/fixture/')[2] == b'<h1>catalog fixture</h1>'
+ assert http(dashboard, '/sites/fixture/pretty')[2] == b'pretty page'
+ assert http(dashboard, '/sites/fixture/nested?x=1')[1]['location'] == '/sites/fixture/nested/?x=1'
+ assert http(dashboard, '/sites/fixture/style.css', headers={'Range':'bytes=-2'})[0] == 206
+ assert http(dashboard, '/sites/fixture/style.css', headers={'Range':'bytes=999999-'})[0] == 416
for path in ['/../secret', '/%2e%2e/secret', '/escape', '/escape-dir/secret', '/.git/config', '/%2fetc/passwd']:
assert http(site_port, path)[0] in (400,403,404), path
+ assert http(dashboard, '/sites/fixture' + path)[0] in (400,403,404), path
assert http(dashboard, headers={'Host':'attacker.invalid'})[0] == 403
ctl = '/_cloud9/sites/fixture/ctl'
assert http(dashboard, ctl, 'POST', 'build', {'Origin':'https://attacker.invalid'})[0] == 403
@@ -199,6 +206,17 @@ def main():
nine.write('sites/fixture/ctl', 'build')
eventually(lambda: json.loads(nine.read('sites/fixture/status'))['phase'] == 'failed')
assert http(site_port)[0] == 200
+ # A published generation replacement must not splice an open fid.
+ saved = (public/'style.css').read_bytes()
+ nine.walk('sites/fixture/public/style.css')
+ nine.rpc(112, struct.pack('<IB', 2, 0))
+ assert nine.rpc(116, struct.pack('<IQI', 2, 0, 2))[4:] == saved[:2]
+ public.rename(root/'previous-public')
+ shutil.copytree(root/'previous-public', public, symlinks=True)
+ (public/'style.css').write_bytes(b'new generation')
+ assert nine.rpc(116, struct.pack('<IQI', 2, 2, 30000))[4:] == saved[2:]
+ nine.rpc(120, struct.pack('<I', 2))
+ assert http(dashboard, '/sites/fixture/style.css')[2] == b'new generation'
nine.s.close()
print('catalog: HTTP serving, paths, MIME, HEAD/range, controls, watch, failure, cancellation, 9P events and passive discovery passed')
except BaseException: