diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml index f81f9b982..bcb98ca7e 100644 --- a/.github/workflows/api-tests.yml +++ b/.github/workflows/api-tests.yml @@ -53,6 +53,7 @@ env: BOOTSTRAP_URL: http://localhost:9013 CERTS_URL: http://localhost:9019 TWINS_URL: http://localhost:9018 + PROVISION_URL: http://localhost:9016 jobs: api-test: @@ -210,6 +211,16 @@ jobs: report: false args: '--header "Authorization: Bearer ${{ env.USER_TOKEN }}" --contrib-unique-data --contrib-openapi-formats-uuid --hypothesis-suppress-health-check=filter_too_much --stateful=links' + - name: Run Provision API tests + if: steps.changes.outputs.provision == 'true' + uses: schemathesis/action@v1 + with: + schema: api/openapi/provision.yml + base-url: ${{ env.PROVISION_URL }} + checks: all + report: false + args: '--header "Authorization: Bearer ${{ env.USER_TOKEN }}" --contrib-unique-data --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 79d9e8aa3..0db8a642b 100644 --- a/Makefile +++ b/Makefile @@ -157,6 +157,7 @@ test_api_auth: TEST_API_URL := http://localhost:8189 test_api_bootstrap: TEST_API_URL := http://localhost:9013 test_api_certs: TEST_API_URL := http://localhost:9019 test_api_twins: TEST_API_URL := http://localhost:9018 +test_api_provision: TEST_API_URL := http://localhost:9016 $(TEST_API): $(call test_api_service,$(@),$(TEST_API_URL)) diff --git a/api/openapi/provision.yml b/api/openapi/provision.yml index e7d57dae2..7f1b03c2f 100644 --- a/api/openapi/provision.yml +++ b/api/openapi/provision.yml @@ -36,13 +36,17 @@ paths: requestBody: $ref: "#/components/requestBodies/ProvisionReq" responses: - '201': + "201": description: Created - '400': + "400": description: Failed due to malformed JSON. "401": description: Missing or invalid access token provided. - '500': + "415": + description: Missing or invalid content type. + "422": + description: Database can't process request. + "500": $ref: "#/components/responses/ServiceError" get: summary: Gets current mapping. @@ -52,11 +56,15 @@ paths: tags: - provision responses: - '200': + "200": $ref: "#/components/responses/ProvisionRes" "401": description: Missing or invalid access token provided. - '500': + "415": + description: Missing or invalid content type. + "422": + description: Database can't process request. + "500": $ref: "#/components/responses/ServiceError" /health: get: @@ -64,9 +72,9 @@ paths: tags: - health responses: - '200': + "200": $ref: "#/components/responses/HealthRes" - '500': + "500": $ref: "#/components/responses/ServiceError" components: @@ -84,9 +92,9 @@ components: external_id: type: string external_key: - type: string + type: string name: - type: string + type: string responses: ServiceError: @@ -100,7 +108,7 @@ components: HealthRes: description: Service Health Check. content: - application/json: + application/health+json: schema: $ref: "./schemas/HealthInfo.yml" diff --git a/cmd/provision/main.go b/cmd/provision/main.go index 6057fd435..90b1b7f47 100644 --- a/cmd/provision/main.go +++ b/cmd/provision/main.go @@ -136,25 +136,21 @@ func loadConfig() (provision.Config, error) { } } - cfg = provision.Config{ - Bootstrap: provision.Bootstrap{ - Content: content, + cfg.Bootstrap.Content = content + // This is default conf for provision if there is no config file + cfg.Channels = []mggroups.Group{ + { + Name: "control-channel", + Metadata: map[string]interface{}{"type": "control"}, + }, { + Name: "data-channel", + Metadata: map[string]interface{}{"type": "data"}, }, - // This is default conf for provision if there is no config file - Channels: []mggroups.Group{ - { - Name: "control-channel", - Metadata: map[string]interface{}{"type": "control"}, - }, { - Name: "data-channel", - Metadata: map[string]interface{}{"type": "data"}, - }, - }, - Things: []mgclients.Client{ - { - Name: "thing", - Metadata: map[string]interface{}{"external_id": "xxxxxx"}, - }, + } + cfg.Things = []mgclients.Client{ + { + Name: "thing", + Metadata: map[string]interface{}{"external_id": "xxxxxx"}, }, }