Skip to content

Commit

Permalink
SMQ-2570 - Update clients and channels api docs (#2578)
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Gateru <[email protected]>
  • Loading branch information
felixgateru authored Dec 10, 2024
1 parent ed7f818 commit 1e77579
Show file tree
Hide file tree
Showing 15 changed files with 1,659 additions and 954 deletions.
41 changes: 35 additions & 6 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,28 @@ on:
- "auth/api/http/**"
- "bootstrap/api**"
- "certs/api/**"
- "channels/api/http/**"
- "clients/api/http/**"
- "consumers/notifiers/api/**"
- "domains/api/http/**"
- "groups/api/http/**"
- "http/api/**"
- "invitations/api/**"
- "journal/api/**"
- "provision/api/**"
- "readers/api/**"
- "clients/api/**"
- "users/api/**"

env:
TOKENS_URL: http://localhost:9002/users/tokens/issue
DOMAINS_URL: http://localhost:8189/domains
CREATE_DOMAINS_URL: http://localhost:9003/domains
USER_IDENTITY: [email protected]
USER_SECRET: 12345678
DOMAIN_NAME: demo-test
USERS_URL: http://localhost:9002
CLIENTS_URL: http://localhost:9000
CLIENTS_URL: http://localhost:9006
CHANNELS_URL: http://localhost:9005
GROUPS_URL: http://localhost:9004
HTTP_ADAPTER_URL: http://localhost:8008
INVITATIONS_URL: http://localhost:9020
AUTH_URL: http://localhost:8189
Expand Down Expand Up @@ -62,8 +67,7 @@ jobs:
- name: Set access token
run: |
export USER_TOKEN=$(curl -sSX POST $TOKENS_URL -H "Content-Type: application/json" -d "{\"identity\": \"$USER_IDENTITY\",\"secret\": \"$USER_SECRET\"}" | jq -r .access_token)
export DOMAIN_ID=$(curl -sSX POST $DOMAINS_URL -H "Content-Type: application/json" -H "Authorization: Bearer $USER_TOKEN" -d "{\"name\":\"$DOMAIN_NAME\",\"alias\":\"$DOMAIN_NAME\"}" | jq -r .id)
export USER_TOKEN=$(curl -sSX POST $TOKENS_URL -H "Content-Type: application/json" -d "{\"identity\": \"$USER_IDENTITY\",\"secret\": \"$USER_SECRET\",\"domain_id\": \"$DOMAIN_ID\"}" | jq -r .access_token)
export DOMAIN_ID=$(curl -sSX POST $CREATE_DOMAINS_URL -H "Content-Type: application/json" -H "Authorization: Bearer $USER_TOKEN" -d "{\"name\":\"$DOMAIN_NAME\",\"alias\":\"$DOMAIN_NAME\"}" | jq -r .id)
echo "USER_TOKEN=$USER_TOKEN" >> $GITHUB_ENV
export CLIENT_SECRET=$(supermq-cli provision test | /usr/bin/grep -Eo '"secret": "[^"]+"' | awk 'NR % 2 == 0' | sed 's/"secret": "\(.*\)"/\1/')
echo "CLIENT_SECRET=$CLIENT_SECRET" >> $GITHUB_ENV
Expand Down Expand Up @@ -92,6 +96,11 @@ jobs:
- ".github/workflows/api-tests.yml"
- "api/openapi/certs.yml"
- "certs/api/**"
domains:
- ".github/workflows/api-tests.yml"
- "api/openapi/domains.yml"
- "domains/api/http/**"
http:
- ".github/workflows/api-tests.yml"
Expand All @@ -116,7 +125,17 @@ jobs:
clients:
- ".github/workflows/api-tests.yml"
- "api/openapi/clients.yml"
- "clients/api/**"
- "clients/api/http/**"
channels:
- ".github/workflows/api-tests.yml"
- "api/openapi/channels.yml"
- "channels/api/http/**"
groups:
- ".github/workflows/api-tests.yml"
- "api/openapi/groups.yml"
- "groups/api/http/**"
users:
- ".github/workflows/api-tests.yml"
Expand All @@ -142,6 +161,16 @@ jobs:
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: Run Channels API tests
if: steps.changes.outputs.channels == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/channels.yml
base-url: ${{ env.CHANNELS_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: Run HTTP Adapter API tests
if: steps.changes.outputs.http == 'true'
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SMQ_DOCKER_IMAGE_NAME_PREFIX ?= supermq
BUILD_DIR ?= build
SERVICES = auth users clients groups channels domains http coap ws postgres-writer postgres-reader timescale-writer \
timescale-reader cli bootstrap mqtt provision certs invitations journal
TEST_API_SERVICES = journal auth bootstrap certs http invitations notifiers provision readers clients users
TEST_API_SERVICES = journal auth bootstrap certs http invitations notifiers provision readers clients users channels groups domains
TEST_API = $(addprefix test_api_,$(TEST_API_SERVICES))
DOCKERS = $(addprefix docker_,$(SERVICES))
DOCKERS_DEV = $(addprefix docker_dev_,$(SERVICES))
Expand Down Expand Up @@ -168,7 +168,10 @@ define test_api_service
endef

test_api_users: TEST_API_URL := http://localhost:9002
test_api_clients: TEST_API_URL := http://localhost:9000
test_api_clients: TEST_API_URL := http://localhost:9006
test_api_domains: TEST_API_URL := http://localhost:9003
test_api_channels: TEST_API_URL := http://localhost:9005
test_api_groups: TEST_API_URL := http://localhost:9004
test_api_http: TEST_API_URL := http://localhost:8008
test_api_invitations: TEST_API_URL := http://localhost:9020
test_api_auth: TEST_API_URL := http://localhost:8189
Expand Down Expand Up @@ -264,4 +267,4 @@ run_addons: check_certs
done

run_live: check_certs
GOPATH=$(go env GOPATH) docker compose -f docker/docker-compose.yml -f docker/docker-compose-live.yaml --env-file docker/.env -p $(DOCKER_PROJECT) $(DOCKER_COMPOSE_COMMAND) $(args)
GOPATH=$(go env GOPATH) docker compose -f docker/docker-compose.yml -f docker/docker-compose-live.yaml --env-file docker/.env -p $(DOCKER_PROJECT) $(DOCKER_COMPOSE_COMMAND) $(args)
5 changes: 1 addition & 4 deletions api/openapi/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,6 @@ components:
client_cert:
type: string
description: Client certificate.
client_key:
type: string
description: Key for the client_cert.
ca_cert:
type: string
description: Issuing CA certificate.
Expand Down Expand Up @@ -652,7 +649,7 @@ components:
content:
application/health+json:
schema:
$ref: "./schemas/HealthInfo.yml"
$ref: "./schemas/health_info.yml"
ConfigUpdateCertsRes:
description: Data retrieved. Config certs updated.
content:
Expand Down
2 changes: 1 addition & 1 deletion api/openapi/certs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ components:
content:
application/health+json:
schema:
$ref: "./schemas/HealthInfo.yml"
$ref: "./schemas/health_info.yml"

securitySchemes:
bearerAuth:
Expand Down
Loading

0 comments on commit 1e77579

Please sign in to comment.