From cd35f1c1a50073ab3a49cac7d6c15685fe8e1e38 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 4 Jan 2019 16:20:41 +0100 Subject: [PATCH] Test the stringification of X-ORIGIN in schema attributes --- Tests/t_ldap_schema_subentry.py | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Tests/t_ldap_schema_subentry.py b/Tests/t_ldap_schema_subentry.py index 3fc394d..fd006a7 100644 --- a/Tests/t_ldap_schema_subentry.py +++ b/Tests/t_ldap_schema_subentry.py @@ -86,6 +86,62 @@ def test_origin_multi_valued(self): self.get_attribute_type('1.3.6.1.4.1.11.1.3.1.1.3').x_origin, ('RFC4876', 'user defined')) + def test_origin_none_str(self): + """Check string representation of an attribute without X-ORIGIN""" + # This should check that the representation: + # - does not contain X-ORIGIN, and + # - is still syntactically valid. + # Checking the full output makes the test simpler, + # though might need to be adjusted in the future. + self.assertEqual( + str(self.get_attribute_type('2.16.840.1.113719.1.301.4.24.1')), + ( + "( 2.16.840.1.113719.1.301.4.24.1 " + + "NAME 'krbHostServer' " + + "EQUALITY caseExactIA5Match " + + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )" + ), + ) + + def test_origin_string_str(self): + """Check string representation of an attr with single-value X-ORIGIN""" + # This should check that the representation: + # - has the X-ORIGIN entry 'Netscape' with no parentheses, and + # - is still syntactically valid. + # Checking the full output makes the test simpler, + # though might need to be adjusted in the future. + self.assertEqual( + str(self.get_attribute_type('2.16.840.1.113730.3.1.2091')), + ( + "( 2.16.840.1.113730.3.1.2091 " + + "NAME 'nsslapd-suffix' " + + "DESC 'Netscape defined attribute type' " + + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 " + + "X-ORIGIN 'Netscape' )" + ), + ) + + def test_origin_multi_valued_str(self): + """Check string representation of an attr with multi-value X-ORIGIN""" + # This should check that the representation: + # - has a parenthesized X-ORIGIN entry, and + # - is still syntactically valid. + # Checking the full output makes the test simpler, + # though might need to be adjusted in the future. + self.assertEqual( + str(self.get_attribute_type('1.3.6.1.4.1.11.1.3.1.1.3')), + ( + "( 1.3.6.1.4.1.11.1.3.1.1.3 NAME 'searchTimeLimit' " + + "DESC 'Maximum time an agent or service allows for a search " + + "to complete' " + + "EQUALITY integerMatch " + + "ORDERING integerOrderingMatch " + + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 " + + "SINGLE-VALUE " + + "X-ORIGIN ( 'RFC4876' 'user defined' ) )" + ), + ) + class TestSubschemaUrlfetchSlapd(SlapdTestCase): ldap_object_class = SimpleLDAPObject