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)
Beispiel #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_encode_data(self):
     self.assertEqual(ENC_16, encode_data(DATA, ENCODING[0],
                                          url_safe=False))
     self.assertEqual(ENC_32, encode_data(DATA, ENCODING[1],
                                          url_safe=False))
     self.assertEqual(ENC_64, encode_data(DATA, ENCODING[2],
                                          url_safe=False))
     self.assertEqual(ENC_16, encode_data(DATA, ENCODING[0], url_safe=True))
     self.assertEqual(ENC_32, encode_data(DATA, ENCODING[1], url_safe=True))
     self.assertEqual(ENC_64, encode_data(DATA, ENCODING[2], url_safe=True))
 def test_encode_data(self):
     self.assertEqual(enc_16, encode_data(data, encoding[0],
                                          url_safe=False))
     self.assertEqual(enc_32, encode_data(data, encoding[1],
                                          url_safe=False))
     self.assertEqual(enc_64, encode_data(data, encoding[2],
                                          url_safe=False))
     self.assertEqual(enc_16, encode_data(data, encoding[0], url_safe=True))
     self.assertEqual(enc_32, encode_data(data, encoding[1], url_safe=True))
     self.assertEqual(enc_64, encode_data(data, 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)
Beispiel #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_encode_data(self):
     self.assertEqual(
         ENC_16,
         encode_data(
             DATA,
             ENCODING[0],
             url_safe=False))
     self.assertEqual(
         ENC_32,
         encode_data(
             DATA,
             ENCODING[1],
             url_safe=False))
     self.assertEqual(
         ENC_64,
         encode_data(
             DATA,
             ENCODING[2],
             url_safe=False))
     self.assertEqual(ENC_16, encode_data(DATA, ENCODING[0], url_safe=True))
     self.assertEqual(ENC_32, encode_data(DATA, ENCODING[1], url_safe=True))
     self.assertEqual(ENC_64, encode_data(DATA, ENCODING[2], url_safe=True))