Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
interfect
funkwhale
Commits
f526f0c1
Verified
Commit
f526f0c1
authored
Mar 31, 2018
by
Eliot Berriot
Browse files
More flexible auth signature factory
parent
e1ebd498
Changes
1
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/federation/factories.py
View file @
f526f0c1
...
...
@@ -16,7 +16,12 @@ class SignatureAuthFactory(factory.Factory):
key
=
factory
.
LazyFunction
(
lambda
:
keys
.
get_key_pair
()[
0
])
key_id
=
factory
.
Faker
(
'url'
)
use_auth_header
=
False
headers
=
[
'(request-target)'
,
'user-agent'
,
'host'
,
'date'
,
'content-type'
,]
class
Meta
:
model
=
requests_http_signature
.
HTTPSignatureAuth
...
...
@@ -29,3 +34,28 @@ class SignedRequestFactory(factory.Factory):
class
Meta
:
model
=
requests
.
Request
@
factory
.
post_generation
def
headers
(
self
,
create
,
extracted
,
**
kwargs
):
default_headers
=
{
'User-Agent'
:
'Test'
,
'Host'
:
'test.host'
,
'Date'
:
'Right now'
,
'Content-Type'
:
'application/activity+json'
}
if
extracted
:
default_headers
.
update
(
extracted
)
self
.
headers
.
update
(
default_headers
)
# @registry.register
# class ActorFactory(factory.DjangoModelFactory):
# url = factory.Faker('url')
# inbox_url = factory.Faker('url')
# outbox_url = factory.Faker('url')
# public_key = factory.LazyFunction(lambda: keys.get_key_pair()[1])
# preferred_username = factory.Faker('username')
# summary = factory.Faker('paragraph')
#
# class Meta:
# model = models.Actor
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment