Skip to content

Commit

Permalink
Merge branch 'main' into refactor/input_on_error
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino authored Jul 1, 2024
2 parents 481fdb6 + de0850a commit bf8a1cf
Show file tree
Hide file tree
Showing 98 changed files with 751 additions and 26 deletions.
7 changes: 7 additions & 0 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ SPDX-License-Identifier: CC-BY-NC-SA-4.0
<!--@include: helpers/index.md-->
<!--@include: http/index.md-->
<!--@include: json-schema/index.md-->
<!--@include: oauth/index.md-->
<!--@include: pocketbase/index.md-->
<!--@include: qrcode/index.md-->
<!--@include: redis/index.md-->
<!--@include: shell/index.md-->
<!--@include: timestamp/index.md-->
<!--@include: zencode/index.md-->
6 changes: 6 additions & 0 deletions docs/examples/oauth/add_data.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"request_uri": "urn:ietf:params:oauth:request_uri:1719239545ed9f269e652d207b90dec394b87225c92346023b",
"data": {
"email": "[email protected]"
}
}
14 changes: 14 additions & 0 deletions docs/examples/oauth/add_data.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"server_data": {
"jwk": {
"kty": "EC",
"crv": "P-256",
"alg": "ES256",
"x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74",
"y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI",
"d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk"
},
"url": "https://valid.issuer.url",
"authentication_url": "https://did.dyne.org/dids/"
}
}
6 changes: 6 additions & 0 deletions docs/examples/oauth/add_data.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I send request_uri 'request_uri' and send data 'data' and send server_data 'server' and add data to authorization details and output into 'result'

Given I have a 'string array' named 'result'
Then print the 'result'
16 changes: 16 additions & 0 deletions docs/examples/oauth/gen_access_token.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"json_body": {
"grant_type": "authorization_code",
"client_id": "did:dyne:sandbox.genericissuer:6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"redirect_uri": "https://Wallet.example.org/cb",
"code": "eyJhbGciOiJFUzI1NiIsImp3ayI6eyJrdHkiOiJFQyIsIngiOiJ0R3hhcWJYR3JsNm92VC11NXNWMU1vUFRESG5ZTEtZbkNpZzM0NW5zSmc4IiwieSI6IlFOT3RBRzd4Sm52cHlGS2lGdmJJdFBxaVBiN2VZSVMtQlRvU0YwaHM3NTgiLCJjcnYiOiJQLTI1NiJ9fQ.eyJzdWIiOiI1NDJiYWNjODAyMDUxZTdhYjBjMWZhNDAxZjAwYzhjNWJjN2Y0NzVhIiwiaWF0IjoxNzE5MjQxMTYzLCJpc3MiOiJodHRwczovL2Rldi5hdXRoei1zZXJ2ZXIxLmZvcmtib21iLmV1L2F1dGh6X3NlcnZlciIsImF1ZCI6ImRpZDpkeW5lOnNhbmRib3guc2lnbnJvb206NEtFeW1XZ0xEVWYxTE5ja2V4WTk2ZGZLejV2SDc5ZGlEZWtnTE1SOUZXcEgiLCJleHAiOjE3MTkyNDQ3NjJ9.1OhQ5FKXuh_QWxm4XMufNqFS2Zkql7bmBzfMuT8GzVEil3HzYM7dAwUo5Zl9shu-w7bEGlKkOIhXssVrMeMlXg"
},
"request": {
"headers": {
"content-length": 42,
"Content-Type": "application/x-www-form-urlencoded",
"DPoP": "eyJhbGciOiJFUzI1NiIsImp3ayI6eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6InpKLTR1d0VWVlYxQW9GcW1yZVlzUlh1SjhGbzVHRVVUeTZ0aklBdjdUcFkiLCJ5IjoiVm9YdmEzVEpHc0o5bjlZVzV3MGplMHp6U2hmYnN3QWd6SHI1TEZCSDNsZyJ9LCJ0eXAiOiJkcG9wK2p3dCJ9.eyJodG0iOiJQT1NUIiwiaHR1IjoiaHR0cHM6Ly9kZXYuYXV0aHotc2VydmVyMS5mb3JrYm9tYi5ldS9hdXRoel9zZXJ2ZXIvdG9rZW4iLCJpYXQiOjE3MTkyNDEzMjYsImp0aSI6IkFad0VwZ2tOTlhrbllWT1JZbjNYNW9HVW1iTVp3V3d1UF9xSDNnOFRjbHcifQ.X2sO6h3GUcTu0h_qNyOsXEB2Z3qzPUd1azOJIeMmfH4zIk-Hd8sHm1RG2RaxZ3n22qSDbKjBap2G9U3Kjw5gLA"
}
}
}
14 changes: 14 additions & 0 deletions docs/examples/oauth/gen_access_token.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"server_data": {
"jwk": {
"kty": "EC",
"crv": "P-256",
"alg": "ES256",
"x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74",
"y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI",
"d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk"
},
"url": "https://valid.issuer.url",
"authentication_url": "https://did.dyne.org/dids/"
}
}
12 changes: 12 additions & 0 deletions docs/examples/oauth/gen_access_token.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Rule unknown ignore
Scenario 'http': url encode

Given I have a 'string dictionary' named 'json_body'
Given I have a 'string dictionary' named 'request'

When I create the http get parameters from 'json_body' using percent encoding
When I move 'json_body' to 'body' in 'request'

Then print the 'request'

Then I send request 'request' and send server_data 'server_data' and generate access token and output into 'result'
8 changes: 8 additions & 0 deletions docs/examples/oauth/gen_auth_code.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"request": {
"body": "client_id=did%3Adyne%3Asandbox%2Egenericissuer%3A6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5&request_uri=urn%3Aietf%3Aparams%3Aoauth%3Arequest_uri%3A1719239545ed9f269e652d207b90dec394b87225c92346023b",
"headers": {
"Authorization": ""
}
}
}
14 changes: 14 additions & 0 deletions docs/examples/oauth/gen_auth_code.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"server_data": {
"jwk": {
"kty": "EC",
"crv": "P-256",
"alg": "ES256",
"x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74",
"y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI",
"d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk"
},
"url": "https://valid.issuer.url",
"authentication_url": "https://did.dyne.org/dids/"
}
}
6 changes: 6 additions & 0 deletions docs/examples/oauth/gen_auth_code.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I send request 'request' and send server_data 'server' and generate authorization code and output into 'result'

Given I have a 'string dictionary' named 'result'
Then print the 'result'
10 changes: 10 additions & 0 deletions docs/examples/oauth/gen_request_uri.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"client": {
"id": "did:dyne:sandbox.genericissuer:6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5",
"clientSecret": "eyJhbGciOiJFUzI1NiJ9.eyJzdWIiOiJwaXBwbyJ9.hiVPL2JTdmcZY7Vcso95KUBEzcTGvmvQ7wlwkCo0G74Unpzny2drvLsu-HzHWyckKbRjwWox-V5gqqKeka8kEQ",
"grants": ["authorization_code"],
"redirectUris": ["https://Wallet.example.org/cb"],
"scope": ["Auth1"],
"resource": "http://issuer1.zenswarm.forkbomb.eu/credential_issuer"
}
}
22 changes: 22 additions & 0 deletions docs/examples/oauth/gen_request_uri.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"server_data": {
"jwk": {
"kty": "EC",
"crv": "P-256",
"alg": "ES256",
"x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74",
"y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI",
"d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk"
},
"url": "https://valid.issuer.url",
"authentication_url": "https://did.dyne.org/dids/"
},
"expires_in": 500,
"request": {
"body": "response_type=code&client_id=did:dyne:sandbox.genericissuer:6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5&state=xyz&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&code_challenge_method=S256&redirect_uri=https%3A%2F%2FWallet.example.org%2Fcb&authorization_details=%5B%7B%22type%22%3A%20%22openid_credential%22%2C%20%22credential_configuration_id%22%3A%20%22Auth1%22%2C%22locations%22%3A%20%5B%22http%3A%2F%2Fissuer1.zenswarm.forkbomb.eu%3A3100%2Fcredential_issuer%2F%22%5D%7D%5D",
"headers": {
"Authorization": ""
}
}
}

6 changes: 6 additions & 0 deletions docs/examples/oauth/gen_request_uri.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I send request 'request' and send client 'client' and send server_data 'server_data' and send expires_in 'expires_in' and generate request uri and output into 'result'

Given I have a 'string dictionary' named 'result'
Then print the 'result'
3 changes: 3 additions & 0 deletions docs/examples/oauth/get_auth_details.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"token": "eyJhbGciOiJFUzI1NiIsImp3ayI6eyJrdHkiOiJFQyIsIngiOiJ0R3hhcWJYR3JsNm92VC11NXNWMU1vUFRESG5ZTEtZbkNpZzM0NW5zSmc4IiwieSI6IlFOT3RBRzd4Sm52cHlGS2lGdmJJdFBxaVBiN2VZSVMtQlRvU0YwaHM3NTgiLCJjcnYiOiJQLTI1NiJ9fQ.eyJzdWIiOiJjYzA3N2Y4MTcwMWU3NDIxNTQ5ZmU0MjBiNDFiNTUxMjVlZDljNmZlIiwiaWF0IjoxNzE5MjQxMzI3LCJpc3MiOiJodHRwczovL2Rldi5hdXRoei1zZXJ2ZXIxLmZvcmtib21iLmV1L2F1dGh6X3NlcnZlciIsImF1ZCI6ImRpZDpkeW5lOnNhbmRib3guc2lnbnJvb206NEtFeW1XZ0xEVWYxTE5ja2V4WTk2ZGZLejV2SDc5ZGlEZWtnTE1SOUZXcEgiLCJleHAiOjE3MTkyNDQ5Mjd9.xLWyO9DkLnSU-9w_4kzmI-znQAwlYJnBbZXpKqmHNpwnFwJUdK26hmVgIQSy2HcHujKyaXX6unjmFe1P5HyK9A"
}
5 changes: 5 additions & 0 deletions docs/examples/oauth/get_auth_details.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"server": {
"url": "https://valid.issuer.url"
}
}
6 changes: 6 additions & 0 deletions docs/examples/oauth/get_auth_details.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rule unknown ignore

Given I send token 'token' and send server_data 'server' and get authorization details from token and output into 'result'

Given I have a 'string array' named 'result'
Then print data
49 changes: 49 additions & 0 deletions docs/examples/oauth/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--
SPDX-FileCopyrightText: 2024 Dyne.org foundation
SPDX-License-Identifier: CC-BY-NC-SA-4.0
-->

## oauth plugin examples

### generate request uri
::: code-group
<<< @/examples/oauth/gen_request_uri.zen{3 gherkin:line-numbers}
<<< @/examples/oauth/gen_request_uri.data{json}
<<< @/examples/oauth/gen_request_uri.keys{json}
:::

### verify request parameters
::: code-group
<<< @/examples/oauth/ver_request_params.zen{15 gherkin:line-numbers}
<<< @/examples/oauth/ver_request_params.data{json}
<<< @/examples/oauth/ver_request_params.keys{json}
:::

### add data to authorization details
::: code-group
<<< @/examples/oauth/add_data.zen{3 gherkin:line-numbers}
<<< @/examples/oauth/add_data.data{json}
<<< @/examples/oauth/add_data.keys{json}
:::

### generate authorization code
::: code-group
<<< @/examples/oauth/gen_auth_code.zen{3 gherkin:line-numbers}
<<< @/examples/oauth/gen_auth_code.data{json}
<<< @/examples/oauth/gen_auth_code.keys{json}
:::

### generate access token
::: code-group
<<< @/examples/oauth/gen_access_token.zen{12 gherkin:line-numbers}
<<< @/examples/oauth/gen_access_token.data{json}
<<< @/examples/oauth/gen_access_token.keys{json}
:::

### get authorization details
::: code-group
<<< @/examples/oauth/get_auth_details.zen{3 gherkin:line-numbers}
<<< @/examples/oauth/get_auth_details.data{json}
<<< @/examples/oauth/get_auth_details.keys{json}
:::
9 changes: 9 additions & 0 deletions docs/examples/oauth/ver_request_params.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"client_id": "did:dyne:sandbox.genericissuer:6Cp8mPUvJmQaMxQPSnNyhb74f9Ga4WqfXCkBneFgikm5",
"request_uri": "urn:ietf:params:oauth:request_uri:1719239545ed9f269e652d207b90dec394b87225c92346023b",
"request": {
"headers": {
"Authorization": ""
}
}
}
14 changes: 14 additions & 0 deletions docs/examples/oauth/ver_request_params.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"server_data": {
"jwk": {
"kty": "EC",
"crv": "P-256",
"alg": "ES256",
"x": "SVqB4JcUD6lsfvqMr-OKUNUphdNn64Eay60978ZlL74",
"y": "lf0u0pMj4lGAzZix5u4Cm5CMQIgMNpkwy163wtKYVKI",
"d": "0g5vAEKzugrXaRbgKG0Tj2qJ5lMP4Bezds1_sTybkfk"
},
"url": "https://valid.issuer.url",
"authentication_url": "https://did.dyne.org/dids/"
}
}
15 changes: 15 additions & 0 deletions docs/examples/oauth/ver_request_params.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Rule unknown ignore

Given I have a 'string' named 'client_id'
Given I have a 'string' named 'request_uri'
Given I have a 'string dictionary' named 'request'

When I set 'body' to 'client_id=' as 'string'
When I append the 'client_id' to 'body'
When I append the string '&request_uri=' to 'body'
When I append the 'request_uri' to 'body'
When I move 'body' in 'request'

Then print the 'request'

Then I send request 'request' and send server_data 'server_data' and verify request parameters
11 changes: 11 additions & 0 deletions docs/examples/pocketbase/create_record.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"create_parameters": {
"collection": "organizations",
"record": {
"name": "Jhon org"
}
},
"record_parameters": {
"requestKey": "testCreate"
}
}
7 changes: 7 additions & 0 deletions docs/examples/pocketbase/create_record.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"pb_address": "http://127.0.0.1:8090",
"my_credentials": {
"email": "[email protected]",
"password": "testtest"
}
}
9 changes: 9 additions & 0 deletions docs/examples/pocketbase/create_record.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Rule unknown ignore

Given I connect to 'pb_address' and start pb client
Given I send my_credentials 'my_credentials' and login

Given I send create_parameters 'create_parameters' and send record_parameters 'record_parameters' and create record and output into 'result'

Given I have a 'string dictionary' named 'result'
Then print the 'result'
6 changes: 6 additions & 0 deletions docs/examples/pocketbase/delete_record.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"delete_parameters": {
"collection": "organizations",
"id": "q3vijjsacrn32tk"
}
}
7 changes: 7 additions & 0 deletions docs/examples/pocketbase/delete_record.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"pb_address": "http://127.0.0.1:8090",
"my_credentials": {
"email": "[email protected]",
"password": "testtest"
}
}
9 changes: 9 additions & 0 deletions docs/examples/pocketbase/delete_record.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Rule unknown ignore

Given I connect to 'pb_address' and start pb client
Given I send my_credentials 'my_credentials' and login

Given I send delete_parameters 'delete_parameters' and delete record and output into 'result'

Given I have a 'string' named 'result'
Then print the 'result'
7 changes: 7 additions & 0 deletions docs/examples/pocketbase/get_one_record.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"show_parameters": {
"collection": "organizations",
"id": "p7viyzsihrn52uj",
"fields": "name"
}
}
3 changes: 3 additions & 0 deletions docs/examples/pocketbase/get_one_record.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pb_address": "http://127.0.0.1:8090"
}
8 changes: 8 additions & 0 deletions docs/examples/pocketbase/get_one_record.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Rule unknown ignore

Given I connect to 'pb_address' and start pb client

Given I send show_parameters 'show_parameters' and get one record and output into 'result'

Given I have a 'string dictionary' named 'result'
Then print the 'result'
10 changes: 10 additions & 0 deletions docs/examples/pocketbase/get_some_records.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"list_parameters": {
"type": "list",
"pagination": {
"page": 2,
"perPage": 20
},
"collection": "organizations"
}
}
3 changes: 3 additions & 0 deletions docs/examples/pocketbase/get_some_records.keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pb_address": "http://127.0.0.1:8090"
}
8 changes: 8 additions & 0 deletions docs/examples/pocketbase/get_some_records.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Rule unknown ignore

Given I connect to 'pb_address' and start pb client

Given I send list_parameters 'list_parameters' and get some records and output into 'result'

Given I have a 'string dictionary' named 'result'
Then print the 'result'
Loading

0 comments on commit bf8a1cf

Please sign in to comment.