Esempio n. 1
0
 def testVectors (self):
     """RFC4648 section 10."""
     for (plaintext, ciphertext) in self.RFC4648_S10:
         self.assertEqual(xsd.base64Binary(plaintext).xsdLiteral(), ciphertext)
         self.assertEqual(xsd.base64Binary(ciphertext, _from_xml=True), plaintext)
     for (hextext, ciphertext) in self.RFC4648_S9:
         plaintext = binascii.unhexlify(hextext)
         self.assertEqual(xsd.base64Binary(plaintext).xsdLiteral(), ciphertext)
         self.assertEqual(xsd.base64Binary(ciphertext, _from_xml=True), plaintext)
Esempio n. 2
0
 def testLimitOverride (self):
     self.assertEqual(six.b('e'), xsd.base64Binary(six.u('ZQ=='), _from_xml=True))
     self.assertEqual(six.b('e\x96'), xsd.base64Binary(six.u('ZZY='), _from_xml=True))
     self.assertRaises(pyxb.SimpleTypeValueError, xsd.base64Binary, six.u('ZZZ='), _from_xml=True)
     xsd.base64Binary.XsdValidateLength(-1)
     self.assertEqual(six.b('e\x96'), xsd.base64Binary(six.u('ZZZ='), _from_xml=True))
     xsd.base64Binary.XsdValidateLength(3)
     self.assertEqual(six.b('e\x96'), xsd.base64Binary(six.u('ZZZ='), _from_xml=True))
     xsd.base64Binary.XsdValidateLength(4)
     self.assertRaises(pyxb.SimpleTypeValueError, xsd.base64Binary, six.u('ZZZ='), _from_xml=True)
Esempio n. 3
0
 def testVectors (self):
     """RFC4648 section 10."""
     for (plaintext, ciphertext) in self.RFC4648_S10:
         plaintexd = plaintext.encode('utf-8')
         ciphertexd = ciphertext.encode('utf-8')
         self.assertEqual(xsd.base64Binary(plaintexd).xsdLiteral(), ciphertext)
         self.assertEqual(xsd.base64Binary(ciphertext, _from_xml=True), plaintexd)
     for (hextext, ciphertext) in self.RFC4648_S9:
         hextexd = hextext.encode('utf-8')
         plaintexd = binascii.unhexlify(hextexd)
         self.assertEqual(xsd.base64Binary(plaintexd).xsdLiteral(), ciphertext)
         self.assertEqual(xsd.base64Binary(ciphertext, _from_xml=True), plaintexd)
Esempio n. 4
0
 def testInvalid(self):
     self.assertRaises(pyxb.SimpleTypeValueError,
                       xsd.base64Binary,
                       u'Z',
                       _from_xml=True)
     self.assertRaises(pyxb.SimpleTypeValueError,
                       xsd.base64Binary,
                       u'Zg',
                       _from_xml=True)
     self.assertRaises(pyxb.SimpleTypeValueError,
                       xsd.base64Binary,
                       u'Zg=',
                       _from_xml=True)
     self.assertEqual(u'f'.encode('utf-8'),
                      xsd.base64Binary(u'Zg==', _from_xml=True))
     self.assertRaises(pyxb.SimpleTypeValueError,
                       xsd.base64Binary,
                       u'ZZZ=',
                       _from_xml=True)
     self.assertRaises(pyxb.SimpleTypeValueError,
                       xsd.base64Binary,
                       u'ZZ==',
                       _from_xml=True)
     self.assertRaises(pyxb.SimpleTypeValueError,
                       xsd.base64Binary,
                       u'ZE==',
                       _from_xml=True)
Esempio n. 5
0
 def testInvalid (self):
     self.assertRaises(pyxb.SimpleTypeValueError, xsd.base64Binary, six.u('Z'), _from_xml=True)
     self.assertRaises(pyxb.SimpleTypeValueError, xsd.base64Binary, six.u('Zg'), _from_xml=True)
     self.assertRaises(pyxb.SimpleTypeValueError, xsd.base64Binary, six.u('Zg='), _from_xml=True)
     self.assertEqual(six.u('f').encode('utf-8'), xsd.base64Binary(six.u('Zg=='), _from_xml=True))
     self.assertRaises(pyxb.SimpleTypeValueError, xsd.base64Binary, six.u('ZZZ='), _from_xml=True)
     self.assertRaises(pyxb.SimpleTypeValueError, xsd.base64Binary, six.u('ZZ=='), _from_xml=True)
     self.assertRaises(pyxb.SimpleTypeValueError, xsd.base64Binary, six.u('ZE=='), _from_xml=True)
Esempio n. 6
0
 def testInvalid (self):
     self.assertRaises(pyxb.BadTypeValueError, xsd.base64Binary, 'Z', _from_xml=True)
     self.assertRaises(pyxb.BadTypeValueError, xsd.base64Binary, 'Zg', _from_xml=True)
     self.assertRaises(pyxb.BadTypeValueError, xsd.base64Binary, 'Zg=', _from_xml=True)
     self.assertEqual('f', xsd.base64Binary('Zg==', _from_xml=True))
     self.assertRaises(pyxb.BadTypeValueError, xsd.base64Binary, 'ZZZ=', _from_xml=True)
     self.assertRaises(pyxb.BadTypeValueError, xsd.base64Binary, 'ZZ==', _from_xml=True)
     self.assertRaises(pyxb.BadTypeValueError, xsd.base64Binary, 'ZE==', _from_xml=True)