From e803f36f78c5202a5a7cce2341d9f32a4c30077d Mon Sep 17 00:00:00 2001 From: b1ackd0t <28790446+rodneyosodo@users.noreply.github.com> Date: Wed, 10 Apr 2024 11:18:54 +0300 Subject: [PATCH] NOISSUE - Add property based testing to invitations API (#2093) Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com> --- .github/workflows/api-tests.yml | 11 +++++++++++ Makefile | 1 + api/openapi/invitations.yml | 15 +++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml index e3c9c281b2..5150fd7972 100644 --- a/.github/workflows/api-tests.yml +++ b/.github/workflows/api-tests.yml @@ -30,6 +30,7 @@ env: DOMAIN_NAME: demo-test USERS_URL: http://localhost:9002 THINGS_URL: http://localhost:9000 + INVITATIONS_URL: http://localhost:9020 jobs: api-test: @@ -137,6 +138,16 @@ jobs: report: false args: '--header "Authorization: Bearer ${{ env.USER_TOKEN }}" --contrib-openapi-formats-uuid --hypothesis-suppress-health-check=filter_too_much --stateful=links' + - name: Run Invitations API tests + if: steps.changes.outputs.invitations == 'true' + uses: schemathesis/action@v1 + with: + schema: api/openapi/invitations.yml + base-url: ${{ env.INVITATIONS_URL }} + checks: all + report: false + args: '--header "Authorization: Bearer ${{ env.USER_TOKEN }}" --contrib-openapi-formats-uuid --hypothesis-suppress-health-check=filter_too_much --stateful=links' + - name: Stop containers if: always() run: make run down args="-v" diff --git a/Makefile b/Makefile index c3fd72b0cb..2f8b397692 100644 --- a/Makefile +++ b/Makefile @@ -152,6 +152,7 @@ endef test_api_users: TEST_API_URL := http://localhost:9002 test_api_things: TEST_API_URL := http://localhost:9000 +test_api_invitations: TEST_API_URL := http://localhost:9020 $(TEST_API): $(call test_api_service,$(@),$(TEST_API_URL)) diff --git a/api/openapi/invitations.yml b/api/openapi/invitations.yml index acaefd6456..1fb3c7ba84 100644 --- a/api/openapi/invitations.yml +++ b/api/openapi/invitations.yml @@ -29,6 +29,7 @@ tags: paths: /invitations: post: + operationId: sendInvitation tags: - Invitations summary: Send invitation @@ -45,6 +46,8 @@ paths: description: Failed due to malformed JSON. "401": description: Missing or invalid access token provided. + "404": + description: A non-existent entity request. "409": description: Failed due to using an existing identity. "415": @@ -53,6 +56,7 @@ paths: $ref: "#/components/responses/ServiceError" get: + operationId: listInvitations tags: - Invitations summary: List invitations @@ -89,6 +93,7 @@ paths: /invitations/accept: post: + operationId: acceptInvitation summary: Accept invitation description: | Current logged in user accepts invitation to join domain. @@ -105,11 +110,14 @@ paths: description: Failed due to malformed query parameters. "401": description: Missing or invalid access token provided. + "404": + description: A non-existent entity request. "500": $ref: "#/components/responses/ServiceError" /invitations/{user_id}/{domain_id}: get: + operationId: getInvitation summary: Retrieves a specific invitation description: | Retrieves a specific invitation that is identifier by the user ID and domain ID. @@ -135,6 +143,7 @@ paths: $ref: "#/components/responses/ServiceError" delete: + operationId: deleteInvitation summary: Deletes a specific invitation description: | Deletes a specific invitation that is identifier by the user ID and domain ID. @@ -452,6 +461,12 @@ components: application/json: schema: $ref: "#/components/schemas/Invitation" + links: + delete: + operationId: deleteInvitation + parameters: + user_id: $response.body#/user_id + domain_id: $response.body#/domain_id InvitationPageRes: description: Data retrieved.