Changeset - cc4182acd584
[Not reviewed]
default
0 7 0
Laman - 5 years ago 2020-04-10 12:14:15

reformatted whitespace with more respect for PEP-8
1 file changed with 0 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/tests/test_shamira.py
Show inline comments
 
@@ -58,46 +58,45 @@ class TestShamira(TestCase):
 

	
 
	def testEncode(self):
 
		share=(2,b"\x00\x01\x02")
 
		for (encoding,encodedStr) in [("hex",'000102'),("b32",'AAAQE==='),("b64",'AAEC')]:
 
			with self.subTest(enc=encoding):
 
				self.assertEqual(encode(share,encoding), "2."+encodedStr)
 

	
 
	def testDecode(self):
 
		with self.assertRaises(MalformedShare):
 
			decode("AAA")
 
			decode("1.")
 
			decode(".AAA")
 
			decode("1AAA")
 
			decode("1.0001020f","hex")
 
			decode("1.000102030","hex")
 
			decode("1.AAAQEAY")
 
			decode("1.AAAQEAy=")
 
			decode("1.AAECAw=","b64")
 
			decode("1.AAECA?==","b64")
 
			decode("256.00010203","hex")
 
		self.assertEqual(decode("1.00010203","hex"), (1,b"\x00\x01\x02\x03"))
 
		self.assertEqual(decode("2.AAAQEAY=","b32"), (2,b"\x00\x01\x02\x03"))
 
		self.assertEqual(decode("3.AAECAw==","b64"), (3,b"\x00\x01\x02\x03"))
 

	
 

	
 
	def testDetectEncoding(self):
 
		for shares in [
 
			["1.00010f"], # bad case
 
			["1.000102030"], # bad char count
 
			["1.AAAQEAY"], # no padding
 
			["1.AAAQe==="], # bad case
 
			["1.AAECA?=="], # bad char
 
			["1.AAECAw="], # bad padding
 
			["1.000102","2.AAAQEAY="], # mixed encoding
 
			["1.000102","2.AAECAw=="],
 
			["1.AAECAw==","2.AAAQE==="],
 
			[".00010203"], # no index
 
			["00010203"] # no index
 
		]:
 
			with self.subTest(shares=shares):
 
				with self.assertRaises(DetectionException):
 
					detectEncoding(shares)
 
		self.assertEqual(detectEncoding(["10.00010203"]), "hex")
 
		self.assertEqual(detectEncoding(["2.AAAQEAY="]), "b32")
 
		self.assertEqual(detectEncoding(["3.AAECAw=="]), "b64")
 
		self.assertEqual(detectEncoding(["3.AAECAwQF","1.00010203"]), "b64")
0 comments (0 inline, 0 general)