Skip to content

Conversation

@meejah
Copy link
Collaborator

@meejah meejah commented Jun 1, 2022

@exarkun
The client side of this might look like:

import json
from autobahn.twisted.websocket import (
    create_client_agent,
)
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks, returnValue, Deferred


@inlineCallbacks
def main(reactor):
    agent = create_client_agent(reactor)
    uri = "ws://127.0.0.1:8888/storage-plugins/privatestorageio-zkapauthz-v2/recover"
    dircap = "URI:DIR2-RO:oibl7ox3nc4cwjqx4f3nrwquxi:qjbyvkxqey7lyaktni6gbg5zyzeiphfnk6jdvjrp6y4wf2ktufeq"
    print("URI", uri)
    with open("/home/meejah/.config/gridsync/PrivateStorage Staging/private/api_auth_token") as f:
        token = f.read()
    proto = yield agent.open(
        uri,
        {"headers": {"Authorization": f"tahoe-lafs {token}"}},
    )

    def status_update(data, is_binary=False):
        print(f"status update: {data}")
        # XXX e.g. hook into UI to display state
    proto.on("message", status_update)

    print("wait for open")
    yield proto.is_open
    print("send recovery request")
    yield proto.sendMessage(json.dumps({"recovery-capability": dircap}).encode("utf8"))
    try:
        print("wait for close")
        yield proto.is_closed
    except Exception as e:
        raise TahoeWebError(f"Error during recovery: {e}")



from twisted.internet.task import react
react(main)

@exarkun
Copy link
Collaborator

exarkun commented Jun 3, 2022

As discussed yesterday, this direction looks good to me.

@meejah
Copy link
Collaborator Author

meejah commented Jun 4, 2022

Tests added

@meejah meejah mentioned this pull request Jun 4, 2022
@meejah
Copy link
Collaborator Author

meejah commented Jun 6, 2022

besides "there's something up with dependencies" which I have yet to figure out, i think this is ready for review @exarkun

(I think the trick is to find an Autobahn with the right testing fixes that is old enough to keep the rest happy?)

meejah and others added 8 commits June 5, 2022 20:30
This avoids a `resolvelib.ResolutionTooDeep` during dependency resolution, for
some reason.

We also switch to getting cryptography from nixpkgs because there is a new
enough version there to satisfy the new constraint in autobahn and it's harder
to get cryptography from an sdist or wheel.

pypi-deps-db only has sdist metadata up to cryptography 3.3.2 after which
cryptography switched to setuptools_rust which breaks mach-nix's metadata
scanner for sdists.

pypi-deps-db has lots of wheel metadata but cryptography distributes abi3
wheels which it seems mach-nix doesn't entirely support (it can't figure out
that though they have the cp36 tag they should be usable by later pythons).
Then we don't need to mutate them later or even offer a mutation API.
Assert against both message lists at the same time so we can see all of the
unexpected values instead of only one.
Copy link
Collaborator

@exarkun exarkun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I pushed some changes and also left some inline comments.

@codecov
Copy link

codecov bot commented Jun 7, 2022

Codecov Report

Merging #410 (2cdfd6c) into main (87c6c9d) will decrease coverage by 0.09%.
The diff coverage is 98.39%.

❗ Current head 2cdfd6c differs from pull request most recent head c1844f5. Consider uploading reports for the commit c1844f5 to get more accurate results

@@            Coverage Diff             @@
##             main     #410      +/-   ##
==========================================
- Coverage   96.32%   96.23%   -0.10%     
==========================================
  Files          63       63              
  Lines        7428     7508      +80     
  Branches     1004     1013       +9     
==========================================
+ Hits         7155     7225      +70     
- Misses        204      210       +6     
- Partials       69       73       +4     
Impacted Files Coverage Δ
src/_zkapauthorizer/resource.py 99.24% <97.56%> (-0.76%) ⬇️
src/_zkapauthorizer/tests/test_client_resource.py 98.00% <98.76%> (-0.55%) ⬇️
src/_zkapauthorizer/model.py 97.42% <100.00%> (ø)
src/_zkapauthorizer/recover.py 97.65% <100.00%> (+0.05%) ⬆️
src/_zkapauthorizer/tests/test_plugin.py 99.70% <100.00%> (+0.01%) ⬆️
...rc/_zkapauthorizer/tests/test_lease_maintenance.py 94.55% <0.00%> (-1.99%) ⬇️
src/_zkapauthorizer/tahoe.py 92.61% <0.00%> (-0.74%) ⬇️
src/_zkapauthorizer/tests/test_model.py 99.49% <0.00%> (-0.26%) ⬇️
src/_zkapauthorizer/tests/strategies.py 97.18% <0.00%> (+0.70%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@meejah meejah merged commit c83fac5 into PrivateStorageio:main Jun 7, 2022
@meejah meejah deleted the poc-websocket-restore branch June 7, 2022 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants