How to use _get_tests method in molecule

Best Python code snippet using molecule_python

test_whycheproof_vectors.py

Source:test_whycheproof_vectors.py Github

copy

Full Screen

...18 pass19@skipIf(version_info.minor < 6, "Test requires sha3 (added in python3.6) to run")20class TestWycheproofEcdsaVerify(TestCase):21 @staticmethod22 def _get_tests(url):23 try:24 test_raw = urlopen(url).read()25 test_json = loads(test_raw)26 return test_json["testGroups"]27 except (JSONDecodeError, URLError) as error:28 SkipTest("Skipping tests, could not download / parse data from {}\nError: {}".format(url, error))29 def _test_runner(self, tests, curve, hashfunc):30 for test_group in tests:31 keybytes = unhexlify(test_group["key"]["uncompressed"])32 public_key = SEC1Encoder.decode_public_key(keybytes, curve)33 for test in test_group["tests"]:34 try:35 message = unhexlify(test["msg"])36 sigbytes = unhexlify(test["sig"])37 signature = DEREncoder.decode_signature(sigbytes)38 expected = test["result"] == "valid"39 result = verify(signature, message, public_key, curve, hashfunc)40 self.assertEqual(result, expected, test)41 except:42 self.assertFalse(test["result"] == "valid", test)43 def test_brainpool224r1_sha224(self):44 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_brainpoolP224r1_sha224_test.json"45 tests = self._get_tests(url)46 self._test_runner(tests, brainpoolP224r1, sha224)47 def test_brainpoolP256r1_sha256(self):48 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_brainpoolP256r1_sha256_test.json"49 tests = self._get_tests(url)50 self._test_runner(tests, brainpoolP256r1, sha256)51 def test_brainpoolP320r1_sha384(self):52 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_brainpoolP320r1_sha384_test.json"53 tests = self._get_tests(url)54 self._test_runner(tests, brainpoolP320r1, sha384)55 def test_brainpoolP384r1_sha384(self):56 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_brainpoolP384r1_sha384_test.json"57 tests = self._get_tests(url)58 self._test_runner(tests, brainpoolP384r1, sha384)59 def test_brainpoolP512r1_sha512(self):60 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_brainpoolP512r1_sha512_test.json"61 tests = self._get_tests(url)62 self._test_runner(tests, brainpoolP512r1, sha512)63 def test_p224_sha224(self):64 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp224r1_sha224_test.json"65 tests = self._get_tests(url)66 self._test_runner(tests, P224, sha224)67 def test_p224_sha256(self):68 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp224r1_sha256_test.json"69 tests = self._get_tests(url)70 self._test_runner(tests, P224, sha256)71 def test_p224_sha3_224(self):72 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp224r1_sha3_224_test.json"73 tests = self._get_tests(url)74 self._test_runner(tests, P224, sha3_224)75 def test_p224_sha3_256(self):76 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp224r1_sha3_256_test.json"77 tests = self._get_tests(url)78 self._test_runner(tests, P224, sha3_256)79 def test_p224_sha3_512(self):80 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp224r1_sha3_512_test.json"81 tests = self._get_tests(url)82 self._test_runner(tests, P224, sha3_512)83 def test_p224_sha512(self):84 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp224r1_sha512_test.json"85 tests = self._get_tests(url)86 self._test_runner(tests, P224, sha512)87 def test_secp256k1_sha256(self):88 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256k1_sha256_test.json"89 tests = self._get_tests(url)90 self._test_runner(tests, secp256k1, sha256)91 def test_secp256k1_sha3_256(self):92 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256k1_sha3_256_test.json"93 tests = self._get_tests(url)94 self._test_runner(tests, secp256k1, sha3_256)95 def test_secp256k1_sha3_512(self):96 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256k1_sha3_512_test.json"97 tests = self._get_tests(url)98 self._test_runner(tests, secp256k1, sha3_512)99 def test_secp256k1_sha512(self):100 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256k1_sha512_test.json"101 tests = self._get_tests(url)102 self._test_runner(tests, secp256k1, sha512)103 def test_p256_sha256(self):104 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256r1_sha256_test.json"105 tests = self._get_tests(url)106 self._test_runner(tests, P256, sha256)107 def test_p256_sha3_256(self):108 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256r1_sha3_256_test.json"109 tests = self._get_tests(url)110 self._test_runner(tests, P256, sha3_256)111 def test_p256_sha3_512(self):112 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256r1_sha3_512_test.json"113 tests = self._get_tests(url)114 self._test_runner(tests, P256, sha3_512)115 def test_p256_sha512(self):116 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp256r1_sha512_test.json"117 tests = self._get_tests(url)118 self._test_runner(tests, P256, sha512)119 def test_p384_sha384(self):120 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp384r1_sha384_test.json"121 tests = self._get_tests(url)122 self._test_runner(tests, P384, sha384)123 def test_p384_sha3_384(self):124 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp384r1_sha3_384_test.json"125 tests = self._get_tests(url)126 self._test_runner(tests, P384, sha3_384)127 def test_p384_sha3_512(self):128 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp384r1_sha3_512_test.json"129 tests = self._get_tests(url)130 self._test_runner(tests, P384, sha3_512)131 def test_p384_sha512(self):132 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp384r1_sha512_test.json"133 tests = self._get_tests(url)134 self._test_runner(tests, P384, sha512)135 def test_p521_sha3_512(self):136 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp521r1_sha3_512_test.json"137 tests = self._get_tests(url)138 self._test_runner(tests, P521, sha3_512)139 def test_p521_sha512(self):140 url = "https://raw.githubusercontent.com/google/wycheproof/master/testvectors/ecdsa_secp521r1_sha512_test.json"141 tests = self._get_tests(url)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful