1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

pytests/dns: use dnsserver.record_from_string

not netcmd.dns.data_to_dns_record, which is a UI function.

The only practical difference is it will raise DNSParseError, not CommandError.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Douglas Bagnall 2021-04-07 15:28:11 +12:00 committed by Douglas Bagnall
parent 55c4f75a28
commit df60fe15b3
3 changed files with 16 additions and 15 deletions

View File

@ -31,7 +31,8 @@ import samba.ndr as ndr
from samba import credentials
from samba.dcerpc import dns, dnsp, dnsserver
from samba.dnsserver import TXTRecord
from samba.netcmd.dns import dns_record_match, data_to_dns_record
from samba.dnsserver import record_from_string
from samba.netcmd.dns import dns_record_match
from samba.tests.subunitrun import SubunitOptions, TestProgram
from samba import werror, WERRORError
from samba.tests.dns_base import DNSTest
@ -1778,7 +1779,7 @@ class TestRPCRoundtrip(DNSTest):
def rpc_update(self, fqn=None, data=None, wType=None, delete=False):
fqn = fqn or ("rpctestrec." + self.get_dns_domain())
rec = data_to_dns_record(wType, data)
rec = record_from_string(wType, data)
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
@ -1824,7 +1825,7 @@ class TestRPCRoundtrip(DNSTest):
name = "%s.%s" % (prefix, self.get_dns_domain())
rec = data_to_dns_record(dnsp.DNS_TYPE_TXT, '"\\"This is a test\\""')
rec = record_from_string(dnsp.DNS_TYPE_TXT, '"\\"This is a test\\""')
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
try:
@ -1903,7 +1904,7 @@ class TestRPCRoundtrip(DNSTest):
prefix = 'rpc' + prefix
name = "%s.%s" % (prefix, self.get_dns_domain())
rec = data_to_dns_record(dnsp.DNS_TYPE_TXT,
rec = record_from_string(dnsp.DNS_TYPE_TXT,
'"\\"This is a test\\"" "" ""')
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
@ -1936,7 +1937,7 @@ class TestRPCRoundtrip(DNSTest):
prefix = 'rpc' + prefix
name = "%s.%s" % (prefix, self.get_dns_domain())
rec = data_to_dns_record(dnsp.DNS_TYPE_TXT,
rec = record_from_string(dnsp.DNS_TYPE_TXT,
'"\\"This is a test\\"" "" "" "more text"')
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
@ -1969,7 +1970,7 @@ class TestRPCRoundtrip(DNSTest):
prefix = 'rpc' + prefix
name = "%s.%s" % (prefix, self.get_dns_domain())
rec = data_to_dns_record(dnsp.DNS_TYPE_TXT,
rec = record_from_string(dnsp.DNS_TYPE_TXT,
'"" "" "\\"This is a test\\""')
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
@ -2026,7 +2027,7 @@ class TestRPCRoundtrip(DNSTest):
prefix = 'rpcnulltextrec'
name = "%s.%s" % (prefix, self.get_dns_domain())
rec = data_to_dns_record(dnsp.DNS_TYPE_TXT, '"NULL\x00BYTE"')
rec = record_from_string(dnsp.DNS_TYPE_TXT, '"NULL\x00BYTE"')
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
try:
@ -2072,7 +2073,7 @@ class TestRPCRoundtrip(DNSTest):
prefix = 'rpc' + prefix
name = "%s.%s" % (prefix, self.get_dns_domain())
rec = data_to_dns_record(dnsp.DNS_TYPE_TXT, '"HIGH\xFFBYTE"')
rec = record_from_string(dnsp.DNS_TYPE_TXT, '"HIGH\xFFBYTE"')
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
try:
@ -2121,7 +2122,7 @@ class TestRPCRoundtrip(DNSTest):
prefix = 'rpc' + prefix
name = "%s.%s" % (prefix, self.get_dns_domain())
rec = data_to_dns_record(dnsp.DNS_TYPE_TXT, '"Th\\\\=is=is a test"')
rec = record_from_string(dnsp.DNS_TYPE_TXT, '"Th\\\\=is=is a test"')
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
try:
@ -2171,7 +2172,7 @@ class TestRPCRoundtrip(DNSTest):
prefix = 'rpc' + prefix
name = "%s.%s" % (prefix, self.get_dns_domain())
rec = data_to_dns_record(dnsp.DNS_TYPE_TXT,
rec = record_from_string(dnsp.DNS_TYPE_TXT,
'"\\"This is a test\\""' +
' "\\"and this is a test, too\\""')
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
@ -2219,7 +2220,7 @@ class TestRPCRoundtrip(DNSTest):
name = "%s.%s" % (prefix, self.get_dns_domain())
rec = data_to_dns_record(dnsp.DNS_TYPE_TXT, '')
rec = record_from_string(dnsp.DNS_TYPE_TXT, '')
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
try:

View File

@ -28,7 +28,7 @@ from samba import credentials, param
from samba.tests import TestCase
from samba.dcerpc import dns, dnsp, dnsserver
from samba.dnsserver import TXTRecord
from samba.netcmd.dns import dns_record_match, data_to_dns_record
from samba.netcmd.dns import dns_record_match
from samba.tests.subunitrun import SubunitOptions, TestProgram
import samba.getopt as options
import optparse

View File

@ -18,7 +18,7 @@
import sys
from samba import credentials
from samba.dcerpc import dns, dnsserver
from samba.netcmd.dns import data_to_dns_record
from samba.dnsserver import record_from_string
from samba.tests.subunitrun import SubunitOptions, TestProgram
from samba import werror, WERRORError
from samba.tests.dns_base import DNSTest
@ -117,7 +117,7 @@ class TestWildCardQueries(DNSTest):
def delete_record(self, dns_conn, typ, name, data):
rec = data_to_dns_record(typ, data)
rec = record_from_string(typ, data)
del_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
del_rec_buf.rec = rec
@ -136,7 +136,7 @@ class TestWildCardQueries(DNSTest):
def add_record(self, dns_conn, typ, name, data):
rec = data_to_dns_record(typ, data)
rec = record_from_string(typ, data)
add_rec_buf = dnsserver.DNS_RPC_RECORD_BUF()
add_rec_buf.rec = rec
try: