mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 07:10:19 +00:00
MG-2071 - Rename viewer relation to contributor (#2237)
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
This commit is contained in:
@@ -626,7 +626,7 @@ components:
|
||||
]
|
||||
relation:
|
||||
type: string
|
||||
enum: ["administrator", "editor", "viewer", "member"]
|
||||
enum: ["administrator", "editor", "contributor", "member"]
|
||||
example: "administrator"
|
||||
description: Policy relations.
|
||||
required:
|
||||
|
||||
@@ -197,7 +197,7 @@ components:
|
||||
enum:
|
||||
- administrator
|
||||
- editor
|
||||
- viewer
|
||||
- contributor
|
||||
- member
|
||||
- domain
|
||||
- parent_group
|
||||
@@ -238,7 +238,7 @@ components:
|
||||
enum:
|
||||
- administrator
|
||||
- editor
|
||||
- viewer
|
||||
- contributor
|
||||
- member
|
||||
- domain
|
||||
- parent_group
|
||||
@@ -406,7 +406,7 @@ components:
|
||||
enum:
|
||||
- administrator
|
||||
- editor
|
||||
- viewer
|
||||
- contributor
|
||||
- member
|
||||
- domain
|
||||
- parent_group
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ const (
|
||||
const (
|
||||
AdministratorRelation = "administrator"
|
||||
EditorRelation = "editor"
|
||||
ViewerRelation = "viewer"
|
||||
ContributorRelation = "contributor"
|
||||
MemberRelation = "member"
|
||||
DomainRelation = "domain"
|
||||
ParentGroupRelation = "parent_group"
|
||||
@@ -86,11 +86,11 @@ type PolicyReq struct {
|
||||
// platform, group, domain, thing, users.
|
||||
ObjectType string `json:"object_type"`
|
||||
|
||||
// Relation contains the relation. Supported relations are administrator, editor, viewer, member,parent_group,group,domain.
|
||||
// Relation contains the relation. Supported relations are administrator, editor, contributor, member,parent_group,group,domain.
|
||||
Relation string `json:"relation,omitempty"`
|
||||
|
||||
// Permission contains the permission. Supported permissions are admin, delete, edit, share, view, membership,
|
||||
// admin_only, edit_only, viewer_only, membership_only, ext_admin, ext_edit, ext_view
|
||||
// admin_only, edit_only, viewer_only, membership_only, ext_admin, ext_edit, ext_view.
|
||||
Permission string `json:"permission,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -571,7 +571,7 @@ func SwitchToPermission(relation string) string {
|
||||
return AdminPermission
|
||||
case EditorRelation:
|
||||
return EditPermission
|
||||
case ViewerRelation:
|
||||
case ContributorRelation:
|
||||
return ViewPermission
|
||||
case MemberRelation:
|
||||
return MembershipPermission
|
||||
@@ -824,7 +824,7 @@ func (svc service) UnassignUsers(ctx context.Context, token, id string, userIds
|
||||
userIds = ids
|
||||
}
|
||||
|
||||
for _, rel := range []string{MemberRelation, ViewerRelation, EditorRelation} {
|
||||
for _, rel := range []string{MemberRelation, ContributorRelation, EditorRelation} {
|
||||
// Remove only non-admins.
|
||||
if err := svc.removeDomainPolicies(ctx, id, rel, userIds...); err != nil {
|
||||
return err
|
||||
|
||||
+18
-18
@@ -1423,7 +1423,7 @@ func TestListObjects(t *testing.T) {
|
||||
pr: auth.PolicyReq{
|
||||
Subject: id,
|
||||
SubjectType: auth.UserType,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ObjectType: auth.ThingType,
|
||||
ObjectKind: auth.ThingsKind,
|
||||
Object: "",
|
||||
@@ -1437,7 +1437,7 @@ func TestListObjects(t *testing.T) {
|
||||
pr: auth.PolicyReq{
|
||||
Subject: inValid,
|
||||
SubjectType: inValid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ObjectType: auth.ThingType,
|
||||
ObjectKind: auth.ThingsKind,
|
||||
Object: inValid,
|
||||
@@ -1476,7 +1476,7 @@ func TestListAllObjects(t *testing.T) {
|
||||
pr: auth.PolicyReq{
|
||||
Subject: id,
|
||||
SubjectType: auth.UserType,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ObjectType: auth.ThingType,
|
||||
ObjectKind: auth.ThingsKind,
|
||||
Object: "",
|
||||
@@ -1490,7 +1490,7 @@ func TestListAllObjects(t *testing.T) {
|
||||
pr: auth.PolicyReq{
|
||||
Subject: inValid,
|
||||
SubjectType: inValid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ObjectType: auth.ThingType,
|
||||
ObjectKind: auth.ThingsKind,
|
||||
Object: inValid,
|
||||
@@ -1541,7 +1541,7 @@ func TestListSubjects(t *testing.T) {
|
||||
pr: auth.PolicyReq{
|
||||
Subject: id,
|
||||
SubjectType: auth.UserType,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ObjectType: auth.ThingType,
|
||||
ObjectKind: auth.ThingsKind,
|
||||
Object: "",
|
||||
@@ -1555,7 +1555,7 @@ func TestListSubjects(t *testing.T) {
|
||||
pr: auth.PolicyReq{
|
||||
Subject: inValid,
|
||||
SubjectType: inValid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ObjectType: auth.ThingType,
|
||||
ObjectKind: auth.ThingsKind,
|
||||
Object: inValid,
|
||||
@@ -1594,7 +1594,7 @@ func TestListAllSubjects(t *testing.T) {
|
||||
pr: auth.PolicyReq{
|
||||
Subject: id,
|
||||
SubjectType: auth.UserType,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ObjectType: auth.ThingType,
|
||||
ObjectKind: auth.ThingsKind,
|
||||
Object: "",
|
||||
@@ -1608,7 +1608,7 @@ func TestListAllSubjects(t *testing.T) {
|
||||
pr: auth.PolicyReq{
|
||||
Subject: inValid,
|
||||
SubjectType: inValid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ObjectType: auth.ThingType,
|
||||
ObjectKind: auth.ThingsKind,
|
||||
Object: inValid,
|
||||
@@ -1646,7 +1646,7 @@ func TestListPermissions(t *testing.T) {
|
||||
pr := auth.PolicyReq{
|
||||
Subject: id,
|
||||
SubjectType: auth.UserType,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ObjectType: auth.ThingType,
|
||||
ObjectKind: auth.ThingsKind,
|
||||
Object: "",
|
||||
@@ -1676,8 +1676,8 @@ func TestSwitchToPermission(t *testing.T) {
|
||||
result: auth.EditPermission,
|
||||
},
|
||||
{
|
||||
desc: "switch to viewer permission",
|
||||
relation: auth.ViewerRelation,
|
||||
desc: "switch to contributor permission",
|
||||
relation: auth.ContributorRelation,
|
||||
result: auth.ViewPermission,
|
||||
},
|
||||
{
|
||||
@@ -2190,7 +2190,7 @@ func TestAssignUsers(t *testing.T) {
|
||||
token: accessToken,
|
||||
domainID: validID,
|
||||
userIDs: []string{validID},
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
checkPolicyReq3: auth.PolicyReq{
|
||||
Domain: groupName,
|
||||
Subject: "testID",
|
||||
@@ -2231,7 +2231,7 @@ func TestAssignUsers(t *testing.T) {
|
||||
token: inValidToken,
|
||||
domainID: validID,
|
||||
userIDs: []string{validID},
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
checkPolicyReq3: auth.PolicyReq{
|
||||
Domain: groupName,
|
||||
Subject: "testID",
|
||||
@@ -2263,7 +2263,7 @@ func TestAssignUsers(t *testing.T) {
|
||||
desc: "assign users with invalid domainID",
|
||||
token: accessToken,
|
||||
domainID: inValid,
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
checkPolicyReq3: auth.PolicyReq{
|
||||
Domain: groupName,
|
||||
Subject: "testID",
|
||||
@@ -2297,7 +2297,7 @@ func TestAssignUsers(t *testing.T) {
|
||||
token: accessToken,
|
||||
userIDs: []string{inValid},
|
||||
domainID: validID,
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
checkPolicyReq3: auth.PolicyReq{
|
||||
Domain: groupName,
|
||||
Subject: "testID",
|
||||
@@ -2338,7 +2338,7 @@ func TestAssignUsers(t *testing.T) {
|
||||
token: accessToken,
|
||||
domainID: validID,
|
||||
userIDs: []string{validID},
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
checkPolicyReq3: auth.PolicyReq{
|
||||
Domain: groupName,
|
||||
Subject: "testID",
|
||||
@@ -2379,7 +2379,7 @@ func TestAssignUsers(t *testing.T) {
|
||||
token: accessToken,
|
||||
domainID: validID,
|
||||
userIDs: []string{validID},
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
checkPolicyReq3: auth.PolicyReq{
|
||||
Domain: groupName,
|
||||
Subject: "testID",
|
||||
@@ -2420,7 +2420,7 @@ func TestAssignUsers(t *testing.T) {
|
||||
token: accessToken,
|
||||
domainID: validID,
|
||||
userIDs: []string{validID},
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
checkPolicyReq3: auth.PolicyReq{
|
||||
Domain: groupName,
|
||||
Subject: "testID",
|
||||
|
||||
@@ -25,7 +25,7 @@ definition thing {
|
||||
definition group {
|
||||
relation administrator: user
|
||||
relation editor: user
|
||||
relation viewer: user
|
||||
relation contributor: user
|
||||
relation member: user
|
||||
|
||||
relation parent_group: group
|
||||
@@ -35,7 +35,7 @@ definition group {
|
||||
permission delete = admin
|
||||
permission edit = admin + editor + parent_group->edit + domain->edit
|
||||
permission share = edit
|
||||
permission view = viewer + edit + parent_group->view + domain->view
|
||||
permission view = contributor + edit + parent_group->view + domain->view
|
||||
permission membership = view + member
|
||||
|
||||
// These permissions are made for listing purposes. They enable listing users who have only particular permission excluding higher-level permissions users.
|
||||
@@ -47,13 +47,13 @@ definition group {
|
||||
// These permission are made for only list purpose. They enable listing users who have only particular permission from parent group excluding higher-level permissions.
|
||||
permission ext_admin = admin - administrator // For list of external admin , not having direct relation with group, but have indirect relation from parent group
|
||||
permission ext_edit = edit - editor // For list of external edit , not having direct relation with group, but have indirect relation from parent group
|
||||
permission ext_view = view - viewer // For list of external view , not having direct relation with group, but have indirect relation from parent group
|
||||
permission ext_view = view - contributor // For list of external view , not having direct relation with group, but have indirect relation from parent group
|
||||
}
|
||||
|
||||
definition domain {
|
||||
relation administrator: user // combination domain + user id
|
||||
relation editor: user
|
||||
relation viewer: user
|
||||
relation contributor: user
|
||||
relation member: user
|
||||
|
||||
relation platform: platform
|
||||
@@ -61,7 +61,7 @@ definition domain {
|
||||
permission admin = administrator + platform->admin
|
||||
permission edit = admin + editor
|
||||
permission share = edit
|
||||
permission view = edit + viewer
|
||||
permission view = edit + contributor
|
||||
permission membership = view + member
|
||||
}
|
||||
|
||||
|
||||
@@ -805,7 +805,7 @@ func TestAssignMembersEndpoint(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
desc: "successfully",
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
req: assignReq{
|
||||
token: valid,
|
||||
@@ -822,7 +822,7 @@ func TestAssignMembersEndpoint(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "successfully with empty member kind",
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
req: assignReq{
|
||||
token: valid,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
@@ -854,7 +854,7 @@ func TestAssignMembersEndpoint(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "unsuccessfully with invalid request",
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
req: assignReq{},
|
||||
resp: assignRes{},
|
||||
@@ -862,7 +862,7 @@ func TestAssignMembersEndpoint(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "unsuccessfully with repo error",
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
req: assignReq{
|
||||
token: valid,
|
||||
@@ -916,7 +916,7 @@ func TestUnassignMembersEndpoint(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
desc: "successfully",
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
req: unassignReq{
|
||||
token: valid,
|
||||
@@ -933,7 +933,7 @@ func TestUnassignMembersEndpoint(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "successfully with empty member kind",
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
req: unassignReq{
|
||||
token: valid,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
@@ -965,7 +965,7 @@ func TestUnassignMembersEndpoint(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "unsuccessfully with invalid request",
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
req: unassignReq{},
|
||||
resp: unassignRes{},
|
||||
@@ -973,7 +973,7 @@ func TestUnassignMembersEndpoint(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "unsuccessfully with repo error",
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
req: unassignReq{
|
||||
token: valid,
|
||||
|
||||
@@ -345,7 +345,7 @@ func TestAssignReqValidation(t *testing.T) {
|
||||
req: assignReq{
|
||||
token: valid,
|
||||
groupID: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
MemberKind: auth.ThingsKind,
|
||||
Members: []string{valid},
|
||||
},
|
||||
@@ -355,7 +355,7 @@ func TestAssignReqValidation(t *testing.T) {
|
||||
desc: "empty token",
|
||||
req: assignReq{
|
||||
groupID: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
MemberKind: auth.ThingsKind,
|
||||
Members: []string{valid},
|
||||
},
|
||||
@@ -366,7 +366,7 @@ func TestAssignReqValidation(t *testing.T) {
|
||||
req: assignReq{
|
||||
token: valid,
|
||||
groupID: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
Members: []string{valid},
|
||||
},
|
||||
err: apiutil.ErrMissingMemberKind,
|
||||
@@ -375,7 +375,7 @@ func TestAssignReqValidation(t *testing.T) {
|
||||
desc: "empty groupID",
|
||||
req: assignReq{
|
||||
token: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
MemberKind: auth.ThingsKind,
|
||||
Members: []string{valid},
|
||||
},
|
||||
@@ -386,7 +386,7 @@ func TestAssignReqValidation(t *testing.T) {
|
||||
req: assignReq{
|
||||
token: valid,
|
||||
groupID: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
MemberKind: auth.ThingsKind,
|
||||
},
|
||||
err: apiutil.ErrEmptyList,
|
||||
@@ -410,7 +410,7 @@ func TestUnAssignReqValidation(t *testing.T) {
|
||||
req: unassignReq{
|
||||
token: valid,
|
||||
groupID: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
MemberKind: auth.ThingsKind,
|
||||
Members: []string{valid},
|
||||
},
|
||||
@@ -420,7 +420,7 @@ func TestUnAssignReqValidation(t *testing.T) {
|
||||
desc: "empty token",
|
||||
req: unassignReq{
|
||||
groupID: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
MemberKind: auth.ThingsKind,
|
||||
Members: []string{valid},
|
||||
},
|
||||
@@ -431,7 +431,7 @@ func TestUnAssignReqValidation(t *testing.T) {
|
||||
req: unassignReq{
|
||||
token: valid,
|
||||
groupID: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
Members: []string{valid},
|
||||
},
|
||||
err: apiutil.ErrMissingMemberKind,
|
||||
@@ -440,7 +440,7 @@ func TestUnAssignReqValidation(t *testing.T) {
|
||||
desc: "empty groupID",
|
||||
req: unassignReq{
|
||||
token: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
MemberKind: auth.ThingsKind,
|
||||
Members: []string{valid},
|
||||
},
|
||||
@@ -451,7 +451,7 @@ func TestUnAssignReqValidation(t *testing.T) {
|
||||
req: unassignReq{
|
||||
token: valid,
|
||||
groupID: valid,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
MemberKind: auth.ThingsKind,
|
||||
},
|
||||
err: apiutil.ErrEmptyList,
|
||||
|
||||
@@ -1675,7 +1675,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "successfully with things kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1693,7 +1693,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "successfully with channels kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ChannelsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1711,7 +1711,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "successfully with groups kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1737,7 +1737,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "successfully with users kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.UsersKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1755,7 +1755,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to repo err",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1773,7 +1773,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to empty page",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1792,7 +1792,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to non empty parent",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1816,7 +1816,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to failed to add policies",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1843,7 +1843,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to failed to assign parent",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1870,7 +1870,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to failed to assign parent and delete policy",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1901,7 +1901,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with invalid kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: "invalid",
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1917,7 +1917,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with invalid token",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.UsersKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{},
|
||||
@@ -1928,7 +1928,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with failed to authorize",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -1945,7 +1945,7 @@ func TestAssign(t *testing.T) {
|
||||
desc: "unsuccessfully with failed to add policies",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2084,7 +2084,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "successfully with things kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2102,7 +2102,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "successfully with channels kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ChannelsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2120,7 +2120,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "successfully with groups kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2146,7 +2146,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "successfully with users kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.UsersKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2164,7 +2164,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to repo err",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2182,7 +2182,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to empty page",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2201,7 +2201,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to non empty parent",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2225,7 +2225,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to failed to add policies",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2252,7 +2252,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to failed to unassign parent",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2279,7 +2279,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with groups kind due to failed to unassign parent and add policy",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.GroupsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2310,7 +2310,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with invalid kind",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: "invalid",
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2326,7 +2326,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with invalid token",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.UsersKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{},
|
||||
@@ -2337,7 +2337,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with failed to authorize",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
@@ -2354,7 +2354,7 @@ func TestUnassign(t *testing.T) {
|
||||
desc: "unsuccessfully with failed to add policies",
|
||||
token: token,
|
||||
groupID: testsutil.GenerateUUID(t),
|
||||
relation: auth.ViewerRelation,
|
||||
relation: auth.ContributorRelation,
|
||||
memberKind: auth.ThingsKind,
|
||||
memberIDs: allowedIDs,
|
||||
idResp: &magistrala.IdentityRes{
|
||||
|
||||
@@ -124,7 +124,7 @@ func CheckRelation(relation string) error {
|
||||
}
|
||||
if relation != auth.AdministratorRelation &&
|
||||
relation != auth.EditorRelation &&
|
||||
relation != auth.ViewerRelation &&
|
||||
relation != auth.ContributorRelation &&
|
||||
relation != auth.MemberRelation &&
|
||||
relation != auth.DomainRelation &&
|
||||
relation != auth.ParentGroupRelation &&
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestCheckRelation(t *testing.T) {
|
||||
{"", apiutil.ErrMissingRelation},
|
||||
{"admin", apiutil.ErrInvalidRelation},
|
||||
{"editor", nil},
|
||||
{"viewer", nil},
|
||||
{"contributor", nil},
|
||||
{"member", nil},
|
||||
{"domain", nil},
|
||||
{"parent_group", nil},
|
||||
|
||||
@@ -26,7 +26,7 @@ var (
|
||||
validInvitation = invitations.Invitation{
|
||||
UserID: testsutil.GenerateUUID(&testing.T{}),
|
||||
DomainID: testsutil.GenerateUUID(&testing.T{}),
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
}
|
||||
validToken = "token"
|
||||
)
|
||||
@@ -155,7 +155,7 @@ func TestSendInvitation(t *testing.T) {
|
||||
req: invitations.Invitation{
|
||||
UserID: testsutil.GenerateUUID(t),
|
||||
DomainID: testsutil.GenerateUUID(t),
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
Resend: true,
|
||||
},
|
||||
err: nil,
|
||||
@@ -227,7 +227,7 @@ func TestViewInvitation(t *testing.T) {
|
||||
InvitedBy: testsutil.GenerateUUID(t),
|
||||
UserID: testsutil.GenerateUUID(t),
|
||||
DomainID: testsutil.GenerateUUID(t),
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
CreatedAt: time.Now().Add(-time.Hour),
|
||||
UpdatedAt: time.Now().Add(-time.Hour),
|
||||
ConfirmedAt: time.Now().Add(-time.Hour),
|
||||
@@ -413,7 +413,7 @@ func TestListInvitations(t *testing.T) {
|
||||
InvitedBy: testsutil.GenerateUUID(t),
|
||||
UserID: testsutil.GenerateUUID(t),
|
||||
DomainID: testsutil.GenerateUUID(t),
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
CreatedAt: time.Now().Add(-time.Hour),
|
||||
UpdatedAt: time.Now().Add(-time.Hour),
|
||||
ConfirmedAt: time.Now().Add(-time.Hour),
|
||||
@@ -613,7 +613,7 @@ func TestAcceptInvitation(t *testing.T) {
|
||||
UserID: userID,
|
||||
DomainID: testsutil.GenerateUUID(t),
|
||||
Token: validToken,
|
||||
Relation: auth.ViewerRelation,
|
||||
Relation: auth.ContributorRelation,
|
||||
ConfirmedAt: time.Now().Add(-time.Second * time.Duration(rand.Intn(100))),
|
||||
},
|
||||
err: nil,
|
||||
|
||||
+16
-16
@@ -280,7 +280,7 @@ type SDK interface {
|
||||
// pm := sdk.PageMetadata{
|
||||
// Offset: 0,
|
||||
// Limit: 10,
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "contributor"
|
||||
// }
|
||||
// channels, _ := sdk.ListUserChannels("user_id_1", pm, "token")
|
||||
// fmt.Println(channels)
|
||||
@@ -292,7 +292,7 @@ type SDK interface {
|
||||
// pm := sdk.PageMetadata{
|
||||
// Offset: 0,
|
||||
// Limit: 10,
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "contributor"
|
||||
// }
|
||||
// groups, _ := sdk.ListUserGroups("user_id_1", pm, "token")
|
||||
// fmt.Println(channels)
|
||||
@@ -304,7 +304,7 @@ type SDK interface {
|
||||
// pm := sdk.PageMetadata{
|
||||
// Offset: 0,
|
||||
// Limit: 10,
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "contributor"
|
||||
// }
|
||||
// things, _ := sdk.ListUserThings("user_id_1", pm, "token")
|
||||
// fmt.Println(things)
|
||||
@@ -439,7 +439,7 @@ type SDK interface {
|
||||
//
|
||||
// example:
|
||||
// req := sdk.UsersRelationRequest{
|
||||
// Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
|
||||
// Relation: "contributor", // available options: "owner", "admin", "editor", "contributor"
|
||||
// UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
|
||||
// }
|
||||
// err := sdk.ShareThing("thing_id", req, "token")
|
||||
@@ -450,7 +450,7 @@ type SDK interface {
|
||||
//
|
||||
// example:
|
||||
// req := sdk.UsersRelationRequest{
|
||||
// Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
|
||||
// Relation: "contributor", // available options: "owner", "admin", "editor", "contributor"
|
||||
// UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
|
||||
// }
|
||||
// err := sdk.UnshareThing("thing_id", req, "token")
|
||||
@@ -463,7 +463,7 @@ type SDK interface {
|
||||
// pm := sdk.PageMetadata{
|
||||
// Offset: 0,
|
||||
// Limit: 10,
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "contributor"
|
||||
// }
|
||||
// users, _ := sdk.ListThingUsers("thing_id", pm, "token")
|
||||
// fmt.Println(users)
|
||||
@@ -571,7 +571,7 @@ type SDK interface {
|
||||
//
|
||||
// example:
|
||||
// req := sdk.UsersRelationRequest{
|
||||
// Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
|
||||
// Relation: "contributor", // available options: "owner", "admin", "editor", "contributor"
|
||||
// UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
|
||||
// }
|
||||
// err := sdk.AddUserToGroup("groupID",req, "token")
|
||||
@@ -582,7 +582,7 @@ type SDK interface {
|
||||
//
|
||||
// example:
|
||||
// req := sdk.UsersRelationRequest{
|
||||
// Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
|
||||
// Relation: "contributor", // available options: "owner", "admin", "editor", "contributor"
|
||||
// UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
|
||||
// }
|
||||
// err := sdk.RemoveUserFromGroup("groupID",req, "token")
|
||||
@@ -595,7 +595,7 @@ type SDK interface {
|
||||
// pm := sdk.PageMetadata{
|
||||
// Offset: 0,
|
||||
// Limit: 10,
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "contributor"
|
||||
// }
|
||||
// groups, _ := sdk.ListGroupUsers("groupID", pm, "token")
|
||||
// fmt.Println(groups)
|
||||
@@ -607,7 +607,7 @@ type SDK interface {
|
||||
// pm := sdk.PageMetadata{
|
||||
// Offset: 0,
|
||||
// Limit: 10,
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "contributor"
|
||||
// }
|
||||
// groups, _ := sdk.ListGroupChannels("groupID", pm, "token")
|
||||
// fmt.Println(groups)
|
||||
@@ -703,7 +703,7 @@ type SDK interface {
|
||||
//
|
||||
// example:
|
||||
// req := sdk.UsersRelationRequest{
|
||||
// Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
|
||||
// Relation: "contributor", // available options: "owner", "admin", "editor", "contributor"
|
||||
// UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
|
||||
// }
|
||||
// err := sdk.AddUserToChannel("channel_id", req, "token")
|
||||
@@ -714,7 +714,7 @@ type SDK interface {
|
||||
//
|
||||
// example:
|
||||
// req := sdk.UsersRelationRequest{
|
||||
// Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
|
||||
// Relation: "contributor", // available options: "owner", "admin", "editor", "contributor"
|
||||
// UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
|
||||
// }
|
||||
// err := sdk.RemoveUserFromChannel("channel_id", req, "token")
|
||||
@@ -727,7 +727,7 @@ type SDK interface {
|
||||
// pm := sdk.PageMetadata{
|
||||
// Offset: 0,
|
||||
// Limit: 10,
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "viewer"
|
||||
// Permission: "edit", // available Options: "administrator", "delete", edit", "view", "share", "owner", "admin", "editor", "contributor"
|
||||
// }
|
||||
// users, _ := sdk.ListChannelUsers("channel_id", pm, "token")
|
||||
// fmt.Println(users)
|
||||
@@ -1096,7 +1096,7 @@ type SDK interface {
|
||||
//
|
||||
// example:
|
||||
// req := sdk.UsersRelationRequest{
|
||||
// Relation: "viewer", // available options: "owner", "admin", "editor", "viewer", "member"
|
||||
// Relation: "contributor", // available options: "owner", "admin", "editor", "contributor", "member"
|
||||
// UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
|
||||
// }
|
||||
// err := sdk.AddUserToDomain("domainID", req, "token")
|
||||
@@ -1107,7 +1107,7 @@ type SDK interface {
|
||||
//
|
||||
// example:
|
||||
// req := sdk.UsersRelationRequest{
|
||||
// Relation: "viewer", // available options: "owner", "admin", "editor", "viewer" , "member"
|
||||
// Relation: "contributor", // available options: "owner", "admin", "editor", "contributor" , "member"
|
||||
// UserIDs: ["user_id_1", "user_id_2", "user_id_3"]
|
||||
// }
|
||||
// err := sdk.RemoveUserFromDomain("domainID", req, "token")
|
||||
@@ -1120,7 +1120,7 @@ type SDK interface {
|
||||
// invitation := sdk.Invitation{
|
||||
// DomainID: "domainID",
|
||||
// UserID: "userID",
|
||||
// Relation: "viewer", // available options: "owner", "admin", "editor", "viewer"
|
||||
// Relation: "contributor", // available options: "owner", "admin", "editor", "contributor"
|
||||
// }
|
||||
// err := sdk.SendInvitation(invitation, "token")
|
||||
// fmt.Println(err)
|
||||
|
||||
@@ -1242,7 +1242,7 @@ func TestShareThing(t *testing.T) {
|
||||
}
|
||||
repoCall3 := auth.On("AddPolicy", mock.Anything, mock.Anything).Return(&magistrala.AddPolicyRes{Added: true}, nil)
|
||||
req := sdk.UsersRelationRequest{
|
||||
Relation: "viewer",
|
||||
Relation: "contributor",
|
||||
UserIDs: []string{tc.channelID},
|
||||
}
|
||||
err := mgsdk.ShareThing(tc.thingID, req, tc.token)
|
||||
|
||||
Reference in New Issue
Block a user