コード例 #1
0
ファイル: name_test.py プロジェクト: moses-palmer/truepy
    def test_unescape_with_escape(self):
        """Tests that Name.unescape for escaped string returns the correct
        string"""
        s = 'hello, "world"; insert <token + value>'

        self.assertEqual(
            s, Name.unescape(Name.escape(s)))
コード例 #2
0
ファイル: name.py プロジェクト: priestd09/truepy
def Name_escape1():
    """Tests that Name.escape for string needing escaping returns the correct
    string"""
    s = 'hello, "world"; insert <token + value>'
    expected = 'hello#2C #22world#22#3B insert #3Ctoken #2B value#3E'

    assert_eq(expected, Name.escape(s))
コード例 #3
0
ファイル: name.py プロジェクト: priestd09/truepy
def Name_escape0():
    """Tests that Name.escape for string not needing escaping returns the input
    string"""
    s = 'hello world'
    expected = s

    assert_eq(expected, Name.escape(s))
コード例 #4
0
def Name_escape1():
    """Tests that Name.escape for string needing escaping returns the correct
    string"""
    s = 'hello, "world"; insert <token + value>'
    expected = 'hello#2C #22world#22#3B insert #3Ctoken #2B value#3E'

    assert_eq(expected, Name.escape(s))
コード例 #5
0
def Name_escape0():
    """Tests that Name.escape for string not needing escaping returns the input
    string"""
    s = 'hello world'
    expected = s

    assert_eq(expected, Name.escape(s))
コード例 #6
0
    def test_escape_with_escape(self):
        """Tests that Name.escape for string needing escaping returns the
        correct string"""
        s = 'hello, "world"; insert <token + value>'
        expected = 'hello#2C #22world#22#3B insert #3Ctoken #2B value#3E'

        self.assertEqual(expected, Name.escape(s))
コード例 #7
0
    def test_unescape_no_escape(self):
        """Tests that Name.unescape for unescaped string returns the input
        string"""
        s = 'hello world'
        expected = s

        self.assertEqual(expected, Name.unescape(s))
コード例 #8
0
    def test_escape_no_escape(self):
        """Tests that Name.escape for string not needing escaping returns the
        input string"""
        s = 'hello world'
        expected = s

        self.assertEqual(expected, Name.escape(s))
コード例 #9
0
ファイル: name_test.py プロジェクト: moses-palmer/truepy
    def test_unescape_no_escape(self):
        """Tests that Name.unescape for unescaped string returns the input
        string"""
        s = 'hello world'
        expected = s

        self.assertEqual(
            expected, Name.unescape(s))
コード例 #10
0
def Name_serialize0():
    """Tests that a name can be serialised to XML"""
    s = 'CN=#3Ctoken#3E , O=organisation '

    assert_eq(
        '<object class="javax.security.auth.x500.X500Principal">'
        '<string>CN=#3Ctoken#3E,O=organisation</string>'
        '</object>', tostring(serialize(Name(s))))
コード例 #11
0
 def test_create_from_name(self):
     """Tests that a name can be created from a cryptography.x509.Name"""
     self.assertEqual(
         '<object class="javax.security.auth.x500.X500Principal">'
         '<string>C=XX,ST=Some-State,L=Madeupville,O=Internet Widgits Pty '
         'Ltd,OU=Loafing dept.</string>'
         '</object>',
         tostring(serialize(Name.from_x509_name(self.certificate.subject))))
コード例 #12
0
    def test_create_from_list(self):
        """Tests that a name can be created from a list"""
        s = [('CN', '<token>'), ('O', 'organisation')]

        self.assertEqual(
            '<object class="javax.security.auth.x500.X500Principal">'
            '<string>CN=#3Ctoken#3E,O=organisation</string>'
            '</object>', tostring(serialize(Name(s))))
コード例 #13
0
ファイル: name_test.py プロジェクト: moses-palmer/truepy
 def test_create_from_name(self):
     """Tests that a name can be created from a cryptography.x509.Name"""
     self.assertEqual(
         '<object class="javax.security.auth.x500.X500Principal">'
         '<string>C=XX,ST=Some-State,L=Madeupville,O=Internet Widgits Pty '
         'Ltd,OU=Loafing dept.</string>'
         '</object>',
         tostring(serialize(Name.from_x509_name(self.certificate.subject))))
コード例 #14
0
ファイル: name_test.py プロジェクト: moses-palmer/truepy
    def test_escape_with_escape(self):
        """Tests that Name.escape for string needing escaping returns the
        correct string"""
        s = 'hello, "world"; insert <token + value>'
        expected = 'hello#2C #22world#22#3B insert #3Ctoken #2B value#3E'

        self.assertEqual(
            expected,
            Name.escape(s))
コード例 #15
0
ファイル: name_test.py プロジェクト: moses-palmer/truepy
    def test_escape_no_escape(self):
        """Tests that Name.escape for string not needing escaping returns the
        input string"""
        s = 'hello world'
        expected = s

        self.assertEqual(
            expected,
            Name.escape(s))
コード例 #16
0
ファイル: license_data.py プロジェクト: datalocker/truepy
def LicenseData_valid_issuer():
    """Test LicenseData() for valid issuer"""
    name = 'CN=name,O=organisation'
    expected = [('CN', 'name'), ('O', 'organisation')]
    unknown = Name(LicenseData.UNKNOWN_NAME)

    license = LicenseData('2014-01-01T00:00:00',
                          '2014-01-01T00:00:01',
                          issuer=name)
    assert_eq(expected, license.issuer)
    assert_eq(unknown, license.holder)
コード例 #17
0
    def test_valid_holder(self):
        """Test LicenseData() for valid holder"""
        name = 'CN=name,O=organisation'
        expected = [('CN', 'name'), ('O', 'organisation')]
        unknown = Name(LicenseData.UNKNOWN_NAME)

        license = LicenseData('2014-01-01T00:00:00',
                              '2014-01-01T00:00:01',
                              holder=name)
        self.assertEqual(unknown, license.issuer)
        self.assertEqual(expected, license.holder)
コード例 #18
0
def Name_invalid_string():
    """Tests that Name() from invalid string raises ValueError"""
    with assert_exception(ValueError):
        Name('CN=invalid escape sequence#01')
    with assert_exception(ValueError):
        Name('CN=valid escape sequence, no type')
コード例 #19
0
def Name_str0():
    """Tests that str(Name()) return the input string"""
    s = 'CN=#3Ctoken#3E,O=organisation'
    assert_eq(s, str(Name(s)))
コード例 #20
0
def Name_unescape2():
    """Tests that Name.unescape for escaped string with invalid escape seqienmce
    raises ValueError"""
    with assert_exception(ValueError):
        Name.unescape('#01')
コード例 #21
0
def Name_valid_string():
    """Tests Name() from valid string returns the correct sequence"""
    assert_eq([('CN', '<token>'), ('O', 'organisation')],
              Name('CN=#3Ctoken#3E,O=organisation'))
コード例 #22
0
def Name_unescape0():
    """Tests that Name.unescape for unescaped string returns the input string"""
    s = 'hello world'
    expected = s

    assert_eq(expected, Name.unescape(s))
コード例 #23
0
def Name_unescape1():
    """Tests that Name.unescape for escaped string returns the correct string"""
    s = 'hello, "world"; insert <token + value>'

    assert_eq(s, Name.unescape(Name.escape(s)))
コード例 #24
0
 def test_unescape_invalid_escape(self):
     """Tests that Name.unescape for escaped string with invalid escape seqienmce
     raises ValueError"""
     with self.assertRaises(ValueError):
         Name.unescape('#01')
コード例 #25
0
ファイル: name.py プロジェクト: priestd09/truepy
def Name_unescape2():
    """Tests that Name.unescape for escaped string with invalid escape seqienmce
    raises ValueError"""
    with assert_exception(ValueError):
        Name.unescape('#01')
コード例 #26
0
ファイル: name_test.py プロジェクト: moses-palmer/truepy
 def test_unescape_invalid_escape(self):
     """Tests that Name.unescape for escaped string with invalid escape seqienmce
     raises ValueError"""
     with self.assertRaises(ValueError):
         Name.unescape('#01')
コード例 #27
0
 def test_valid_string(self):
     """Tests Name() from valid string returns the correct sequence"""
     self.assertEqual([('CN', '<token>'), ('O', 'organisation')],
                      Name('CN=#3Ctoken#3E,O=organisation'))
コード例 #28
0
 def test_invalid_string(self):
     """Tests that Name() from invalid string raises ValueError"""
     with self.assertRaises(ValueError):
         Name('CN=invalid escape sequence#01')
     with self.assertRaises(ValueError):
         Name('CN=valid escape sequence, no type')
コード例 #29
0
ファイル: name.py プロジェクト: priestd09/truepy
def Name_unescape0():
    """Tests that Name.unescape for unescaped string returns the input string"""
    s = 'hello world'
    expected = s

    assert_eq(expected, Name.unescape(s))
コード例 #30
0
ファイル: name.py プロジェクト: priestd09/truepy
def Name_unescape1():
    """Tests that Name.unescape for escaped string returns the correct string"""
    s = 'hello, "world"; insert <token + value>'

    assert_eq(s, Name.unescape(Name.escape(s)))
コード例 #31
0
def Name_str1():
    """Tests that str(Name()) return the input string with leading and trailing
    space stripped for values"""
    s = 'CN=#3Ctoken#3E , O=organisation '
    expected = 'CN=#3Ctoken#3E,O=organisation'
    assert_eq(expected, str(Name(s)))
コード例 #32
0
    def test_unescape_with_escape(self):
        """Tests that Name.unescape for escaped string returns the correct
        string"""
        s = 'hello, "world"; insert <token + value>'

        self.assertEqual(s, Name.unescape(Name.escape(s)))
コード例 #33
0
 def test_str(self):
     """Tests that str(Name()) return the input string"""
     s = 'CN=#3Ctoken#3E,O=organisation'
     self.assertEqual(s, str(Name(s)))
コード例 #34
0
 def test_str_strip_space(self):
     """Tests that str(Name()) return the input string with leading and
     trailing space stripped for values"""
     s = 'CN=#3Ctoken#3E , O=organisation '
     expected = 'CN=#3Ctoken#3E,O=organisation'
     self.assertEqual(expected, str(Name(s)))