Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
ZKAPAuthorizer
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Administrator
ZKAPAuthorizer
Commits
90c597fa
Commit
90c597fa
authored
5 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Add a very boring zkap collection resource
parent
1342a6e1
No related branches found
Branches containing commit
No related tags found
1 merge request
!59
Unblinded token web interface
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/_zkapauthorizer/resource.py
+28
-0
28 additions, 0 deletions
src/_zkapauthorizer/resource.py
src/_zkapauthorizer/tests/test_client_resource.py
+60
-11
60 additions, 11 deletions
src/_zkapauthorizer/tests/test_client_resource.py
with
88 additions
and
11 deletions
src/_zkapauthorizer/resource.py
+
28
−
0
View file @
90c597fa
...
...
@@ -77,6 +77,13 @@ def from_configuration(node_config, store, redeemer=None):
controller
,
),
)
root
.
putChild
(
b
"
zkap
"
,
_ZKAPCollection
(
store
,
controller
,
),
)
return
root
...
...
@@ -89,6 +96,27 @@ def application_json(request):
request
.
responseHeaders
.
setRawHeaders
(
u
"
content-type
"
,
[
u
"
application/json
"
])
class
_ZKAPCollection
(
Resource
):
"""
This class implements inspection of ZKAPs. Users **GET** this resource to
find out about ZKAPs in the system.
"""
_log
=
Logger
()
def
__init__
(
self
,
store
,
controller
):
self
.
_store
=
store
self
.
_controller
=
controller
Resource
.
__init__
(
self
)
def
render_GET
(
self
,
request
):
"""
Retrieve some ZKAPs and associated informatin.
"""
application_json
(
request
)
return
dumps
({
u
"
total
"
:
0
,
u
"
zkaps
"
:
[]})
class
_VoucherCollection
(
Resource
):
"""
This class implements redemption of vouchers. Users **PUT** such numbers
...
...
This diff is collapsed.
Click to expand it.
src/_zkapauthorizer/tests/test_client_resource.py
+
60
−
11
View file @
90c597fa
...
...
@@ -205,32 +205,81 @@ def root_from_config(config):
)
class
Voucher
Tests
(
TestCase
):
class
Resource
Tests
(
TestCase
):
"""
Tests relating to ``/voucher`` as implemented by the
``_zkapauthorizer.resource`` module and its handling of
vouchers.
General tests for the resources exposed by the plugin.
"""
@given
(
tahoe_configs
(),
requests
(
just
([
u
"
zkap
"
])
|
just
([
u
"
voucher
"
])))
def
test_reachable
(
self
,
get_config
,
request
):
"""
A resource is reachable at a child of the resource returned by
``from_configuration``.
"""
tempdir
=
self
.
useFixture
(
TempDir
())
config
=
get_config
(
tempdir
.
join
(
b
"
tahoe
"
),
b
"
tub.port
"
)
root
=
root_from_config
(
config
)
self
.
assertThat
(
getChildForRequest
(
root
,
request
),
Provides
([
IResource
]),
)
class
ZKAPTests
(
TestCase
):
"""
Tests relating to ``/zkap`` as implemented by the
``_zkapauthorizer.resource`` module.
"""
def
setUp
(
self
):
super
(
Voucher
Tests
,
self
).
setUp
()
super
(
ZKAP
Tests
,
self
).
setUp
()
self
.
useFixture
(
CaptureTwistedLogs
())
@given
(
tahoe_configs
()
,
requests
(
just
([
u
"
voucher
"
]))
)
def
test_
reachable
(
self
,
get_config
,
request
):
@given
(
tahoe_configs
())
def
test_
get
(
self
,
get_config
):
"""
A resource is reachable at the ``voucher`` child of a the resource
returned by ``from_configuration``.
"""
tempdir
=
self
.
useFixture
(
TempDir
())
config
=
get_config
(
tempdir
.
join
(
b
"
tahoe
"
),
b
"
tub.port
"
)
root
=
root_from_config
(
config
)
agent
=
RequestTraversalAgent
(
root
)
requesting
=
agent
.
request
(
b
"
GET
"
,
b
"
http://127.0.0.1/zkap
"
,
)
self
.
addDetail
(
u
"
requesting result
"
,
text_content
(
u
"
{}
"
.
format
(
vars
(
requesting
.
result
))),
)
self
.
assertThat
(
getChildForRequest
(
root
,
request
),
Provides
([
IResource
]),
requesting
,
succeeded
(
MatchesAll
(
ok_response
(
headers
=
application_json
()),
AfterPreprocessing
(
json_content
,
succeeded
(
Equals
({
u
"
total
"
:
0
,
u
"
zkaps
"
:
[],
}),
)
),
),
),
)
class
VoucherTests
(
TestCase
):
"""
Tests relating to ``/voucher`` as implemented by the
``_zkapauthorizer.resource`` module and its handling of
vouchers.
"""
def
setUp
(
self
):
super
(
VoucherTests
,
self
).
setUp
()
self
.
useFixture
(
CaptureTwistedLogs
())
@given
(
tahoe_configs
(),
vouchers
())
def
test_put_voucher
(
self
,
get_config
,
voucher
):
"""
...
...
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