Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
requests-http-message-signatures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
requests-http-message-signatures
Commits
ebf27189
Unverified
Commit
ebf27189
authored
3 years ago
by
Georg Krause
Browse files
Options
Downloads
Patches
Plain Diff
Remove python2 compatibility code
parent
0d89ee66
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
requests_http_message_signatures/__init__.py
+4
-6
4 additions, 6 deletions
requests_http_message_signatures/__init__.py
test/test.py
+3
-3
3 additions, 3 deletions
test/test.py
with
7 additions
and
9 deletions
requests_http_message_signatures/__init__.py
+
4
−
6
View file @
ebf27189
from
__future__
import
absolute_import
,
division
,
print_function
,
unicode_literals
import
base64
,
hashlib
,
hmac
,
time
import
email.utils
import
requests
from
requests.compat
import
urlparse
from
urllib.parse
import
urlparse
from
requests.exceptions
import
RequestException
class
RequestsHttpSignatureException
(
RequestException
):
class
RequestsHttp
Message
Signature
s
Exception
(
RequestException
):
"""
An error occurred while constructing the HTTP Signature for your request.
"""
...
...
@@ -103,7 +101,7 @@ class HTTPSignatureAuth(requests.auth.AuthBase):
def
add_digest
(
self
,
request
):
if
request
.
body
is
None
and
"
digest
"
in
self
.
headers
:
raise
RequestsHttpSignatureException
(
raise
RequestsHttp
Message
Signature
s
Exception
(
"
Could not compute digest header for request without a body
"
)
if
request
.
body
is
not
None
and
"
Digest
"
not
in
request
.
headers
:
...
...
@@ -202,7 +200,7 @@ class HTTPSignatureAuth(requests.auth.AuthBase):
elif
scheme
==
"
Signature
"
:
assert
"
Signature
"
in
request
.
headers
,
"
No Signature header found
"
else
:
raise
RequestsHttpSignatureException
(
raise
RequestsHttp
Message
Signature
s
Exception
(
'
Unknown signature scheme
"
{}
"'
.
format
(
scheme
)
)
...
...
This diff is collapsed.
Click to expand it.
test/test.py
+
3
−
3
View file @
ebf27189
...
...
@@ -13,10 +13,10 @@ sys.path.insert(
0
,
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
..
"
))
)
# noqa
from
requests_http_signature
import
(
from
requests_http_
message_
signature
s
import
(
HTTPSignatureAuth
,
HTTPSignatureHeaderAuth
,
RequestsHttpSignatureException
,
RequestsHttp
Message
Signature
s
Exception
,
)
hmac_secret
=
b
"
monorail_cat
"
...
...
@@ -77,7 +77,7 @@ class TestRequestsHTTPSignature(unittest.TestCase):
url
,
auth
=
HTTPSignatureAuth
(
key
=
hmac_secret
[::
-
1
],
key_id
=
"
sekret
"
)
)
with
self
.
assertRaisesRegex
(
RequestsHttpSignatureException
,
RequestsHttp
Message
Signature
s
Exception
,
"
Could not compute digest header for request without a body
"
,
):
self
.
session
.
get
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment