commit d146df52431f1a94ce79e257e5c84b65bbad75d1
parent 9dc24c7b844073aef53db7a48ba5ff6329f4f03e
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Wed, 9 Oct 2019 16:44:27 +0200
fix names
Diffstat:
2 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/sandbox/src/main/kotlin/JSON.kt b/sandbox/src/main/kotlin/JSON.kt
@@ -51,10 +51,10 @@ data class IniLetter(
val date: String,
val time: String,
val recipient: String,
- val exp_length: Int,
- val exponent: String,
- val mod_length: Int,
- val modulus: String,
+ val public_exponent_length: Int,
+ val public_exponent: String,
+ val public_modulus_length: Int,
+ val public_modulus: String,
val hash: String
)
@@ -68,14 +68,14 @@ data class HiaLetter(
val date: String,
val time: String,
val recipient: String,
- val ia_exp_length: Int,
+ val ia_exponent_length: Int,
val ia_exponent: String,
- val ia_mod_length: Int,
+ val ia_modulus_length: Int,
val ia_modulus: String,
val ia_hash: String,
- val enc_exp_length: Int,
+ val enc_exponent_length: Int,
val enc_exponent: String,
- val enc_mod_length: Int,
+ val enc_modulus_length: Int,
val enc_modulus: String,
val enc_hash: String
)
diff --git a/sandbox/src/main/python/libeufin-cli b/sandbox/src/main/python/libeufin-cli
@@ -99,21 +99,27 @@ def customer_info(obj, customer_id):
)
@click.option(
"--customer-id",
+ required=True,
help="id of the customer at the bank (used to pick keyset on disk)"
)
@click.pass_obj
def keyletter(obj, customer_id):
+ url = urljoin(
+ obj["base_url"], "/admin/customers/{}".format(customer_id)
+ )
+
try:
- url = urljoin(
- obj["base_url"], "/admin/customers/{}".format(customer_id)
- )
resp = get(url)
except Exception:
print("Could not connect to the bank, aborting")
return
- assert(resp.status_code == 200)
+ if resp.status_code != 200:
+ print("Couldn't query info about the customer: {}".format(resp.status_code))
+ return
+
+
user_id = resp.json().get("ebicsInfo", {}).get("userId")
name = resp.json().get("name")
assert(user_id)
@@ -157,7 +163,7 @@ def keyletter(obj, customer_id):
# Make the request body.
body = dict(
- INI=dict(
+ ini=dict(
userId=user_id,
customerId=customer_id,
name=name,
@@ -172,7 +178,7 @@ def keyletter(obj, customer_id):
hash=hashlib.sha256("{} {}".format(es_exponent, es_modulus).encode()).hexdigest()
),
- HIA=dict(
+ hia=dict(
userId=user_id,
customerId=customer_id,
name=name,
@@ -194,14 +200,19 @@ def keyletter(obj, customer_id):
)
)
+ url = urljoin(
+ obj["base_url"], "/admin/customers/{}/ebics/keyletter".format(customer_id)
+ )
+
try:
+ print("POSTing {}".format(body))
resp = post(url, json=body)
except Exception:
print("Could not reach the bank, aborting now")
return
if resp.status_code != 200:
- print("Bank did not accept this letter.")
+ print("Bank did not accept this letter: {}.".format(resp.status_code))
return
print("Letter accepted by the bank!")