Ejemplo n.º 1
0
 def test_codec_identity(self):
   # Not zero-destructive.
   self.assertEqual(
     codec.base64_urlsafe_decode(codec.base64_urlsafe_encode(ZERO_BYTES)),
     ZERO_BYTES
   )
   self.assertEqual(
     codec.base64_urlsafe_decode(codec.base64_urlsafe_encode(RANDOM_BYTES_1024)),
     RANDOM_BYTES_1024
   )
Ejemplo n.º 2
0
 def test_codec_identity(self):
   # Not zero-destructive.
   self.assertEqual(
     base64_urlsafe_decode(base64_urlsafe_encode(zero_bytes)),
     zero_bytes
   )
   self.assertEqual(
     base64_urlsafe_decode(base64_urlsafe_encode(random_bytes_1024)),
     random_bytes_1024
   )
Ejemplo n.º 3
0
  def test_correctness(self):
    self.assertEqual(codec.base64_urlsafe_encode(URL_SAFETY_TEST_BYTES),
                     URL_SAFETY_TEST_SAFE_ENCODED)
    self.assertEqual(codec.base64_encode(URL_SAFETY_TEST_BYTES),
                     URL_SAFETY_TEST_STANDARD_ENCODED)
    self.assertEqual(codec.base64_urlsafe_decode(URL_SAFETY_TEST_SAFE_ENCODED),
                     URL_SAFETY_TEST_BYTES)
    self.assertEqual(codec.base64_decode(URL_SAFETY_TEST_STANDARD_ENCODED),
                     URL_SAFETY_TEST_BYTES)

    # Tests whether this decoder can decode standard encoded base64
    # representation too.
    self.assertEqual(
      codec.base64_urlsafe_decode(URL_SAFETY_TEST_STANDARD_ENCODED),
      URL_SAFETY_TEST_BYTES
    )
Ejemplo n.º 4
0
  def test_correctness(self):
    self.assertEqual(base64_urlsafe_encode(url_safety_test_bytes),
                     url_safety_test_safe_encoded)
    self.assertEqual(base64_encode(url_safety_test_bytes),
                     url_safety_test_standard_encoded)
    self.assertEqual(base64_urlsafe_decode(url_safety_test_safe_encoded),
                     url_safety_test_bytes)
    self.assertEqual(base64_decode(url_safety_test_standard_encoded),
                     url_safety_test_bytes)

    # Tests whether this decoder can decode standard encoded base64
    # representation too.
    self.assertEqual(
      base64_urlsafe_decode(url_safety_test_standard_encoded),
      url_safety_test_bytes
    )