Skip to content

Commit fa480f0

Browse files
committed
Successfully create and self-sign a License
1 parent 2d84c2f commit fa480f0

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ else
4141
endif
4242

4343
# To see all pytest output, uncomment --capture=no, ...
44-
PYTESTOPTS = --capture=no --log-cli-level=INFO
44+
PYTESTOPTS = --capture=no --log-cli-level=WARNING
4545

4646
PY3TEST = $(PY3) -m pytest $(PYTESTOPTS)
4747

@@ -77,7 +77,7 @@ test:
7777
$(PY3TEST)
7878

7979
analyze:
80-
flake8 --color never -j 1 --max-line-length=250 \
80+
$(PY3) -m flake8 --color never -j 1 --max-line-length=250 \
8181
--ignore=W503,E201,E202,E203,E127,E221,E223,E226,E231,E241,E242,E251,E265,E272,E274 \
8282
slip39
8383

slip39/invoice/payments.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ def reload(
207207
# Iterate using authorizations.send(...) instead of next; if nothing to send, leave 'send' None
208208
credentials = None
209209
while True:
210-
log.detail( f"Next authorizations, new credentials {credentials!r}" )
211210
key,lic = authorizations.send( credentials )
212211
credentials = None
213212
if key is None or lic is None:
@@ -237,7 +236,6 @@ def reload(
237236
yield Process.PROMPT, "Enter {} username (leave empty for no change): ".format(
238237
deduce_name( basename=basename, filename=kwds.get( 'filename' ), package=kwds.get( 'package' )))
239238
)
240-
log.warning( f" Got username: {username_update}" )
241239
userpass_updated |= bool( username_update )
242240
if username_update:
243241
username = username_update
@@ -247,7 +245,6 @@ def reload(
247245
yield Process.PROMPT, "Enter {} password (leave empty for no change): ".format(
248246
deduce_name( basename=basename, filename=kwds.get( 'filename' ), package=kwds.get( 'package' )))
249247
)
250-
log.warning( f" Got password: {password_update}" )
251248
userpass_updated |= bool( password_update )
252249
if password_update:
253250
password = password_update

slip39/invoice/payments_test.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_grants( tmp_path ):
7272
product = "Self Signed",
7373
keypair = keyp_ss.into_keypair( username=user_ss, password=pswd_ss ),
7474
)
75-
log.warning( f"Author: {author}" )
75+
log.info( f"Author: {author}" )
7676

7777
# Now create the License suitable for self-signing; no client (so any client can sign it)
7878
lic = licensing.license(
@@ -81,7 +81,7 @@ def test_grants( tmp_path ):
8181
grant = {'self-signed': { 'some-capability': 10 }},
8282
confirm = False, # Not a real domain...
8383
)
84-
log.warning( f"Self-Signable License: {lic}" )
84+
log.info( f"Self-Signable License: {lic}" )
8585

8686
# We've got a self-signed.crypto-license, signed by the Vendor, with no specific Client
8787
# specified. It's good for anyone to use. Lets make a link to it, under the name that our
@@ -107,14 +107,14 @@ def test_grants( tmp_path ):
107107
ls = subprocess.run(
108108
[ 'ls', '-l', str( here ) ], stdout=subprocess.PIPE,
109109
)
110-
log.warning( f"Test directory:\n{ls.stdout.decode( 'UTF-8' )}\n\n" )
110+
log.info( f"Test directory:\n{ls.stdout.decode( 'UTF-8' )}\n\n" )
111111

112112
client = licensing.Agent(
113113
name = "Perry Kundert",
114114
service = "client-user",
115115
pubkey = keyp_cl['vk'],
116116
)
117-
log.warning( f"Client: {client}" )
117+
log.info( f"Client: {client}" )
118118

119119
# We'll be loading an existing Client Agent keypair, so restrict it from registering a new one.
120120
# It must try to load the Author's License (using the author.service as the basename), and then
@@ -131,21 +131,31 @@ def test_grants( tmp_path ):
131131

132132
username = user_cl
133133
password = pswd_cl
134+
grants = None
134135
try:
135136
key,val = next( reloader )
136137
while True:
137-
log.warning( f"test_grants <-- {key}: {val}" )
138+
log.info( f"test_grants <-- {key}: {val}" )
138139
if key == Process.PROMPT:
139140
if 'username' in val:
140-
log.warning( f"test_grants --> {username}" )
141+
log.info( f"test_grants --> {username}" )
141142
key,val = reloader.send( username )
142143
continue
143144
elif 'password' in val:
144-
log.warning( f"test_grants --> {password}" )
145+
log.info( f"test_grants --> {password}" )
145146
key,val = reloader.send( password )
146147
continue
147148
else:
148-
log.warning( f"test_grants -x- ignoring {val}" )
149+
log.info( f"test_grants -x- ignoring {val}" )
150+
elif key == Process.GRANTS:
151+
grants = val
149152
key,val = next( reloader )
150153
except StopIteration:
151-
log.warning( f"test_grants xxx Done w/ key == {key}, val == {val}" )
154+
log.info( f"test_grants xxx Done w/ key == {key}, val == {val}" )
155+
156+
assert str( grants ) == """\
157+
{
158+
"self-signed":{
159+
"some-capability":10
160+
}
161+
}"""

0 commit comments

Comments
 (0)