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))))
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))))
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)
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)
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)))
def Name_str0(): """Tests that str(Name()) return the input string""" s = 'CN=#3Ctoken#3E,O=organisation' assert_eq(s, str(Name(s)))
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')
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'))
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')
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'))
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)))
def test_str(self): """Tests that str(Name()) return the input string""" s = 'CN=#3Ctoken#3E,O=organisation' self.assertEqual(s, str(Name(s)))