generate.py (2603B)
1 # script to generate the generateKey tests 2 3 import os 4 5 here = os.path.dirname(__file__) 6 7 successes_html = """<!DOCTYPE html> 8 <meta charset=utf-8> 9 <meta name="timeout" content="long"> 10 <title>WebCryptoAPI: generateKey() Successful Calls</title> 11 <link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com"> 12 <link rel="help" href="https://www.w3.org/TR/WebCryptoAPI/#dfn-SubtleCrypto-method-generateKey"> 13 <script src="/resources/testharness.js"></script> 14 <script src="/resources/testharnessreport.js"></script> 15 16 <script src="/WebCryptoAPI/util/helpers.js"></script> 17 <script src="successes.js"></script> 18 19 <h1>generateKey Tests for Good Parameters</h1> 20 <p> 21 <strong>Warning!</strong> RSA key generation is intrinsically 22 very slow, so the related tests can take up to 23 several minutes to complete, depending on browser! 24 </p> 25 26 <div id="log"></div> 27 <script> 28 run_test([%s]); 29 </script>""" 30 31 failures_html = """<!DOCTYPE html> 32 <meta charset=utf-8> 33 <meta name="timeout" content="long"> 34 <title>WebCryptoAPI: generateKey() for Failures</title> 35 <link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com"> 36 <link rel="help" href="https://www.w3.org/TR/WebCryptoAPI/#dfn-SubtleCrypto-method-generateKey"> 37 <script src="/resources/testharness.js"></script> 38 <script src="/resources/testharnessreport.js"></script> 39 40 <script src="/WebCryptoAPI/util/helpers.js"></script> 41 <script src="failures.js"></script> 42 43 <h1>generateKey Tests for Bad Parameters</h1> 44 45 <div id="log"></div> 46 <script> 47 run_test([%s]); 48 </script> 49 """ 50 51 successes_worker = """// META: timeout=long 52 importScripts("/resources/testharness.js"); 53 importScripts("../util/helpers.js"); 54 importScripts("successes.js"); 55 56 run_test([%s]); 57 done();""" 58 59 failures_worker = """// META: timeout=long 60 importScripts("/resources/testharness.js"); 61 importScripts("../util/helpers.js"); 62 importScripts("failures.js"); 63 run_test([%s]); 64 done();""" 65 66 names = ["AES-CTR", "AES-CBC", "AES-GCM", "AES-KW", "HMAC", "RSASSA-PKCS1-v1_5", 67 "RSA-PSS", "RSA-OAEP", "ECDSA", "ECDH", "Ed25519", "Ed448", "X25519", 68 "X448"] 69 70 for filename_pattern, template in [("test_successes_%s.https.html", successes_html), 71 ("test_failures_%s.https.html", failures_html), 72 ("successes_%s.https.worker.js", successes_worker), 73 ("failures_%s.https.worker.js", failures_worker)]: 74 for name in names: 75 path = os.path.join(here, os.pardir, "generateKey", filename_pattern % name) 76 with open(path, "w") as f: 77 f.write(template % '"%s"' % name)