mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-24 13:48:49 +08:00
NOISSUE - Fix Linting (#1938)
* Fix linting Signed-off-by: rodneyosodo <blackd0t@protonmail.com> * Remove parentID when creating groups Signed-off-by: rodneyosodo <blackd0t@protonmail.com> --------- Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
This commit is contained in:
parent
fa00c82b98
commit
6da9a5da21
@ -405,7 +405,7 @@ func (svc service) authenticate(token string) (string, string, error) {
|
|||||||
return key.Issuer, key.Subject, nil
|
return key.Issuer, key.Subject, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch the relative permission for the relation
|
// Switch the relative permission for the relation.
|
||||||
func SwitchToPermission(relation string) string {
|
func SwitchToPermission(relation string) string {
|
||||||
switch relation {
|
switch relation {
|
||||||
case OwnerRelation:
|
case OwnerRelation:
|
||||||
|
@ -13,14 +13,12 @@ import (
|
|||||||
mfclients "github.com/mainflux/mainflux/pkg/clients"
|
mfclients "github.com/mainflux/mainflux/pkg/clients"
|
||||||
"github.com/mainflux/mainflux/pkg/errors"
|
"github.com/mainflux/mainflux/pkg/errors"
|
||||||
mfgroups "github.com/mainflux/mainflux/pkg/groups"
|
mfgroups "github.com/mainflux/mainflux/pkg/groups"
|
||||||
"github.com/mainflux/mainflux/pkg/uuid"
|
|
||||||
cpostgres "github.com/mainflux/mainflux/users/postgres"
|
cpostgres "github.com/mainflux/mainflux/users/postgres"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
idProvider = uuid.New()
|
|
||||||
password = "$tr0ngPassw0rd"
|
password = "$tr0ngPassw0rd"
|
||||||
clientIdentity = "client-identity@example.com"
|
clientIdentity = "client-identity@example.com"
|
||||||
clientName = "client name"
|
clientName = "client name"
|
||||||
@ -33,7 +31,7 @@ func TestClientsRetrieveByID(t *testing.T) {
|
|||||||
repo := cpostgres.NewRepository(database)
|
repo := cpostgres.NewRepository(database)
|
||||||
|
|
||||||
client := mfclients.Client{
|
client := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: clientName,
|
Name: clientName,
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: clientIdentity,
|
Identity: clientIdentity,
|
||||||
@ -71,7 +69,7 @@ func TestClientsRetrieveByIdentity(t *testing.T) {
|
|||||||
repo := cpostgres.NewRepository(database)
|
repo := cpostgres.NewRepository(database)
|
||||||
|
|
||||||
client := mfclients.Client{
|
client := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: clientName,
|
Name: clientName,
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: clientIdentity,
|
Identity: clientIdentity,
|
||||||
@ -103,7 +101,7 @@ func TestClientsRetrieveAll(t *testing.T) {
|
|||||||
grepo := gpostgres.New(database)
|
grepo := gpostgres.New(database)
|
||||||
|
|
||||||
nClients := uint64(200)
|
nClients := uint64(200)
|
||||||
ownerID := testsutil.GenerateUUID(t, idProvider)
|
ownerID := testsutil.GenerateUUID(t)
|
||||||
|
|
||||||
meta := mfclients.Metadata{
|
meta := mfclients.Metadata{
|
||||||
"admin": "true",
|
"admin": "true",
|
||||||
@ -114,7 +112,7 @@ func TestClientsRetrieveAll(t *testing.T) {
|
|||||||
expectedClients := []mfclients.Client{}
|
expectedClients := []mfclients.Client{}
|
||||||
|
|
||||||
sharedGroup := mfgroups.Group{
|
sharedGroup := mfgroups.Group{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "shared-group",
|
Name: "shared-group",
|
||||||
}
|
}
|
||||||
_, err := grepo.Save(context.Background(), sharedGroup)
|
_, err := grepo.Save(context.Background(), sharedGroup)
|
||||||
@ -123,7 +121,7 @@ func TestClientsRetrieveAll(t *testing.T) {
|
|||||||
for i := uint64(0); i < nClients; i++ {
|
for i := uint64(0); i < nClients; i++ {
|
||||||
identity := fmt.Sprintf("TestRetrieveAll%d@example.com", i)
|
identity := fmt.Sprintf("TestRetrieveAll%d@example.com", i)
|
||||||
client := mfclients.Client{
|
client := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: identity,
|
Name: identity,
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: identity,
|
Identity: identity,
|
||||||
@ -388,7 +386,7 @@ func TestClientsUpdateMetadata(t *testing.T) {
|
|||||||
repo := cpostgres.NewRepository(database)
|
repo := cpostgres.NewRepository(database)
|
||||||
|
|
||||||
client1 := mfclients.Client{
|
client1 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "enabled-client",
|
Name: "enabled-client",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client1-update@example.com",
|
Identity: "client1-update@example.com",
|
||||||
@ -402,7 +400,7 @@ func TestClientsUpdateMetadata(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
client2 := mfclients.Client{
|
client2 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "disabled-client",
|
Name: "disabled-client",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client2-update@example.com",
|
Identity: "client2-update@example.com",
|
||||||
@ -544,7 +542,7 @@ func TestClientsUpdateTags(t *testing.T) {
|
|||||||
repo := cpostgres.NewRepository(database)
|
repo := cpostgres.NewRepository(database)
|
||||||
|
|
||||||
client1 := mfclients.Client{
|
client1 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "enabled-client-with-tags",
|
Name: "enabled-client-with-tags",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client1-update-tags@example.com",
|
Identity: "client1-update-tags@example.com",
|
||||||
@ -554,7 +552,7 @@ func TestClientsUpdateTags(t *testing.T) {
|
|||||||
Status: mfclients.EnabledStatus,
|
Status: mfclients.EnabledStatus,
|
||||||
}
|
}
|
||||||
client2 := mfclients.Client{
|
client2 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "disabled-client-with-tags",
|
Name: "disabled-client-with-tags",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client2-update-tags@example.com",
|
Identity: "client2-update-tags@example.com",
|
||||||
@ -620,7 +618,7 @@ func TestClientsUpdateSecret(t *testing.T) {
|
|||||||
repo := cpostgres.NewRepository(database)
|
repo := cpostgres.NewRepository(database)
|
||||||
|
|
||||||
client1 := mfclients.Client{
|
client1 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "enabled-client",
|
Name: "enabled-client",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client1-update@example.com",
|
Identity: "client1-update@example.com",
|
||||||
@ -629,7 +627,7 @@ func TestClientsUpdateSecret(t *testing.T) {
|
|||||||
Status: mfclients.EnabledStatus,
|
Status: mfclients.EnabledStatus,
|
||||||
}
|
}
|
||||||
client2 := mfclients.Client{
|
client2 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "disabled-client",
|
Name: "disabled-client",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client2-update@example.com",
|
Identity: "client2-update@example.com",
|
||||||
@ -704,7 +702,7 @@ func TestClientsUpdateIdentity(t *testing.T) {
|
|||||||
repo := cpostgres.NewRepository(database)
|
repo := cpostgres.NewRepository(database)
|
||||||
|
|
||||||
client1 := mfclients.Client{
|
client1 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "enabled-client",
|
Name: "enabled-client",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client1-update@example.com",
|
Identity: "client1-update@example.com",
|
||||||
@ -713,7 +711,7 @@ func TestClientsUpdateIdentity(t *testing.T) {
|
|||||||
Status: mfclients.EnabledStatus,
|
Status: mfclients.EnabledStatus,
|
||||||
}
|
}
|
||||||
client2 := mfclients.Client{
|
client2 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "disabled-client",
|
Name: "disabled-client",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client2-update@example.com",
|
Identity: "client2-update@example.com",
|
||||||
@ -783,23 +781,23 @@ func TestClientsUpdateOwner(t *testing.T) {
|
|||||||
repo := cpostgres.NewRepository(database)
|
repo := cpostgres.NewRepository(database)
|
||||||
|
|
||||||
client1 := mfclients.Client{
|
client1 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "enabled-client-with-owner",
|
Name: "enabled-client-with-owner",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client1-update-owner@example.com",
|
Identity: "client1-update-owner@example.com",
|
||||||
Secret: password,
|
Secret: password,
|
||||||
},
|
},
|
||||||
Owner: testsutil.GenerateUUID(t, idProvider),
|
Owner: testsutil.GenerateUUID(t),
|
||||||
Status: mfclients.EnabledStatus,
|
Status: mfclients.EnabledStatus,
|
||||||
}
|
}
|
||||||
client2 := mfclients.Client{
|
client2 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "disabled-client-with-owner",
|
Name: "disabled-client-with-owner",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client2-update-owner@example.com",
|
Identity: "client2-update-owner@example.com",
|
||||||
Secret: password,
|
Secret: password,
|
||||||
},
|
},
|
||||||
Owner: testsutil.GenerateUUID(t, idProvider),
|
Owner: testsutil.GenerateUUID(t),
|
||||||
Status: mfclients.DisabledStatus,
|
Status: mfclients.DisabledStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,7 +822,7 @@ func TestClientsUpdateOwner(t *testing.T) {
|
|||||||
desc: "update owner for enabled client",
|
desc: "update owner for enabled client",
|
||||||
client: mfclients.Client{
|
client: mfclients.Client{
|
||||||
ID: client1.ID,
|
ID: client1.ID,
|
||||||
Owner: testsutil.GenerateUUID(t, idProvider),
|
Owner: testsutil.GenerateUUID(t),
|
||||||
},
|
},
|
||||||
err: nil,
|
err: nil,
|
||||||
},
|
},
|
||||||
@ -832,7 +830,7 @@ func TestClientsUpdateOwner(t *testing.T) {
|
|||||||
desc: "update owner for disabled client",
|
desc: "update owner for disabled client",
|
||||||
client: mfclients.Client{
|
client: mfclients.Client{
|
||||||
ID: client2.ID,
|
ID: client2.ID,
|
||||||
Owner: testsutil.GenerateUUID(t, idProvider),
|
Owner: testsutil.GenerateUUID(t),
|
||||||
},
|
},
|
||||||
err: errors.ErrNotFound,
|
err: errors.ErrNotFound,
|
||||||
},
|
},
|
||||||
@ -840,7 +838,7 @@ func TestClientsUpdateOwner(t *testing.T) {
|
|||||||
desc: "update owner for invalid client",
|
desc: "update owner for invalid client",
|
||||||
client: mfclients.Client{
|
client: mfclients.Client{
|
||||||
ID: wrongID,
|
ID: wrongID,
|
||||||
Owner: testsutil.GenerateUUID(t, idProvider),
|
Owner: testsutil.GenerateUUID(t),
|
||||||
},
|
},
|
||||||
err: errors.ErrNotFound,
|
err: errors.ErrNotFound,
|
||||||
},
|
},
|
||||||
@ -859,7 +857,7 @@ func TestClientsChangeStatus(t *testing.T) {
|
|||||||
repo := cpostgres.NewRepository(database)
|
repo := cpostgres.NewRepository(database)
|
||||||
|
|
||||||
client1 := mfclients.Client{
|
client1 := mfclients.Client{
|
||||||
ID: testsutil.GenerateUUID(t, idProvider),
|
ID: testsutil.GenerateUUID(t),
|
||||||
Name: "enabled-client",
|
Name: "enabled-client",
|
||||||
Credentials: mfclients.Credentials{
|
Credentials: mfclients.Credentials{
|
||||||
Identity: "client1-update@example.com",
|
Identity: "client1-update@example.com",
|
||||||
|
@ -90,7 +90,7 @@ func TestCreateChannel(t *testing.T) {
|
|||||||
desc: "create channel with parent",
|
desc: "create channel with parent",
|
||||||
channel: sdk.Channel{
|
channel: sdk.Channel{
|
||||||
Name: gName,
|
Name: gName,
|
||||||
ParentID: testsutil.GenerateUUID(t, idProvider),
|
ParentID: testsutil.GenerateUUID(t),
|
||||||
Status: mfclients.EnabledStatus.String(),
|
Status: mfclients.EnabledStatus.String(),
|
||||||
},
|
},
|
||||||
err: nil,
|
err: nil,
|
||||||
@ -596,7 +596,7 @@ func TestListChannelsByThing(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list channel with authorized token",
|
desc: "list channel with authorized token",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
clientID: testsutil.GenerateUUID(t, idProvider),
|
clientID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{},
|
page: sdk.PageMetadata{},
|
||||||
response: aChannels,
|
response: aChannels,
|
||||||
err: nil,
|
err: nil,
|
||||||
@ -604,7 +604,7 @@ func TestListChannelsByThing(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list channel with offset and limit",
|
desc: "list channel with offset and limit",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
clientID: testsutil.GenerateUUID(t, idProvider),
|
clientID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{
|
page: sdk.PageMetadata{
|
||||||
Offset: 6,
|
Offset: 6,
|
||||||
Total: nChannels,
|
Total: nChannels,
|
||||||
@ -617,7 +617,7 @@ func TestListChannelsByThing(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list channel with given name",
|
desc: "list channel with given name",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
clientID: testsutil.GenerateUUID(t, idProvider),
|
clientID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{
|
page: sdk.PageMetadata{
|
||||||
Name: gName,
|
Name: gName,
|
||||||
Offset: 6,
|
Offset: 6,
|
||||||
@ -631,7 +631,7 @@ func TestListChannelsByThing(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list channel with given level",
|
desc: "list channel with given level",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
clientID: testsutil.GenerateUUID(t, idProvider),
|
clientID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{
|
page: sdk.PageMetadata{
|
||||||
Level: 1,
|
Level: 1,
|
||||||
Offset: 6,
|
Offset: 6,
|
||||||
@ -645,7 +645,7 @@ func TestListChannelsByThing(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list channel with metadata",
|
desc: "list channel with metadata",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
clientID: testsutil.GenerateUUID(t, idProvider),
|
clientID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{
|
page: sdk.PageMetadata{
|
||||||
Metadata: validMetadata,
|
Metadata: validMetadata,
|
||||||
Offset: 6,
|
Offset: 6,
|
||||||
@ -659,7 +659,7 @@ func TestListChannelsByThing(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list channel with an invalid token",
|
desc: "list channel with an invalid token",
|
||||||
token: invalidToken,
|
token: invalidToken,
|
||||||
clientID: testsutil.GenerateUUID(t, idProvider),
|
clientID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{},
|
page: sdk.PageMetadata{},
|
||||||
response: []sdk.Channel(nil),
|
response: []sdk.Channel(nil),
|
||||||
err: errors.NewSDKErrorWithStatus(errors.Wrap(errors.ErrAuthorization, errors.ErrAuthentication), http.StatusUnauthorized),
|
err: errors.NewSDKErrorWithStatus(errors.Wrap(errors.ErrAuthorization, errors.ErrAuthentication), http.StatusUnauthorized),
|
||||||
|
@ -77,7 +77,7 @@ func TestCreateGroup(t *testing.T) {
|
|||||||
desc: "create group with parent",
|
desc: "create group with parent",
|
||||||
group: sdk.Group{
|
group: sdk.Group{
|
||||||
Name: gName,
|
Name: gName,
|
||||||
ParentID: testsutil.GenerateUUID(t, idProvider),
|
ParentID: testsutil.GenerateUUID(t),
|
||||||
Status: clients.EnabledStatus.String(),
|
Status: clients.EnabledStatus.String(),
|
||||||
},
|
},
|
||||||
err: nil,
|
err: nil,
|
||||||
|
@ -487,7 +487,7 @@ func TestListThingsByChannel(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list things with authorized token",
|
desc: "list things with authorized token",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
channelID: testsutil.GenerateUUID(t, idProvider),
|
channelID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{},
|
page: sdk.PageMetadata{},
|
||||||
response: aThings,
|
response: aThings,
|
||||||
err: nil,
|
err: nil,
|
||||||
@ -495,7 +495,7 @@ func TestListThingsByChannel(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list things with offset and limit",
|
desc: "list things with offset and limit",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
channelID: testsutil.GenerateUUID(t, idProvider),
|
channelID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{
|
page: sdk.PageMetadata{
|
||||||
Offset: 4,
|
Offset: 4,
|
||||||
Limit: nThing,
|
Limit: nThing,
|
||||||
@ -506,7 +506,7 @@ func TestListThingsByChannel(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list things with given name",
|
desc: "list things with given name",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
channelID: testsutil.GenerateUUID(t, idProvider),
|
channelID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{
|
page: sdk.PageMetadata{
|
||||||
Name: Identity,
|
Name: Identity,
|
||||||
Offset: 6,
|
Offset: 6,
|
||||||
@ -519,7 +519,7 @@ func TestListThingsByChannel(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list things with given ownerID",
|
desc: "list things with given ownerID",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
channelID: testsutil.GenerateUUID(t, idProvider),
|
channelID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{
|
page: sdk.PageMetadata{
|
||||||
OwnerID: user.Owner,
|
OwnerID: user.Owner,
|
||||||
Offset: 6,
|
Offset: 6,
|
||||||
@ -531,7 +531,7 @@ func TestListThingsByChannel(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list things with given subject",
|
desc: "list things with given subject",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
channelID: testsutil.GenerateUUID(t, idProvider),
|
channelID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{
|
page: sdk.PageMetadata{
|
||||||
Subject: subject,
|
Subject: subject,
|
||||||
Offset: 6,
|
Offset: 6,
|
||||||
@ -543,7 +543,7 @@ func TestListThingsByChannel(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list things with given object",
|
desc: "list things with given object",
|
||||||
token: adminToken,
|
token: adminToken,
|
||||||
channelID: testsutil.GenerateUUID(t, idProvider),
|
channelID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{
|
page: sdk.PageMetadata{
|
||||||
Object: object,
|
Object: object,
|
||||||
Offset: 6,
|
Offset: 6,
|
||||||
@ -555,7 +555,7 @@ func TestListThingsByChannel(t *testing.T) {
|
|||||||
{
|
{
|
||||||
desc: "list things with an invalid token",
|
desc: "list things with an invalid token",
|
||||||
token: invalidToken,
|
token: invalidToken,
|
||||||
channelID: testsutil.GenerateUUID(t, idProvider),
|
channelID: testsutil.GenerateUUID(t),
|
||||||
page: sdk.PageMetadata{},
|
page: sdk.PageMetadata{},
|
||||||
response: []sdk.Thing(nil),
|
response: []sdk.Thing(nil),
|
||||||
err: errors.NewSDKErrorWithStatus(errors.ErrAuthentication, http.StatusUnauthorized),
|
err: errors.NewSDKErrorWithStatus(errors.ErrAuthentication, http.StatusUnauthorized),
|
||||||
@ -955,11 +955,11 @@ func TestEnableThing(t *testing.T) {
|
|||||||
}
|
}
|
||||||
mfsdk := sdk.NewSDK(conf)
|
mfsdk := sdk.NewSDK(conf)
|
||||||
|
|
||||||
enabledThing1 := sdk.Thing{ID: testsutil.GenerateUUID(t, idProvider), Credentials: sdk.Credentials{Identity: "client1@example.com", Secret: generateUUID(t)}, Status: mfclients.EnabledStatus.String()}
|
enabledThing1 := sdk.Thing{ID: testsutil.GenerateUUID(t), Credentials: sdk.Credentials{Identity: "client1@example.com", Secret: generateUUID(t)}, Status: mfclients.EnabledStatus.String()}
|
||||||
disabledThing1 := sdk.Thing{ID: testsutil.GenerateUUID(t, idProvider), Credentials: sdk.Credentials{Identity: "client3@example.com", Secret: generateUUID(t)}, Status: mfclients.DisabledStatus.String()}
|
disabledThing1 := sdk.Thing{ID: testsutil.GenerateUUID(t), Credentials: sdk.Credentials{Identity: "client3@example.com", Secret: generateUUID(t)}, Status: mfclients.DisabledStatus.String()}
|
||||||
endisabledThing1 := disabledThing1
|
endisabledThing1 := disabledThing1
|
||||||
endisabledThing1.Status = mfclients.EnabledStatus.String()
|
endisabledThing1.Status = mfclients.EnabledStatus.String()
|
||||||
endisabledThing1.ID = testsutil.GenerateUUID(t, idProvider)
|
endisabledThing1.ID = testsutil.GenerateUUID(t)
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
desc string
|
desc string
|
||||||
@ -1076,11 +1076,11 @@ func TestDisableThing(t *testing.T) {
|
|||||||
}
|
}
|
||||||
mfsdk := sdk.NewSDK(conf)
|
mfsdk := sdk.NewSDK(conf)
|
||||||
|
|
||||||
enabledThing1 := sdk.Thing{ID: testsutil.GenerateUUID(t, idProvider), Credentials: sdk.Credentials{Identity: "client1@example.com", Secret: generateUUID(t)}, Status: mfclients.EnabledStatus.String()}
|
enabledThing1 := sdk.Thing{ID: testsutil.GenerateUUID(t), Credentials: sdk.Credentials{Identity: "client1@example.com", Secret: generateUUID(t)}, Status: mfclients.EnabledStatus.String()}
|
||||||
disabledThing1 := sdk.Thing{ID: testsutil.GenerateUUID(t, idProvider), Credentials: sdk.Credentials{Identity: "client3@example.com", Secret: generateUUID(t)}, Status: mfclients.DisabledStatus.String()}
|
disabledThing1 := sdk.Thing{ID: testsutil.GenerateUUID(t), Credentials: sdk.Credentials{Identity: "client3@example.com", Secret: generateUUID(t)}, Status: mfclients.DisabledStatus.String()}
|
||||||
disenabledThing1 := enabledThing1
|
disenabledThing1 := enabledThing1
|
||||||
disenabledThing1.Status = mfclients.DisabledStatus.String()
|
disenabledThing1.Status = mfclients.DisabledStatus.String()
|
||||||
disenabledThing1.ID = testsutil.GenerateUUID(t, idProvider)
|
disenabledThing1.ID = testsutil.GenerateUUID(t)
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
desc string
|
desc string
|
||||||
|
@ -917,11 +917,11 @@ func TestEnableClient(t *testing.T) {
|
|||||||
}
|
}
|
||||||
mfsdk := sdk.NewSDK(conf)
|
mfsdk := sdk.NewSDK(conf)
|
||||||
|
|
||||||
enabledClient1 := sdk.User{ID: testsutil.GenerateUUID(t, idProvider), Credentials: sdk.Credentials{Identity: "client1@example.com", Secret: "password"}, Status: mfclients.EnabledStatus.String()}
|
enabledClient1 := sdk.User{ID: testsutil.GenerateUUID(t), Credentials: sdk.Credentials{Identity: "client1@example.com", Secret: "password"}, Status: mfclients.EnabledStatus.String()}
|
||||||
disabledClient1 := sdk.User{ID: testsutil.GenerateUUID(t, idProvider), Credentials: sdk.Credentials{Identity: "client3@example.com", Secret: "password"}, Status: mfclients.DisabledStatus.String()}
|
disabledClient1 := sdk.User{ID: testsutil.GenerateUUID(t), Credentials: sdk.Credentials{Identity: "client3@example.com", Secret: "password"}, Status: mfclients.DisabledStatus.String()}
|
||||||
endisabledClient1 := disabledClient1
|
endisabledClient1 := disabledClient1
|
||||||
endisabledClient1.Status = mfclients.EnabledStatus.String()
|
endisabledClient1.Status = mfclients.EnabledStatus.String()
|
||||||
endisabledClient1.ID = testsutil.GenerateUUID(t, idProvider)
|
endisabledClient1.ID = testsutil.GenerateUUID(t)
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
desc string
|
desc string
|
||||||
@ -1042,11 +1042,11 @@ func TestDisableClient(t *testing.T) {
|
|||||||
}
|
}
|
||||||
mfsdk := sdk.NewSDK(conf)
|
mfsdk := sdk.NewSDK(conf)
|
||||||
|
|
||||||
enabledClient1 := sdk.User{ID: testsutil.GenerateUUID(t, idProvider), Credentials: sdk.Credentials{Identity: "client1@example.com", Secret: "password"}, Status: mfclients.EnabledStatus.String()}
|
enabledClient1 := sdk.User{ID: testsutil.GenerateUUID(t), Credentials: sdk.Credentials{Identity: "client1@example.com", Secret: "password"}, Status: mfclients.EnabledStatus.String()}
|
||||||
disabledClient1 := sdk.User{ID: testsutil.GenerateUUID(t, idProvider), Credentials: sdk.Credentials{Identity: "client3@example.com", Secret: "password"}, Status: mfclients.DisabledStatus.String()}
|
disabledClient1 := sdk.User{ID: testsutil.GenerateUUID(t), Credentials: sdk.Credentials{Identity: "client3@example.com", Secret: "password"}, Status: mfclients.DisabledStatus.String()}
|
||||||
disenabledClient1 := enabledClient1
|
disenabledClient1 := enabledClient1
|
||||||
disenabledClient1.Status = mfclients.DisabledStatus.String()
|
disenabledClient1.Status = mfclients.DisabledStatus.String()
|
||||||
disenabledClient1.ID = testsutil.GenerateUUID(t, idProvider)
|
disenabledClient1.ID = testsutil.GenerateUUID(t)
|
||||||
|
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
desc string
|
desc string
|
||||||
|
@ -186,12 +186,10 @@ func createGroups(s sdk.SDK, conf Config, token string) ([]sdk.Group, error) {
|
|||||||
var err error
|
var err error
|
||||||
groups := []sdk.Group{}
|
groups := []sdk.Group{}
|
||||||
|
|
||||||
parentID := ""
|
|
||||||
for i := uint64(0); i < conf.Num; i++ {
|
for i := uint64(0); i < conf.Num; i++ {
|
||||||
group := sdk.Group{
|
group := sdk.Group{
|
||||||
Name: fmt.Sprintf("%s-%s", conf.Prefix, namesgenerator.Generate()),
|
Name: fmt.Sprintf("%s-%s", conf.Prefix, namesgenerator.Generate()),
|
||||||
ParentID: parentID,
|
Status: sdk.EnabledStatus,
|
||||||
Status: sdk.EnabledStatus,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group, err = s.CreateGroup(group, token)
|
group, err = s.CreateGroup(group, token)
|
||||||
@ -199,7 +197,6 @@ func createGroups(s sdk.SDK, conf Config, token string) ([]sdk.Group, error) {
|
|||||||
return []sdk.Group{}, fmt.Errorf("failed to create the group: %w", err)
|
return []sdk.Group{}, fmt.Errorf("failed to create the group: %w", err)
|
||||||
}
|
}
|
||||||
groups = append(groups, group)
|
groups = append(groups, group)
|
||||||
parentID = group.ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups, nil
|
return groups, nil
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/mainflux/mainflux/internal/testsutil"
|
"github.com/mainflux/mainflux/internal/testsutil"
|
||||||
mfclients "github.com/mainflux/mainflux/pkg/clients"
|
mfclients "github.com/mainflux/mainflux/pkg/clients"
|
||||||
"github.com/mainflux/mainflux/pkg/errors"
|
"github.com/mainflux/mainflux/pkg/errors"
|
||||||
"github.com/mainflux/mainflux/pkg/uuid"
|
|
||||||
cpostgres "github.com/mainflux/mainflux/users/postgres"
|
cpostgres "github.com/mainflux/mainflux/users/postgres"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -23,7 +22,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
idProvider = uuid.New()
|
|
||||||
invalidName = strings.Repeat("m", maxNameSize+10)
|
invalidName = strings.Repeat("m", maxNameSize+10)
|
||||||
password = "$tr0ngPassw0rd"
|
password = "$tr0ngPassw0rd"
|
||||||
clientIdentity = "client-identity@example.com"
|
clientIdentity = "client-identity@example.com"
|
||||||
|
@ -476,6 +476,7 @@ func (svc service) updateOwnerPolicy(ctx context.Context, previousOwnerID, owner
|
|||||||
}
|
}
|
||||||
return svc.addOwnerPolicy(ctx, ownerID, userID)
|
return svc.addOwnerPolicy(ctx, ownerID, userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc service) addOwnerPolicy(ctx context.Context, ownerID, userID string) error {
|
func (svc service) addOwnerPolicy(ctx context.Context, ownerID, userID string) error {
|
||||||
if ownerID != "" {
|
if ownerID != "" {
|
||||||
if _, err := svc.auth.AddPolicy(ctx, &mainflux.AddPolicyReq{
|
if _, err := svc.auth.AddPolicy(ctx, &mainflux.AddPolicyReq{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user