FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
voltron/tests/http_api_tests.py at master · awesome-python/voltron · GitHub
awesome-python
/
voltron
Public
forked from
snare/voltron
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
voltron
/
tests
/
http_api_tests.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
163 lines (117 loc) · 4.1 KB
Breadcrumbs
voltron
/
tests
/
http_api_tests.py
Copy path
File metadata and controls
163 lines (117 loc) · 4.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
"""
Tests that emulate the debugger adaptor and just test the interaction between
the front end and back end API classes. HTTP edition!
Tests:
Server (via HTTP)
"""
import
logging
import
sys
import
json
import
time
import
subprocess
from
nose
.
tools
import
*
import
voltron
from
voltron
.
core
import
*
from
voltron
.
api
import
*
from
voltron
.
plugin
import
*
import
platform
if
platform
.
system
()
==
'Darwin'
:
sys
.
path
.
append
(
"/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python"
)
from
.
common
import
*
import
requests
log
=
logging
.
getLogger
(
'tests'
)
class
APIHostNotSupportedRequest
(
APIRequest
):
@
server_side
def
dispatch
(
self
):
return
APIDebuggerHostNotSupportedErrorResponse
()
class
APIHostNotSupportedPlugin
(
APIPlugin
):
request
=
"host_not_supported"
request_class
=
APIHostNotSupportedRequest
response_class
=
APIResponse
def
setup
():
global
server
,
client
,
target
,
pm
,
adaptor
,
methods
log
.
info
(
"setting up API tests"
)
# set up voltron
voltron
.
setup_env
()
voltron
.
config
[
'server'
]
=
{
"listen"
: {
"tcp"
: [
"127.0.0.1"
,
5555
]
}
}
pm
=
PluginManager
()
plugin
=
pm
.
debugger_plugin_for_host
(
'mock'
)
adaptor
=
plugin
.
adaptor_class
()
voltron
.
debugger
=
adaptor
# inject mock methods
inject_mock
(
adaptor
)
# start up a voltron server
server
=
Server
()
server
.
start
()
time
.
sleep
(
2
)
def
teardown
():
server
.
stop
()
time
.
sleep
(
2
)
def
test_disassemble
():
data
=
requests
.
get
(
'http://localhost:5555/api/disassemble?count=16'
).
text
res
=
APIResponse
(
data
=
data
)
assert
res
.
is_success
assert
res
.
disassembly
==
disassemble_response
def
test_command
():
data
=
requests
.
get
(
'http://localhost:5555/api/command?command=reg%20read'
).
text
res
=
APIResponse
(
data
=
data
)
assert
res
.
is_success
assert
res
.
output
==
command_response
def
test_targets
():
data
=
requests
.
get
(
'http://localhost:5555/api/targets'
).
text
res
=
api_response
(
'targets'
,
data
=
data
)
assert
res
.
is_success
assert
res
.
targets
==
targets_response
def
test_memory
():
data
=
requests
.
get
(
'http://localhost:5555/api/registers'
).
text
res
=
api_response
(
'registers'
,
data
=
data
)
url
=
'http://localhost:5555/api/memory?address={}&length=64'
.
format
(
res
.
registers
[
'rip'
])
data
=
requests
.
get
(
url
).
text
res
=
api_response
(
'memory'
,
data
=
data
)
assert
res
.
is_success
assert
res
.
memory
==
memory_response
def
test_registers
():
data
=
requests
.
get
(
'http://localhost:5555/api/registers'
).
text
res
=
api_response
(
'registers'
,
data
=
data
)
assert
res
.
is_success
assert
res
.
registers
==
registers_response
def
test_stack_length_missing
():
data
=
requests
.
get
(
'http://localhost:5555/api/stack'
).
text
res
=
APIErrorResponse
(
data
=
data
)
assert
res
.
is_error
assert
res
.
message
==
'length'
def
test_stack
():
data
=
requests
.
get
(
'http://localhost:5555/api/stack?length=64'
).
text
res
=
api_response
(
'stack'
,
data
=
data
)
assert
res
.
is_success
assert
res
.
memory
==
stack_response
def
test_state
():
data
=
requests
.
get
(
'http://localhost:5555/api/state'
).
text
res
=
api_response
(
'state'
,
data
=
data
)
assert
res
.
is_success
assert
res
.
state
==
state_response
def
test_version
():
data
=
requests
.
get
(
'http://localhost:5555/api/version'
).
text
res
=
api_response
(
'version'
,
data
=
data
)
assert
res
.
is_success
assert
res
.
api_version
==
1.1
assert
res
.
host_version
==
'lldb-something'
def
test_bad_json
():
data
=
requests
.
post
(
'http://localhost:5555/api/request'
,
data
=
'xxx'
).
text
res
=
APIResponse
(
data
=
data
)
assert
res
.
is_error
assert
res
.
code
==
0x1001
def
test_bad_request
():
data
=
requests
.
post
(
'http://localhost:5555/api/request'
,
data
=
'{"type":"request","request":"no_such_request"}'
).
text
res
=
APIResponse
(
data
=
data
)
assert
res
.
is_error
assert
res
.
code
==
0x1002
def
test_breakpoints
():
data
=
requests
.
get
(
'http://localhost:5555/api/breakpoints'
).
text
res
=
api_response
(
'breakpoints'
,
data
=
data
)
assert
res
.
is_success
assert
res
.
breakpoints
==
breakpoints_response
Back
|
FazBrowse Home
|
New Git URL