diff --git a/0bs-samples/python/demo-address-output.log b/0bs-samples/python/demo-address-output.log index b6ca15f..f7239b2 100644 --- a/0bs-samples/python/demo-address-output.log +++ b/0bs-samples/python/demo-address-output.log @@ -13,14 +13,14 @@ nonce = 0 balances: Waves = 50000000000 GavX8vzkqv7ew3J2V1PMC2TCzoGM2Lt7amms2G3NaMU2 (BATT1) = 1000 - FH6v21twyAwDeR7J2TTp7zQEAq5rXBvyfWvK8QMvfRAZ (AustriaPro V1) = 50000000 + FH6uv21twyAwDeR7J2TTp7zQEAq5rXBvyfWvK8QMvfRAZ (AustriaPro V1) = 50000000 ------------------------------------------ Balance 0bsnetwork Coin: 500 Balance AustriaPro Token V1: 50 ------------------------------------------ Info about Asset: status = Issued -assetId = FH6v21twyAwDeR7J2TTp7zQEAq5rXBvyfWvK8QMvfRAZ +assetId = FH6uv21twyAwDeR7J2TTp7zQEAq5rXBvyfWvK8QMvfRAZ issuer = 3MpZXYBKdsMKGWzNxmNSm27QPYHmev7jB5K name = AustriaPro V1 description = AustriaPro Test Token V1 diff --git a/docnos3-testclient/README.md b/docnos3-testclient/README.md new file mode 100644 index 0000000..8826961 --- /dev/null +++ b/docnos3-testclient/README.md @@ -0,0 +1,3 @@ +# DocNoS-API Tests +Zwei einfache Python Scripts, um die API-Requests "create" (Erstellen einer Notarisierung) und "verify" (Prüfen einer Notarisierung) zu testen. +Voraussetzung: Zugriff auf ein DocNoS-API Service (URL und API-Token) diff --git a/docnos3-testclient/test_common.py b/docnos3-testclient/test_common.py new file mode 100644 index 0000000..49ea170 --- /dev/null +++ b/docnos3-testclient/test_common.py @@ -0,0 +1,18 @@ +''' +Common content and configuration for DocNoS API tests + +@copyright 2020 baumann.at +@author Chris Baumann +@version v0.2 2020/09/30 + +''' + +url_create = 'https://YOUR-DOCNOS-API-SERVER/docnos3-api/create/' +url_verify = 'https://YOUR-DOCNOS-API-SERVER/dev9/docnos3-api/verify/' + +# STD +apiToken = 'API-TOKEN-FOR-STD' +# BlockStempel +#apiToken = 'API-TOKEN-FOR-BLOCKSTEMPEL' + +defaultContent = 'some content 12345XX' diff --git a/docnos3-testclient/test_create.py b/docnos3-testclient/test_create.py new file mode 100644 index 0000000..a54ce12 --- /dev/null +++ b/docnos3-testclient/test_create.py @@ -0,0 +1,75 @@ +''' +Simple script to test DocNoS API function "create" + +configuration see test_common.py + +@copyright 2020 baumann.at +@author Chris Baumann +@version v0.2 2020/09/30 + +''' +import sys +import datetime +import hashlib +import json +import requests # install with "pip3 install requests" if necessary + +from test_common import * + +print('------------------------------------') +print('DocNos Test ... create') + +''' +A valid DocNos Create Request looks like this: (sha256 is required, sha512 and sha3/512 optional) +{ + "hashes": { + "sha256": "1a482edb60960719895a6b1c50121c938a62357cd68fe9ab29be1b8b343b663c", + "sha512": "294a725daacea98a340ce946182105e12448e7c1147424f94a0eb453eb531373a39f0e563d828aea092e53d4481a02282ca3ba313a029bf5c09956759de26363", + "sha3\/512": "f210c7bc0c281b844a989160186eb0f8a1ac2a996cd3d6db8e0b4074815e3521b50dccbd2ac597c7192a692e16f2ffa0491a0823a991212af44c2a8c3087dec0" + }, + "remarks": "optional remarks" +} + +''' + +# Build API request +# SHA2 256 +sha256 = hashlib.sha256(defaultContent.encode('utf-8')).hexdigest() +#print(sha256) +# SHA2 512 +sha512 = hashlib.sha512(defaultContent.encode('utf-8')).hexdigest() +#print(sha512) +# SHA3 512 +sha3_512 = hashlib.sha3_512(defaultContent.encode('utf-8')).hexdigest() +#print(sha3_512) +#print('------------------------------------') + + +hashes = { + 'sha256': sha256, + 'sha512': sha512, + 'sha3/512' : sha3_512 +} + +request = { + 'hashes': hashes, + 'remarks': 'optional remarks' +} + +postData = json.dumps(request) +print('JSON-Request:') +print(postData) +print('------------------------------------') + +length = str(len(postData)) + +httpHeaders = { + 'Content-type':'application/json', + 'Accept':'application/json', + 'Content-Length': length, + 'X-ApiToken': apiToken} +#print(httpHeaders) + +response = requests.post(url_create, data = postData, headers = httpHeaders) +print(str(response)) +print('RESULT: ' + response.text) diff --git a/docnos3-testclient/test_verify.py b/docnos3-testclient/test_verify.py new file mode 100644 index 0000000..26d966e --- /dev/null +++ b/docnos3-testclient/test_verify.py @@ -0,0 +1,40 @@ +''' +Simple script to test DocNoS API function "verify" + +configuration see test_common.py + +@copyright 2020 baumann.at +@author Chris Baumann +@version v0.2 2020/09/30 + +''' +import sys +import hashlib +import json +import requests # install with "pip3 install requests" if necessary + +from test_common import * + +print('------------------------------------') +print('DocNos Test ... verify') + +# SHA2 256 +sha256_hash_to_verify = hashlib.sha256(defaultContent.encode('utf-8')).hexdigest() +#print(sha256_hash_to_verify) + +httpHeaders = { + 'Accept':'application/json' +} + +# search for specific hash +key = 'hash' +value = 'sha256:' + sha256_hash_to_verify + +# OR search for given transaction-id +#key = 'txid' +#value = '4307fa407a136936fe8deba3babe541b59e5ebe6f8aa7df00ba7fcc83e6b792b' + +response = requests.get(url_verify, params={key: value}, headers = httpHeaders) + +print(str(response)) +print('RESULT: ' + response.text)