Example #1
0
 def validate_claim_code(self, field):
     try:
         claiming.unpack_claim_code(field.data)
     except claiming.InvalidClaimCode:
         raise wtforms.validators.ValidationError(
             "`{}` doesn't look like a valid claim code :(".format(field.data)
         )
Example #2
0
 def test_encoding(self):
     for cc, device, secret in CC_TEST_VECTORS:
         self.assertEqual(claiming.encode(device, secret), cc)
         dec_device, dec_secret, _, _ = claiming.unpack_claim_code(cc)
         self.assertEqual(dec_device, device)
         self.assertEqual(dec_secret, secret)
Example #3
0
 def validate_claim_code(self, field):
     try:
         claiming.unpack_claim_code(field.data)
     except claiming.InvalidClaimCode:
         raise wtforms.validators.ValidationError("`{}` doesn't look like a valid claim code :(".format(field.data))
Example #4
0
 def test_encoding(self):
     for cc, device, secret in CC_TEST_VECTORS:
         self.assertEqual(claiming.encode(device, secret), cc)
         dec_device, dec_secret, _, _ = claiming.unpack_claim_code(cc)
         self.assertEqual(dec_device, device)
         self.assertEqual(dec_secret, secret)