Archived
handover/collab: Git multi-agent design v0, AGENTS template, roots/manifest, gitignore proposal, upload preflight (+6 tests)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b78764c0b7
commit
6f58c3299d
6 files changed
+193
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import json, os, subprocess, sys, tempfile, unittest
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
TOOL = os.path.join(HERE, 'upload_preflight.py')
|
||||
|
||||
def run(files, extra=()):
|
||||
d = tempfile.mkdtemp()
|
||||
for name, content in files.items():
|
||||
p = os.path.join(d, name); os.makedirs(os.path.dirname(p), exist_ok=True)
|
||||
open(p, 'wb').write(content)
|
||||
cand = os.path.join(d, 'cand.txt'); open(cand, 'w').write('\n'.join(files) + '\n')
|
||||
out = os.path.join(d, 'rep.json')
|
||||
r = subprocess.run([sys.executable, TOOL, d, cand, out, *extra], capture_output=True)
|
||||
return r.returncode, json.load(open(out))
|
||||
|
||||
class T(unittest.TestCase):
|
||||
def test_clean_passes(self):
|
||||
rc, rep = run({'a/readme.md': b'# hello\nglobal token in a model\n'})
|
||||
self.assertEqual(rc, 0); self.assertEqual(rep['result'], 'PASS')
|
||||
def test_signed_url_blocks(self):
|
||||
rc, rep = run({'n.md': b'see https://x.oss/obj?OSSAccessKeyId=abc&Expires=1799999999&Signature=zz\n'})
|
||||
self.assertEqual(rc, 1); self.assertTrue(rep['secret_hits'])
|
||||
def test_private_key_blocks(self):
|
||||
rc, rep = run({'k.txt': b'-----BEGIN OPENSSH PRIVATE KEY-----\nxx\n'})
|
||||
self.assertEqual(rc, 1)
|
||||
def test_secret_filename_blocks(self):
|
||||
rc, rep = run({'.git-credentials': b'x\n'})
|
||||
self.assertEqual(rc, 1); self.assertTrue(rep['secret_names'])
|
||||
def test_size_limit_blocks(self):
|
||||
rc, rep = run({'big.bin': b'\x00' * (2 * 2**20)}, ('--max-file-mb', '1'))
|
||||
self.assertEqual(rc, 1); self.assertTrue(rep['too_large'])
|
||||
def test_url_credentials_block(self):
|
||||
rc, rep = run({'c.cfg': b'url = https://user:pass1234@host/repo.git\n'})
|
||||
self.assertEqual(rc, 1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user