Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
url-checker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
url-checker
Commits
4e315e81
Commit
4e315e81
authored
Dec 02, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lint
parent
b8bd2d34
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
30 deletions
+15
-30
test_urlchecker_db.py
test_urlchecker_db.py
+0
-1
test_urlchecker_dns.py
test_urlchecker_dns.py
+2
-2
test_urlchecker_http.py
test_urlchecker_http.py
+8
-21
test_urlchecker_network.py
test_urlchecker_network.py
+2
-1
urlchecker_dns.py
urlchecker_dns.py
+1
-1
urlchecker_http.py
urlchecker_http.py
+1
-3
urlchecker_network.py
urlchecker_network.py
+1
-1
No files found.
test_urlchecker_db.py
View file @
4e315e81
import
unittest
from
urlchecker_db
import
LogDB
import
peewee
class
UrlCheckerDBTestCase
(
unittest
.
TestCase
):
...
...
test_urlchecker_dns.py
View file @
4e315e81
...
...
@@ -43,7 +43,7 @@ class UrlCheckerDNSTestCase(unittest.TestCase):
rdtype
=
"foo"
answer_list
=
[
"4.3.2.1"
,
"1.2.3.4"
]
status_id
=
logStatus
(
self
.
db
,
"foo"
)
result
=
logDnsQuery
(
logDnsQuery
(
self
.
db
,
status_id
,
resolver_ip
,
domain
,
rdtype
,
answer_list
)
answer_list
.
extend
(
"127.0.0.1"
)
...
...
@@ -165,7 +165,7 @@ class UrlCheckerDNSTestCase(unittest.TestCase):
rdtype_2
=
rdtype
+
"bar"
answer_list
=
[
"4.3.2.1"
,
"1.2.3.4"
]
status_id
=
logStatus
(
self
.
db
,
"foo"
)
result
=
logDnsQuery
(
logDnsQuery
(
self
.
db
,
status_id
,
resolver_ip
,
domain
,
rdtype
,
answer_list
)
logDnsQuery
(
...
...
test_urlchecker_http.py
View file @
4e315e81
...
...
@@ -29,21 +29,7 @@ class UrlCheckerHttpTestCase(unittest.TestCase):
################################################
# getUserAgent
################################################
def
test_getUserAgent_default
(
self
):
result
=
getUserAgent
()
assert
(
result
==
"URLCHECKER/0 (+https://lab.nexedi.com/romain/url-checker)"
)
def
test_getUserAgent_default
(
self
):
result
=
getUserAgent
(
None
)
assert
(
result
==
"URLCHECKER/0 (+https://lab.nexedi.com/romain/url-checker)"
)
def
test_getUserAgent_default
(
self
):
def
test_getUserAgent_version
(
self
):
result
=
getUserAgent
(
"0.0.3"
)
assert
(
result
...
...
@@ -56,7 +42,7 @@ class UrlCheckerHttpTestCase(unittest.TestCase):
def
test_request_arguments
(
self
):
url_to_proxy
=
"http://example.org/"
with
mock
.
patch
(
"urlchecker_http.requests.request"
)
as
mock_request
:
re
sponse
=
re
quest
(
url_to_proxy
)
request
(
url_to_proxy
)
assert
mock_request
.
call_count
==
1
mock_request
.
assert_called_with
(
"GET"
,
...
...
@@ -178,6 +164,7 @@ class UrlCheckerHttpTestCase(unittest.TestCase):
assert
self
.
db
.
HttpCodeChange
.
get
().
url
==
url
assert
self
.
db
.
HttpCodeChange
.
get
().
status_code
==
status_code
assert
self
.
db
.
HttpCodeChange
.
get
().
status_id
==
status_id
assert
result
==
status_id
def
test_logHttpStatus_insertOnlyOnePerStatusIdIPUrl
(
self
):
ip
=
"127.0.0.1"
...
...
@@ -189,7 +176,7 @@ class UrlCheckerHttpTestCase(unittest.TestCase):
logHttpStatus
(
self
.
db
,
ip
,
url
,
status_code
+
1
,
status_id
)
except
peewee
.
IntegrityError
:
assert
self
.
db
.
HttpCodeChange
.
select
().
count
()
==
1
assert
self
.
db
.
HttpCodeChange
.
get
().
status
==
result
assert
self
.
db
.
HttpCodeChange
.
get
().
status
_id
==
result
else
:
raise
NotImplementedError
(
"Expected IntegrityError"
)
...
...
@@ -263,10 +250,10 @@ class UrlCheckerHttpTestCase(unittest.TestCase):
url_2
=
url
+
"2"
status_code
=
200
status_id
=
logStatus
(
self
.
db
,
"foo"
)
result
=
logHttpStatus
(
self
.
db
,
ip
,
url
,
status_code
,
status_id
)
result_2
=
logHttpStatus
(
self
.
db
,
ip_2
,
url
,
status_code
,
status_id
)
result_3
=
logHttpStatus
(
self
.
db
,
ip
,
url_2
,
status_code
,
status_id
)
result_4
=
logHttpStatus
(
self
.
db
,
ip_2
,
url_2
,
status_code
,
status_id
)
logHttpStatus
(
self
.
db
,
ip
,
url
,
status_code
,
status_id
)
logHttpStatus
(
self
.
db
,
ip_2
,
url
,
status_code
,
status_id
)
logHttpStatus
(
self
.
db
,
ip
,
url_2
,
status_code
,
status_id
)
logHttpStatus
(
self
.
db
,
ip_2
,
url_2
,
status_code
,
status_id
)
assert
self
.
db
.
HttpCodeChange
.
select
().
count
()
==
4
################################################
...
...
test_urlchecker_network.py
View file @
4e315e81
...
...
@@ -29,6 +29,7 @@ class UrlCheckerNetworkTestCase(unittest.TestCase):
assert
self
.
db
.
NetworkChange
.
get
().
transport
==
transport
assert
self
.
db
.
NetworkChange
.
get
().
state
==
state
assert
self
.
db
.
NetworkChange
.
get
().
status_id
==
status_id
assert
result
==
status_id
def
test_logNetwork_insertOnlyOnePerStatusIdIPPortTransport
(
self
):
ip
=
"127.0.0.1"
...
...
@@ -37,7 +38,7 @@ class UrlCheckerNetworkTestCase(unittest.TestCase):
state
=
"bar"
status_id
=
logStatus
(
self
.
db
,
"foo"
)
result
=
logNetwork
(
self
.
db
,
ip
,
transport
,
port
,
state
,
status_id
)
logNetwork
(
self
.
db
,
ip
,
transport
,
port
,
state
,
status_id
)
try
:
logNetwork
(
self
.
db
,
ip
,
transport
,
port
,
state
+
"."
,
status_id
)
except
peewee
.
IntegrityError
:
...
...
urlchecker_dns.py
View file @
4e315e81
...
...
@@ -58,7 +58,7 @@ def queryDNS(db, status_id, resolver_ip, resolver, domain_text, rdtype):
):
answer_list
=
[]
logD
NS
Query
(
db
,
status_id
,
resolver_ip
,
domain_text
,
rdtype
,
answer_list
)
logD
ns
Query
(
db
,
status_id
,
resolver_ip
,
domain_text
,
rdtype
,
answer_list
)
return
answer_list
...
...
urlchecker_http.py
View file @
4e315e81
import
requests
from
urllib.parse
import
urlparse
,
urlunsplit
import
sys
import
traceback
from
forcediphttpsadapter.adapters
import
ForcedIPHTTPSAdapter
...
...
@@ -79,7 +77,7 @@ def logHttpStatus(db, ip, url, code, status_id):
previous_entry
=
db
.
HttpCodeChange
.
create
(
status
=
status_id
,
ip
=
ip
,
url
=
url
,
status_code
=
code
)
return
previous_entry
.
status
return
previous_entry
.
status
_id
def
checkHttpStatus
(
db
,
status_id
,
url
,
ip
,
bot_version
):
...
...
urlchecker_network.py
View file @
4e315e81
...
...
@@ -30,7 +30,7 @@ def logNetwork(db, ip, transport, port, state, status_id):
port
=
port
,
state
=
state
,
)
return
previous_entry
.
status
return
previous_entry
.
status
_id
def
isTcpPortOpen
(
db
,
ip
,
port
,
status_id
):
...
...
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