Skip to content

Commit

Permalink
SMQ-2570 - Update SDK to align with new architecture (#2585)
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Gateru <[email protected]>
  • Loading branch information
felixgateru authored Dec 23, 2024
1 parent 7486317 commit 4f73a52
Show file tree
Hide file tree
Showing 39 changed files with 11,815 additions and 8,362 deletions.
54 changes: 27 additions & 27 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,74 +80,74 @@ jobs:
filters: |
journal:
- ".github/workflows/api-tests.yml"
- "api/openapi/journal.yml"
- "apidocs/openapi/journal.yml"
- "journal/api/**"
auth:
- ".github/workflows/api-tests.yml"
- "api/openapi/auth.yml"
- "apidocs/openapi/auth.yml"
- "auth/api/http/**"
bootstrap:
- ".github/workflows/api-tests.yml"
- "api/openapi/bootstrap.yml"
- "apidocs/openapi/bootstrap.yml"
- "bootstrap/api/**"
certs:
- ".github/workflows/api-tests.yml"
- "api/openapi/certs.yml"
- "apidocs/openapi/certs.yml"
- "certs/api/**"
domains:
- ".github/workflows/api-tests.yml"
- "api/openapi/domains.yml"
- "apidocs/openapi/domains.yml"
- "domains/api/http/**"
http:
- ".github/workflows/api-tests.yml"
- "api/openapi/http.yml"
- "apidocs/openapi/http.yml"
- "http/api/**"
invitations:
- ".github/workflows/api-tests.yml"
- "api/openapi/invitations.yml"
- "apidocs/openapi/invitations.yml"
- "invitations/api/**"
provision:
- ".github/workflows/api-tests.yml"
- "api/openapi/provision.yml"
- "apidocs/openapi/provision.yml"
- "provision/api/**"
readers:
- ".github/workflows/api-tests.yml"
- "api/openapi/readers.yml"
- "apidocs/openapi/readers.yml"
- "readers/api/**"
clients:
- ".github/workflows/api-tests.yml"
- "api/openapi/clients.yml"
- "apidocs/openapi/clients.yml"
- "clients/api/http/**"
channels:
- ".github/workflows/api-tests.yml"
- "api/openapi/channels.yml"
- "apidocs/openapi/channels.yml"
- "channels/api/http/**"
groups:
- ".github/workflows/api-tests.yml"
- "api/openapi/groups.yml"
- "apidocs/openapi/groups.yml"
- "groups/api/http/**"
users:
- ".github/workflows/api-tests.yml"
- "api/openapi/users.yml"
- "apidocs/openapi/users.yml"
- "users/api/**"
- name: Run Users API tests
if: steps.changes.outputs.users == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/users.yml
schema: apidocs/openapi/users.yml
base-url: ${{ env.USERS_URL }}
checks: all
report: false
Expand All @@ -157,7 +157,7 @@ jobs:
if: steps.changes.outputs.groups == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/groups.yml
schema: apidocs/openapi/groups.yml
base-url: ${{ env.GROUPS_URL }}
checks: all
report: false
Expand All @@ -167,7 +167,7 @@ jobs:
if: steps.changes.outputs.clients == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/clients.yml
schema: apidocs/openapi/clients.yml
base-url: ${{ env.CLIENTS_URL }}
checks: all
report: false
Expand All @@ -177,7 +177,7 @@ jobs:
if: steps.changes.outputs.channels == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/channels.yml
schema: apidocs/openapi/channels.yml
base-url: ${{ env.CHANNELS_URL }}
checks: all
report: false
Expand All @@ -187,7 +187,7 @@ jobs:
if: steps.changes.outputs.http == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/http.yml
schema: apidocs/openapi/http.yml
base-url: ${{ env.HTTP_ADAPTER_URL }}
checks: all
report: false
Expand All @@ -197,7 +197,7 @@ jobs:
if: steps.changes.outputs.invitations == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/invitations.yml
schema: apidocs/openapi/invitations.yml
base-url: ${{ env.INVITATIONS_URL }}
checks: all
report: false
Expand All @@ -207,7 +207,7 @@ jobs:
if: steps.changes.outputs.auth == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/auth.yml
schema: apidocs/openapi/auth.yml
base-url: ${{ env.AUTH_URL }}
checks: all
report: false
Expand All @@ -217,7 +217,7 @@ jobs:
if: steps.changes.outputs.domains == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/domains.yml
schema: apidocs/openapi/domains.yml
base-url: ${{ env.DOMAIN_URL }}
checks: all
report: false
Expand All @@ -227,7 +227,7 @@ jobs:
if: steps.changes.outputs.journal == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/journal.yml
schema: apidocs/openapi/journal.yml
base-url: ${{ env.JOURNAL_URL }}
checks: all
report: false
Expand All @@ -237,7 +237,7 @@ jobs:
if: steps.changes.outputs.bootstrap == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/bootstrap.yml
schema: apidocs/openapi/bootstrap.yml
base-url: ${{ env.BOOTSTRAP_URL }}
checks: all
report: false
Expand All @@ -247,7 +247,7 @@ jobs:
if: steps.changes.outputs.certs == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/certs.yml
schema: apidocs/openapi/certs.yml
base-url: ${{ env.CERTS_URL }}
checks: all
report: false
Expand All @@ -257,7 +257,7 @@ jobs:
if: steps.changes.outputs.provision == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/provision.yml
schema: apidocs/openapi/provision.yml
base-url: ${{ env.PROVISION_URL }}
checks: all
report: false
Expand All @@ -273,7 +273,7 @@ jobs:
if: steps.changes.outputs.readers == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/readers.yml
schema: apidocs/openapi/readers.yml
base-url: ${{ env.POSTGRES_READER_URL }}
checks: all
report: false
Expand All @@ -283,7 +283,7 @@ jobs:
if: steps.changes.outputs.readers == 'true'
uses: schemathesis/action@v1
with:
schema: api/openapi/readers.yml
schema: apidocs/openapi/readers.yml
base-url: ${{ env.TIMESCALE_READER_URL }}
checks: all
report: false
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/events/producer/streams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ func TestChangeState(t *testing.T) {
for _, tc := range cases {
tc.session = smqauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := tv.boot.On("RetrieveByID", context.Background(), tc.domainID, tc.id).Return(config, tc.retrieveErr)
sdkCall1 := tv.sdk.On("ConnectClient", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(errors.NewSDKError(tc.connectErr))
sdkCall1 := tv.sdk.On("ConnectClients", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(errors.NewSDKError(tc.connectErr))
repoCall1 := tv.boot.On("ChangeState", context.Background(), mock.Anything, mock.Anything, mock.Anything).Return(tc.stateErr)
err := tv.svc.ChangeState(context.Background(), tc.session, tc.token, tc.id, tc.state)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
Expand Down
6 changes: 3 additions & 3 deletions bootstrap/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (bs bootstrapService) UpdateConnections(ctx context.Context, session smqaut
}

for _, c := range disconnect {
if err := bs.sdk.DisconnectClient(id, c, []string{"Publish", "Subscribe"}, session.DomainID, token); err != nil {
if err := bs.sdk.DisconnectClients(c, []string{id}, []string{"Publish", "Subscribe"}, session.DomainID, token); err != nil {
if errors.Contains(err, repoerr.ErrNotFound) {
continue
}
Expand Down Expand Up @@ -337,7 +337,7 @@ func (bs bootstrapService) ChangeState(ctx context.Context, session smqauthn.Ses
switch state {
case Active:
for _, c := range cfg.Channels {
if err := bs.sdk.ConnectClient(cfg.ClientID, c.ID, []string{"Publish", "Subscribe"}, session.DomainID, token); err != nil {
if err := bs.sdk.ConnectClients(c.ID, []string{cfg.ClientID}, []string{"Publish", "Subscribe"}, session.DomainID, token); err != nil {
// Ignore conflict errors as they indicate the connection already exists.
if errors.Contains(err, svcerr.ErrConflict) {
continue
Expand All @@ -347,7 +347,7 @@ func (bs bootstrapService) ChangeState(ctx context.Context, session smqauthn.Ses
}
case Inactive:
for _, c := range cfg.Channels {
if err := bs.sdk.DisconnectClient(cfg.ClientID, c.ID, []string{"Publish", "Subscribe"}, session.DomainID, token); err != nil {
if err := bs.sdk.DisconnectClients(c.ID, []string{cfg.ClientID}, []string{"Publish", "Subscribe"}, session.DomainID, token); err != nil {
if errors.Contains(err, repoerr.ErrNotFound) {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ func TestChangeState(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
tc.session = smqauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := boot.On("RetrieveByID", context.Background(), tc.domainID, tc.id).Return(c, tc.retrieveErr)
sdkCall := sdk.On("ConnectClient", mock.Anything, mock.Anything, []string{"Publish", "Subscribe"}, mock.Anything, tc.token).Return(tc.connectErr)
sdkCall := sdk.On("ConnectClients", mock.Anything, mock.Anything, []string{"Publish", "Subscribe"}, mock.Anything, tc.token).Return(tc.connectErr)
repoCall1 := boot.On("ChangeState", context.Background(), mock.Anything, mock.Anything, mock.Anything).Return(tc.stateErr)
err := svc.ChangeState(context.Background(), tc.session, tc.token, tc.id, tc.state)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
Expand Down
2 changes: 1 addition & 1 deletion channels/api/http/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ func TestSetChannelParentGroupEndpoint(t *testing.T) {
id: validID,
data: fmt.Sprintf(`{"parent_group_id":"%s"}`, validID),
contentType: contentType,
status: http.StatusAccepted,
status: http.StatusOK,
err: nil,
},
{
Expand Down
2 changes: 1 addition & 1 deletion channels/api/http/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (res updateChannelRes) Empty() bool {
type setChannelParentGroupRes struct{}

func (res setChannelParentGroupRes) Code() int {
return http.StatusAccepted
return http.StatusOK
}

func (res setChannelParentGroupRes) Headers() map[string]string {
Expand Down
Loading

0 comments on commit 4f73a52

Please sign in to comment.