def test_encodeDecode_b64(self):
        """
        1. Encode the reference string using base 64 encoding.  
        2. Check to ensure that the encoded string does not match the reference 
           string (i.e. that it has actually been encoded).  Fail if strings match.
        3. Decode the string using base 64 encoding
        4. Compare decoded string with the reference string.  Fail if strings
           do not match.
        
        Do this with url_safe = True once and once with url_safe = False
        """
        encoded_string = encodingSupport.encode_data(self.reference_string,
                                    encoding="b64", url_safe=True)
        msg = "(B64 - url_safe == True) Reference string was not encoded."
        self.assertNotEqual(encoded_string, self.reference_string, msg)

        decoded_string = encodingSupport.decode_data(encoded_string,
                                    encoding="b64", url_safe=True)
        msg = "(B64 - url_safe == True) Decoded string does not match reference string"
        self.assertEqual(decoded_string, self.reference_string, msg)

        encoded_string = encodingSupport.encode_data(self.reference_string,
                                    encoding="b64", url_safe=False)
        msg = "(B64 - url_safe == False) Reference string was not encoded."
        self.assertNotEqual(encoded_string, self.reference_string, msg)

        decoded_string = encodingSupport.decode_data(encoded_string,
                                    encoding="b64", url_safe=False)
        msg = "(B64 - url_safe == False) Decoded string does not match reference string"
        self.assertEqual(decoded_string, self.reference_string, msg)
Exemple #2
0
    def test_encodeDecode_b64(self):
        """
        1. Encode the reference string using base 64 encoding.
        2. Check to ensure that the encoded string does not match the reference
           string (i.e. that it has actually been encoded).  Fail if strings match.
        3. Decode the string using base 64 encoding
        4. Compare decoded string with the reference string.  Fail if strings
           do not match.

        Do this with url_safe = True once and once with url_safe = False
        """
        encoded_string = encodingSupport.encode_data(self.reference_string,
                                                     encoding="b64", url_safe=True)
        msg = "(B64 - url_safe == True) Reference string was not encoded."
        self.assertNotEqual(encoded_string, self.reference_string, msg)

        decoded_string = encodingSupport.decode_data(encoded_string,
                                                     encoding="b64", url_safe=True)
        msg = "(B64 - url_safe == True) Decoded string does not match reference string"
        self.assertEqual(decoded_string, self.reference_string, msg)

        encoded_string = encodingSupport.encode_data(self.reference_string,
                                                     encoding="b64", url_safe=False)
        msg = "(B64 - url_safe == False) Reference string was not encoded."
        self.assertNotEqual(encoded_string, self.reference_string, msg)

        decoded_string = encodingSupport.decode_data(encoded_string,
                                                     encoding="b64", url_safe=False)
        msg = "(B64 - url_safe == False) Decoded string does not match reference string"
        self.assertEqual(decoded_string, self.reference_string, msg)
 def test_symmetric_text(self, data):
     for enc in ENCODING:
         for tf in [True, False]:
             self.assertEqual(
                 data,
                 decode_data(encode_data(data, enc, url_safe=tf),
                             enc,
                             url_safe=tf))
 def test_symmetric_binary(self, data):
     for enc in encoding:
         for tf in [True, False]:
             self.assertEqual(
                 data,
                 decode_data(encode_data(data, enc, url_safe=tf),
                             enc,
                             url_safe=tf))
 def test_symmetric_text(self, data):
     for enc in ENCODING:
         for tf in [True, False]:
             self.assertEqual(
                 data,
                 decode_data(
                     encode_data(
                         data,
                         enc,
                         url_safe=tf),
                     enc,
                     url_safe=tf))
 def test_decode_data(self):
     self.assertEqual(DATA, decode_data(ENC_16, ENCODING[0],
                                        url_safe=False))
     self.assertEqual(DATA, decode_data(ENC_32, ENCODING[1],
                                        url_safe=False))
     self.assertEqual(DATA, decode_data(ENC_64, ENCODING[2],
                                        url_safe=False))
     self.assertEqual(DATA, decode_data(ENC_16, ENCODING[0], url_safe=True))
     self.assertEqual(DATA, decode_data(ENC_32, ENCODING[1], url_safe=True))
     self.assertEqual(DATA, decode_data(ENC_64, ENCODING[2], url_safe=True))
 def test_decode_data(self):
     self.assertEqual(data, decode_data(enc_16, encoding[0],
                                        url_safe=False))
     self.assertEqual(data, decode_data(enc_32, encoding[1],
                                        url_safe=False))
     self.assertEqual(data, decode_data(enc_64, encoding[2],
                                        url_safe=False))
     self.assertEqual(data, decode_data(enc_16, encoding[0], url_safe=True))
     self.assertEqual(data, decode_data(enc_32, encoding[1], url_safe=True))
     self.assertEqual(data, decode_data(enc_64, encoding[2], url_safe=True))
    def test_encodeDecode_b16(self):
        """
        1. Encode the reference string using base 16 encoding.  
        2. Check to ensure that the encoded string does not match the reference 
           string (i.e. that it has actually been encoded).  Fail if strings match.
        3. Decode the string using base 16 encoding
        4. Compare decoded string with the reference string.  Fail if strings
           do not match.
        """
        encoded_string = encodingSupport.encode_data(self.reference_string, encoding="b16")
        msg = "(B16) Reference string was not encoded."
        self.assertNotEqual(encoded_string, self.reference_string, msg)

        decoded_string = encodingSupport.decode_data(encoded_string, encoding="b16")
        msg = "(B16) Decoded string does not match reference string"
        self.assertEqual(decoded_string, self.reference_string, msg)
Exemple #9
0
    def test_encodeDecode_b16(self):
        """
        1. Encode the reference string using base 16 encoding.
        2. Check to ensure that the encoded string does not match the reference
           string (i.e. that it has actually been encoded).  Fail if strings match.
        3. Decode the string using base 16 encoding
        4. Compare decoded string with the reference string.  Fail if strings
           do not match.
        """
        encoded_string = encodingSupport.encode_data(self.reference_string,
                                                     encoding="b16")
        msg = "(B16) Reference string was not encoded."
        self.assertNotEqual(encoded_string, self.reference_string, msg)

        decoded_string = encodingSupport.decode_data(
            encoded_string, encoding="b16")
        msg = "(B16) Decoded string does not match reference string"
        self.assertEqual(decoded_string, self.reference_string, msg)
 def test_decode_data(self):
     self.assertEqual(
         DATA,
         decode_data(
             ENC_16,
             ENCODING[0],
             url_safe=False))
     self.assertEqual(
         DATA,
         decode_data(
             ENC_32,
             ENCODING[1],
             url_safe=False))
     self.assertEqual(
         DATA,
         decode_data(
             ENC_64,
             ENCODING[2],
             url_safe=False))
     self.assertEqual(DATA, decode_data(ENC_16, ENCODING[0], url_safe=True))
     self.assertEqual(DATA, decode_data(ENC_32, ENCODING[1], url_safe=True))
     self.assertEqual(DATA, decode_data(ENC_64, ENCODING[2], url_safe=True))