~myers-1/pyopenssl/npn

« back to all changes in this revision

Viewing changes to OpenSSL/test/test_crypto.py

  • Committer: Jean-Paul Calderone
  • Date: 2011-04-25 23:41:32 UTC
  • mfrom: (128.2.10 run-on-pypy)
  • Revision ID: exarkun@divmod.com-20110425234132-0f76yf59poaegjxu
Various fixes which make pyOpenSSL more likely to work with PyPy

  * Fix a consistent refcounting bug across most modules
  * switch from tp_setattr to tp_setattro
  * Fix a general bug in error handling when setting invalid X509Name attributes

Show diffs side-by-side

added added

removed removed

Lines of Context:
618
618
                name, type(name), X509NameType))
619
619
 
620
620
 
 
621
    def test_onlyStringAttributes(self):
 
622
        """
 
623
        Attempting to set a non-L{str} attribute name on an L{X509NameType}
 
624
        instance causes L{TypeError} to be raised.
 
625
        """
 
626
        name = self._x509name()
 
627
        # Beyond these cases, you may also think that unicode should be
 
628
        # rejected.  Sorry, you're wrong.  unicode is automatically converted to
 
629
        # str outside of the control of X509Name, so there's no way to reject
 
630
        # it.
 
631
        self.assertRaises(TypeError, setattr, name, None, "hello")
 
632
        self.assertRaises(TypeError, setattr, name, 30, "hello")
 
633
        class evil(str):
 
634
            pass
 
635
        self.assertRaises(TypeError, setattr, name, evil(), "hello")
 
636
 
 
637
 
 
638
    def test_setInvalidAttribute(self):
 
639
        """
 
640
        Attempting to set any attribute name on an L{X509NameType} instance for
 
641
        which no corresponding NID is defined causes L{AttributeError} to be
 
642
        raised.
 
643
        """
 
644
        name = self._x509name()
 
645
        self.assertRaises(AttributeError, setattr, name, "no such thing", None)
 
646
 
 
647
 
621
648
    def test_attributes(self):
622
649
        """
623
650
        L{X509NameType} instances have attributes for each standard (?)