Пример #1
0
	def test_string_parse(self):
		dn = DistinguishedName.from_rfc2253_str("cn=foo,ou=bar,o=koo")
		self.assertEqual(dn, DistinguishedName([ RelativeDistinguishedName.create("CN", "foo"), RelativeDistinguishedName.create("OU", "bar"), RelativeDistinguishedName.create("O", "koo") ]))

		dn = DistinguishedName.from_rfc2253_str("cn=foo,ou=bar,o=koo+ou=moo")
		self.assertEqual(dn, DistinguishedName([ RelativeDistinguishedName.create("CN", "foo"), RelativeDistinguishedName.create("OU", "bar"), RelativeDistinguishedName.create("O", "koo", "OU", "moo") ]))

		dn = DistinguishedName.from_rfc2253_str("")
		self.assertEqual(dn, DistinguishedName([ ]))
Пример #2
0
	def test_simple_dn_2(self):
		elements = [ RelativeDistinguishedName.create("CN", "Rick Astley"), RelativeDistinguishedName.create("OU", "Infinite Persistence Systems Inc.") ]
		dn1 = DistinguishedName(elements)
		self.assertEqual(dn1.rfc2253_str, "OU=Infinite Persistence Systems Inc.,CN=Rick Astley")

		elements = [ RelativeDistinguishedName.create("OU", "Infinite Persistence Systems Inc."), RelativeDistinguishedName.create("CN", "Rick Astley") ]
		dn2 = DistinguishedName(elements)
		self.assertEqual(dn2.rfc2253_str, "CN=Rick Astley,OU=Infinite Persistence Systems Inc.")

		self.assertNotEqual(dn1, dn2)
Пример #3
0
	def test_equality_dn(self):
		dn1 = DistinguishedName([ RelativeDistinguishedName.create("CN", "Foo"), RelativeDistinguishedName.create("CN", "Bar") ])
		dn2 = DistinguishedName([ RelativeDistinguishedName.create("CN", "Bar"), RelativeDistinguishedName.create("CN", "Foo") ])
		dn3 = DistinguishedName([ RelativeDistinguishedName.create("CN", "Foo"), RelativeDistinguishedName.create("CN", "Bar") ])
		self.assertNotEqual(dn1, dn2)
		self.assertEqual(dn1, dn3)
Пример #4
0
	def test_simple_dn_3(self):
		elements = [ RelativeDistinguishedName.create("CN", "Rick Astley"), RelativeDistinguishedName.create("CN", "Foo Bar"), RelativeDistinguishedName.create("OU", "OrgUnit"), RelativeDistinguishedName.create("CN", "Bar Foo") ]
		dn = DistinguishedName(elements)
		self.assertEqual(dn.rfc2253_str, "CN=Bar Foo,OU=OrgUnit,CN=Foo Bar,CN=Rick Astley")
Пример #5
0
	def test_simple_dn_1(self):
		elements = [ RelativeDistinguishedName.create("CN", "Rick Astley") ]
		dn = DistinguishedName(elements)
		self.assertEqual(dn.rfc2253_str, "CN=Rick Astley")