diff --git a/domains/roleactions.go b/domains/roleactions.go index 70ea3c6fba..bf47e67cb6 100644 --- a/domains/roleactions.go +++ b/domains/roleactions.go @@ -39,7 +39,7 @@ const ( ChannelRead roles.Action = "channel_read" ChannelDelete roles.Action = "channel_delete" ChannelSetParentGroup roles.Action = "channel_set_parent_group" - ChannelConnectToClient roles.Action = "channel_connect_to_client" + ChannelConnectToClient roles.Action = "channel_connect_to_client" ChannelPublish roles.Action = "channel_publish" ChannelSubscribe roles.Action = "channel_subscribe" ChannelManageRole roles.Action = "channel_manage_role" diff --git a/readers/api/endpoint_test.go b/readers/api/endpoint_test.go index 46325db281..7afbc80f06 100644 --- a/readers/api/endpoint_test.go +++ b/readers/api/endpoint_test.go @@ -13,6 +13,8 @@ import ( chmocks "github.com/absmach/magistrala/channels/mocks" climocks "github.com/absmach/magistrala/clients/mocks" + grpcChannelsV1 "github.com/absmach/magistrala/internal/grpc/channels/v1" + grpcClientsV1 "github.com/absmach/magistrala/internal/grpc/clients/v1" "github.com/absmach/magistrala/internal/testsutil" "github.com/absmach/magistrala/pkg/apiutil" mgauthn "github.com/absmach/magistrala/pkg/authn" @@ -23,6 +25,7 @@ import ( "github.com/absmach/magistrala/readers/api" "github.com/absmach/magistrala/readers/mocks" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" ) const ( @@ -150,7 +153,7 @@ func TestReadAll(t *testing.T) { }{ { desc: "read page with valid offset and limit", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusOK, @@ -162,22 +165,16 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with valid offset and limit as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{Limit: 10}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, }, - { - desc: "read page as user without domain id", - url: fmt.Sprintf("%s/%s/channels/%s/messages", ts.URL, "", chanID), - token: userToken, - status: http.StatusBadRequest, - }, { desc: "read page with negative offset as client", url: fmt.Sprintf("%s/channels/%s/messages?offset=-1&limit=10", ts.URL, chanID), @@ -250,7 +247,7 @@ func TestReadAll(t *testing.T) { authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{Limit: 10}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, @@ -262,7 +259,7 @@ func TestReadAll(t *testing.T) { authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, @@ -274,7 +271,7 @@ func TestReadAll(t *testing.T) { authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{Format: "messages"}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, @@ -508,7 +505,7 @@ func TestReadAll(t *testing.T) { authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages", Interval: "10h"}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, @@ -569,61 +566,61 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with valid offset and limit as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{Limit: 10}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, }, { desc: "read page with negative offset as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=-1&limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=-1&limit=10", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with negative limit as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&limit=-10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=-10", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with zero limit as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&limit=0", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=0", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with non-integer offset as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=abc&limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=abc&limit=10", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with non-integer limit as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&limit=abc", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=abc", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with invalid channel id as user", - url: fmt.Sprintf("%s/%s/channels//messages?offset=0&limit=10", ts.URL, domainID), + url: fmt.Sprintf("%s/channels//messages?offset=0&limit=10", ts.URL), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with invalid token as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID), token: invalidToken, authResponse: false, status: http.StatusUnauthorized, @@ -631,21 +628,21 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with multiple offset as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&offset=1&limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&offset=1&limit=10", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with multiple limit as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&limit=20&limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=20&limit=10", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with empty token as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0&limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID), token: "", authResponse: false, status: http.StatusUnauthorized, @@ -653,55 +650,55 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with default offset as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?limit=10", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?limit=10", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{Limit: 10}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, }, { desc: "read page with default limit as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?offset=0", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?offset=0", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, }, { desc: "read page with senml format as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?format=messages", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?format=messages", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{Format: "messages"}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, }, { desc: "read page with subtopic as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?subtopic=%s&protocol=%s", ts.URL, domainID, chanID, subtopic, httpProt), + url: fmt.Sprintf("%s/channels/%s/messages?subtopic=%s&protocol=%s", ts.URL, chanID, subtopic, httpProt), token: userToken, authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{Subtopic: subtopic, Protocol: httpProt}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages", Subtopic: subtopic, Protocol: httpProt}, Total: uint64(len(queryMsgs)), Messages: queryMsgs[0:10], }, }, { desc: "read page with subtopic and protocol as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?subtopic=%s&protocol=%s", ts.URL, domainID, chanID, subtopic, httpProt), + url: fmt.Sprintf("%s/channels/%s/messages?subtopic=%s&protocol=%s", ts.URL, chanID, subtopic, httpProt), token: userToken, authResponse: true, status: http.StatusOK, @@ -713,7 +710,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with publisher as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?publisher=%s", ts.URL, domainID, chanID, pubID2), + url: fmt.Sprintf("%s/channels/%s/messages?publisher=%s", ts.URL, chanID, pubID2), token: userToken, authResponse: true, status: http.StatusOK, @@ -725,7 +722,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with protocol as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?protocol=http", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?protocol=http", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusOK, @@ -737,7 +734,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with name as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?name=%s", ts.URL, domainID, chanID, msgName), + url: fmt.Sprintf("%s/channels/%s/messages?name=%s", ts.URL, chanID, msgName), token: userToken, authResponse: true, status: http.StatusOK, @@ -749,7 +746,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with value as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?v=%f", ts.URL, domainID, chanID, v), + url: fmt.Sprintf("%s/channels/%s/messages?v=%f", ts.URL, chanID, v), token: userToken, authResponse: true, status: http.StatusOK, @@ -761,7 +758,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with value and equal comparator as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, domainID, chanID, v, readers.EqualKey), + url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v, readers.EqualKey), token: userToken, authResponse: true, status: http.StatusOK, @@ -773,7 +770,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with value and lower-than comparator as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, domainID, chanID, v+1, readers.LowerThanKey), + url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v+1, readers.LowerThanKey), token: userToken, authResponse: true, status: http.StatusOK, @@ -785,7 +782,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with value and lower-than-or-equal comparator as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, domainID, chanID, v+1, readers.LowerThanEqualKey), + url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v+1, readers.LowerThanEqualKey), token: userToken, authResponse: true, status: http.StatusOK, @@ -797,7 +794,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with value and greater-than comparator as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, domainID, chanID, v-1, readers.GreaterThanKey), + url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v-1, readers.GreaterThanKey), token: userToken, status: http.StatusOK, authResponse: true, @@ -809,7 +806,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with value and greater-than-or-equal comparator as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, domainID, chanID, v-1, readers.GreaterThanEqualKey), + url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v-1, readers.GreaterThanEqualKey), token: userToken, authResponse: true, status: http.StatusOK, @@ -821,21 +818,21 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with non-float value as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?v=ab01", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?v=ab01", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with value and wrong comparator as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?v=%f&comparator=wrong", ts.URL, domainID, chanID, v-1), + url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=wrong", ts.URL, chanID, v-1), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with boolean value as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?vb=true", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?vb=true", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusOK, @@ -847,14 +844,14 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with non-boolean value as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?vb=yes", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?vb=yes", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with string value as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?vs=%s", ts.URL, domainID, chanID, vs), + url: fmt.Sprintf("%s/channels/%s/messages?vs=%s", ts.URL, chanID, vs), token: userToken, authResponse: true, status: http.StatusOK, @@ -866,7 +863,7 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with data value as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?vd=%s", ts.URL, domainID, chanID, vd), + url: fmt.Sprintf("%s/channels/%s/messages?vd=%s", ts.URL, chanID, vd), token: userToken, authResponse: true, status: http.StatusOK, @@ -878,21 +875,21 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with non-float from as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?from=ABCD", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?from=ABCD", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with non-float to as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?to=ABCD", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?to=ABCD", ts.URL, chanID), token: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with from/to as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?from=%f&to=%f", ts.URL, domainID, chanID, messages[19].Time, messages[4].Time), + url: fmt.Sprintf("%s/channels/%s/messages?from=%f&to=%f", ts.URL, chanID, messages[19].Time, messages[4].Time), token: userToken, authResponse: true, status: http.StatusOK, @@ -904,33 +901,33 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with aggregation as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?aggregation=MAX", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?aggregation=MAX", ts.URL, chanID), key: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with interval as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?interval=10h", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?interval=10h", ts.URL, chanID), key: userToken, authResponse: true, status: http.StatusOK, res: pageRes{ - PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages", Interval: "10h"}, + PageMetadata: readers.PageMetadata{Limit: 10, Format: "messages"}, Total: uint64(len(messages)), Messages: messages[0:10], }, }, { desc: "read page with aggregation and interval as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?aggregation=MAX&interval=10h", ts.URL, domainID, chanID), + url: fmt.Sprintf("%s/channels/%s/messages?aggregation=MAX&interval=10h", ts.URL, chanID), key: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with aggregation, interval, to and from as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?aggregation=MAX&interval=10h&from=%f&to=%f", ts.URL, domainID, chanID, messages[19].Time, messages[4].Time), + url: fmt.Sprintf("%s/channels/%s/messages?aggregation=MAX&interval=10h&from=%f&to=%f", ts.URL, chanID, messages[19].Time, messages[4].Time), key: userToken, authResponse: true, status: http.StatusOK, @@ -942,35 +939,35 @@ func TestReadAll(t *testing.T) { }, { desc: "read page with invalid aggregation and valid interval, to and from as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?aggregation=invalid&interval=10h&from=%f&to=%f", ts.URL, domainID, chanID, messages[19].Time, messages[4].Time), + url: fmt.Sprintf("%s/channels/%s/messages?aggregation=invalid&interval=10h&from=%f&to=%f", ts.URL, chanID, messages[19].Time, messages[4].Time), key: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with invalid interval and valid aggregation, to and from as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?aggregation=MAX&interval=10hrs&from=%f&to=%f", ts.URL, domainID, chanID, messages[19].Time, messages[4].Time), + url: fmt.Sprintf("%s/channels/%s/messages?aggregation=MAX&interval=10hrs&from=%f&to=%f", ts.URL, chanID, messages[19].Time, messages[4].Time), key: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with aggregation, interval and to with missing from as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?aggregation=MAX&interval=10h&to=%f", ts.URL, domainID, chanID, messages[4].Time), + url: fmt.Sprintf("%s/channels/%s/messages?aggregation=MAX&interval=10h&to=%f", ts.URL, chanID, messages[4].Time), key: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with aggregation, interval and to with invalid from as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?aggregation=MAX&interval=10h&to=ABCD&from=%f", ts.URL, domainID, chanID, messages[4].Time), + url: fmt.Sprintf("%s/channels/%s/messages?aggregation=MAX&interval=10h&to=ABCD&from=%f", ts.URL, chanID, messages[4].Time), key: userToken, authResponse: true, status: http.StatusBadRequest, }, { desc: "read page with aggregation, interval and to with invalid to as user", - url: fmt.Sprintf("%s/%s/channels/%s/messages?aggregation=MAX&interval=10h&from=%f&to=ABCD", ts.URL, domainID, chanID, messages[4].Time), + url: fmt.Sprintf("%s/channels/%s/messages?aggregation=MAX&interval=10h&from=%f&to=ABCD", ts.URL, chanID, messages[4].Time), key: userToken, authResponse: true, status: http.StatusBadRequest, @@ -978,7 +975,14 @@ func TestReadAll(t *testing.T) { } for _, tc := range cases { - repo.On("ReadAll", chanID, tc.res.PageMetadata).Return(readers.MessagesPage{Total: tc.res.Total, Messages: fromSenml(tc.res.Messages)}, nil) + authnCall := authn.On("Authenticate", mock.Anything, tc.token).Return(validSession, tc.authnErr) + if tc.key != "" { + authnCall = clients.On("Authenticate", mock.Anything, &grpcClientsV1.AuthnReq{ + ClientSecret: tc.key, + }).Return(&grpcClientsV1.AuthnRes{Id: testsutil.GenerateUUID(t), Authenticated: true}, tc.authnErr) + } + authzCall := channels.On("Authorize", mock.Anything, mock.Anything).Return(&grpcChannelsV1.AuthzRes{Authorized: true}, tc.err) + repoCall := repo.On("ReadAll", chanID, tc.res.PageMetadata).Return(readers.MessagesPage{Total: tc.res.Total, Messages: fromSenml(tc.res.Messages)}, nil) req := testRequest{ client: ts.Client(), method: http.MethodGet, @@ -992,11 +996,13 @@ func TestReadAll(t *testing.T) { var page pageRes err = json.NewDecoder(res.Body).Decode(&page) assert.Nil(t, err, fmt.Sprintf("%s: unexpected error while decoding response body: %s", tc.desc, err)) - assert.Nil(t, err, fmt.Sprintf("%s: unexpected error %s", tc.desc, err)) assert.Equal(t, tc.status, res.StatusCode, fmt.Sprintf("%s: expected %d got %d", tc.desc, tc.status, res.StatusCode)) assert.Equal(t, tc.res.Total, page.Total, fmt.Sprintf("%s: expected %d got %d", tc.desc, tc.res.Total, page.Total)) assert.ElementsMatch(t, tc.res.Messages, page.Messages, fmt.Sprintf("%s: got incorrect body from response", tc.desc)) + authzCall.Unset() + authnCall.Unset() + repoCall.Unset() } } diff --git a/readers/api/requests.go b/readers/api/requests.go index df08f79639..c32be45b96 100644 --- a/readers/api/requests.go +++ b/readers/api/requests.go @@ -20,7 +20,6 @@ type listMessagesReq struct { chanID string token string key string - domainID string pageMeta readers.PageMetadata } @@ -28,9 +27,6 @@ func (req listMessagesReq) validate() error { if req.token == "" && req.key == "" { return apiutil.ErrBearerToken } - if req.token != "" && req.domainID == "" { - return apiutil.ErrMissingDomainID - } if req.chanID == "" { return apiutil.ErrMissingID