Skip to content

Commit

Permalink
feat(verifier): verification qr code contains intent-url (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino authored Sep 11, 2024
1 parent cad8ce9 commit 5f776de
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
26 changes: 13 additions & 13 deletions test/step_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ steps:
body:
file: ${{env.path_to_wallet}}/verifier/card_to_qr.data.json
captures:
qr_json:
jsonpath: $.qr_json
params_json:
jsonpath: $.params_json
check:
status: 200
jsonpath:
$.qr_json:
$.params_json:
- isDefined: true
isObject: true
$.qr_json.ru:
$.params_json.ru:
- eq: "https://admin.signroom.io/api/collections/templates_public_data/records?filter=%28id%3D%224tusaoh7g5y6wyw%22%29&fields=schema"
$.qrcode:
- isDefined: true
Expand All @@ -145,13 +145,13 @@ steps:
url: http://${{env.mz_host}}/temp_ver_qr_to_info
method: POST
json:
rp: ${{captures.qr_json.rp}}
t: ${{captures.qr_json.t}}
m: ${{captures.qr_json.m}}
exp: ${{captures.qr_json.exp}}
ru: ${{captures.qr_json.ru}}
sid: ${{captures.qr_json.sid}}
id: ${{captures.qr_json.id}}
rp: ${{captures.params_json.rp}}
t: ${{captures.params_json.t}}
m: ${{captures.params_json.m}}
exp: ${{captures.params_json.exp}}
ru: ${{captures.params_json.ru}}
sid: ${{captures.params_json.sid}}
id: ${{captures.params_json.id}}
credential_array:
- ${{captures.credential}}
captures:
Expand Down Expand Up @@ -201,15 +201,15 @@ steps:
status: 200
jsonpath:
$.id:
- eq: ${{captures.qr_json.sid}}
- eq: ${{captures.params_json.sid}}

- name: verifier checks rp response
http:
url: http://${{env.verifier_host}}/verify
method: POST
json:
message: ${{captures.message}}
claims_url: ${{captures.qr_json.ru}}
claims_url: ${{captures.params_json.ru}}
check:
status: 200
jsonpath:
Expand Down
4 changes: 2 additions & 2 deletions test/wallet.bats
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ load ./bats_utils
@test "Verifier generate qr [card_to_qr.zen]" {
zexe $VERIFIER/card_to_qr.zen $VERIFIER/card_to_qr.data.json $VERIFIER/card_to_qr.keys.json
save_tmp_output card_to_qr.output.json
assert_output --regexp '^\{"qr_json":\{"exp":[0-9]{10},"id":"hn20gz30ync7sng","m":"f","rp":"http://localhost:3003/","ru":"https://admin\.signroom\.io/api/collections/templates_public_data/records\?filter=%28id%3D%224tusaoh7g5y6wyw%22%29&fields=schema","sid":"[A-Z2-9]{5}","t":"ehUYkktwQVWy_v9MXeTaf9:APA91bG28isX0dJJEzW6K5qA8N67-V7bZjYhEXYsWNyL_7xiJsBVTuKgEalgK_ajlK_6u2hY3tFlq0e649F4lhb909VHVfHGKrWFVb0uBdY61RmnLcxhwkltm2yyxxdXje1qWCavb281"\},"qr_text":".*,"ru":"https://admin\.signroom\.io/api/collections/templates_public_data/records\?filter=%28id%3D%224tusaoh7g5y6wyw%22%29&fields=schema","sid":"[A-Z2-9]{5}"\}'
assert_output --regexp '^\{"intent-url":".*,"params_json":\{"exp":[0-9]{10},"id":"hn20gz30ync7sng","m":"f","rp":"http://localhost:3003/","ru":"https://admin\.signroom\.io/api/collections/templates_public_data/records\?filter=%28id%3D%224tusaoh7g5y6wyw%22%29&fields=schema","sid":"[A-Z2-9]{5}","t":"ehUYkktwQVWy_v9MXeTaf9:APA91bG28isX0dJJEzW6K5qA8N67-V7bZjYhEXYsWNyL_7xiJsBVTuKgEalgK_ajlK_6u2hY3tFlq0e649F4lhb909VHVfHGKrWFVb0uBdY61RmnLcxhwkltm2yyxxdXje1qWCavb281"\},"ru":"https://admin\.signroom\.io/api/collections/templates_public_data/records\?filter=%28id%3D%224tusaoh7g5y6wyw%22%29&fields=schema","sid":"[A-Z2-9]{5}"\}'
}

@test "Holder scan qr [ver_qr_to_info.zen]" {
cred=$(jq ".credential" $BATS_FILE_TMPDIR/post_credential.output.json)
jq_extract_raw "qr_json" card_to_qr.output.json > $BATS_FILE_TMPDIR/temp_temp_vp.data.json
jq_extract_raw "params_json" card_to_qr.output.json > $BATS_FILE_TMPDIR/temp_temp_vp.data.json
jq ".credential_array = [$cred]" $BATS_FILE_TMPDIR/temp_temp_vp.data.json > $BATS_FILE_TMPDIR/ver_qr_to_info_test.data.json
# scan_ver_qr_1
zexe $WALLET/ver_qr_to_info_1_qr_checks.zen ver_qr_to_info_test.data.json $WALLET/ver_qr_to_info.keys.json
Expand Down
3 changes: 2 additions & 1 deletion verifier/card_to_qr.keys.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
"7",
"8",
"9"
]
],
"intent-url": "DIDroom4VP://"
}
33 changes: 17 additions & 16 deletions verifier/card_to_qr.zen
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,26 @@ and I have a 'string' named 'id'
Given I have a 'string array' named 'letters'
and I have a 'float' named '1'
and I have a 'float' named '5'
and I have a 'string' named 'intent-url'

When I create the 'string dictionary' named 'qr_json'
When I create the 'string dictionary' named 'params_json'

# relying party
When I move 'relying_party' to 'rp' in 'qr_json'
When I move 'relying_party' to 'rp' in 'params_json'

# t
When I move 'registrationToken' to 't' in 'qr_json'
When I move 'registrationToken' to 't' in 'params_json'

# m
When I move 'm' in 'qr_json'
When I move 'm' in 'params_json'

# id
When I move 'id' in 'qr_json'
When I move 'id' in 'params_json'

# exp
When I create the timestamp
and I create the result of 'timestamp' + 'expires_in'
and I move 'result' to 'exp' in 'qr_json'
and I move 'result' to 'exp' in 'params_json'

# request uri
When I set 'filter' to '(id="' as 'string'
Expand All @@ -44,7 +45,7 @@ When I append the 'pb_api' to 'pb_url'
and I create url from 'pb_url'
and I append percent encoding of 'filter' as http request to 'url'
and I append percent encoding of 'fields' as http request to 'url'
and I move 'url' to 'ru' in 'qr_json'
and I move 'url' to 'ru' in 'params_json'

# sid
When I write string '' in 'sid'
Expand All @@ -53,17 +54,17 @@ When I pick random object in 'letters'
and I append the 'random object' to 'sid'
and I remove 'random object'
EndForEach
When I copy 'sid' in 'qr_json'
When I copy 'sid' in 'params_json'

# stringify
When I create json escaped string of 'qr_json'
and I rename 'json_escaped_string' to 'qr_text'
# intent url
When I create http get parameters from 'params_json' using percent encoding
and I append 'http get parameters' to 'intent-url'

Then print the 'qr_text'
Then print the 'intent-url'
Then print the 'sid'
Then print the 'ru' from 'qr_json'
Then print the 'qr_json'
Then print the 'ru' from 'params_json'
Then print the 'params_json'

Then I send text 'qr_text' and create qr code and output into 'qrcode'
Then I manipulate and delete and output into 'qr_text'
Then I send text 'intent-url' and create qr code and output into 'qrcode'
Then I manipulate and delete and output into 'intent-url'
# Then I manipulate and delete and output into 'qr_json'

0 comments on commit 5f776de

Please sign in to comment.