def asLDIF(self): r = [] r.append(ldif.attributeAsLDIF('dn', self.dn.getText())) r.append(ldif.attributeAsLDIF('changetype', 'modify')) for m in self.modifications: r.append(m.asLDIF()) r.append(b"\n") return b''.join(r)
def asLDIF(self): r = [] r.append(ldif.attributeAsLDIF('dn', str(self.dn))) r.append(ldif.attributeAsLDIF('changetype', 'modify')) for m in self.modifications: r.append(m.asLDIF()) r.append("\n") return ''.join(r)
def asLDIF(self): r=[] values = list(self) values.sort() r.append(ldif.attributeAsLDIF('replace', self.key)) for v in values: r.append(ldif.attributeAsLDIF(self.key, v)) r.append(b'-\n') return b''.join(r)
def asLDIF(self): r = [] values = list(self) values.sort() r.append(ldif.attributeAsLDIF('delete', self.key)) for v in values: r.append(ldif.attributeAsLDIF(self.key, v)) r.append('-\n') return ''.join(r)
def test_contains_nonprintable_characters(self): """ Value is a string containing nonprintable characters. Returned value is base64 encoded. """ result = attributeAsLDIF(b'key', b'val\xFFue') self.assertEqual(result, b'key:: %s\n' % encode(b'val\xFFue'))
def test_contains_nonprintable_characters(self): """ Value is a string containing nonprintable characters. Returned value is base64 encoded. """ result = attributeAsLDIF(b"key", b"val\xFFue") self.assertEqual(result, b"key:: %s\n" % encode(b"val\xFFue"))
def test_endswith_special_character(self): """ Value is a string ending with one of the reserved characters. Returned value is base64 encoded. """ for c in b'\0', b'\n', b'\r', b' ': value = b'value' + c result = attributeAsLDIF(b'key', value) self.assertEqual(result, b'key:: %s\n' % encode(value))
def test_endswith_special_character(self): """ Value is a string ending with one of the reserved characters. Returned value is base64 encoded. """ for c in b"\0", b"\n", b"\r", b" ": value = b"value" + c result = attributeAsLDIF(b"key", value) self.assertEqual(result, b"key:: %s\n" % encode(value))
def test_contains_special_characters(self): """ Value is a string with one of the reserved characters somewhere in its middle. Returned value is base64 encoded. """ for c in b"\0", b"\n", b"\r": value = b"foo" + c + b"bar" result = attributeAsLDIF(b"key", value) self.assertEqual(result, b"key:: %s\n" % encode(value))
def test_contains_special_characters(self): """ Value is a string with one of the reserved characters somewhere in its middle. Returned value is base64 encoded. """ for c in b'\0', b'\n', b'\r': value = b'foo' + c + b'bar' result = attributeAsLDIF(b'key', value) self.assertEqual(result, b'key:: %s\n' % encode(value))
def asLDIF(self): r = [] r.append(ldif.attributeAsLDIF('dn', str(self.dn))) r.append(ldif.attributeAsLDIF('changetype', 'delete')) r.append("\n") return ''.join(r)
def test_wireable_object(self): """Value is an object with toWire method returning its bytes representation""" result = attributeAsLDIF("dn", WireableObject()) self.assertEqual(result, b"dn: wire\n")
def test_unicode_string(self): """Key and value are unicode strings""" result = attributeAsLDIF("another key", "another value") self.assertEqual(result, b"another key: another value\n")
def test_byte_string(self): """Key and value are byte strings""" result = attributeAsLDIF(b"some key", b"some value") self.assertEqual(result, b"some key: some value\n")
def test_unicode_string(self): """Key and value are unicode strings""" result = attributeAsLDIF(u'another key', u'another value') self.assertEqual(result, b'another key: another value\n')
def test_byte_string(self): """Key and value are byte strings""" result = attributeAsLDIF(b'some key', b'some value') self.assertEqual(result, b'some key: some value\n')
def asLDIF(self): r = [] r.append(ldif.attributeAsLDIF('dn', self.dn.getText())) r.append(ldif.attributeAsLDIF('changetype', 'delete')) r.append(b"\n") return b''.join(r)
def test_wireable_object(self): """Value is an object with toWire method returning its bytes representation""" result = attributeAsLDIF('dn', WireableObject()) self.assertEqual(result, b'dn: wire\n')
def asLDIF(self): l = self.entry.toWire().splitlines() assert l[0].startswith(b'dn:') l[1:1] = [ldif.attributeAsLDIF('changetype', 'add').rstrip(b'\n')] return b''.join([x + b'\n' for x in l])
def asLDIF(self): l = str(self.entry).splitlines() assert l[0].startswith('dn:') l[1:1] = [ldif.attributeAsLDIF('changetype', 'add').rstrip('\n')] return ''.join([x + '\n' for x in l])