pusharmor 0.0.35__tar.gz → 0.0.44__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pusharmor-0.0.35 → pusharmor-0.0.44}/PKG-INFO +1 -1
- {pusharmor-0.0.35 → pusharmor-0.0.44}/pusharmor.egg-info/PKG-INFO +1 -1
- {pusharmor-0.0.35 → pusharmor-0.0.44}/pusharmor.py +27 -22
- {pusharmor-0.0.35 → pusharmor-0.0.44}/tests/test_cli.py +28 -25
- {pusharmor-0.0.35 → pusharmor-0.0.44}/README.md +0 -0
- {pusharmor-0.0.35 → pusharmor-0.0.44}/pusharmor.egg-info/SOURCES.txt +0 -0
- {pusharmor-0.0.35 → pusharmor-0.0.44}/pusharmor.egg-info/dependency_links.txt +0 -0
- {pusharmor-0.0.35 → pusharmor-0.0.44}/pusharmor.egg-info/entry_points.txt +0 -0
- {pusharmor-0.0.35 → pusharmor-0.0.44}/pusharmor.egg-info/requires.txt +0 -0
- {pusharmor-0.0.35 → pusharmor-0.0.44}/pusharmor.egg-info/top_level.txt +0 -0
- {pusharmor-0.0.35 → pusharmor-0.0.44}/pyproject.toml +0 -0
- {pusharmor-0.0.35 → pusharmor-0.0.44}/setup.cfg +0 -0
- {pusharmor-0.0.35 → pusharmor-0.0.44}/tests/test_golden.py +0 -0
- {pusharmor-0.0.35 → pusharmor-0.0.44}/tests/test_version.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
# PushArmor command-line client, version 0.0.
|
|
2
|
+
# PushArmor command-line client, version 0.0.44
|
|
3
3
|
"""PushArmor command-line client.
|
|
4
4
|
|
|
5
5
|
The top part is the core layer: encodings, keys, signed requests, HPKE,
|
|
@@ -42,7 +42,7 @@ except BaseException: # missing, or broken: no _cffi_backend is ImportError, a
|
|
|
42
42
|
sys.stderr.write("error: " + CRYPTO_MISSING + "\n")
|
|
43
43
|
sys.exit(1)
|
|
44
44
|
|
|
45
|
-
VERSION = "0.0.
|
|
45
|
+
VERSION = "0.0.44"
|
|
46
46
|
USER_AGENT = "PushArmor-CLI/" + VERSION
|
|
47
47
|
|
|
48
48
|
# ---- encodings ----
|
|
@@ -952,7 +952,7 @@ FETCH_GAP_S = 60
|
|
|
952
952
|
PLATFORMS = {"android": "Android", "ios": "iPhone", "chrome": "Chrome", "firefox": "Firefox", "cli": "Command line"}
|
|
953
953
|
MONTHS = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split()
|
|
954
954
|
REC_KEYS = ("from", "name", "platform", "type", "body", "date")
|
|
955
|
-
NOT_LOGGED_IN = "This device is not logged in. Run: pusharmor login"
|
|
955
|
+
NOT_LOGGED_IN = "This device is not logged in. Run: `pusharmor login`"
|
|
956
956
|
LOGGED_OUT = "This device is logged out. Log in to resume."
|
|
957
957
|
REMOVED = "This device was removed from the account. Log in again."
|
|
958
958
|
UNREACHABLE = "The relay server could not be reached. Check your internet connection and try again."
|
|
@@ -1303,8 +1303,8 @@ def check_private(path, want):
|
|
|
1303
1303
|
return
|
|
1304
1304
|
q = quoted_path(path)
|
|
1305
1305
|
if st.st_uid != os.getuid():
|
|
1306
|
-
raise Fail("%s belongs to another user. Run: chown $(id -un) %s" % (q, q))
|
|
1307
|
-
raise Fail("%s must not be readable by other users. Run: chmod %o %s" % (q, want, q))
|
|
1306
|
+
raise Fail("%s belongs to another user. Run: `chown $(id -un) %s`" % (q, q))
|
|
1307
|
+
raise Fail("%s must not be readable by other users. Run: `chmod %o %s`" % (q, want, q))
|
|
1308
1308
|
|
|
1309
1309
|
|
|
1310
1310
|
def check_unshared(path, folder):
|
|
@@ -1317,7 +1317,7 @@ def check_unshared(path, folder):
|
|
|
1317
1317
|
return
|
|
1318
1318
|
mode = stat.S_IMODE(st.st_mode)
|
|
1319
1319
|
if mode & 0o022:
|
|
1320
|
-
raise Fail("%s can be changed by other users. Run: chmod go-w %s" % (quoted_path(path), quoted_path(path)))
|
|
1320
|
+
raise Fail("%s can be changed by other users. Run: `chmod go-w %s`" % (quoted_path(path), quoted_path(path)))
|
|
1321
1321
|
|
|
1322
1322
|
|
|
1323
1323
|
def quoted_path(path):
|
|
@@ -2104,6 +2104,11 @@ def receive_pair(cx, pt):
|
|
|
2104
2104
|
r = post_pair(cx, frm, "open", send)
|
|
2105
2105
|
if r not in ("sent", "429") and cx.mode == "pair" and frm == cx.target:
|
|
2106
2106
|
raise Fail(pair_reason(r, peer_label(p))) # its fingerprint would never show; pair again sends it
|
|
2107
|
+
if r not in ("sent", "429"):
|
|
2108
|
+
with cx.store.state(write=False) as d:
|
|
2109
|
+
sid = short_id(frm, d["peers"])
|
|
2110
|
+
log("warning", 'Unable to continue pairing with "%s". %s Run: `pusharmor pair %s` to try again.'
|
|
2111
|
+
% (peer_label(p), pair_reason(r, peer_label(p)), sid))
|
|
2107
2112
|
|
|
2108
2113
|
|
|
2109
2114
|
def pair_note(cx, d, x, text):
|
|
@@ -2115,7 +2120,7 @@ def pair_note(cx, d, x, text):
|
|
|
2115
2120
|
if x in cx.also:
|
|
2116
2121
|
return None
|
|
2117
2122
|
cx.also.add(x)
|
|
2118
|
-
text = '"%s" also wants to pair. Run: pusharmor pair %s'
|
|
2123
|
+
text = '"%s" also wants to pair. Run: `pusharmor pair %s`'
|
|
2119
2124
|
return ("info", text % (peer_label(d["peers"].get(x)), short_id(x, d["peers"])))
|
|
2120
2125
|
|
|
2121
2126
|
|
|
@@ -2140,7 +2145,7 @@ def on_commit(cx, frm, c_n, listed):
|
|
|
2140
2145
|
ruling = p["ruling"]
|
|
2141
2146
|
unpin(p)
|
|
2142
2147
|
p["ruling"] = ruling
|
|
2143
|
-
notes.append(pair_note(cx, d, frm, 'Pairing with "%s" failed. Run: pusharmor pair %s to start again.'))
|
|
2148
|
+
notes.append(pair_note(cx, d, frm, 'Pairing with "%s" failed. Run: `pusharmor pair %s` to start again.'))
|
|
2144
2149
|
# the old entry is gone: decide the new commit on its own
|
|
2145
2150
|
if dec["entry"].startswith("created") or dec["entry"] == "n_wiped_x_replied":
|
|
2146
2151
|
e = d["pairs"][frm] = new_entry("X", "prompted", secrets.token_bytes(32), c_n)
|
|
@@ -2151,12 +2156,12 @@ def on_commit(cx, frm, c_n, listed):
|
|
|
2151
2156
|
d["pair_auto"] = [t for t in d["pair_auto"] if 0 <= now - t < PAIR_CAP_WINDOW_S] + [now]
|
|
2152
2157
|
notice = dec["notice"]
|
|
2153
2158
|
if notice in ("commit", "represent"):
|
|
2154
|
-
notes.append(pair_note(cx, d, frm, '"%s" wants to pair. Run: pusharmor pair %s'))
|
|
2159
|
+
notes.append(pair_note(cx, d, frm, '"%s" wants to pair. Run: `pusharmor pair %s`'))
|
|
2155
2160
|
elif notice == "crossing":
|
|
2156
2161
|
notes.append(pair_note(cx, d, frm, 'Pairing with "%s" is in progress. (%s)'))
|
|
2157
2162
|
again = e["msg"] # X may never have got this device's commit: send the stored one again
|
|
2158
2163
|
elif notice == "half_state":
|
|
2159
|
-
notes.append(pair_note(cx, d, frm, '"%s" wants to pair again. Run: pusharmor pair %s'))
|
|
2164
|
+
notes.append(pair_note(cx, d, frm, '"%s" wants to pair again. Run: `pusharmor pair %s`'))
|
|
2160
2165
|
else:
|
|
2161
2166
|
notes.append(("warning", UNREADABLE))
|
|
2162
2167
|
for n in notes:
|
|
@@ -2195,7 +2200,7 @@ def on_open(cx, d, e, p, o, notes):
|
|
|
2195
2200
|
return notes.append(("warning", UNREADABLE))
|
|
2196
2201
|
if not open_matches_commit(o, b64d(e["c_N"])):
|
|
2197
2202
|
d["pairs"].pop(frm, None)
|
|
2198
|
-
return notes.append(pair_note(cx, d, frm, 'Pairing with "%s" failed. Run: pusharmor pair %s to start again.'))
|
|
2203
|
+
return notes.append(pair_note(cx, d, frm, 'Pairing with "%s" failed. Run: `pusharmor pair %s` to start again.'))
|
|
2199
2204
|
r_x = b64d(e["r"])
|
|
2200
2205
|
pin_peer(p, o["sign_pub"], o["enc_pub"], pairing_id(o["r"], r_x))
|
|
2201
2206
|
e.update(state="shown", fingerprint=sas(o["sign_pub"], o["enc_pub"], k["sign_pub"], k["enc_pub"], o["r"], r_x),
|
|
@@ -2345,7 +2350,7 @@ def sweep(cx):
|
|
|
2345
2350
|
if a == "drop_pin" and p and not p["approve_verified"]:
|
|
2346
2351
|
unpin(p)
|
|
2347
2352
|
dropped = True
|
|
2348
|
-
log("info", 'Pairing with "%s" timed out. Run: pusharmor pair %s to start again.'
|
|
2353
|
+
log("info", 'Pairing with "%s" timed out. Run: `pusharmor pair %s` to start again.'
|
|
2349
2354
|
% (peer_label(p), short_id(x, d["peers"])))
|
|
2350
2355
|
if dropped:
|
|
2351
2356
|
reconcile_allow(cx)
|
|
@@ -2472,12 +2477,12 @@ def cmd_login(cx, args):
|
|
|
2472
2477
|
try:
|
|
2473
2478
|
raw = ask("Code: ")
|
|
2474
2479
|
except EOFError:
|
|
2475
|
-
raise Fail("No code was entered. Run pusharmor login again.")
|
|
2480
|
+
raise Fail("No code was entered. Run `pusharmor login` again.")
|
|
2476
2481
|
code = re.sub(r"[\s\"'`]", "", raw)
|
|
2477
2482
|
if not re.fullmatch(r"[A-Za-z0-9_-]{34}", code):
|
|
2478
2483
|
code, tries = None, tries + 1
|
|
2479
2484
|
if tries >= CODE_TRIES:
|
|
2480
|
-
raise Fail("The code was not accepted after %d tries. Run pusharmor login to get a new code."
|
|
2485
|
+
raise Fail("The code was not accepted after %d tries. Run `pusharmor login` to get a new code."
|
|
2481
2486
|
% CODE_TRIES)
|
|
2482
2487
|
print("The code is not correct. Copy the whole code from the page and paste it again.")
|
|
2483
2488
|
continue
|
|
@@ -2570,7 +2575,7 @@ def register_with(cx, code, stream, push, ntfy):
|
|
|
2570
2575
|
if attempt == 0:
|
|
2571
2576
|
with contextlib.suppress(ApiError, TempFail):
|
|
2572
2577
|
send_push(cx)
|
|
2573
|
-
log("warning", "This device could not confirm that it can receive messages. Run pusharmor listen to try again.")
|
|
2578
|
+
log("warning", "This device could not confirm that it can receive messages. Run `pusharmor listen` to try again.")
|
|
2574
2579
|
|
|
2575
2580
|
|
|
2576
2581
|
def undo_register(cx):
|
|
@@ -2598,7 +2603,7 @@ def choose_evict(peers):
|
|
|
2598
2603
|
a = ""
|
|
2599
2604
|
picks = sorted({int(w) for w in a.split() if re.fullmatch(r"[0-9]{1,2}", w) and 1 <= int(w) <= len(rows)})
|
|
2600
2605
|
if not picks or len(picks) > 9:
|
|
2601
|
-
raise Fail("No devices were chosen to remove, so you are not logged in. Run pusharmor login to try again.")
|
|
2606
|
+
raise Fail("No devices were chosen to remove, so you are not logged in. Run `pusharmor login` to try again.")
|
|
2602
2607
|
return [rows[i - 1]["id"] for i in picks]
|
|
2603
2608
|
|
|
2604
2609
|
|
|
@@ -2652,7 +2657,7 @@ def cmd_logout(cx, args):
|
|
|
2652
2657
|
cx.setup()
|
|
2653
2658
|
with cx.store.state() as d:
|
|
2654
2659
|
d["reg"], d["logout_pending"] = "logged_out", True
|
|
2655
|
-
print("Logged out. Run pusharmor login to log in again.")
|
|
2660
|
+
print("Logged out. Run `pusharmor login` to log in again.")
|
|
2656
2661
|
retry_pending_logout(cx)
|
|
2657
2662
|
with cx.store.state(write=False) as d:
|
|
2658
2663
|
if d.get("logout_pending"):
|
|
@@ -2665,7 +2670,7 @@ def resolve_peer(cx, text, with_self=False):
|
|
|
2665
2670
|
ids = list(d["peers"]) + ([cx.me] if with_self else [])
|
|
2666
2671
|
x = resolve_id(text, ids)
|
|
2667
2672
|
if x is None:
|
|
2668
|
-
raise Fail('No device matches "%s". Run pusharmor pair to see your devices.' % text)
|
|
2673
|
+
raise Fail('No device matches "%s". Run `pusharmor pair` to see your devices.' % text)
|
|
2669
2674
|
return x
|
|
2670
2675
|
|
|
2671
2676
|
|
|
@@ -2783,7 +2788,7 @@ def cmd_pair(cx, args):
|
|
|
2783
2788
|
strict=True)
|
|
2784
2789
|
except EOFError:
|
|
2785
2790
|
print() # Ctrl-D leaves the cursor after the prompt
|
|
2786
|
-
raise Fail("No answer was given. Run pusharmor pair %s again." % sid)
|
|
2791
|
+
raise Fail("No answer was given. Run `pusharmor pair %s` again." % sid)
|
|
2787
2792
|
if not yes:
|
|
2788
2793
|
try:
|
|
2789
2794
|
deny(cx, x)
|
|
@@ -2819,7 +2824,7 @@ def cmd_pair(cx, args):
|
|
|
2819
2824
|
told, deadline = wait, time.time() + PAIR_WAIT_S # each wait ends after PAIR_WAIT_S
|
|
2820
2825
|
pt = stream.next(deadline)
|
|
2821
2826
|
if pt is None:
|
|
2822
|
-
raise Fail('Pairing with "%s" timed out. Run: pusharmor pair %s to try again.' % (name, sid))
|
|
2827
|
+
raise Fail('Pairing with "%s" timed out. Run: `pusharmor pair %s` to try again.' % (name, sid))
|
|
2823
2828
|
pair_receive(cx, pt, stream)
|
|
2824
2829
|
|
|
2825
2830
|
|
|
@@ -2910,7 +2915,7 @@ def cmd_send(cx, args):
|
|
|
2910
2915
|
for t in args.to:
|
|
2911
2916
|
pid = resolve_id(t, list(d["peers"]))
|
|
2912
2917
|
if pid is None:
|
|
2913
|
-
raise Fail('No device matches "%s". Run pusharmor pair to see your devices.' % t)
|
|
2918
|
+
raise Fail('No device matches "%s". Run `pusharmor pair` to see your devices.' % t)
|
|
2914
2919
|
if pid not in ready:
|
|
2915
2920
|
p = d["peers"][pid]
|
|
2916
2921
|
why = ("unknown" if p["missing"] else "unapproved" if not (
|
|
@@ -2919,7 +2924,7 @@ def cmd_send(cx, args):
|
|
|
2919
2924
|
raise Fail(SEND_WHY[why] % peer_label(p), EXIT_SEND)
|
|
2920
2925
|
targets.append(pid)
|
|
2921
2926
|
if not targets:
|
|
2922
|
-
raise Fail("No device is paired yet. Run pusharmor pair to pair one.", EXIT_SEND)
|
|
2927
|
+
raise Fail("No device is paired yet. Run `pusharmor pair` to pair one.", EXIT_SEND)
|
|
2923
2928
|
m, names = {}, {}
|
|
2924
2929
|
for pid in dict.fromkeys(targets):
|
|
2925
2930
|
p = d["peers"][pid]
|
|
@@ -299,14 +299,14 @@ def test_permissions(tmp_path):
|
|
|
299
299
|
os.chmod(st.keys_dir, mode)
|
|
300
300
|
with pytest.raises(pa.Fail) as e:
|
|
301
301
|
st.load_keys()
|
|
302
|
-
assert str(e.value) == "'%s' must not be readable by other users. Run: chmod 700 '%s'" % (
|
|
302
|
+
assert str(e.value) == "'%s' must not be readable by other users. Run: `chmod 700 '%s'`" % (
|
|
303
303
|
st.keys_dir, st.keys_dir)
|
|
304
304
|
os.chmod(st.keys_dir, 0o700)
|
|
305
305
|
for mode in (0o644, 0o670, 0o602):
|
|
306
306
|
os.chmod(st.key_path, mode)
|
|
307
307
|
with pytest.raises(pa.Fail) as e:
|
|
308
308
|
st.load_keys()
|
|
309
|
-
assert str(e.value) == "'%s' must not be readable by other users. Run: chmod 600 '%s'" % (
|
|
309
|
+
assert str(e.value) == "'%s' must not be readable by other users. Run: `chmod 600 '%s'`" % (
|
|
310
310
|
st.key_path, st.key_path)
|
|
311
311
|
os.chmod(st.key_path, 0o600)
|
|
312
312
|
uid = os.getuid()
|
|
@@ -314,7 +314,7 @@ def test_permissions(tmp_path):
|
|
|
314
314
|
mp.setattr(pa.os, "getuid", lambda: uid + 1)
|
|
315
315
|
with pytest.raises(pa.Fail) as e:
|
|
316
316
|
pa.check_private(st.key_path, 0o600)
|
|
317
|
-
assert str(e.value) == "'%s' belongs to another user. Run: chown $(id -un) '%s'" % (st.key_path, st.key_path)
|
|
317
|
+
assert str(e.value) == "'%s' belongs to another user. Run: `chown $(id -un) '%s'`" % (st.key_path, st.key_path)
|
|
318
318
|
|
|
319
319
|
|
|
320
320
|
def test_version_refused(tmp_path):
|
|
@@ -401,7 +401,7 @@ def test_typed_text_that_is_not_utf8(net, tmp_path, monkeypatch, capsys):
|
|
|
401
401
|
|
|
402
402
|
monkeypatch.setattr(pa, "input", bad, raising=False)
|
|
403
403
|
assert run(tmp_path / "a", "login") == 1
|
|
404
|
-
assert "The code was not accepted after 3 tries. Run pusharmor login to get a new code." in capsys.readouterr().err
|
|
404
|
+
assert "The code was not accepted after 3 tries. Run `pusharmor login` to get a new code." in capsys.readouterr().err
|
|
405
405
|
me = login(monkeypatch, tmp_path / "b")
|
|
406
406
|
monkeypatch.setattr(pa, "input", bad, raising=False)
|
|
407
407
|
assert run(tmp_path / "b", "delete", pa.id_hex(me)[:8]) == 1
|
|
@@ -547,8 +547,8 @@ def test_ctrl_d_at_the_fingerprint_prompt_keeps_the_pairing(net, tmp_path, monke
|
|
|
547
547
|
tb.join(30)
|
|
548
548
|
assert codes.get("b") == 1 and not eof[0]
|
|
549
549
|
err = capsys.readouterr().err
|
|
550
|
-
sid = err.split("Run pusharmor pair ")[1].split("
|
|
551
|
-
assert "No answer was given. Run pusharmor pair %s again.\n" % sid in err and pa.id_hex(ida).startswith(sid)
|
|
550
|
+
sid = err.split("Run `pusharmor pair ")[1].split("`")[0]
|
|
551
|
+
assert "No answer was given. Run `pusharmor pair %s` again.\n" % sid in err and pa.id_hex(ida).startswith(sid)
|
|
552
552
|
assert not any(m == "POST" and "/deny/" in path for m, path in net.log)
|
|
553
553
|
sb = state(b)
|
|
554
554
|
assert sb["pairs"][ida]["state"] == "shown" and sb["peers"][ida]["pinned"]
|
|
@@ -575,7 +575,7 @@ def test_abort_in_shown_drops_the_pin_and_keeps_the_ruling(net, tmp_path, monkey
|
|
|
575
575
|
p = state(b)["peers"][ida]
|
|
576
576
|
assert state(b)["pairs"][ida]["c_N"] == pa.b64e(b"d" * 32)
|
|
577
577
|
assert not p["pinned"] and p["pairing_id"] == "" and p["ruling"] == "none" # the new request clears "denied"
|
|
578
|
-
assert 'failed. Run: pusharmor pair %s to start again.' % pa.id_hex(ida)[:6] in capsys.readouterr().err
|
|
578
|
+
assert 'failed. Run: `pusharmor pair %s` to start again.' % pa.id_hex(ida)[:6] in capsys.readouterr().err
|
|
579
579
|
|
|
580
580
|
|
|
581
581
|
def pair_with_b_answer(monkeypatch, net, a, b, ida, idb, answer):
|
|
@@ -670,8 +670,8 @@ def test_abort_then_decides_the_new_commit(net, tmp_path, monkeypatch, capsys):
|
|
|
670
670
|
e = state(b)["pairs"][ida]
|
|
671
671
|
assert e["role"] == "X" and e["c_N"] == pa.b64e(b"d" * 32)
|
|
672
672
|
err = capsys.readouterr().err
|
|
673
|
-
assert 'failed. Run: pusharmor pair %s to start again.' % pa.id_hex(ida)[:6] in err
|
|
674
|
-
assert "wants to pair. Run: pusharmor pair %s" % pa.id_hex(ida)[:6] in err
|
|
673
|
+
assert 'failed. Run: `pusharmor pair %s` to start again.' % pa.id_hex(ida)[:6] in err
|
|
674
|
+
assert "wants to pair. Run: `pusharmor pair %s`" % pa.id_hex(ida)[:6] in err
|
|
675
675
|
|
|
676
676
|
|
|
677
677
|
def test_peer_list_opens_stored_remove_messages(net, tmp_path, monkeypatch, capsys):
|
|
@@ -795,7 +795,7 @@ def test_send_reads_a_bounded_amount_of_stdin(net, tmp_path, monkeypatch, capsys
|
|
|
795
795
|
assert big.buffer.tell() == pa.CONTENT_CAP * 4 + 1
|
|
796
796
|
monkeypatch.setattr(sys, "stdin", Stdin(tty=False, data=b"y" * 100 + b"\n"))
|
|
797
797
|
assert run(tmp_path, "send") == 4
|
|
798
|
-
assert "No device is paired yet. Run pusharmor pair to pair one." in capsys.readouterr().err
|
|
798
|
+
assert "No device is paired yet. Run `pusharmor pair` to pair one." in capsys.readouterr().err
|
|
799
799
|
|
|
800
800
|
|
|
801
801
|
def test_pair_timeouts_quote_the_device_name(net, tmp_path, monkeypatch, capsys):
|
|
@@ -811,8 +811,8 @@ def test_pair_timeouts_quote_the_device_name(net, tmp_path, monkeypatch, capsys)
|
|
|
811
811
|
capsys.readouterr()
|
|
812
812
|
assert run(a, "pair", pa.id_hex(idb)[:6]) == 1
|
|
813
813
|
err = capsys.readouterr().err
|
|
814
|
-
assert 'Pairing with "bee" timed out. Run: pusharmor pair %s to start again.\n' % pa.id_hex(idb)[:6] in err
|
|
815
|
-
assert 'error: Pairing with "bee" timed out. Run: pusharmor pair %s to try again.\n' % pa.id_hex(idb)[:6] in err
|
|
814
|
+
assert 'Pairing with "bee" timed out. Run: `pusharmor pair %s` to start again.\n' % pa.id_hex(idb)[:6] in err
|
|
815
|
+
assert 'error: Pairing with "bee" timed out. Run: `pusharmor pair %s` to try again.\n' % pa.id_hex(idb)[:6] in err
|
|
816
816
|
assert 'info: Waiting for "bee". Open PushArmor on it to continue pairing. Press Ctrl+C to stop.\n' in err
|
|
817
817
|
|
|
818
818
|
|
|
@@ -837,9 +837,9 @@ def test_another_device_that_wants_to_pair_is_shown_once(net, tmp_path, monkeypa
|
|
|
837
837
|
cx.target = "x" * 40
|
|
838
838
|
with cx.store.state(write=False) as d:
|
|
839
839
|
notes = [pa.pair_note(cx, d, ida, '"%s" wants to pair. Compare the fingerprint: pusharmor pair %s'),
|
|
840
|
-
pa.pair_note(cx, d, ida, '"%s" wants to pair. Run: pusharmor pair %s')]
|
|
840
|
+
pa.pair_note(cx, d, ida, '"%s" wants to pair. Run: `pusharmor pair %s`')]
|
|
841
841
|
name = pa.peer_label(d["peers"][ida])
|
|
842
|
-
assert notes == [("info", '"%s" also wants to pair. Run: pusharmor pair %s' % (name, pa.id_hex(ida)[:6])), None]
|
|
842
|
+
assert notes == [("info", '"%s" also wants to pair. Run: `pusharmor pair %s`' % (name, pa.id_hex(ida)[:6])), None]
|
|
843
843
|
|
|
844
844
|
|
|
845
845
|
@pytest.mark.skipif(os.name == "nt", reason="no POSIX modes on Windows")
|
|
@@ -849,7 +849,7 @@ def test_chmod_hint_quotes_a_path_with_a_space(tmp_path):
|
|
|
849
849
|
path.chmod(0o777)
|
|
850
850
|
with pytest.raises(pa.Fail) as e:
|
|
851
851
|
pa.check_unshared(str(path), True)
|
|
852
|
-
assert str(e.value) == "'%s' can be changed by other users. Run: chmod go-w '%s'" % (path, path)
|
|
852
|
+
assert str(e.value) == "'%s' can be changed by other users. Run: `chmod go-w '%s'`" % (path, path)
|
|
853
853
|
|
|
854
854
|
|
|
855
855
|
def test_wipe_removes_temp_files(net, tmp_path, monkeypatch):
|
|
@@ -899,7 +899,7 @@ def test_group_writable_is_refused_even_with_a_user_private_group(name, members,
|
|
|
899
899
|
capsys.readouterr()
|
|
900
900
|
assert run(cfg, "send", "hi") == 1
|
|
901
901
|
assert capsys.readouterr().err == (
|
|
902
|
-
"error: '%s' can be changed by other users. Run: chmod go-w '%s'
|
|
902
|
+
"error: '%s' can be changed by other users. Run: `chmod go-w '%s'`\n" % (path, path))
|
|
903
903
|
path.chmod(0o700 if path == cfg else 0o600)
|
|
904
904
|
|
|
905
905
|
|
|
@@ -911,7 +911,7 @@ def test_saving_keys_checks_the_config_folder(tmp_path):
|
|
|
911
911
|
k = {"id": pa.b64e(b"i" * 30), "sign": b"s" * 32, "enc": b"e" * 32, "push": b"p" * 32, "auth": b"a" * 16}
|
|
912
912
|
with pytest.raises(pa.Fail) as e:
|
|
913
913
|
pa.Store(str(root)).save_keys(k)
|
|
914
|
-
assert str(e.value) == "'%s' can be changed by other users. Run: chmod go-w '%s'" % (root, root)
|
|
914
|
+
assert str(e.value) == "'%s' can be changed by other users. Run: `chmod go-w '%s'`" % (root, root)
|
|
915
915
|
assert not (root / "keys").exists()
|
|
916
916
|
|
|
917
917
|
|
|
@@ -961,7 +961,7 @@ def test_config_folder_and_state_files_others_can_change_are_refused(net, tmp_pa
|
|
|
961
961
|
cfg.chmod(0o777)
|
|
962
962
|
assert run(cfg, "send", "hi") == 1
|
|
963
963
|
assert capsys.readouterr().err == (
|
|
964
|
-
"error: '%s' can be changed by other users. Run: chmod go-w '%s'
|
|
964
|
+
"error: '%s' can be changed by other users. Run: `chmod go-w '%s'`\n" % (cfg, cfg))
|
|
965
965
|
_group(monkeypatch, "me", [])
|
|
966
966
|
cfg.chmod(0o775) # group-writable, even with the user's own private primary group: refused
|
|
967
967
|
assert run(cfg, "send", "hi") == 1
|
|
@@ -975,7 +975,7 @@ def test_config_folder_and_state_files_others_can_change_are_refused(net, tmp_pa
|
|
|
975
975
|
capsys.readouterr()
|
|
976
976
|
assert run(cfg, "send", "hi") == 1
|
|
977
977
|
assert capsys.readouterr().err == (
|
|
978
|
-
"error: '%s' can be changed by other users. Run: chmod go-w '%s'
|
|
978
|
+
"error: '%s' can be changed by other users. Run: `chmod go-w '%s'`\n" % (path, path))
|
|
979
979
|
path.chmod(0o644)
|
|
980
980
|
assert run(cfg, "send", "hi") == 4
|
|
981
981
|
|
|
@@ -1007,7 +1007,7 @@ def test_symlinked_config_folder_files_and_chains_are_followed(net, tmp_path, mo
|
|
|
1007
1007
|
(store / name).chmod(0o666)
|
|
1008
1008
|
capsys.readouterr()
|
|
1009
1009
|
assert run(top, "send", "hi") == 1
|
|
1010
|
-
assert capsys.readouterr().err == "error: '%s' can be changed by other users. Run: chmod go-w '%s'
|
|
1010
|
+
assert capsys.readouterr().err == "error: '%s' can be changed by other users. Run: `chmod go-w '%s'`\n" % (
|
|
1011
1011
|
top / name, top / name)
|
|
1012
1012
|
(store / name).chmod(0o600)
|
|
1013
1013
|
real.chmod(0o777)
|
|
@@ -1851,7 +1851,7 @@ def test_unknown_device_error_is_one_line(net, tmp_path, monkeypatch, capsys):
|
|
|
1851
1851
|
def test_not_logged_in_is_one_line(tmp_path, capsys):
|
|
1852
1852
|
(tmp_path / "c").mkdir(mode=0o700)
|
|
1853
1853
|
assert run(tmp_path / "c", "send", "hi") == pa.EXIT_LOGIN
|
|
1854
|
-
assert capsys.readouterr().err.splitlines() == ["error: This device is not logged in. Run: pusharmor login"]
|
|
1854
|
+
assert capsys.readouterr().err.splitlines() == ["error: This device is not logged in. Run: `pusharmor login`"]
|
|
1855
1855
|
|
|
1856
1856
|
|
|
1857
1857
|
@pytest.mark.parametrize("word, line", [
|
|
@@ -1949,7 +1949,7 @@ def test_command_texts_are_the_approved_sentences(net, tmp_path, monkeypatch, ca
|
|
|
1949
1949
|
assert err_of(2, "send") == "error: There is no message to send. Give a message, or pipe text into pusharmor send.\n"
|
|
1950
1950
|
assert err_of(2, "send", " ") == "error: The message is empty.\n"
|
|
1951
1951
|
assert err_of(1, "send", "--to", "abcdef", "hi") == (
|
|
1952
|
-
'error: No device matches "abcdef". Run pusharmor pair to see your devices.\n')
|
|
1952
|
+
'error: No device matches "abcdef". Run `pusharmor pair` to see your devices.\n')
|
|
1953
1953
|
assert err_of(2, "rename", 'bad "name"') == (
|
|
1954
1954
|
"error: The name must be 1 to 32 plain ASCII characters, with no double quote.\n")
|
|
1955
1955
|
assert err_of(1, "pair", pa.id_hex(me)[:6]) == "error: This is the device you are using. Choose another device.\n"
|
|
@@ -1963,7 +1963,7 @@ def test_command_texts_are_the_approved_sentences(net, tmp_path, monkeypatch, ca
|
|
|
1963
1963
|
with pytest.raises(pa.Fail) as e:
|
|
1964
1964
|
pa.choose_evict([])
|
|
1965
1965
|
assert str(e.value) == (
|
|
1966
|
-
"No devices were chosen to remove, so you are not logged in. Run pusharmor login to try again.")
|
|
1966
|
+
"No devices were chosen to remove, so you are not logged in. Run `pusharmor login` to try again.")
|
|
1967
1967
|
net.hooks[("POST", "peers")] = lambda *a: net.reply(503, {})
|
|
1968
1968
|
monkeypatch.setattr(pa.time, "sleep", lambda s: None)
|
|
1969
1969
|
assert err_of(0, "logout") == (
|
|
@@ -1976,7 +1976,7 @@ def test_login_ctrl_d_at_the_code_prompt(net, tmp_path, monkeypatch, capsys):
|
|
|
1976
1976
|
|
|
1977
1977
|
monkeypatch.setattr(pa, "input", eof, raising=False)
|
|
1978
1978
|
assert run(tmp_path, "login") == 1
|
|
1979
|
-
assert capsys.readouterr().err == "error: No code was entered. Run pusharmor login again.\n"
|
|
1979
|
+
assert capsys.readouterr().err == "error: No code was entered. Run `pusharmor login` again.\n"
|
|
1980
1980
|
|
|
1981
1981
|
|
|
1982
1982
|
def test_every_stderr_line_has_a_severity_prefix(net, tmp_path, monkeypatch, capsys):
|
|
@@ -2240,7 +2240,10 @@ def test_pair_again_sends_the_open_again_and_says_when_it_fails(net, tmp_path, m
|
|
|
2240
2240
|
if path == "/v1/pair/" + hi.id else None)
|
|
2241
2241
|
lo.pump() # not in a pair run for hi: no error here
|
|
2242
2242
|
assert lo.entry(hi)["state"] == "shown"
|
|
2243
|
-
|
|
2243
|
+
short = pa.id_hex(hi.id)[:6]
|
|
2244
|
+
assert capsys.readouterr().err.splitlines()[-1] == (
|
|
2245
|
+
'warning: Unable to continue pairing with "%s". %s Run: `pusharmor pair %s` to try again.'
|
|
2246
|
+
% (pa.peer_label(state(lo.cfg)["peers"][hi.id]), pa.SERVER_DOWN, short))
|
|
2244
2247
|
assert run(lo.cfg, "pair", pa.id_hex(hi.id)[:8]) == 1
|
|
2245
2248
|
assert capsys.readouterr().err.splitlines()[-1] == "error: " + pa.SERVER_DOWN
|
|
2246
2249
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|