Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_cdxj_valid():
# Missing fields
assert not util.isValidCDXJ('test')
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/~salam 20160305192247 {"locator": "urn:ipfs/QmeVWGtnfuJ1QnpmtKKnyArVgEpq7v31kktEfh6c8mDiXE/QmZWKQRBNXNrVZ69LoGpMNJi5NU66gDhnGtQukWJepv7Kr", "encryption_method": "xor", "encryption_key": "radon", "mime_type": "text/html", "status_code": "200"}""")
# Bad JSON in third field
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 radon""")
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 {}""")
#Invalid datetime
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 2016030519224 {}""")
# Invalid SURT URI, pywb catches its own ValueError
def test_cdxj_valid():
# Missing fields
assert not util.isValidCDXJ('test')
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/~salam 20160305192247 {"locator": "urn:ipfs/QmeVWGtnfuJ1QnpmtKKnyArVgEpq7v31kktEfh6c8mDiXE/QmZWKQRBNXNrVZ69LoGpMNJi5NU66gDhnGtQukWJepv7Kr", "encryption_method": "xor", "encryption_key": "radon", "mime_type": "text/html", "status_code": "200"}""")
# Bad JSON in third field
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 radon""")
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 {}""")
#Invalid datetime
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 2016030519224 {}""")
# Invalid SURT URI, pywb catches its own ValueError
def test_cdxj_valid():
# Missing fields
assert not util.isValidCDXJ('test')
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/~salam 20160305192247 {"locator": "urn:ipfs/QmeVWGtnfuJ1QnpmtKKnyArVgEpq7v31kktEfh6c8mDiXE/QmZWKQRBNXNrVZ69LoGpMNJi5NU66gDhnGtQukWJepv7Kr", "encryption_method": "xor", "encryption_key": "radon", "mime_type": "text/html", "status_code": "200"}""")
# Bad JSON in third field
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 radon""")
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 {}""")
#Invalid datetime
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 2016030519224 {}""")
# Invalid SURT URI, pywb catches its own ValueError
def test_cdxj_valid():
# Missing fields
assert not util.isValidCDXJ('test')
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/~salam 20160305192247 {"locator": "urn:ipfs/QmeVWGtnfuJ1QnpmtKKnyArVgEpq7v31kktEfh6c8mDiXE/QmZWKQRBNXNrVZ69LoGpMNJi5NU66gDhnGtQukWJepv7Kr", "encryption_method": "xor", "encryption_key": "radon", "mime_type": "text/html", "status_code": "200"}""")
# Bad JSON in third field
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 radon""")
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 {}""")
#Invalid datetime
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 2016030519224 {}""")
# Invalid SURT URI, pywb catches its own ValueError
def test_cdxj_valid():
# Missing fields
assert not util.isValidCDXJ('test')
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/~salam 20160305192247 {"locator": "urn:ipfs/QmeVWGtnfuJ1QnpmtKKnyArVgEpq7v31kktEfh6c8mDiXE/QmZWKQRBNXNrVZ69LoGpMNJi5NU66gDhnGtQukWJepv7Kr", "encryption_method": "xor", "encryption_key": "radon", "mime_type": "text/html", "status_code": "200"}""")
# Bad JSON in third field
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 radon""")
# Valid SURT
assert util.isValidCDXJ(r"""edu,odu,cs)/ 20160305192247 {}""")
#Invalid datetime
assert not util.isValidCDXJ(r"""edu,odu,cs)/ 2016030519224 {}""")
# Invalid SURT URI, pywb catches its own ValueError