2019-10-07 08:14:47 -06:00
|
|
|
// Copyright (c) Mainflux
|
2018-08-26 13:15:48 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-08-06 17:06:55 +02:00
|
|
|
package api_test
|
|
|
|
|
|
|
|
import (
|
2021-01-26 12:23:15 +01:00
|
|
|
"encoding/json"
|
2018-08-06 17:06:55 +02:00
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
2021-01-26 12:23:15 +01:00
|
|
|
"time"
|
2018-08-06 17:06:55 +02:00
|
|
|
|
NOISSUE - Switch to Google Zanzibar Access control approach (#1919)
* Return Auth service
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Compose to run with SpiceDB and Auth svc
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update auth gRPC API
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove Users' policies
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Move Groups to internal
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use shared groups in Users
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove unused code
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use pkg Groups in Things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove Things groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Make imports consistent
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Groups networking
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove things groups-specific API
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Move Things Clients to the root
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Move Clients to Users root
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Temporarily remove tracing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix imports
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add buffer config for gRPC
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update auth type for Things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use Auth for login
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add temporary solution for refresh token
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Tokenizer interface
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Updade tokens issuing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix token issuing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update JWT validator and refactor Tokenizer
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Rename access timeout
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Rename login to authenticate
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Identify to use SubjectID
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add Auth to Groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use the Auth service for Groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update auth schema
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix Auth for Groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add auth for addons (#14)
Signed-off-by: Arvindh <arvindh91@gmail.com>
Speparate Login and Refresh tokens
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Merge authN and authZ requests for things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add connect and disconnect
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update sharing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix policies addition and removal
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update relation with roels
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add gRPC to Things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Assign and Unassign members to group and Listing of Group members (#15)
* add auth for addons
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add assign and unassign to group
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add group incomplete repo implementation
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Move coap mqtt and ws policies to spicedb (#16)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Remove old policies
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
NOISSUE - Things authorize to return thingID (#18)
This commit modifies the authorize endpoint to the grpc endpoint to return thingID. The authorize endpoint allows adapters to get the publisher of the message.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Add Groups to users service (#17)
* add assign and unassign to group
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add group incomplete repo implementation
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users stable 1
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users stable 2
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users & things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* Amend signature
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix merge error
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Fix es code (#21)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Fix Bugs (#20)
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Test e2e (#19)
* fix: connect method
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix: e2e
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix changes in sdk and e2e
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(docker): remove unnecessary port mapping
Remove the port mapping for MQTT broker in the docker-compose.yml file.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Enable group listing
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(responses): update ChannelsPage struct
The ChannelsPage struct in the responses.go file has been updated. The "Channels" field has been renamed to "Groups" to provide more accurate naming. This change ensures consistency and clarity in the codebase.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(things): add UpdateClientSecret method
Add the UpdateClientSecret method to the things service. This method allows updating the client secret for a specific client identified by the provided token, id, and key parameters.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Use smaller buffers for gRPC
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Clean up tests (#22)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add Connect Disconnect endpoints (#23)
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix list of things in a channel and Add connect disconnect endpoint
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix list of things in a channel and Add connect disconnect endpoint
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add: Things share with users (#25)
* fix list of things in a channel and Add connect disconnect endpoint
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: things share with other users
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Rename gRPC Services (#24)
* Rename things and users auth service
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* docs: add authorization docs for gRPC services
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Rename things and users grpc services
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Remove mainflux.env package
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add: Listing of things, channels, groups, users (#26)
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Clean Up Users (#27)
* feat(groups): rename redis package to events
- Renamed the `redis` package to `events` in the `internal/groups` directory.
- Updated the file paths and names accordingly.
- This change reflects the more accurate purpose of the package and improves code organization.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(auth): Modify identity method
Change request and response of identity method
Add accessToken and refreshToken to Token response
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* clean up users, remove dead code
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(users): add unit tests for user service
This commit adds unit tests for the user service in the `users` package. The tests cover various scenarios and ensure the correct behavior of the service.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add: List of user groups & removed repeating code in groups (#29)
* removed repeating code in list groups
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: list of user group
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix: otel handler operator name for endpoints
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Clean Up Things Service (#28)
* Rework things service
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* add tests
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Clean Up Auth Service (#30)
* clean up auth service
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(auth): remove unused import
Remove the unused import of `emptypb` in `auth.pb.go`. This import is not being used in the codebase and can be safely removed.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Update API docs (#31)
Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Remove TODO comments and cleanup the code
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Update dependenices
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Co-authored-by: b1ackd0t <28790446+rodneyosodo@users.noreply.github.com>
Co-authored-by: Arvindh <30824765+arvindh123@users.noreply.github.com>
2023-10-15 22:02:13 +02:00
|
|
|
authmocks "github.com/mainflux/mainflux/auth/mocks"
|
2022-03-06 01:49:34 +01:00
|
|
|
"github.com/mainflux/mainflux/internal/apiutil"
|
2020-06-03 15:16:19 +02:00
|
|
|
"github.com/mainflux/mainflux/pkg/transformers/senml"
|
2021-01-26 12:23:15 +01:00
|
|
|
"github.com/mainflux/mainflux/pkg/uuid"
|
2018-08-06 17:06:55 +02:00
|
|
|
"github.com/mainflux/mainflux/readers"
|
|
|
|
"github.com/mainflux/mainflux/readers/api"
|
|
|
|
"github.com/mainflux/mainflux/readers/mocks"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2018-12-05 13:09:25 +01:00
|
|
|
svcName = "test-service"
|
2022-02-09 21:25:34 +01:00
|
|
|
thingToken = "1"
|
|
|
|
userToken = "token"
|
|
|
|
email = "user@example.com"
|
2018-12-05 13:09:25 +01:00
|
|
|
invalid = "invalid"
|
2021-01-26 12:23:15 +01:00
|
|
|
numOfMessages = 100
|
2019-11-05 11:57:16 +01:00
|
|
|
valueFields = 5
|
2021-01-26 12:23:15 +01:00
|
|
|
subtopic = "topic"
|
|
|
|
mqttProt = "mqtt"
|
|
|
|
httpProt = "http"
|
|
|
|
msgName = "temperature"
|
2023-07-07 12:14:55 +03:00
|
|
|
instanceID = "5de9b29a-feb9-11ed-be56-0242ac120002"
|
2019-11-05 11:57:16 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
v float64 = 5
|
|
|
|
vs = "value"
|
|
|
|
vb = true
|
|
|
|
vd = "dataValue"
|
|
|
|
sum float64 = 42
|
2019-11-05 11:57:16 +01:00
|
|
|
|
2023-10-16 12:43:33 +03:00
|
|
|
idProvider = uuid.New()
|
2021-01-26 12:23:15 +01:00
|
|
|
)
|
2018-08-06 17:06:55 +02:00
|
|
|
|
NOISSUE - Switch to Google Zanzibar Access control approach (#1919)
* Return Auth service
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Compose to run with SpiceDB and Auth svc
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update auth gRPC API
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove Users' policies
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Move Groups to internal
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use shared groups in Users
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove unused code
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use pkg Groups in Things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove Things groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Make imports consistent
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Groups networking
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove things groups-specific API
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Move Things Clients to the root
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Move Clients to Users root
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Temporarily remove tracing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix imports
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add buffer config for gRPC
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update auth type for Things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use Auth for login
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add temporary solution for refresh token
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Tokenizer interface
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Updade tokens issuing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix token issuing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update JWT validator and refactor Tokenizer
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Rename access timeout
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Rename login to authenticate
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Identify to use SubjectID
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add Auth to Groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use the Auth service for Groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update auth schema
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix Auth for Groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add auth for addons (#14)
Signed-off-by: Arvindh <arvindh91@gmail.com>
Speparate Login and Refresh tokens
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Merge authN and authZ requests for things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add connect and disconnect
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update sharing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix policies addition and removal
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update relation with roels
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add gRPC to Things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Assign and Unassign members to group and Listing of Group members (#15)
* add auth for addons
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add assign and unassign to group
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add group incomplete repo implementation
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Move coap mqtt and ws policies to spicedb (#16)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Remove old policies
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
NOISSUE - Things authorize to return thingID (#18)
This commit modifies the authorize endpoint to the grpc endpoint to return thingID. The authorize endpoint allows adapters to get the publisher of the message.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Add Groups to users service (#17)
* add assign and unassign to group
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add group incomplete repo implementation
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users stable 1
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users stable 2
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users & things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* Amend signature
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix merge error
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Fix es code (#21)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Fix Bugs (#20)
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Test e2e (#19)
* fix: connect method
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix: e2e
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix changes in sdk and e2e
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(docker): remove unnecessary port mapping
Remove the port mapping for MQTT broker in the docker-compose.yml file.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Enable group listing
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(responses): update ChannelsPage struct
The ChannelsPage struct in the responses.go file has been updated. The "Channels" field has been renamed to "Groups" to provide more accurate naming. This change ensures consistency and clarity in the codebase.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(things): add UpdateClientSecret method
Add the UpdateClientSecret method to the things service. This method allows updating the client secret for a specific client identified by the provided token, id, and key parameters.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Use smaller buffers for gRPC
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Clean up tests (#22)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add Connect Disconnect endpoints (#23)
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix list of things in a channel and Add connect disconnect endpoint
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix list of things in a channel and Add connect disconnect endpoint
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add: Things share with users (#25)
* fix list of things in a channel and Add connect disconnect endpoint
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: things share with other users
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Rename gRPC Services (#24)
* Rename things and users auth service
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* docs: add authorization docs for gRPC services
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Rename things and users grpc services
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Remove mainflux.env package
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add: Listing of things, channels, groups, users (#26)
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Clean Up Users (#27)
* feat(groups): rename redis package to events
- Renamed the `redis` package to `events` in the `internal/groups` directory.
- Updated the file paths and names accordingly.
- This change reflects the more accurate purpose of the package and improves code organization.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(auth): Modify identity method
Change request and response of identity method
Add accessToken and refreshToken to Token response
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* clean up users, remove dead code
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(users): add unit tests for user service
This commit adds unit tests for the user service in the `users` package. The tests cover various scenarios and ensure the correct behavior of the service.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add: List of user groups & removed repeating code in groups (#29)
* removed repeating code in list groups
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: list of user group
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix: otel handler operator name for endpoints
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Clean Up Things Service (#28)
* Rework things service
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* add tests
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Clean Up Auth Service (#30)
* clean up auth service
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(auth): remove unused import
Remove the unused import of `emptypb` in `auth.pb.go`. This import is not being used in the codebase and can be safely removed.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Update API docs (#31)
Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Remove TODO comments and cleanup the code
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Update dependenices
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Co-authored-by: b1ackd0t <28790446+rodneyosodo@users.noreply.github.com>
Co-authored-by: Arvindh <30824765+arvindh123@users.noreply.github.com>
2023-10-15 22:02:13 +02:00
|
|
|
func newServer(repo readers.MessageRepository) *httptest.Server {
|
|
|
|
auth := new(authmocks.Service)
|
|
|
|
|
|
|
|
mux := api.MakeHandler(repo, auth, svcName, instanceID)
|
2018-08-06 17:06:55 +02:00
|
|
|
return httptest.NewServer(mux)
|
|
|
|
}
|
|
|
|
|
|
|
|
type testRequest struct {
|
|
|
|
client *http.Client
|
|
|
|
method string
|
|
|
|
url string
|
|
|
|
token string
|
2022-03-06 01:49:34 +01:00
|
|
|
key string
|
2018-08-06 17:06:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (tr testRequest) make() (*http.Response, error) {
|
|
|
|
req, err := http.NewRequest(tr.method, tr.url, nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if tr.token != "" {
|
2022-03-06 01:49:34 +01:00
|
|
|
req.Header.Set("Authorization", apiutil.BearerPrefix+tr.token)
|
|
|
|
}
|
|
|
|
if tr.key != "" {
|
|
|
|
req.Header.Set("Authorization", apiutil.ThingPrefix+tr.key)
|
2018-08-06 17:06:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return tr.client.Do(req)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestReadAll(t *testing.T) {
|
2021-01-26 12:23:15 +01:00
|
|
|
chanID, err := idProvider.ID()
|
2023-04-12 08:30:01 -07:00
|
|
|
assert.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err))
|
2021-01-26 12:23:15 +01:00
|
|
|
pubID, err := idProvider.ID()
|
2023-04-12 08:30:01 -07:00
|
|
|
assert.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err))
|
2021-01-26 12:23:15 +01:00
|
|
|
pubID2, err := idProvider.ID()
|
2023-04-12 08:30:01 -07:00
|
|
|
assert.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err))
|
2021-01-26 12:23:15 +01:00
|
|
|
|
|
|
|
now := time.Now().Unix()
|
|
|
|
|
|
|
|
var messages []senml.Message
|
|
|
|
var queryMsgs []senml.Message
|
|
|
|
var valueMsgs []senml.Message
|
|
|
|
var boolMsgs []senml.Message
|
|
|
|
var stringMsgs []senml.Message
|
|
|
|
var dataMsgs []senml.Message
|
|
|
|
|
|
|
|
for i := 0; i < numOfMessages; i++ {
|
|
|
|
// Mix possible values as well as value sum.
|
|
|
|
msg := senml.Message{
|
|
|
|
Channel: chanID,
|
|
|
|
Publisher: pubID,
|
|
|
|
Protocol: mqttProt,
|
|
|
|
Time: float64(now - int64(i)),
|
|
|
|
Name: "name",
|
|
|
|
}
|
|
|
|
|
|
|
|
count := i % valueFields
|
|
|
|
switch count {
|
|
|
|
case 0:
|
|
|
|
msg.Value = &v
|
|
|
|
valueMsgs = append(valueMsgs, msg)
|
|
|
|
case 1:
|
|
|
|
msg.BoolValue = &vb
|
|
|
|
boolMsgs = append(boolMsgs, msg)
|
|
|
|
case 2:
|
|
|
|
msg.StringValue = &vs
|
|
|
|
stringMsgs = append(stringMsgs, msg)
|
|
|
|
case 3:
|
|
|
|
msg.DataValue = &vd
|
|
|
|
dataMsgs = append(dataMsgs, msg)
|
|
|
|
case 4:
|
|
|
|
msg.Sum = &sum
|
|
|
|
msg.Subtopic = subtopic
|
|
|
|
msg.Protocol = httpProt
|
|
|
|
msg.Publisher = pubID2
|
|
|
|
msg.Name = msgName
|
|
|
|
queryMsgs = append(queryMsgs, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
messages = append(messages, msg)
|
|
|
|
}
|
|
|
|
|
|
|
|
repo := mocks.NewMessageRepository(chanID, fromSenml(messages))
|
NOISSUE - Switch to Google Zanzibar Access control approach (#1919)
* Return Auth service
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Compose to run with SpiceDB and Auth svc
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update auth gRPC API
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove Users' policies
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Move Groups to internal
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use shared groups in Users
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove unused code
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use pkg Groups in Things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove Things groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Make imports consistent
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Groups networking
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Remove things groups-specific API
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Move Things Clients to the root
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Move Clients to Users root
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Temporarily remove tracing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix imports
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add buffer config for gRPC
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update auth type for Things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use Auth for login
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add temporary solution for refresh token
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Tokenizer interface
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Updade tokens issuing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix token issuing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update JWT validator and refactor Tokenizer
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Rename access timeout
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Rename login to authenticate
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update Identify to use SubjectID
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add Auth to Groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Use the Auth service for Groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update auth schema
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix Auth for Groups
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add auth for addons (#14)
Signed-off-by: Arvindh <arvindh91@gmail.com>
Speparate Login and Refresh tokens
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Merge authN and authZ requests for things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add connect and disconnect
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update sharing
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Fix policies addition and removal
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Update relation with roels
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Add gRPC to Things
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Assign and Unassign members to group and Listing of Group members (#15)
* add auth for addons
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add assign and unassign to group
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add group incomplete repo implementation
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Move coap mqtt and ws policies to spicedb (#16)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Remove old policies
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
NOISSUE - Things authorize to return thingID (#18)
This commit modifies the authorize endpoint to the grpc endpoint to return thingID. The authorize endpoint allows adapters to get the publisher of the message.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Add Groups to users service (#17)
* add assign and unassign to group
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add group incomplete repo implementation
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users stable 1
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users stable 2
Signed-off-by: Arvindh <arvindh91@gmail.com>
* groups for users & things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* Amend signature
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix merge error
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Fix es code (#21)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Fix Bugs (#20)
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Test e2e (#19)
* fix: connect method
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix: e2e
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* fix changes in sdk and e2e
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(docker): remove unnecessary port mapping
Remove the port mapping for MQTT broker in the docker-compose.yml file.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Enable group listing
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(responses): update ChannelsPage struct
The ChannelsPage struct in the responses.go file has been updated. The "Channels" field has been renamed to "Groups" to provide more accurate naming. This change ensures consistency and clarity in the codebase.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(things): add UpdateClientSecret method
Add the UpdateClientSecret method to the things service. This method allows updating the client secret for a specific client identified by the provided token, id, and key parameters.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Use smaller buffers for gRPC
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Clean up tests (#22)
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add Connect Disconnect endpoints (#23)
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix bugs
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix list of things in a channel and Add connect disconnect endpoint
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix list of things in a channel and Add connect disconnect endpoint
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add: Things share with users (#25)
* fix list of things in a channel and Add connect disconnect endpoint
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: things share with other users
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Rename gRPC Services (#24)
* Rename things and users auth service
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* docs: add authorization docs for gRPC services
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Rename things and users grpc services
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* Remove mainflux.env package
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add: Listing of things, channels, groups, users (#26)
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: listing of channels, users, groups, things
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Clean Up Users (#27)
* feat(groups): rename redis package to events
- Renamed the `redis` package to `events` in the `internal/groups` directory.
- Updated the file paths and names accordingly.
- This change reflects the more accurate purpose of the package and improves code organization.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(auth): Modify identity method
Change request and response of identity method
Add accessToken and refreshToken to Token response
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* clean up users, remove dead code
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(users): add unit tests for user service
This commit adds unit tests for the user service in the `users` package. The tests cover various scenarios and ensure the correct behavior of the service.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Add: List of user groups & removed repeating code in groups (#29)
* removed repeating code in list groups
Signed-off-by: Arvindh <arvindh91@gmail.com>
* add: list of user group
Signed-off-by: Arvindh <arvindh91@gmail.com>
* fix: otel handler operator name for endpoints
Signed-off-by: Arvindh <arvindh91@gmail.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Clean Up Things Service (#28)
* Rework things service
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* add tests
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Clean Up Auth Service (#30)
* clean up auth service
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
* feat(auth): remove unused import
Remove the unused import of `emptypb` in `auth.pb.go`. This import is not being used in the codebase and can be safely removed.
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
---------
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* NOISSUE - Update API docs (#31)
Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Remove TODO comments and cleanup the code
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
* Update dependenices
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
---------
Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Co-authored-by: b1ackd0t <28790446+rodneyosodo@users.noreply.github.com>
Co-authored-by: Arvindh <30824765+arvindh123@users.noreply.github.com>
2023-10-15 22:02:13 +02:00
|
|
|
ts := newServer(repo)
|
2018-08-06 17:06:55 +02:00
|
|
|
defer ts.Close()
|
|
|
|
|
2021-01-26 12:23:15 +01:00
|
|
|
cases := []struct {
|
|
|
|
desc string
|
|
|
|
req string
|
2018-08-06 17:06:55 +02:00
|
|
|
url string
|
|
|
|
token string
|
2022-03-06 01:49:34 +01:00
|
|
|
key string
|
2018-08-06 17:06:55 +02:00
|
|
|
status int
|
2021-01-26 12:23:15 +01:00
|
|
|
res pageRes
|
2018-08-06 17:06:55 +02:00
|
|
|
}{
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
|
|
|
desc: "read page with valid offset and limit",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages)),
|
|
|
|
Messages: messages[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with valid offset and limit as user",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages)),
|
|
|
|
Messages: messages[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with negative offset as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=-1&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with negative limit as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=-10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with zero limit as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=0", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with non-integer offset as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=abc&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with non-integer limit as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=abc", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with invalid channel id as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels//messages?offset=0&limit=10", ts.URL),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with invalid token as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: invalid,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusUnauthorized,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with multiple offset as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&offset=1&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with multiple limit as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=20&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with empty token as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID),
|
|
|
|
token: "",
|
|
|
|
status: http.StatusUnauthorized,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with default offset as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages)),
|
|
|
|
Messages: messages[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with default limit as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages)),
|
|
|
|
Messages: messages[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with senml format as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?format=messages", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages)),
|
|
|
|
Messages: messages[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with subtopic as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?subtopic=%s&protocol=%s", ts.URL, chanID, subtopic, httpProt),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with subtopic and protocol as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?subtopic=%s&protocol=%s", ts.URL, chanID, subtopic, httpProt),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with publisher as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?publisher=%s", ts.URL, chanID, pubID2),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with protocol as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?protocol=http", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with name as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?name=%s", ts.URL, chanID, msgName),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with value as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f", ts.URL, chanID, v),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with value and equal comparator as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v, readers.EqualKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with value and lower-than comparator as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v+1, readers.LowerThanKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with value and lower-than-or-equal comparator as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v+1, readers.LowerThanEqualKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with value and greater-than comparator as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v-1, readers.GreaterThanKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with value and greater-than-or-equal comparator as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v-1, readers.GreaterThanEqualKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with non-float value as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=ab01", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with value and wrong comparator as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=wrong", ts.URL, chanID, v-1),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with boolean value as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?vb=true", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(boolMsgs)),
|
|
|
|
Messages: boolMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with non-boolean value as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?vb=yes", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with string value as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?vs=%s", ts.URL, chanID, vs),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(stringMsgs)),
|
|
|
|
Messages: stringMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with data value as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?vd=%s", ts.URL, chanID, vd),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(dataMsgs)),
|
|
|
|
Messages: dataMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with non-float from as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?from=ABCD", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
desc: "read page with non-float to as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?to=ABCD", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with from/to as thing",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?from=%f&to=%f", ts.URL, chanID, messages[19].Time, messages[4].Time),
|
2022-03-06 01:49:34 +01:00
|
|
|
key: thingToken,
|
2022-02-09 21:25:34 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages[5:20])),
|
|
|
|
Messages: messages[5:15],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "read page with valid offset and limit as user",
|
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusOK,
|
2021-01-26 12:23:15 +01:00
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages)),
|
|
|
|
Messages: messages[0:10],
|
|
|
|
},
|
2018-08-06 17:06:55 +02:00
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with negative offset as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=-1&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with negative limit as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=-10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with zero limit as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=0", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with non-integer offset as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=abc&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with non-integer limit as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=abc", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with invalid channel id as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels//messages?offset=0&limit=10", ts.URL),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with invalid token as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: invalid,
|
2022-02-01 17:33:23 +01:00
|
|
|
status: http.StatusUnauthorized,
|
2018-08-06 17:06:55 +02:00
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with multiple offset as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&offset=1&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with multiple limit as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=20&limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with empty token as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0&limit=10", ts.URL, chanID),
|
2018-08-06 17:06:55 +02:00
|
|
|
token: "",
|
2022-02-01 17:33:23 +01:00
|
|
|
status: http.StatusUnauthorized,
|
2018-08-06 17:06:55 +02:00
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with default offset as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?limit=10", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusOK,
|
2021-01-26 12:23:15 +01:00
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages)),
|
|
|
|
Messages: messages[0:10],
|
|
|
|
},
|
2018-08-06 17:06:55 +02:00
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with default limit as user",
|
2018-12-05 13:09:25 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?offset=0", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2018-08-06 17:06:55 +02:00
|
|
|
status: http.StatusOK,
|
2021-01-26 12:23:15 +01:00
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages)),
|
|
|
|
Messages: messages[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with senml format as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?format=messages", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages)),
|
|
|
|
Messages: messages[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with subtopic as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?subtopic=%s&protocol=%s", ts.URL, chanID, subtopic, httpProt),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with subtopic and protocol as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?subtopic=%s&protocol=%s", ts.URL, chanID, subtopic, httpProt),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with publisher as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?publisher=%s", ts.URL, chanID, pubID2),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with protocol as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?protocol=http", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
2018-08-06 17:06:55 +02:00
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with name as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?name=%s", ts.URL, chanID, msgName),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(queryMsgs)),
|
|
|
|
Messages: queryMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with value as user",
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f", ts.URL, chanID, v),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
status: http.StatusOK,
|
2021-01-26 12:23:15 +01:00
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
2021-02-09 22:44:04 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with value and equal comparator as user",
|
2021-02-09 22:44:04 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v, readers.EqualKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-02-09 22:44:04 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with value and lower-than comparator as user",
|
2021-02-09 22:44:04 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v+1, readers.LowerThanKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-02-09 22:44:04 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with value and lower-than-or-equal comparator as user",
|
2021-02-09 22:44:04 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v+1, readers.LowerThanEqualKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-02-09 22:44:04 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with value and greater-than comparator as user",
|
2021-02-09 22:44:04 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v-1, readers.GreaterThanKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-02-09 22:44:04 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with value and greater-than-or-equal comparator as user",
|
2021-02-09 22:44:04 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=%s", ts.URL, chanID, v-1, readers.GreaterThanEqualKey),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-02-09 22:44:04 +01:00
|
|
|
status: http.StatusOK,
|
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(valueMsgs)),
|
|
|
|
Messages: valueMsgs[0:10],
|
|
|
|
},
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with non-float value as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=ab01", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusBadRequest,
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
},
|
2021-02-09 22:44:04 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with value and wrong comparator as user",
|
2021-02-09 22:44:04 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?v=%f&comparator=wrong", ts.URL, chanID, v-1),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-02-09 22:44:04 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with boolean value as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?vb=true", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
status: http.StatusOK,
|
2021-01-26 12:23:15 +01:00
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(boolMsgs)),
|
|
|
|
Messages: boolMsgs[0:10],
|
|
|
|
},
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with non-boolean value as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?vb=yes", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with string value as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?vs=%s", ts.URL, chanID, vs),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
status: http.StatusOK,
|
2021-01-26 12:23:15 +01:00
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(stringMsgs)),
|
|
|
|
Messages: stringMsgs[0:10],
|
|
|
|
},
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with data value as user",
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?vd=%s", ts.URL, chanID, vd),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
status: http.StatusOK,
|
2021-01-26 12:23:15 +01:00
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(dataMsgs)),
|
|
|
|
Messages: dataMsgs[0:10],
|
|
|
|
},
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with non-float from as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?from=ABCD", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusBadRequest,
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with non-float to as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?to=ABCD", ts.URL, chanID),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
2021-01-26 12:23:15 +01:00
|
|
|
status: http.StatusBadRequest,
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
},
|
2021-01-26 12:23:15 +01:00
|
|
|
{
|
2022-02-09 21:25:34 +01:00
|
|
|
desc: "read page with from/to as user",
|
2021-01-26 12:23:15 +01:00
|
|
|
url: fmt.Sprintf("%s/channels/%s/messages?from=%f&to=%f", ts.URL, chanID, messages[19].Time, messages[4].Time),
|
2022-03-06 01:49:34 +01:00
|
|
|
token: userToken,
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
status: http.StatusOK,
|
2021-01-26 12:23:15 +01:00
|
|
|
res: pageRes{
|
|
|
|
Total: uint64(len(messages[5:20])),
|
|
|
|
Messages: messages[5:15],
|
|
|
|
},
|
MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to (#1312)
* MF-1061 - Implement InfluxDB filters value, v, vb, vs, vd, from, to
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use time filters as float64 instead of int64
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix reviews
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove unnecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use a const for limit in tests
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Fix typo
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Revert float64 cast when dividing
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Remove value filter in favour to v
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Use v, vb, vs, vd
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
* Rm unecessary cast
Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-12-25 19:23:54 +01:00
|
|
|
},
|
2018-08-06 17:06:55 +02:00
|
|
|
}
|
|
|
|
|
2021-01-26 12:23:15 +01:00
|
|
|
for _, tc := range cases {
|
2018-08-06 17:06:55 +02:00
|
|
|
req := testRequest{
|
|
|
|
client: ts.Client(),
|
|
|
|
method: http.MethodGet,
|
|
|
|
url: tc.url,
|
|
|
|
token: tc.token,
|
2022-03-06 01:49:34 +01:00
|
|
|
key: tc.key,
|
2018-08-06 17:06:55 +02:00
|
|
|
}
|
|
|
|
res, err := req.make()
|
2021-01-26 12:23:15 +01:00
|
|
|
assert.Nil(t, err, fmt.Sprintf("%s: unexpected error %s", tc.desc, err))
|
|
|
|
|
|
|
|
var page pageRes
|
MF-1718 - Use static code analysis in CI (#1729)
* things, twins, and logger lint fixed
Signed-off-by: aryan <aryangodara03@gmail.com>
* all services updated, auth jwt not working, ineffectual assignment issue
Signed-off-by: aryan <aryangodara03@gmail.com>
* handle error from grpc server in endpointtest
Signed-off-by: aryan <aryangodara03@gmail.com>
* temp commit, auth/jwt needs to be resolved
Signed-off-by: aryan <aryangodara03@gmail.com>
* revert back to jwt v4 temporarily
Signed-off-by: aryan <aryangodara03@gmail.com>
* updated jwt tokenizer
Signed-off-by: aryan <aryangodara03@gmail.com>
* resolve EOF error for httptest requests
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix auth jwt, update to registeredclaims
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix ineffective assignment, auth/api/grpc endpoint failing
Signed-off-by: aryan <aryangodara03@gmail.com>
* temp commit, remove later
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix grpc server setup
Signed-off-by: aryan <aryangodara03@gmail.com>
* resolve golangci tests, remove debug statements
Signed-off-by: aryan <aryangodara03@gmail.com>
* update golangci version and modify linters used
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix failing tests
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix grpc server for setup tests
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix logging and errors inlined
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix remarks, update grpc setup_test
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix setup_test
Signed-off-by: aryan <aryangodara03@gmail.com>
* update setup_test grpc
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix data race
Signed-off-by: aryan <aryangodara03@gmail.com>
* update setup_test grpc
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix grpc setup down to single simple function
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix linting issues
Signed-off-by: aryan <aryangodara03@gmail.com>
* resolve pr comments
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix tests, handle returned errors, go mod tidy vendor
Signed-off-by: aryan <aryangodara03@gmail.com>
* fix errors from new linters
Signed-off-by: aryan <aryangodara03@gmail.com>
---------
Signed-off-by: aryan <aryangodara03@gmail.com>
2023-04-22 08:14:35 -07:00
|
|
|
err = json.NewDecoder(res.Body).Decode(&page)
|
|
|
|
assert.Nil(t, err, fmt.Sprintf("%s: unexpected error while decoding response body: %s", tc.desc, err))
|
|
|
|
|
2021-01-26 12:23:15 +01:00
|
|
|
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))
|
2023-04-12 08:30:01 -07:00
|
|
|
assert.ElementsMatch(t, tc.res.Messages, page.Messages, fmt.Sprintf("%s: got incorrect body from response", tc.desc))
|
2021-01-26 12:23:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type pageRes struct {
|
|
|
|
readers.PageMetadata
|
|
|
|
Total uint64 `json:"total"`
|
|
|
|
Messages []senml.Message `json:"messages,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func fromSenml(in []senml.Message) []readers.Message {
|
|
|
|
var ret []readers.Message
|
|
|
|
for _, m := range in {
|
|
|
|
ret = append(ret, m)
|
2018-08-06 17:06:55 +02:00
|
|
|
}
|
2021-01-26 12:23:15 +01:00
|
|
|
return ret
|
2018-08-06 17:06:55 +02:00
|
|
|
}
|