add new changes of ereuseapitest
This commit is contained in:
parent
aa966b5b93
commit
0ad35de5d6
|
@ -899,7 +899,7 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice):
|
|||
if 'dpp' not in app.blueprints.keys() or not self.device.hid:
|
||||
return
|
||||
|
||||
from ereuse_devicehub.modules.dpp.models import Dpp
|
||||
from ereuse_devicehub.modules.dpp.models import Dpp, ALGORITHM
|
||||
|
||||
dpp = "{chid}:{phid}".format(chid=self.device.chid, phid=self.phid_dpp)
|
||||
if Dpp.query.filter_by(key=dpp).all():
|
||||
|
@ -916,15 +916,14 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice):
|
|||
|
||||
api = API(api_dlt, token_dlt, "ethereum")
|
||||
docSig = self.phid_dpp
|
||||
docID = "{}".format(self.uuid or '')
|
||||
issuerID = "{dh}:{user}".format(dh=dh_instance, user=g.user.id)
|
||||
|
||||
result = api.issue_passport(dpp, docID, docSig, issuerID)
|
||||
result = api.issue_passport(dpp, ALGORITHM, docSig, dh_instance)
|
||||
|
||||
if result['Status'] is not StatusCode.Success.value:
|
||||
return
|
||||
|
||||
timestamp = result['Data'].get('data', {}).get('timestamp', time.time())
|
||||
docID = "{}".format(self.uuid or '')
|
||||
d_issue = {
|
||||
"device_id": self.device.id,
|
||||
"snapshot": self,
|
||||
|
|
|
@ -954,11 +954,24 @@ class Device(Thing):
|
|||
return API(api_dlt, token_dlt, "ethereum")
|
||||
|
||||
def register_dlt(self):
|
||||
if not app.config.get('ID_FEDERATED'):
|
||||
return
|
||||
|
||||
api = self.connect_api()
|
||||
if not api:
|
||||
return
|
||||
|
||||
result = api.register_device(self.chid)
|
||||
snapshot = [x for x in self.actions if x.t == 'Snapshot']
|
||||
if not snapshot:
|
||||
return
|
||||
snapshot = snapshot[0]
|
||||
from ereuse_devicehub.modules.dpp.models import ALGORITHM
|
||||
result = api.register_device(
|
||||
self.chid,
|
||||
ALGORITHM,
|
||||
snapshot.phid_dpp,
|
||||
app.config.get('ID_FEDERATED')
|
||||
)
|
||||
self.register_proof(result)
|
||||
|
||||
if app.config.get('ID_FEDERATED'):
|
||||
|
|
Reference in a new issue