From 294efaa073ac69d92845b3914edc7a55e1bc50be Mon Sep 17 00:00:00 2001 From: ilya-korotya Date: Thu, 8 Aug 2024 17:44:38 +0200 Subject: [PATCH 1/4] add build and push pipeline for dev tag --- .github/workflows/publis-container-dev.yaml | 77 +++++++++++++++++++++ .github/workflows/push-container.yaml | 8 ++- 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publis-container-dev.yaml diff --git a/.github/workflows/publis-container-dev.yaml b/.github/workflows/publis-container-dev.yaml new file mode 100644 index 0000000..0e7bdac --- /dev/null +++ b/.github/workflows/publis-container-dev.yaml @@ -0,0 +1,77 @@ +name: Publish driver-did-iden3 to Privado AWS ECR +on: + push: + tags: + - 'v*.*.*-dev' + workflow_dispatch: + +env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID_PRIVADO_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION_PRIVADO_ID }} + ECR_REPOSITORY: driver-did-iden3 + +jobs: + build_driver: + env: + STATE_CONTRACT_ADDRESS_MAIN: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" + STATE_CONTRACT_ADDRESS_AMOY: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" + STATE_CONTRACT_ADDRESS_PRIVADO_MAIN: "0x0DDd8701C91d8d1Ba35c9DbA98A45fe5bA8A877E" + STATE_CONTRACT_ADDRESS_PRIVADO_TEST: "0xE5BfD683F1Ca574B5be881b7DbbcFDCE9DDBAb90" + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 16 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ env.AWS_DEFAULT_REGION }} + role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/PolygonIDActionsRole + role-session-name: GitHubActionsSession + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v2 + id: login-ecr + + - name: Build file with supported networks + run: | + cd driver-did-iden3 + echo -e "polygon:" > resolvers.settings.yaml + echo -e " amoy:" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_AMOY }}" >> resolvers.settings.yaml + echo -e " networkURL: ${{ secrets.POLYGON_AMOY_NODE_URL }}" >> resolvers.settings.yaml + echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml + echo -e " main:" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_MAIN }}" >> resolvers.settings.yaml + echo -e " networkURL: ${{ secrets.POLYGON_MAIN_NODE_URL }}" >> resolvers.settings.yaml + echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml + echo -e "privado:" >> resolvers.settings.yaml + echo -e " main:" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_PRIVADO_MAIN }}" >> resolvers.settings.yaml + echo -e " networkURL: ${{ secrets.PRIVADO_MAIN_NODE_URL }}" >> resolvers.settings.yaml + echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml + echo -e " test:" >> resolvers.settings.yaml + echo -e " contractAddress: ${{ env.STATE_CONTRACT_ADDRESS_PRIVADO_TEST }}" >> resolvers.settings.yaml + echo -e " networkURL: ${{ secrets.PRIVADO_TEST_NODE_URL }}" >> resolvers.settings.yaml + echo -e " walletKey: ${{ secrets.SIGNER_PRIVATE_KEY }}" >> resolvers.settings.yaml + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: build and deploy to DockerHub + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} + run: | + cd driver-did-iden3 && \ + docker buildx build --push \ + --platform linux/amd64,linux/arm64 \ + -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ github.ref_name }} \ diff --git a/.github/workflows/push-container.yaml b/.github/workflows/push-container.yaml index 826254f..5d9e524 100644 --- a/.github/workflows/push-container.yaml +++ b/.github/workflows/push-container.yaml @@ -1,7 +1,11 @@ +# This workflow builds a docker image and pushes it to GitHub Container Registry +# We need to have this image in public registry for compatibility with universal resolver name: Publish driver-did-iden3 on: - release: - types: [published] + push: + tags: + - '!v*.*.*-dev' + - 'v*' workflow_dispatch: jobs: From a6ab26135e9de6d8e87410a1519a611f41ac7040 Mon Sep 17 00:00:00 2001 From: ilya-korotya Date: Thu, 8 Aug 2024 18:39:04 +0200 Subject: [PATCH 2/4] fix e2e tests --- .github/workflows/e2e.yaml | 2 + .../http_nameservice.postman_collection.json | 93 +++++++++++++++---- 2 files changed, 79 insertions(+), 16 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 7ac73b2..4feb86b 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -58,6 +58,8 @@ jobs: newman run tests/e2e/http_nameservice.postman_collection.json \ -g ./tests/e2e/dev_env.json \ --global-var issuer_server=${{ secrets.ISSUER_URL }} \ + --global-var username=${{ secrets.ISSUER_NODE_USER }} \ + --global-var password=${{ secrets.ISSUER_NODE_PASSWROD }} \ --bail --verbose - name: Run state tests diff --git a/tests/e2e/http_nameservice.postman_collection.json b/tests/e2e/http_nameservice.postman_collection.json index b0e9d67..673df3c 100644 --- a/tests/e2e/http_nameservice.postman_collection.json +++ b/tests/e2e/http_nameservice.postman_collection.json @@ -1,8 +1,9 @@ { "info": { - "_postman_id": "301f6d89-ec5b-42a4-b00f-d3005d9988e6", + "_postman_id": "aefc13c9-2239-409c-ba32-b0c10b4ad7c9", "name": "Nameservice e2e Iden3", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "37022085" }, "item": [ { @@ -27,16 +28,32 @@ "pm.collectionVariables.set(\"issuer_identity\", pm.response.json().identifier);", "pm.collectionVariables.set(\"issuer_genesis_state\", pm.response.json().state.state)" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"did_metadata\":{\n \"method\": \"iden3\",\n \"blockchain\":\"polygon\",\n \"network\": \"amoy\",\n \"type\": \"BJJ\"\n }\n}", + "raw": "{\n \"didMetadata\": {\n \"method\": \"polygonid\",\n \"blockchain\": \"polygon\",\n \"network\": \"amoy\",\n \"type\": \"BJJ\"\n }\n}", "options": { "raw": { "language": "json" @@ -44,12 +61,11 @@ } }, "url": { - "raw": "{{issuer_server}}/api/v1/identities", + "raw": "{{issuer_server}}/v1/identities", "host": [ "{{issuer_server}}" ], "path": [ - "api", "v1", "identities" ] @@ -78,16 +94,32 @@ "", "pm.collectionVariables.set(\"user_identity\", pm.response.json().identifier);" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"did_metadata\":{\n \"method\": \"iden3\",\n \"blockchain\":\"polygon\",\n \"network\": \"amoy\",\n \"type\": \"BJJ\"\n }\n}", + "raw": "{\n \"didMetadata\": {\n \"method\": \"polygonid\",\n \"blockchain\": \"polygon\",\n \"network\": \"amoy\",\n \"type\": \"BJJ\"\n }\n}", "options": { "raw": { "language": "json" @@ -95,12 +127,11 @@ } }, "url": { - "raw": "{{issuer_server}}/api/v1/identities", + "raw": "{{issuer_server}}/v1/identities", "host": [ "{{issuer_server}}" ], "path": [ - "api", "v1", "identities" ] @@ -322,11 +353,27 @@ "pm.collectionVariables.set(\"age_claim_non_merklized_id\", pm.response.json().id);", "" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, "method": "POST", "header": [], "body": { @@ -339,12 +386,11 @@ } }, "url": { - "raw": "{{issuer_server}}/api/v1/identities/{{issuer_identity}}/claims", + "raw": "{{issuer_server}}/v1/identities/{{issuer_identity}}/claims", "host": [ "{{issuer_server}}" ], "path": [ - "api", "v1", "identities", "{{issuer_identity}}", @@ -392,7 +438,8 @@ " postman.setNextRequest(pm.info.requestId); // retry the current request", "}" ], - "type": "text/javascript" + "type": "text/javascript", + "packages": {} } } ], @@ -400,6 +447,21 @@ "disableBodyPruning": true }, "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, "method": "GET", "header": [], "body": { @@ -412,12 +474,11 @@ } }, "url": { - "raw": "{{issuer_server}}/api/v1/identities/{{issuer_identity}}/claims/{{age_claim_non_merklized_id}}", + "raw": "{{issuer_server}}/v1/identities/{{issuer_identity}}/claims/{{age_claim_non_merklized_id}}", "host": [ "{{issuer_server}}" ], "path": [ - "api", "v1", "identities", "{{issuer_identity}}", From be693352e8dcb624832195f2d57acc9805621e04 Mon Sep 17 00:00:00 2001 From: ilya-korotya Date: Thu, 8 Aug 2024 18:52:02 +0200 Subject: [PATCH 3/4] update issuer node API to new one --- .../http_nameservice.postman_collection.json | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/e2e/http_nameservice.postman_collection.json b/tests/e2e/http_nameservice.postman_collection.json index 673df3c..fa92a62 100644 --- a/tests/e2e/http_nameservice.postman_collection.json +++ b/tests/e2e/http_nameservice.postman_collection.json @@ -13,11 +13,11 @@ "listen": "test", "script": { "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", "});", "pm.test(\"Content-Type header is application/json\", () => {", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json; charset=utf-8');", + " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');", "});", "", "pm.test(\"Identifier is not empty\", () => {", @@ -80,11 +80,11 @@ "listen": "test", "script": { "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", "});", "pm.test(\"Content-Type header is application/json\", () => {", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json; charset=utf-8');", + " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');", "});", "", "pm.test(\"Identifier is not empty\", () => {", @@ -343,11 +343,11 @@ "listen": "test", "script": { "exec": [ - "pm.test(\"Status code is 202\", function () {", - " pm.response.to.have.status(202);", + "pm.test(\"Status code is 201\", function () {", + " pm.response.to.have.status(201);", "});", "pm.test(\"Content-Type header is application/json\", () => {", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json; charset=utf-8');", + " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');", "});", "", "pm.collectionVariables.set(\"age_claim_non_merklized_id\", pm.response.json().id);", @@ -386,13 +386,12 @@ } }, "url": { - "raw": "{{issuer_server}}/v1/identities/{{issuer_identity}}/claims", + "raw": "{{issuer_server}}/v1/{{issuer_identity}}/claims", "host": [ "{{issuer_server}}" ], "path": [ "v1", - "identities", "{{issuer_identity}}", "claims" ] @@ -415,7 +414,7 @@ " pm.response.to.have.status(200);", "});", "pm.test(\"Content-Type header is application/json\", () => {", - " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json; charset=utf-8');", + " pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');", "});", "", "pm.test(\"Proof section is NOT empty\", function () {", @@ -474,13 +473,12 @@ } }, "url": { - "raw": "{{issuer_server}}/v1/identities/{{issuer_identity}}/claims/{{age_claim_non_merklized_id}}", + "raw": "{{issuer_server}}/v1/{{issuer_identity}}/claims/{{age_claim_non_merklized_id}}", "host": [ "{{issuer_server}}" ], "path": [ "v1", - "identities", "{{issuer_identity}}", "claims", "{{age_claim_non_merklized_id}}" From c3e1b61bfc4cbb4119090af4525a6440b014c5e1 Mon Sep 17 00:00:00 2001 From: ilya-korotya Date: Thu, 8 Aug 2024 19:12:27 +0200 Subject: [PATCH 4/4] call publish state --- .../http_nameservice.postman_collection.json | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/e2e/http_nameservice.postman_collection.json b/tests/e2e/http_nameservice.postman_collection.json index fa92a62..796cf00 100644 --- a/tests/e2e/http_nameservice.postman_collection.json +++ b/tests/e2e/http_nameservice.postman_collection.json @@ -399,6 +399,41 @@ }, "response": [] }, + { + "name": "Publish issuer state", + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "{{password}}", + "type": "string" + }, + { + "key": "username", + "value": "{{username}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [], + "url": { + "raw": "{{issuer_server}}/v1/{{issuer_identity}}/state/publish", + "host": [ + "{{issuer_server}}" + ], + "path": [ + "v1", + "{{issuer_identity}}", + "state", + "publish" + ] + } + }, + "response": [] + }, { "name": "KYCAgeCredential(Non merklized) wait for MTP", "event": [