Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
deckard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
22
Issues
22
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
deckard
Commits
e663f5ff
Commit
e663f5ff
authored
Dec 12, 2018
by
Štěpán Balážik
Committed by
Stepan Balazik
Jan 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scenario: clean-up raw data handling
parent
ea966ba2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
scenario.py
pydnstest/scenario.py
+10
-12
No files found.
pydnstest/scenario.py
View file @
e663f5ff
...
...
@@ -260,8 +260,7 @@ class Entry:
self
.
fired
=
0
# RAW
self
.
raw_data
=
None
# type: Optional[bytes]
self
.
is_raw_data_entry
=
self
.
process_raw
()
self
.
raw_data
=
self
.
process_raw
()
# MATCH
self
.
match_fields
=
self
.
process_match
()
...
...
@@ -286,10 +285,9 @@ class Entry:
def
process_raw
(
self
):
try
:
self
.
raw_data
=
binascii
.
unhexlify
(
self
.
node
[
"/raw"
]
.
value
)
return
True
return
binascii
.
unhexlify
(
self
.
node
[
"/raw"
]
.
value
)
except
KeyError
:
return
Fals
e
return
Non
e
def
process_match
(
self
):
try
:
...
...
@@ -374,7 +372,7 @@ class Entry:
def
__str__
(
self
):
txt
=
'ENTRY_BEGIN
\n
'
if
not
self
.
is_raw_data_entry
:
if
self
.
raw_data
is
None
:
txt
+=
'MATCH {0}
\n
'
.
format
(
' '
.
join
(
self
.
match_fields
))
txt
+=
'ADJUST {0}
\n
'
.
format
(
' '
.
join
(
self
.
adjust_fields
))
txt
+=
'REPLY {rcode} {flags}
\n
'
.
format
(
...
...
@@ -390,7 +388,7 @@ class Entry:
for
rr
in
sect
:
txt
+=
str
(
rr
)
txt
+=
'
\n
'
if
self
.
is_raw_data_entry
:
if
self
.
raw_data
is
not
None
:
txt
+=
'RAW
\n
'
if
self
.
raw_data
:
txt
+=
binascii
.
hexlify
(
self
.
raw_data
)
...
...
@@ -459,7 +457,7 @@ class Entry:
raise
ValueError
(
"
%
s,
\"
%
s
\"
:
%
s"
%
(
self
.
node
.
span
,
code
,
errstr
))
def
cmp_raw
(
self
,
raw_value
):
assert
self
.
is_raw_data_entry
assert
self
.
raw_data
is
not
None
expected
=
None
if
self
.
raw_data
is
not
None
:
expected
=
binascii
.
hexlify
(
self
.
raw_data
)
...
...
@@ -472,7 +470,7 @@ class Entry:
def
reply
(
self
,
query
)
->
Optional
[
DNSBlob
]:
if
'do_not_answer'
in
self
.
adjust_fields
:
return
None
if
self
.
is_raw_data_entry
:
if
self
.
raw_data
is
not
None
:
copy_id
=
'raw_data'
in
self
.
adjust_fields
assert
self
.
raw_data
is
not
None
return
DNSReplyRaw
(
self
.
raw_data
,
query
,
copy_id
)
...
...
@@ -681,7 +679,7 @@ class Step:
if
not
self
.
data
:
raise
ValueError
(
"response definition required"
)
expected
=
self
.
data
[
0
]
if
expected
.
is_raw_data_entry
is
Tru
e
:
if
expected
.
raw_data
is
not
Non
e
:
self
.
log
.
debug
(
"raw answer:
%
s"
,
ctx
.
last_raw_answer
.
to_text
())
expected
.
cmp_raw
(
ctx
.
last_raw_answer
)
else
:
...
...
@@ -721,7 +719,7 @@ class Step:
"""
if
not
self
.
data
:
raise
ValueError
(
"query definition required"
)
if
self
.
data
[
0
]
.
is_raw_data_entry
is
Tru
e
:
if
self
.
data
[
0
]
.
raw_data
is
not
Non
e
:
data_to_wire
=
self
.
data
[
0
]
.
raw_data
else
:
# Don't use a message copy as the EDNS data portion is not copied.
...
...
@@ -754,7 +752,7 @@ class Step:
time
.
sleep
(
0.1
)
# Wait for a response for a reasonable time
answer
=
None
if
not
self
.
data
[
0
]
.
is_raw_data_entry
:
if
self
.
data
[
0
]
.
raw_data
is
None
:
while
True
:
if
(
datetime
.
now
()
-
tstart
)
.
total_seconds
()
>
5
:
raise
RuntimeError
(
"Server took too long to respond"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment