mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 06:50:18 +00:00
NOISSUE - Improve tests in Auth service (#262)
Signed-off-by: felix.gateru <felix.gateru@gmail.com>
This commit is contained in:
@@ -49,6 +49,7 @@ jobs:
|
||||
- "auth/domains.go"
|
||||
- "auth/keys.go"
|
||||
- "auth/policies.go"
|
||||
- "auth/service.go"
|
||||
- "pkg/events/events.go"
|
||||
- "provision/service.go"
|
||||
- "pkg/groups/groups.go"
|
||||
@@ -109,6 +110,7 @@ jobs:
|
||||
mv ./auth/mocks/authz.go ./auth/mocks/authz.go.tmp
|
||||
mv ./auth/mocks/domains.go ./auth/mocks/domains.go.tmp
|
||||
mv ./auth/mocks/keys.go ./auth/mocks/keys.go.tmp
|
||||
mv ./auth/mocks/service.go ./auth/mocks/service.go.tmp
|
||||
mv ./pkg/events/mocks/publisher.go ./pkg/events/mocks/publisher.go.tmp
|
||||
mv ./pkg/events/mocks/subscriber.go ./pkg/events/mocks/subscriber.go.tmp
|
||||
mv ./provision/mocks/service.go ./provision/mocks/service.go.tmp
|
||||
@@ -140,6 +142,7 @@ jobs:
|
||||
check_mock_changes ./auth/mocks/authz.go "Auth Authz ./auth/mocks/authz.go"
|
||||
check_mock_changes ./auth/mocks/domains.go "Auth Domains ./auth/mocks/domains.go"
|
||||
check_mock_changes ./auth/mocks/keys.go "Auth Keys ./auth/mocks/keys.go"
|
||||
check_mock_changes ./auth/mocks/service.go "Auth Service ./auth/mocks/service.go"
|
||||
check_mock_changes ./pkg/events/mocks/publisher.go "ES Publisher ./pkg/events/mocks/publisher.go"
|
||||
check_mock_changes ./pkg/events/mocks/subscriber.go "EE Subscriber ./pkg/events/mocks/subscriber.go"
|
||||
check_mock_changes ./provision/mocks/service.go "Provision Service ./provision/mocks/service.go"
|
||||
|
||||
+213
-214
@@ -654,7 +654,7 @@ type AddPolicyRes struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Authorized bool `protobuf:"varint,1,opt,name=authorized,proto3" json:"authorized,omitempty"`
|
||||
Added bool `protobuf:"varint,1,opt,name=added,proto3" json:"added,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AddPolicyRes) Reset() {
|
||||
@@ -689,9 +689,9 @@ func (*AddPolicyRes) Descriptor() ([]byte, []int) {
|
||||
return file_auth_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *AddPolicyRes) GetAuthorized() bool {
|
||||
func (x *AddPolicyRes) GetAdded() bool {
|
||||
if x != nil {
|
||||
return x.Authorized
|
||||
return x.Added
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -701,7 +701,7 @@ type AddPoliciesRes struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Authorized bool `protobuf:"varint,1,opt,name=authorized,proto3" json:"authorized,omitempty"`
|
||||
Added bool `protobuf:"varint,1,opt,name=added,proto3" json:"added,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AddPoliciesRes) Reset() {
|
||||
@@ -736,9 +736,9 @@ func (*AddPoliciesRes) Descriptor() ([]byte, []int) {
|
||||
return file_auth_proto_rawDescGZIP(), []int{10}
|
||||
}
|
||||
|
||||
func (x *AddPoliciesRes) GetAuthorized() bool {
|
||||
func (x *AddPoliciesRes) GetAdded() bool {
|
||||
if x != nil {
|
||||
return x.Authorized
|
||||
return x.Added
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -1938,119 +1938,45 @@ var file_auth_proto_rawDesc = []byte{
|
||||
0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x18, 0x01, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41,
|
||||
0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x52, 0x0e, 0x61, 0x64, 0x64,
|
||||
0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x22, 0x2e, 0x0a, 0x0c, 0x41,
|
||||
0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x61,
|
||||
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
|
||||
0x0a, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x22, 0x30, 0x0a, 0x0e, 0x41,
|
||||
0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x12, 0x1e, 0x0a,
|
||||
0x0a, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x08, 0x52, 0x0a, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x22, 0xca, 0x02,
|
||||
0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65,
|
||||
0x71, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10,
|
||||
0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52,
|
||||
0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73,
|
||||
0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
|
||||
0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x5e, 0x0a, 0x11, 0x44, 0x65,
|
||||
0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x12,
|
||||
0x49, 0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65,
|
||||
0x73, 0x52, 0x65, 0x71, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, 0x67,
|
||||
0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f,
|
||||
0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x52, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50,
|
||||
0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x22, 0x2b, 0x0a, 0x0f, 0x44, 0x65,
|
||||
0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07,
|
||||
0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x22, 0x2d, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74,
|
||||
0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64,
|
||||
0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x22, 0xc1, 0x02, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x4f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d,
|
||||
0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69,
|
||||
0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70,
|
||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f,
|
||||
0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f,
|
||||
0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12,
|
||||
0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x6c,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x6c,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18,
|
||||
0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a,
|
||||
0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24,
|
||||
0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18,
|
||||
0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0a, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x52, 0x0a, 0x0e, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08,
|
||||
0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74,
|
||||
0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xac,
|
||||
0x02, 0x0a, 0x0f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52,
|
||||
0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a,
|
||||
0x10, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e,
|
||||
0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16,
|
||||
0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
|
||||
0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50,
|
||||
0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,
|
||||
0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x27, 0x0a,
|
||||
0x0f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73,
|
||||
0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xc2, 0x02, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x53,
|
||||
0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f,
|
||||
0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61,
|
||||
0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79,
|
||||
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65,
|
||||
0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65,
|
||||
0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d,
|
||||
0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f,
|
||||
0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12,
|
||||
0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e,
|
||||
0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65,
|
||||
0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0a,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x53, 0x0a, 0x0f, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09,
|
||||
0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65,
|
||||
0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e,
|
||||
0x22, 0xad, 0x02, 0x0a, 0x10, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x22, 0x24, 0x0a, 0x0c, 0x41,
|
||||
0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x61,
|
||||
0x64, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x61, 0x64, 0x64, 0x65,
|
||||
0x64, 0x22, 0x26, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73,
|
||||
0x52, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x22, 0xca, 0x02, 0x0a, 0x0f, 0x44, 0x65,
|
||||
0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64,
|
||||
0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6b,
|
||||
0x69, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a,
|
||||
0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6b,
|
||||
0x69, 0x6e, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f,
|
||||
0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x5e, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
|
||||
0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x12, 0x49, 0x0a, 0x11, 0x64,
|
||||
0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71,
|
||||
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72,
|
||||
0x61, 0x6c, 0x61, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
|
||||
0x52, 0x65, 0x71, 0x52, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63,
|
||||
0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x22, 0x2b, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
|
||||
0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c,
|
||||
0x65, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65,
|
||||
0x74, 0x65, 0x64, 0x22, 0x2d, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c,
|
||||
0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65,
|
||||
0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74,
|
||||
0x65, 0x64, 0x22, 0xc1, 0x02, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x73, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21, 0x0a,
|
||||
0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20,
|
||||
@@ -2069,10 +1995,61 @@ var file_auth_proto_rawDesc = []byte{
|
||||
0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65,
|
||||
0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e,
|
||||
0x22, 0x28, 0x0a, 0x10, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x73, 0x52, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xfc, 0x01, 0x0a, 0x12, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65,
|
||||
0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x52, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f, 0x6c, 0x69,
|
||||
0x63, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69,
|
||||
0x63, 0x69, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65,
|
||||
0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78,
|
||||
0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xac, 0x02, 0x0a, 0x0f, 0x43,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x12, 0x16,
|
||||
0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
|
||||
0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x73, 0x75, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18,
|
||||
0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x65,
|
||||
0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
|
||||
0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70,
|
||||
0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54,
|
||||
0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74,
|
||||
0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x27, 0x0a, 0x0f, 0x43, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x22, 0xc2, 0x02, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21,
|
||||
0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70,
|
||||
0x65, 0x12, 0x29, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73,
|
||||
0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x07, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6e,
|
||||
0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x09, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65,
|
||||
0x6e, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x53, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x53,
|
||||
0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6f,
|
||||
0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6f,
|
||||
0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61,
|
||||
0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e,
|
||||
0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xad, 0x02, 0x0a,
|
||||
0x10, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65,
|
||||
0x71, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
@@ -2081,103 +2058,125 @@ var file_auth_proto_rawDesc = []byte{
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52,
|
||||
0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
|
||||
0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x69,
|
||||
0x6c, 0x74, 0x65, 0x72, 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x50, 0x65,
|
||||
0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xef, 0x01, 0x0a, 0x12, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
|
||||
0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x73,
|
||||
0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65,
|
||||
0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x65, 0x72,
|
||||
0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b,
|
||||
0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x32, 0x51, 0x0a, 0x0c, 0x41,
|
||||
0x75, 0x74, 0x68, 0x7a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x41, 0x0a, 0x09, 0x41,
|
||||
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73,
|
||||
0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x52,
|
||||
0x65, 0x71, 0x1a, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e,
|
||||
0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x73, 0x22, 0x00, 0x32, 0xc6,
|
||||
0x08, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x32,
|
||||
0x0a, 0x05, 0x49, 0x73, 0x73, 0x75, 0x65, 0x12, 0x14, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74,
|
||||
0x72, 0x61, 0x6c, 0x61, 0x2e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e,
|
||||
0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e,
|
||||
0x22, 0x00, 0x12, 0x36, 0x0a, 0x07, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x12, 0x16, 0x2e,
|
||||
0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x52, 0x65, 0x66, 0x72, 0x65,
|
||||
0x73, 0x68, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61,
|
||||
0x6c, 0x61, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x08, 0x49, 0x64,
|
||||
0x65, 0x6e, 0x74, 0x69, 0x66, 0x79, 0x12, 0x17, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72,
|
||||
0x61, 0x6c, 0x61, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a,
|
||||
0x17, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x49, 0x64, 0x65,
|
||||
0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x09, 0x41, 0x75,
|
||||
0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74,
|
||||
0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x52, 0x65,
|
||||
0x71, 0x1a, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41,
|
||||
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x41, 0x0a,
|
||||
0x09, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x18, 0x2e, 0x6d, 0x61, 0x67,
|
||||
0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63,
|
||||
0x79, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c,
|
||||
0x61, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x22, 0x00,
|
||||
0x12, 0x47, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12,
|
||||
0x1a, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41, 0x64, 0x64,
|
||||
0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x6d, 0x61,
|
||||
0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a,
|
||||
0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f,
|
||||
0x74, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61,
|
||||
0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e,
|
||||
0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x28, 0x0a, 0x10,
|
||||
0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73,
|
||||
0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xfc, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x50,
|
||||
0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64,
|
||||
0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x04,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f,
|
||||
0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72,
|
||||
0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03,
|
||||
0x28, 0x09, 0x52, 0x11, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xef, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65,
|
||||
0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f,
|
||||
0x6d, 0x61, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f,
|
||||
0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74,
|
||||
0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d,
|
||||
0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x32, 0x51, 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x7a,
|
||||
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x41, 0x0a, 0x09, 0x41, 0x75, 0x74, 0x68, 0x6f,
|
||||
0x72, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c,
|
||||
0x61, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x18,
|
||||
0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41, 0x75, 0x74, 0x68,
|
||||
0x6f, 0x72, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x73, 0x22, 0x00, 0x32, 0xc6, 0x08, 0x0a, 0x0b, 0x41,
|
||||
0x75, 0x74, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x49, 0x73,
|
||||
0x73, 0x75, 0x65, 0x12, 0x14, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61,
|
||||
0x2e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6d, 0x61, 0x67, 0x69,
|
||||
0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x00, 0x12, 0x36,
|
||||
0x0a, 0x07, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x12, 0x16, 0x2e, 0x6d, 0x61, 0x67, 0x69,
|
||||
0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x52, 0x65,
|
||||
0x71, 0x1a, 0x11, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x54,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x08, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69,
|
||||
0x66, 0x79, 0x12, 0x17, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e,
|
||||
0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6d, 0x61,
|
||||
0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74,
|
||||
0x79, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x09, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72,
|
||||
0x69, 0x7a, 0x65, 0x12, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61,
|
||||
0x2e, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e,
|
||||
0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x6f,
|
||||
0x72, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x09, 0x41, 0x64, 0x64,
|
||||
0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72,
|
||||
0x61, 0x6c, 0x61, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71,
|
||||
0x1a, 0x18, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41, 0x64,
|
||||
0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0b,
|
||||
0x41, 0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x1a, 0x2e, 0x6d, 0x61,
|
||||
0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69,
|
||||
0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0c, 0x44, 0x65, 0x6c,
|
||||
0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69,
|
||||
0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c,
|
||||
0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72,
|
||||
0x61, 0x6c, 0x61, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
|
||||
0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50,
|
||||
0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x1d, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74,
|
||||
0x72, 0x61, 0x6c, 0x61, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63,
|
||||
0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1d, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72,
|
||||
0x61, 0x6c, 0x61, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69,
|
||||
0x65, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x4f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1a, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72,
|
||||
0x61, 0x6c, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52,
|
||||
0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e,
|
||||
0x4c, 0x69, 0x73, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00,
|
||||
0x12, 0x4a, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x4f, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74,
|
||||
0x72, 0x61, 0x6c, 0x61, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73,
|
||||
0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50,
|
||||
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61,
|
||||
0x6c, 0x61, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52,
|
||||
0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e,
|
||||
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x22,
|
||||
0x00, 0x12, 0x50, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63,
|
||||
0x69, 0x65, 0x73, 0x12, 0x1d, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61,
|
||||
0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52,
|
||||
0x65, 0x71, 0x1a, 0x1d, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e,
|
||||
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65,
|
||||
0x73, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x73, 0x12, 0x1a, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e,
|
||||
0x4c, 0x69, 0x73, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1a,
|
||||
0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74,
|
||||
0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0c,
|
||||
0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x6d,
|
||||
0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69,
|
||||
0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4f, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74,
|
||||
0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73,
|
||||
0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0e,
|
||||
0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1a,
|
||||
0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74,
|
||||
0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x6d, 0x61, 0x67,
|
||||
0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0c, 0x43, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73,
|
||||
0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61,
|
||||
0x6c, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52,
|
||||
0x65, 0x73, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x53,
|
||||
0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74,
|
||||
0x72, 0x61, 0x6c, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x73, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c,
|
||||
0x6c, 0x61, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52,
|
||||
0x65, 0x73, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x75, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c,
|
||||
0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65,
|
||||
0x73, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x75, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x73, 0x12, 0x1c, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c,
|
||||
0x61, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52,
|
||||
0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e,
|
||||
0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73,
|
||||
0x22, 0x00, 0x12, 0x53, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61,
|
||||
0x6c, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61,
|
||||
0x6c, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x6d, 0x61, 0x67,
|
||||
0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00,
|
||||
0x12, 0x4d, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x53, 0x75, 0x62, 0x6a, 0x65,
|
||||
0x63, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61,
|
||||
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71,
|
||||
0x1a, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12,
|
||||
0x4d, 0x0a, 0x0d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73,
|
||||
0x12, 0x1c, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x43, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1c,
|
||||
0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x43, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x53,
|
||||
0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x12, 0x1e, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65,
|
||||
0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x61, 0x2e, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65,
|
||||
0x73, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x6d, 0x61, 0x67, 0x69, 0x73, 0x74, 0x72,
|
||||
0x61, 0x6c, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
+2
-2
@@ -98,9 +98,9 @@ message AddPoliciesReq{
|
||||
repeated AddPolicyReq addPoliciesReq= 1;
|
||||
}
|
||||
|
||||
message AddPolicyRes { bool authorized = 1; }
|
||||
message AddPolicyRes { bool added = 1; }
|
||||
|
||||
message AddPoliciesRes { bool authorized = 1; }
|
||||
message AddPoliciesRes { bool added = 1; }
|
||||
|
||||
message DeletePolicyReq {
|
||||
string domain = 1;
|
||||
|
||||
+11
-10
@@ -292,12 +292,12 @@ func (client grpcClient) AddPolicy(ctx context.Context, in *magistrala.AddPolicy
|
||||
}
|
||||
|
||||
apr := res.(addPolicyRes)
|
||||
return &magistrala.AddPolicyRes{Authorized: apr.authorized}, nil
|
||||
return &magistrala.AddPolicyRes{Added: apr.added}, nil
|
||||
}
|
||||
|
||||
func decodeAddPolicyResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
res := grpcRes.(*magistrala.AddPolicyRes)
|
||||
return addPolicyRes{authorized: res.Authorized}, nil
|
||||
return addPolicyRes{added: res.Added}, nil
|
||||
}
|
||||
|
||||
func encodeAddPolicyRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
@@ -341,12 +341,12 @@ func (client grpcClient) AddPolicies(ctx context.Context, in *magistrala.AddPoli
|
||||
}
|
||||
|
||||
apr := res.(addPoliciesRes)
|
||||
return &magistrala.AddPoliciesRes{Authorized: apr.authorized}, nil
|
||||
return &magistrala.AddPoliciesRes{Added: apr.added}, nil
|
||||
}
|
||||
|
||||
func decodeAddPoliciesResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
res := grpcRes.(*magistrala.AddPoliciesRes)
|
||||
return addPoliciesRes{authorized: res.Authorized}, nil
|
||||
return addPoliciesRes{added: res.Added}, nil
|
||||
}
|
||||
|
||||
func encodeAddPoliciesRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
@@ -532,7 +532,7 @@ func (client grpcClient) CountObjects(ctx context.Context, in *magistrala.CountO
|
||||
ctx, cancel := context.WithTimeout(ctx, client.timeout)
|
||||
defer cancel()
|
||||
|
||||
res, err := client.countObjects(ctx, listObjectsReq{
|
||||
res, err := client.countObjects(ctx, countObjectsReq{
|
||||
Domain: in.GetDomain(),
|
||||
SubjectType: in.GetSubjectType(),
|
||||
Subject: in.GetSubject(),
|
||||
@@ -712,11 +712,12 @@ func decodeListPermissionsResponse(_ context.Context, grpcRes interface{}) (inte
|
||||
func encodeListPermissionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
req := grpcReq.(listPermissionsReq)
|
||||
return &magistrala.ListPermissionsReq{
|
||||
Domain: req.Domain,
|
||||
SubjectType: req.SubjectType,
|
||||
Subject: req.Subject,
|
||||
ObjectType: req.ObjectType,
|
||||
Object: req.Object,
|
||||
Domain: req.Domain,
|
||||
SubjectType: req.SubjectType,
|
||||
Subject: req.Subject,
|
||||
ObjectType: req.ObjectType,
|
||||
Object: req.Object,
|
||||
FilterPermissions: req.FilterPermissions,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ func addPolicyEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
if err != nil {
|
||||
return addPolicyRes{}, err
|
||||
}
|
||||
return addPolicyRes{authorized: true}, err
|
||||
return addPolicyRes{added: true}, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func addPoliciesEndpoint(svc auth.Service) endpoint.Endpoint {
|
||||
if err := svc.AddPolicies(ctx, prs); err != nil {
|
||||
return addPoliciesRes{}, err
|
||||
}
|
||||
return addPoliciesRes{authorized: true}, nil
|
||||
return addPoliciesRes{added: true}, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+862
-227
File diff suppressed because it is too large
Load Diff
@@ -100,11 +100,6 @@ func (req policyReq) validate() error {
|
||||
type policiesReq []policyReq
|
||||
|
||||
func (prs policiesReq) validate() error {
|
||||
for _, pr := range prs {
|
||||
if err := pr.validate(); err != nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ type authorizeRes struct {
|
||||
}
|
||||
|
||||
type addPolicyRes struct {
|
||||
authorized bool
|
||||
added bool
|
||||
}
|
||||
type addPoliciesRes struct {
|
||||
authorized bool
|
||||
added bool
|
||||
}
|
||||
|
||||
type deletePolicyRes struct {
|
||||
|
||||
@@ -337,7 +337,7 @@ func decodeAddPolicyRequest(_ context.Context, grpcReq interface{}) (interface{}
|
||||
|
||||
func encodeAddPolicyResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
res := grpcRes.(addPolicyRes)
|
||||
return &magistrala.AddPolicyRes{Authorized: res.authorized}, nil
|
||||
return &magistrala.AddPolicyRes{Added: res.added}, nil
|
||||
}
|
||||
|
||||
func decodeAddPoliciesRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
@@ -361,7 +361,7 @@ func decodeAddPoliciesRequest(_ context.Context, grpcReq interface{}) (interface
|
||||
|
||||
func encodeAddPoliciesResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
res := grpcRes.(addPoliciesRes)
|
||||
return &magistrala.AddPoliciesRes{Authorized: res.authorized}, nil
|
||||
return &magistrala.AddPoliciesRes{Added: res.added}, nil
|
||||
}
|
||||
|
||||
func decodeDeletePolicyRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
@@ -478,8 +478,8 @@ func decodeCountSubjectsRequest(_ context.Context, grpcReq interface{}) (interfa
|
||||
}
|
||||
|
||||
func encodeCountSubjectsResponse(_ context.Context, grpcRes interface{}) (interface{}, error) {
|
||||
res := grpcRes.(countObjectsRes)
|
||||
return &magistrala.CountObjectsRes{Count: int64(res.count)}, nil
|
||||
res := grpcRes.(countSubjectsRes)
|
||||
return &magistrala.CountSubjectsRes{Count: int64(res.count)}, nil
|
||||
}
|
||||
|
||||
func decodeListPermissionsRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
|
||||
@@ -7,27 +7,13 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/auth"
|
||||
"github.com/absmach/magistrala/auth/jwt"
|
||||
"github.com/absmach/magistrala/auth/mocks"
|
||||
"github.com/absmach/magistrala/pkg/uuid"
|
||||
)
|
||||
|
||||
var (
|
||||
svc auth.Service
|
||||
krepo *mocks.KeyRepository
|
||||
prepo *mocks.PolicyAgent
|
||||
)
|
||||
var svc *mocks.Service
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
krepo = new(mocks.KeyRepository)
|
||||
prepo = new(mocks.PolicyAgent)
|
||||
drepo := new(mocks.DomainsRepository)
|
||||
idProvider := uuid.NewMock()
|
||||
|
||||
t := jwt.New([]byte(secret))
|
||||
|
||||
svc = auth.New(krepo, drepo, idProvider, t, prepo, loginDuration, refreshDuration, invalidDuration)
|
||||
svc = new(mocks.Service)
|
||||
startGRPCServer(svc, port)
|
||||
|
||||
code := m.Run()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -218,13 +218,20 @@ func TestRetrieve(t *testing.T) {
|
||||
desc string
|
||||
id string
|
||||
token string
|
||||
key auth.Key
|
||||
status int
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "retrieve an existing key",
|
||||
id: k.AccessToken,
|
||||
token: token.AccessToken,
|
||||
desc: "retrieve an existing key",
|
||||
id: k.AccessToken,
|
||||
token: token.AccessToken,
|
||||
key: auth.Key{
|
||||
Subject: id,
|
||||
Type: auth.AccessKey,
|
||||
IssuedAt: time.Now(),
|
||||
ExpiresAt: time.Now().Add(refreshDuration),
|
||||
},
|
||||
status: http.StatusOK,
|
||||
err: nil,
|
||||
},
|
||||
@@ -242,6 +249,13 @@ func TestRetrieve(t *testing.T) {
|
||||
status: http.StatusUnauthorized,
|
||||
err: errors.ErrAuthentication,
|
||||
},
|
||||
{
|
||||
desc: "retrieve a key with an empty token",
|
||||
token: "",
|
||||
id: k.AccessToken,
|
||||
status: http.StatusUnauthorized,
|
||||
err: errors.ErrAuthentication,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
@@ -251,7 +265,7 @@ func TestRetrieve(t *testing.T) {
|
||||
url: fmt.Sprintf("%s/keys/%s", ts.URL, tc.id),
|
||||
token: tc.token,
|
||||
}
|
||||
repocall := krepo.On("Retrieve", mock.Anything, mock.Anything, mock.Anything).Return(auth.Key{}, tc.err)
|
||||
repocall := krepo.On("Retrieve", mock.Anything, mock.Anything, mock.Anything).Return(tc.key, tc.err)
|
||||
res, err := req.make()
|
||||
assert.Nil(t, err, fmt.Sprintf("%s: unexpected error %s", tc.desc, err))
|
||||
assert.Equal(t, tc.status, res.StatusCode, fmt.Sprintf("%s: expected status code %d got %d", tc.desc, tc.status, res.StatusCode))
|
||||
@@ -298,6 +312,12 @@ func TestRevoke(t *testing.T) {
|
||||
token: "wrong",
|
||||
status: http.StatusUnauthorized,
|
||||
},
|
||||
{
|
||||
desc: "revoke key with empty token",
|
||||
id: k.AccessToken,
|
||||
token: "",
|
||||
status: http.StatusUnauthorized,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// Copyright (c) Abstract Machines
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package keys
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/auth"
|
||||
"github.com/absmach/magistrala/internal/apiutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var valid = "valid"
|
||||
|
||||
func TestIssueKeyReqValidate(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
req issueKeyReq
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "valid request",
|
||||
req: issueKeyReq{
|
||||
token: valid,
|
||||
Type: auth.AccessKey,
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "empty token",
|
||||
req: issueKeyReq{
|
||||
token: "",
|
||||
Type: auth.AccessKey,
|
||||
},
|
||||
err: apiutil.ErrBearerToken,
|
||||
},
|
||||
{
|
||||
desc: "invalid key type",
|
||||
req: issueKeyReq{
|
||||
token: valid,
|
||||
Type: auth.KeyType(100),
|
||||
},
|
||||
err: apiutil.ErrInvalidAPIKey,
|
||||
},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
err := tc.req.validate()
|
||||
assert.Equal(t, tc.err, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestKeyReqValidate(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
req keyReq
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "valid request",
|
||||
req: keyReq{
|
||||
token: valid,
|
||||
id: valid,
|
||||
},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "empty token",
|
||||
req: keyReq{
|
||||
token: "",
|
||||
id: valid,
|
||||
},
|
||||
err: apiutil.ErrBearerToken,
|
||||
},
|
||||
{
|
||||
desc: "empty id",
|
||||
req: keyReq{
|
||||
token: valid,
|
||||
id: "",
|
||||
},
|
||||
err: apiutil.ErrMissingID,
|
||||
},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
err := tc.req.validate()
|
||||
assert.Equal(t, tc.err, err)
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/absmach/magistrala"
|
||||
"github.com/absmach/magistrala/auth"
|
||||
"github.com/absmach/magistrala/internal/api"
|
||||
"github.com/absmach/magistrala/internal/apiutil"
|
||||
"github.com/absmach/magistrala/pkg/errors"
|
||||
"github.com/go-chi/chi/v5"
|
||||
@@ -23,27 +23,27 @@ const contentType = "application/json"
|
||||
// MakeHandler returns a HTTP handler for API endpoints.
|
||||
func MakeHandler(svc auth.Service, mux *chi.Mux, logger *slog.Logger) *chi.Mux {
|
||||
opts := []kithttp.ServerOption{
|
||||
kithttp.ServerErrorEncoder(apiutil.LoggingErrorEncoder(logger, encodeError)),
|
||||
kithttp.ServerErrorEncoder(apiutil.LoggingErrorEncoder(logger, api.EncodeError)),
|
||||
}
|
||||
mux.Route("/keys", func(r chi.Router) {
|
||||
r.Post("/", kithttp.NewServer(
|
||||
issueEndpoint(svc),
|
||||
decodeIssue,
|
||||
encodeResponse,
|
||||
api.EncodeResponse,
|
||||
opts...,
|
||||
).ServeHTTP)
|
||||
|
||||
r.Get("/{id}", kithttp.NewServer(
|
||||
(retrieveEndpoint(svc)),
|
||||
decodeKeyReq,
|
||||
encodeResponse,
|
||||
api.EncodeResponse,
|
||||
opts...,
|
||||
).ServeHTTP)
|
||||
|
||||
r.Delete("/{id}", kithttp.NewServer(
|
||||
(revokeEndpoint(svc)),
|
||||
decodeKeyReq,
|
||||
encodeResponse,
|
||||
api.EncodeResponse,
|
||||
opts...,
|
||||
).ServeHTTP)
|
||||
})
|
||||
@@ -52,7 +52,7 @@ func MakeHandler(svc auth.Service, mux *chi.Mux, logger *slog.Logger) *chi.Mux {
|
||||
|
||||
func decodeIssue(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
if !strings.Contains(r.Header.Get("Content-Type"), contentType) {
|
||||
return nil, errors.ErrUnsupportedContentType
|
||||
return nil, apiutil.ErrUnsupportedContentType
|
||||
}
|
||||
|
||||
req := issueKeyReq{token: apiutil.ExtractBearerToken(r)}
|
||||
@@ -70,48 +70,3 @@ func decodeKeyReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func encodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error {
|
||||
w.Header().Set("Content-Type", contentType)
|
||||
|
||||
if ar, ok := response.(magistrala.Response); ok {
|
||||
for k, v := range ar.Headers() {
|
||||
w.Header().Set(k, v)
|
||||
}
|
||||
|
||||
w.WriteHeader(ar.Code())
|
||||
|
||||
if ar.Empty() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
func encodeError(_ context.Context, err error, w http.ResponseWriter) {
|
||||
switch {
|
||||
case errors.Contains(err, errors.ErrMalformedEntity),
|
||||
err == apiutil.ErrMissingID,
|
||||
err == apiutil.ErrInvalidAPIKey:
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
case errors.Contains(err, errors.ErrAuthentication),
|
||||
err == apiutil.ErrBearerToken:
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
case errors.Contains(err, errors.ErrNotFound):
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
case errors.Contains(err, errors.ErrConflict):
|
||||
w.WriteHeader(http.StatusConflict)
|
||||
case errors.Contains(err, errors.ErrUnsupportedContentType):
|
||||
w.WriteHeader(http.StatusUnsupportedMediaType)
|
||||
default:
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if errorVal, ok := err.(errors.Error); ok {
|
||||
w.Header().Set("Content-Type", contentType)
|
||||
if err := json.NewEncoder(w).Encode(apiutil.ErrorRes{Err: errorVal.Msg()}); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,4 +183,7 @@ type DomainsRepository interface {
|
||||
|
||||
// ListDomains list all the domains
|
||||
ListDomains(ctx context.Context, pm Page) (DomainsPage, error)
|
||||
|
||||
// CheckPolicy check policy in domains database.
|
||||
CheckPolicy(ctx context.Context, pc Policy) error
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
// Copyright (c) Abstract Machines
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package auth_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/absmach/magistrala/auth"
|
||||
"github.com/absmach/magistrala/internal/apiutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestStatusString(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
status auth.Status
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
desc: "Enabled",
|
||||
status: auth.EnabledStatus,
|
||||
expected: "enabled",
|
||||
},
|
||||
{
|
||||
desc: "Disabled",
|
||||
status: auth.DisabledStatus,
|
||||
expected: "disabled",
|
||||
},
|
||||
{
|
||||
desc: "Freezed",
|
||||
status: auth.FreezeStatus,
|
||||
expected: "freezed",
|
||||
},
|
||||
{
|
||||
desc: "All",
|
||||
status: auth.AllStatus,
|
||||
expected: "all",
|
||||
},
|
||||
{
|
||||
desc: "Unknown",
|
||||
status: auth.Status(100),
|
||||
expected: "unknown",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
got := tc.status.String()
|
||||
assert.Equal(t, tc.expected, got, "String() = %v, expected %v", got, tc.expected)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestToStatus(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
status string
|
||||
expetcted auth.Status
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "Enabled",
|
||||
status: "enabled",
|
||||
expetcted: auth.EnabledStatus,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "Disabled",
|
||||
status: "disabled",
|
||||
expetcted: auth.DisabledStatus,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "Freezed",
|
||||
status: "freezed",
|
||||
expetcted: auth.FreezeStatus,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "All",
|
||||
status: "all",
|
||||
expetcted: auth.AllStatus,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "Unknown",
|
||||
status: "unknown",
|
||||
expetcted: auth.Status(0),
|
||||
err: apiutil.ErrInvalidStatus,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
got, err := auth.ToStatus(tc.status)
|
||||
assert.Equal(t, tc.err, err, "ToStatus() error = %v, expected %v", err, tc.err)
|
||||
assert.Equal(t, tc.expetcted, got, "ToStatus() = %v, expected %v", got, tc.expetcted)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatusMarshalJSON(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
expected []byte
|
||||
status auth.Status
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "Enabled",
|
||||
expected: []byte(`"enabled"`),
|
||||
status: auth.EnabledStatus,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "Disabled",
|
||||
expected: []byte(`"disabled"`),
|
||||
status: auth.DisabledStatus,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "All",
|
||||
expected: []byte(`"all"`),
|
||||
status: auth.AllStatus,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "Unknown",
|
||||
expected: []byte(`"unknown"`),
|
||||
status: auth.Status(100),
|
||||
err: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
got, err := tc.status.MarshalJSON()
|
||||
assert.Equal(t, tc.err, err, "MarshalJSON() error = %v, expected %v", err, tc.err)
|
||||
assert.Equal(t, tc.expected, got, "MarshalJSON() = %v, expected %v", got, tc.expected)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatusUnmarshalJSON(t *testing.T) {
|
||||
cases := []struct {
|
||||
desc string
|
||||
expected auth.Status
|
||||
status []byte
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "Enabled",
|
||||
expected: auth.EnabledStatus,
|
||||
status: []byte(`"enabled"`),
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "Disabled",
|
||||
expected: auth.DisabledStatus,
|
||||
status: []byte(`"disabled"`),
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "All",
|
||||
expected: auth.AllStatus,
|
||||
status: []byte(`"all"`),
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "Unknown",
|
||||
expected: auth.Status(0),
|
||||
status: []byte(`"unknown"`),
|
||||
err: apiutil.ErrInvalidStatus,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
var s auth.Status
|
||||
err := s.UnmarshalJSON(tc.status)
|
||||
assert.Equal(t, tc.err, err, "UnmarshalJSON() error = %v, expected %v", err, tc.err)
|
||||
assert.Equal(t, tc.expected, s, "UnmarshalJSON() = %v, expected %v", s, tc.expected)
|
||||
})
|
||||
}
|
||||
}
|
||||
+52
-7
@@ -9,13 +9,26 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/absmach/magistrala/auth"
|
||||
"github.com/absmach/magistrala/auth/jwt"
|
||||
authjwt "github.com/absmach/magistrala/auth/jwt"
|
||||
"github.com/absmach/magistrala/pkg/errors"
|
||||
"github.com/lestrrat-go/jwx/v2/jwa"
|
||||
"github.com/lestrrat-go/jwx/v2/jwt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const secret = "test"
|
||||
const (
|
||||
tokenType = "type"
|
||||
userField = "user"
|
||||
domainField = "domain"
|
||||
issuerName = "magistrala.auth"
|
||||
secret = "test"
|
||||
)
|
||||
|
||||
var (
|
||||
errInvalidIssuer = errors.New("invalid token issuer value")
|
||||
reposecret = []byte("test")
|
||||
)
|
||||
|
||||
func key() auth.Key {
|
||||
exp := time.Now().UTC().Add(10 * time.Minute).Round(time.Second)
|
||||
@@ -29,8 +42,26 @@ func key() auth.Key {
|
||||
}
|
||||
}
|
||||
|
||||
func newToken(issuerName string, key auth.Key) string {
|
||||
builder := jwt.NewBuilder()
|
||||
builder.
|
||||
Issuer(issuerName).
|
||||
IssuedAt(key.IssuedAt).
|
||||
Subject(key.Subject).
|
||||
Claim(tokenType, "r").
|
||||
Expiration(key.ExpiresAt)
|
||||
builder.Claim(userField, key.User)
|
||||
builder.Claim(domainField, key.Domain)
|
||||
if key.ID != "" {
|
||||
builder.JwtID(key.ID)
|
||||
}
|
||||
tkn, _ := builder.Build()
|
||||
tokn, _ := jwt.Sign(tkn, jwt.WithKey(jwa.HS512, reposecret))
|
||||
return string(tokn)
|
||||
}
|
||||
|
||||
func TestIssue(t *testing.T) {
|
||||
tokenizer := jwt.New([]byte(secret))
|
||||
tokenizer := authjwt.New([]byte(secret))
|
||||
|
||||
cases := []struct {
|
||||
desc string
|
||||
@@ -54,7 +85,7 @@ func TestIssue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
tokenizer := jwt.New([]byte(secret))
|
||||
tokenizer := authjwt.New([]byte(secret))
|
||||
|
||||
token, err := tokenizer.Issue(key())
|
||||
require.Nil(t, err, fmt.Sprintf("issuing key expected to succeed: %s", err))
|
||||
@@ -70,6 +101,8 @@ func TestParse(t *testing.T) {
|
||||
expToken, err := tokenizer.Issue(expKey)
|
||||
require.Nil(t, err, fmt.Sprintf("issuing expired key expected to succeed: %s", err))
|
||||
|
||||
inValidToken := newToken("invalid", key())
|
||||
|
||||
cases := []struct {
|
||||
desc string
|
||||
key auth.Key
|
||||
@@ -83,7 +116,7 @@ func TestParse(t *testing.T) {
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "parse ivalid key",
|
||||
desc: "parse invalid key",
|
||||
key: auth.Key{},
|
||||
token: "invalid",
|
||||
err: errors.ErrAuthentication,
|
||||
@@ -92,13 +125,25 @@ func TestParse(t *testing.T) {
|
||||
desc: "parse expired key",
|
||||
key: auth.Key{},
|
||||
token: expToken,
|
||||
err: jwt.ErrExpiry,
|
||||
err: authjwt.ErrExpiry,
|
||||
},
|
||||
{
|
||||
desc: "parse expired API key",
|
||||
key: apiKey,
|
||||
token: apiToken,
|
||||
err: jwt.ErrExpiry,
|
||||
err: authjwt.ErrExpiry,
|
||||
},
|
||||
{
|
||||
desc: "parse token with invalid issuer",
|
||||
key: auth.Key{},
|
||||
token: inValidToken,
|
||||
err: errInvalidIssuer,
|
||||
},
|
||||
{
|
||||
desc: "parse token with invalid content",
|
||||
key: auth.Key{},
|
||||
token: newToken(issuerName, key()),
|
||||
err: authjwt.ErrJSONHandle,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
// Copyright (c) Abstract Machines
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
"github.com/absmach/magistrala"
|
||||
"github.com/absmach/magistrala/pkg/errors"
|
||||
svcerr "github.com/absmach/magistrala/pkg/errors/service"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
const InvalidValue = "invalid"
|
||||
|
||||
var _ magistrala.AuthServiceClient = (*AuthClient)(nil)
|
||||
|
||||
type AuthClient struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (m *AuthClient) Issue(ctx context.Context, in *magistrala.IssueReq, opts ...grpc.CallOption) (*magistrala.Token, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
if in.GetUserId() == InvalidValue || in.GetUserId() == "" {
|
||||
return &magistrala.Token{}, svcerr.ErrAuthentication
|
||||
}
|
||||
|
||||
return ret.Get(0).(*magistrala.Token), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) Refresh(ctx context.Context, in *magistrala.RefreshReq, opts ...grpc.CallOption) (*magistrala.Token, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
if in.GetRefreshToken() == InvalidValue || in.GetRefreshToken() == "" {
|
||||
return &magistrala.Token{}, svcerr.ErrAuthentication
|
||||
}
|
||||
|
||||
return ret.Get(0).(*magistrala.Token), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) Identify(ctx context.Context, in *magistrala.IdentityReq, opts ...grpc.CallOption) (*magistrala.IdentityRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
if in.GetToken() == InvalidValue || in.GetToken() == "" {
|
||||
return &magistrala.IdentityRes{}, svcerr.ErrAuthentication
|
||||
}
|
||||
|
||||
return ret.Get(0).(*magistrala.IdentityRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) Authorize(ctx context.Context, in *magistrala.AuthorizeReq, opts ...grpc.CallOption) (*magistrala.AuthorizeRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
if in.GetSubject() == InvalidValue || in.GetSubject() == "" {
|
||||
return &magistrala.AuthorizeRes{Authorized: false}, svcerr.ErrAuthorization
|
||||
}
|
||||
if in.GetObject() == InvalidValue || in.GetObject() == "" {
|
||||
return &magistrala.AuthorizeRes{Authorized: false}, errors.ErrAuthorization
|
||||
}
|
||||
|
||||
return ret.Get(0).(*magistrala.AuthorizeRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) AddPolicy(ctx context.Context, in *magistrala.AddPolicyReq, opts ...grpc.CallOption) (*magistrala.AddPolicyRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.AddPolicyRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) AddPolicies(ctx context.Context, in *magistrala.AddPoliciesReq, opts ...grpc.CallOption) (*magistrala.AddPoliciesRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.AddPoliciesRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) DeletePolicy(ctx context.Context, in *magistrala.DeletePolicyReq, opts ...grpc.CallOption) (*magistrala.DeletePolicyRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.DeletePolicyRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) DeletePolicies(ctx context.Context, in *magistrala.DeletePoliciesReq, opts ...grpc.CallOption) (*magistrala.DeletePoliciesRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.DeletePoliciesRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) ListObjects(ctx context.Context, in *magistrala.ListObjectsReq, opts ...grpc.CallOption) (*magistrala.ListObjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListObjectsRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) ListAllObjects(ctx context.Context, in *magistrala.ListObjectsReq, opts ...grpc.CallOption) (*magistrala.ListObjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListObjectsRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) CountObjects(ctx context.Context, in *magistrala.CountObjectsReq, opts ...grpc.CallOption) (*magistrala.CountObjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.CountObjectsRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) ListSubjects(ctx context.Context, in *magistrala.ListSubjectsReq, opts ...grpc.CallOption) (*magistrala.ListSubjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListSubjectsRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) ListAllSubjects(ctx context.Context, in *magistrala.ListSubjectsReq, opts ...grpc.CallOption) (*magistrala.ListSubjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListSubjectsRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) CountSubjects(ctx context.Context, in *magistrala.CountSubjectsReq, opts ...grpc.CallOption) (*magistrala.CountSubjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.CountSubjectsRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *AuthClient) ListPermissions(ctx context.Context, in *magistrala.ListPermissionsReq, opts ...grpc.CallOption) (*magistrala.ListPermissionsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListPermissionsRes), ret.Error(1)
|
||||
}
|
||||
@@ -17,6 +17,24 @@ type DomainsRepository struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// CheckPolicy provides a mock function with given fields: ctx, pc
|
||||
func (_m *DomainsRepository) CheckPolicy(ctx context.Context, pc auth.Policy) error {
|
||||
ret := _m.Called(ctx, pc)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for CheckPolicy")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.Policy) error); ok {
|
||||
r0 = rf(ctx, pc)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Delete provides a mock function with given fields: ctx, id
|
||||
func (_m *DomainsRepository) Delete(ctx context.Context, id string) error {
|
||||
ret := _m.Called(ctx, id)
|
||||
|
||||
+599
-70
@@ -1,127 +1,656 @@
|
||||
// Code generated by mockery v2.38.0. DO NOT EDIT.
|
||||
|
||||
// Copyright (c) Abstract Machines
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
"github.com/absmach/magistrala"
|
||||
"github.com/absmach/magistrala/pkg/errors"
|
||||
svcerr "github.com/absmach/magistrala/pkg/errors/service"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"google.golang.org/grpc"
|
||||
auth "github.com/absmach/magistrala/auth"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
const InvalidValue = "invalid"
|
||||
|
||||
var _ magistrala.AuthServiceClient = (*Service)(nil)
|
||||
|
||||
// Service is an autogenerated mock type for the Service type
|
||||
type Service struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (m *Service) Issue(ctx context.Context, in *magistrala.IssueReq, opts ...grpc.CallOption) (*magistrala.Token, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
if in.GetUserId() == InvalidValue || in.GetUserId() == "" {
|
||||
return &magistrala.Token{}, svcerr.ErrAuthentication
|
||||
// AddPolicies provides a mock function with given fields: ctx, prs
|
||||
func (_m *Service) AddPolicies(ctx context.Context, prs []auth.PolicyReq) error {
|
||||
ret := _m.Called(ctx, prs)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AddPolicies")
|
||||
}
|
||||
|
||||
return ret.Get(0).(*magistrala.Token), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *Service) Refresh(ctx context.Context, in *magistrala.RefreshReq, opts ...grpc.CallOption) (*magistrala.Token, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
if in.GetRefreshToken() == InvalidValue || in.GetRefreshToken() == "" {
|
||||
return &magistrala.Token{}, svcerr.ErrAuthentication
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []auth.PolicyReq) error); ok {
|
||||
r0 = rf(ctx, prs)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return ret.Get(0).(*magistrala.Token), ret.Error(1)
|
||||
return r0
|
||||
}
|
||||
|
||||
func (m *Service) Identify(ctx context.Context, in *magistrala.IdentityReq, opts ...grpc.CallOption) (*magistrala.IdentityRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
if in.GetToken() == InvalidValue || in.GetToken() == "" {
|
||||
return &magistrala.IdentityRes{}, svcerr.ErrAuthentication
|
||||
// AddPolicy provides a mock function with given fields: ctx, pr
|
||||
func (_m *Service) AddPolicy(ctx context.Context, pr auth.PolicyReq) error {
|
||||
ret := _m.Called(ctx, pr)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AddPolicy")
|
||||
}
|
||||
|
||||
return ret.Get(0).(*magistrala.IdentityRes), ret.Error(1)
|
||||
}
|
||||
|
||||
func (m *Service) Authorize(ctx context.Context, in *magistrala.AuthorizeReq, opts ...grpc.CallOption) (*magistrala.AuthorizeRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
if in.GetSubject() == InvalidValue || in.GetSubject() == "" {
|
||||
return &magistrala.AuthorizeRes{Authorized: false}, svcerr.ErrAuthorization
|
||||
}
|
||||
if in.GetObject() == InvalidValue || in.GetObject() == "" {
|
||||
return &magistrala.AuthorizeRes{Authorized: false}, errors.ErrAuthorization
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) error); ok {
|
||||
r0 = rf(ctx, pr)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return ret.Get(0).(*magistrala.AuthorizeRes), ret.Error(1)
|
||||
return r0
|
||||
}
|
||||
|
||||
func (m *Service) AddPolicy(ctx context.Context, in *magistrala.AddPolicyReq, opts ...grpc.CallOption) (*magistrala.AddPolicyRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// AssignUsers provides a mock function with given fields: ctx, token, id, userIds, relation
|
||||
func (_m *Service) AssignUsers(ctx context.Context, token string, id string, userIds []string, relation string) error {
|
||||
ret := _m.Called(ctx, token, id, userIds, relation)
|
||||
|
||||
return ret.Get(0).(*magistrala.AddPolicyRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AssignUsers")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, []string, string) error); ok {
|
||||
r0 = rf(ctx, token, id, userIds, relation)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
func (m *Service) AddPolicies(ctx context.Context, in *magistrala.AddPoliciesReq, opts ...grpc.CallOption) (*magistrala.AddPoliciesRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// Authorize provides a mock function with given fields: ctx, pr
|
||||
func (_m *Service) Authorize(ctx context.Context, pr auth.PolicyReq) error {
|
||||
ret := _m.Called(ctx, pr)
|
||||
|
||||
return ret.Get(0).(*magistrala.AddPoliciesRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Authorize")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) error); ok {
|
||||
r0 = rf(ctx, pr)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
func (m *Service) DeletePolicy(ctx context.Context, in *magistrala.DeletePolicyReq, opts ...grpc.CallOption) (*magistrala.DeletePolicyRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// ChangeDomainStatus provides a mock function with given fields: ctx, token, id, d
|
||||
func (_m *Service) ChangeDomainStatus(ctx context.Context, token string, id string, d auth.DomainReq) (auth.Domain, error) {
|
||||
ret := _m.Called(ctx, token, id, d)
|
||||
|
||||
return ret.Get(0).(*magistrala.DeletePolicyRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ChangeDomainStatus")
|
||||
}
|
||||
|
||||
var r0 auth.Domain
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.DomainReq) (auth.Domain, error)); ok {
|
||||
return rf(ctx, token, id, d)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.DomainReq) auth.Domain); ok {
|
||||
r0 = rf(ctx, token, id, d)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.Domain)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, string, auth.DomainReq) error); ok {
|
||||
r1 = rf(ctx, token, id, d)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (m *Service) DeletePolicies(ctx context.Context, in *magistrala.DeletePoliciesReq, opts ...grpc.CallOption) (*magistrala.DeletePoliciesRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// CountObjects provides a mock function with given fields: ctx, pr
|
||||
func (_m *Service) CountObjects(ctx context.Context, pr auth.PolicyReq) (int, error) {
|
||||
ret := _m.Called(ctx, pr)
|
||||
|
||||
return ret.Get(0).(*magistrala.DeletePoliciesRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for CountObjects")
|
||||
}
|
||||
|
||||
var r0 int
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) (int, error)); ok {
|
||||
return rf(ctx, pr)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) int); ok {
|
||||
r0 = rf(ctx, pr)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, auth.PolicyReq) error); ok {
|
||||
r1 = rf(ctx, pr)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (m *Service) ListObjects(ctx context.Context, in *magistrala.ListObjectsReq, opts ...grpc.CallOption) (*magistrala.ListObjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// CountSubjects provides a mock function with given fields: ctx, pr
|
||||
func (_m *Service) CountSubjects(ctx context.Context, pr auth.PolicyReq) (int, error) {
|
||||
ret := _m.Called(ctx, pr)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListObjectsRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for CountSubjects")
|
||||
}
|
||||
|
||||
var r0 int
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) (int, error)); ok {
|
||||
return rf(ctx, pr)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) int); ok {
|
||||
r0 = rf(ctx, pr)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, auth.PolicyReq) error); ok {
|
||||
r1 = rf(ctx, pr)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (m *Service) ListAllObjects(ctx context.Context, in *magistrala.ListObjectsReq, opts ...grpc.CallOption) (*magistrala.ListObjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// CreateDomain provides a mock function with given fields: ctx, token, d
|
||||
func (_m *Service) CreateDomain(ctx context.Context, token string, d auth.Domain) (auth.Domain, error) {
|
||||
ret := _m.Called(ctx, token, d)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListObjectsRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for CreateDomain")
|
||||
}
|
||||
|
||||
var r0 auth.Domain
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, auth.Domain) (auth.Domain, error)); ok {
|
||||
return rf(ctx, token, d)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, auth.Domain) auth.Domain); ok {
|
||||
r0 = rf(ctx, token, d)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.Domain)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, auth.Domain) error); ok {
|
||||
r1 = rf(ctx, token, d)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (m *Service) CountObjects(ctx context.Context, in *magistrala.CountObjectsReq, opts ...grpc.CallOption) (*magistrala.CountObjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// DeletePolicies provides a mock function with given fields: ctx, prs
|
||||
func (_m *Service) DeletePolicies(ctx context.Context, prs []auth.PolicyReq) error {
|
||||
ret := _m.Called(ctx, prs)
|
||||
|
||||
return ret.Get(0).(*magistrala.CountObjectsRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeletePolicies")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []auth.PolicyReq) error); ok {
|
||||
r0 = rf(ctx, prs)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
func (m *Service) ListSubjects(ctx context.Context, in *magistrala.ListSubjectsReq, opts ...grpc.CallOption) (*magistrala.ListSubjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// DeletePolicy provides a mock function with given fields: ctx, pr
|
||||
func (_m *Service) DeletePolicy(ctx context.Context, pr auth.PolicyReq) error {
|
||||
ret := _m.Called(ctx, pr)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListSubjectsRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeletePolicy")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) error); ok {
|
||||
r0 = rf(ctx, pr)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
func (m *Service) ListAllSubjects(ctx context.Context, in *magistrala.ListSubjectsReq, opts ...grpc.CallOption) (*magistrala.ListSubjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// Identify provides a mock function with given fields: ctx, token
|
||||
func (_m *Service) Identify(ctx context.Context, token string) (auth.Key, error) {
|
||||
ret := _m.Called(ctx, token)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListSubjectsRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Identify")
|
||||
}
|
||||
|
||||
var r0 auth.Key
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) (auth.Key, error)); ok {
|
||||
return rf(ctx, token)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) auth.Key); ok {
|
||||
r0 = rf(ctx, token)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.Key)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, token)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (m *Service) CountSubjects(ctx context.Context, in *magistrala.CountSubjectsReq, opts ...grpc.CallOption) (*magistrala.CountSubjectsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// Issue provides a mock function with given fields: ctx, token, key
|
||||
func (_m *Service) Issue(ctx context.Context, token string, key auth.Key) (auth.Token, error) {
|
||||
ret := _m.Called(ctx, token, key)
|
||||
|
||||
return ret.Get(0).(*magistrala.CountSubjectsRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Issue")
|
||||
}
|
||||
|
||||
var r0 auth.Token
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, auth.Key) (auth.Token, error)); ok {
|
||||
return rf(ctx, token, key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, auth.Key) auth.Token); ok {
|
||||
r0 = rf(ctx, token, key)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.Token)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, auth.Key) error); ok {
|
||||
r1 = rf(ctx, token, key)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (m *Service) ListPermissions(ctx context.Context, in *magistrala.ListPermissionsReq, opts ...grpc.CallOption) (*magistrala.ListPermissionsRes, error) {
|
||||
ret := m.Called(ctx, in)
|
||||
// ListAllObjects provides a mock function with given fields: ctx, pr
|
||||
func (_m *Service) ListAllObjects(ctx context.Context, pr auth.PolicyReq) (auth.PolicyPage, error) {
|
||||
ret := _m.Called(ctx, pr)
|
||||
|
||||
return ret.Get(0).(*magistrala.ListPermissionsRes), ret.Error(1)
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListAllObjects")
|
||||
}
|
||||
|
||||
var r0 auth.PolicyPage
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) (auth.PolicyPage, error)); ok {
|
||||
return rf(ctx, pr)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) auth.PolicyPage); ok {
|
||||
r0 = rf(ctx, pr)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.PolicyPage)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, auth.PolicyReq) error); ok {
|
||||
r1 = rf(ctx, pr)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ListAllSubjects provides a mock function with given fields: ctx, pr
|
||||
func (_m *Service) ListAllSubjects(ctx context.Context, pr auth.PolicyReq) (auth.PolicyPage, error) {
|
||||
ret := _m.Called(ctx, pr)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListAllSubjects")
|
||||
}
|
||||
|
||||
var r0 auth.PolicyPage
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) (auth.PolicyPage, error)); ok {
|
||||
return rf(ctx, pr)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq) auth.PolicyPage); ok {
|
||||
r0 = rf(ctx, pr)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.PolicyPage)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, auth.PolicyReq) error); ok {
|
||||
r1 = rf(ctx, pr)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ListDomains provides a mock function with given fields: ctx, token, page
|
||||
func (_m *Service) ListDomains(ctx context.Context, token string, page auth.Page) (auth.DomainsPage, error) {
|
||||
ret := _m.Called(ctx, token, page)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListDomains")
|
||||
}
|
||||
|
||||
var r0 auth.DomainsPage
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, auth.Page) (auth.DomainsPage, error)); ok {
|
||||
return rf(ctx, token, page)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, auth.Page) auth.DomainsPage); ok {
|
||||
r0 = rf(ctx, token, page)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.DomainsPage)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, auth.Page) error); ok {
|
||||
r1 = rf(ctx, token, page)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ListObjects provides a mock function with given fields: ctx, pr, nextPageToken, limit
|
||||
func (_m *Service) ListObjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) (auth.PolicyPage, error) {
|
||||
ret := _m.Called(ctx, pr, nextPageToken, limit)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListObjects")
|
||||
}
|
||||
|
||||
var r0 auth.PolicyPage
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq, string, int32) (auth.PolicyPage, error)); ok {
|
||||
return rf(ctx, pr, nextPageToken, limit)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq, string, int32) auth.PolicyPage); ok {
|
||||
r0 = rf(ctx, pr, nextPageToken, limit)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.PolicyPage)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, auth.PolicyReq, string, int32) error); ok {
|
||||
r1 = rf(ctx, pr, nextPageToken, limit)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ListPermissions provides a mock function with given fields: ctx, pr, filterPermission
|
||||
func (_m *Service) ListPermissions(ctx context.Context, pr auth.PolicyReq, filterPermission []string) (auth.Permissions, error) {
|
||||
ret := _m.Called(ctx, pr, filterPermission)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListPermissions")
|
||||
}
|
||||
|
||||
var r0 auth.Permissions
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq, []string) (auth.Permissions, error)); ok {
|
||||
return rf(ctx, pr, filterPermission)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq, []string) auth.Permissions); ok {
|
||||
r0 = rf(ctx, pr, filterPermission)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(auth.Permissions)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, auth.PolicyReq, []string) error); ok {
|
||||
r1 = rf(ctx, pr, filterPermission)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ListSubjects provides a mock function with given fields: ctx, pr, nextPageToken, limit
|
||||
func (_m *Service) ListSubjects(ctx context.Context, pr auth.PolicyReq, nextPageToken string, limit int32) (auth.PolicyPage, error) {
|
||||
ret := _m.Called(ctx, pr, nextPageToken, limit)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListSubjects")
|
||||
}
|
||||
|
||||
var r0 auth.PolicyPage
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq, string, int32) (auth.PolicyPage, error)); ok {
|
||||
return rf(ctx, pr, nextPageToken, limit)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, auth.PolicyReq, string, int32) auth.PolicyPage); ok {
|
||||
r0 = rf(ctx, pr, nextPageToken, limit)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.PolicyPage)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, auth.PolicyReq, string, int32) error); ok {
|
||||
r1 = rf(ctx, pr, nextPageToken, limit)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// ListUserDomains provides a mock function with given fields: ctx, token, userID, page
|
||||
func (_m *Service) ListUserDomains(ctx context.Context, token string, userID string, page auth.Page) (auth.DomainsPage, error) {
|
||||
ret := _m.Called(ctx, token, userID, page)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListUserDomains")
|
||||
}
|
||||
|
||||
var r0 auth.DomainsPage
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.Page) (auth.DomainsPage, error)); ok {
|
||||
return rf(ctx, token, userID, page)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.Page) auth.DomainsPage); ok {
|
||||
r0 = rf(ctx, token, userID, page)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.DomainsPage)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, string, auth.Page) error); ok {
|
||||
r1 = rf(ctx, token, userID, page)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// RetrieveDomain provides a mock function with given fields: ctx, token, id
|
||||
func (_m *Service) RetrieveDomain(ctx context.Context, token string, id string) (auth.Domain, error) {
|
||||
ret := _m.Called(ctx, token, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for RetrieveDomain")
|
||||
}
|
||||
|
||||
var r0 auth.Domain
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) (auth.Domain, error)); ok {
|
||||
return rf(ctx, token, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) auth.Domain); ok {
|
||||
r0 = rf(ctx, token, id)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.Domain)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
|
||||
r1 = rf(ctx, token, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// RetrieveDomainPermissions provides a mock function with given fields: ctx, token, id
|
||||
func (_m *Service) RetrieveDomainPermissions(ctx context.Context, token string, id string) (auth.Permissions, error) {
|
||||
ret := _m.Called(ctx, token, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for RetrieveDomainPermissions")
|
||||
}
|
||||
|
||||
var r0 auth.Permissions
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) (auth.Permissions, error)); ok {
|
||||
return rf(ctx, token, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) auth.Permissions); ok {
|
||||
r0 = rf(ctx, token, id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(auth.Permissions)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
|
||||
r1 = rf(ctx, token, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// RetrieveKey provides a mock function with given fields: ctx, token, id
|
||||
func (_m *Service) RetrieveKey(ctx context.Context, token string, id string) (auth.Key, error) {
|
||||
ret := _m.Called(ctx, token, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for RetrieveKey")
|
||||
}
|
||||
|
||||
var r0 auth.Key
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) (auth.Key, error)); ok {
|
||||
return rf(ctx, token, id)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) auth.Key); ok {
|
||||
r0 = rf(ctx, token, id)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.Key)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
|
||||
r1 = rf(ctx, token, id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// Revoke provides a mock function with given fields: ctx, token, id
|
||||
func (_m *Service) Revoke(ctx context.Context, token string, id string) error {
|
||||
ret := _m.Called(ctx, token, id)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Revoke")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
|
||||
r0 = rf(ctx, token, id)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UnassignUsers provides a mock function with given fields: ctx, token, id, userIds, relation
|
||||
func (_m *Service) UnassignUsers(ctx context.Context, token string, id string, userIds []string, relation string) error {
|
||||
ret := _m.Called(ctx, token, id, userIds, relation)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UnassignUsers")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, []string, string) error); ok {
|
||||
r0 = rf(ctx, token, id, userIds, relation)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateDomain provides a mock function with given fields: ctx, token, id, d
|
||||
func (_m *Service) UpdateDomain(ctx context.Context, token string, id string, d auth.DomainReq) (auth.Domain, error) {
|
||||
ret := _m.Called(ctx, token, id, d)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UpdateDomain")
|
||||
}
|
||||
|
||||
var r0 auth.Domain
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.DomainReq) (auth.Domain, error)); ok {
|
||||
return rf(ctx, token, id, d)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.DomainReq) auth.Domain); ok {
|
||||
r0 = rf(ctx, token, id, d)
|
||||
} else {
|
||||
r0 = ret.Get(0).(auth.Domain)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, string, auth.DomainReq) error); ok {
|
||||
r1 = rf(ctx, token, id, d)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// NewService creates a new instance of Service. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewService(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Service {
|
||||
mock := &Service{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
+24
-29
@@ -40,7 +40,7 @@ func (repo domainRepo) Save(ctx context.Context, d auth.Domain) (ad auth.Domain,
|
||||
VALUES (:id, :name, :tags, :alias, :metadata, :created_at, :updated_at, :updated_by, :created_by, :status)
|
||||
RETURNING id, name, tags, alias, metadata, created_at, updated_at, updated_by, created_by, status;`
|
||||
|
||||
dbd, err := toDBDomains(d)
|
||||
dbd, err := toDBDomain(d)
|
||||
if err != nil {
|
||||
return auth.Domain{}, errors.Wrap(repoerr.ErrCreateEntity, repoerr.ErrRollbackTx)
|
||||
}
|
||||
@@ -74,22 +74,26 @@ func (repo domainRepo) RetrieveByID(ctx context.Context, id string) (auth.Domain
|
||||
ID: id,
|
||||
}
|
||||
|
||||
row, err := repo.db.NamedQueryContext(ctx, q, dbdp)
|
||||
rows, err := repo.db.NamedQueryContext(ctx, q, dbdp)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return auth.Domain{}, errors.Wrap(errors.ErrNotFound, err)
|
||||
}
|
||||
return auth.Domain{}, errors.Wrap(errors.ErrViewEntity, err)
|
||||
return auth.Domain{}, postgres.HandleError(repoerr.ErrViewEntity, err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
defer row.Close()
|
||||
row.Next()
|
||||
dbd := dbDomain{}
|
||||
if err := row.StructScan(&dbd); err != nil {
|
||||
return auth.Domain{}, errors.Wrap(errors.ErrNotFound, err)
|
||||
}
|
||||
if rows.Next() {
|
||||
if err = rows.StructScan(&dbd); err != nil {
|
||||
return auth.Domain{}, postgres.HandleError(repoerr.ErrViewEntity, err)
|
||||
}
|
||||
|
||||
return toDomain(dbd)
|
||||
domain, err := toDomain(dbd)
|
||||
if err != nil {
|
||||
return auth.Domain{}, errors.Wrap(repoerr.ErrFailedOpDB, err)
|
||||
}
|
||||
|
||||
return domain, nil
|
||||
}
|
||||
return auth.Domain{}, repoerr.ErrNotFound
|
||||
}
|
||||
|
||||
func (repo domainRepo) RetrievePermissions(ctx context.Context, subject, id string) ([]string, error) {
|
||||
@@ -131,9 +135,6 @@ func (repo domainRepo) RetrieveAllByIDs(ctx context.Context, pm auth.Page) (auth
|
||||
if err != nil {
|
||||
return auth.DomainsPage{}, errors.Wrap(repoerr.ErrFailedOpDB, err)
|
||||
}
|
||||
if query == "" {
|
||||
return auth.DomainsPage{}, nil
|
||||
}
|
||||
|
||||
q = `SELECT d.id as id, d.name as name, d.tags as tags, d.alias as alias, d.metadata as metadata, d.created_at as created_at, d.updated_at as updated_at, d.updated_by as updated_by, d.created_by as created_by, d.status as status
|
||||
FROM domains d`
|
||||
@@ -179,9 +180,6 @@ func (repo domainRepo) ListDomains(ctx context.Context, pm auth.Page) (auth.Doma
|
||||
if err != nil {
|
||||
return auth.DomainsPage{}, errors.Wrap(repoerr.ErrFailedOpDB, err)
|
||||
}
|
||||
if query == "" {
|
||||
return auth.DomainsPage{}, nil
|
||||
}
|
||||
|
||||
q = `SELECT d.id as id, d.name as name, d.tags as tags, d.alias as alias, d.metadata as metadata, d.created_at as created_at, d.updated_at as updated_at, d.updated_by as updated_by, d.created_by as created_by, d.status as status, pc.relation as relation
|
||||
FROM domains as d
|
||||
@@ -269,7 +267,7 @@ func (repo domainRepo) Update(ctx context.Context, id, userID string, dr auth.Do
|
||||
RETURNING id, name, tags, alias, metadata, created_at, updated_at, updated_by, created_by, status;`,
|
||||
upq, ws)
|
||||
|
||||
dbd, err := toDBDomains(d)
|
||||
dbd, err := toDBDomain(d)
|
||||
if err != nil {
|
||||
return auth.Domain{}, errors.Wrap(errors.ErrUpdateEntity, err)
|
||||
}
|
||||
@@ -295,18 +293,15 @@ func (repo domainRepo) Update(ctx context.Context, id, userID string, dr auth.Do
|
||||
|
||||
// Delete delete domain from database.
|
||||
func (repo domainRepo) Delete(ctx context.Context, id string) error {
|
||||
q := fmt.Sprintf(`
|
||||
DELETE FROM
|
||||
domains
|
||||
WHERE
|
||||
id = '%s'
|
||||
;`, id)
|
||||
q := "DELETE FROM domains WHERE id = $1;"
|
||||
|
||||
row, err := repo.db.NamedQueryContext(ctx, q, nil)
|
||||
res, err := repo.db.ExecContext(ctx, q, id)
|
||||
if err != nil {
|
||||
return postgres.HandleError(repoerr.ErrRemoveEntity, err)
|
||||
}
|
||||
defer row.Close()
|
||||
if rows, _ := res.RowsAffected(); rows == 0 {
|
||||
return repoerr.ErrNotFound
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -349,7 +344,7 @@ func (repo domainRepo) CheckPolicy(ctx context.Context, pc auth.Policy) error {
|
||||
defer row.Close()
|
||||
row.Next()
|
||||
if err := row.StructScan(&dbpc); err != nil {
|
||||
return err
|
||||
return errors.Wrap(repoerr.ErrNotFound, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -421,7 +416,7 @@ type dbDomain struct {
|
||||
UpdatedAt sql.NullTime `db:"updated_at,omitempty"`
|
||||
}
|
||||
|
||||
func toDBDomains(d auth.Domain) (dbDomain, error) {
|
||||
func toDBDomain(d auth.Domain) (dbDomain, error) {
|
||||
data := []byte("{}")
|
||||
if len(d.Metadata) > 0 {
|
||||
b, err := json.Marshal(d.Metadata)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+7
-2
@@ -39,6 +39,9 @@ var (
|
||||
// ErrFailedToRetrieveChildren failed to retrieve groups.
|
||||
ErrFailedToRetrieveChildren = errors.New("failed to retrieve all groups")
|
||||
|
||||
// ErrExpiry indicates that the token is expired.
|
||||
ErrExpiry = errors.New("token is expired")
|
||||
|
||||
errIssueUser = errors.New("failed to issue new login key")
|
||||
errIssueTmp = errors.New("failed to issue new temporary key")
|
||||
errRevoke = errors.New("failed to remove key")
|
||||
@@ -76,6 +79,8 @@ type Authn interface {
|
||||
// implementation, and all of its decorators (e.g. logging & metrics).
|
||||
// Token is a string value of the actual Key and is used to authenticate
|
||||
// an Auth service request.
|
||||
|
||||
//go:generate mockery --name Service --output=./mocks --filename service.go --quiet --note "Copyright (c) Abstract Machines"
|
||||
type Service interface {
|
||||
Authn
|
||||
Authz
|
||||
@@ -151,9 +156,9 @@ func (svc service) RetrieveKey(ctx context.Context, token, id string) (Key, erro
|
||||
|
||||
func (svc service) Identify(ctx context.Context, token string) (Key, error) {
|
||||
key, err := svc.tokenizer.Parse(token)
|
||||
if err == ErrAPIKeyExpired {
|
||||
if errors.Contains(err, ErrExpiry) {
|
||||
err = svc.keys.Remove(ctx, key.Issuer, key.ID)
|
||||
return Key{}, errors.Wrap(ErrAPIKeyExpired, err)
|
||||
return Key{}, errors.Wrap(ErrKeyExpired, err)
|
||||
}
|
||||
if err != nil {
|
||||
return Key{}, errors.Wrap(svcerr.ErrAuthentication, errors.Wrap(errIdentify, err))
|
||||
|
||||
+2404
-80
File diff suppressed because it is too large
Load Diff
@@ -176,9 +176,9 @@ func dec(in []byte) ([]byte, error) {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
func newService() (bootstrap.Service, *authmocks.Service, *sdkmocks.SDK) {
|
||||
func newService() (bootstrap.Service, *authmocks.AuthClient, *sdkmocks.SDK) {
|
||||
things := mocks.NewConfigsRepository()
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
sdk := new(sdkmocks.SDK)
|
||||
|
||||
return bootstrap.New(auth, things, sdk, encKey), auth, sdk
|
||||
@@ -720,7 +720,7 @@ func TestUpdateConnections(t *testing.T) {
|
||||
repoCall1 := sdk.On("Thing", mock.Anything, mock.Anything).Return(mgsdk.Thing{ID: c.ThingID, Credentials: mgsdk.Credentials{Secret: c.ThingKey}}, nil)
|
||||
repoCall2 := sdk.On("Channel", mock.Anything, mock.Anything).Return(mgsdk.Channel{}, nil)
|
||||
repoCall3 := auth.On("DeletePolicy", mock.Anything, mock.Anything).Return(&magistrala.DeletePolicyRes{Deleted: true}, nil)
|
||||
repoCall4 := auth.On("AddPolicy", mock.Anything, mock.Anything).Return(&magistrala.AddPolicyRes{Authorized: true}, nil)
|
||||
repoCall4 := auth.On("AddPolicy", mock.Anything, mock.Anything).Return(&magistrala.AddPolicyRes{Added: true}, nil)
|
||||
req := testRequest{
|
||||
client: bs.Client(),
|
||||
method: http.MethodPut,
|
||||
|
||||
@@ -77,9 +77,9 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func newService(t *testing.T, url string) (bootstrap.Service, *authmocks.Service, *sdkmocks.SDK) {
|
||||
func newService(t *testing.T, url string) (bootstrap.Service, *authmocks.AuthClient, *sdkmocks.SDK) {
|
||||
things := mocks.NewConfigsRepository()
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
sdk := new(sdkmocks.SDK)
|
||||
|
||||
svc := bootstrap.New(auth, things, sdk, encKey)
|
||||
|
||||
@@ -56,9 +56,9 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func newService() (bootstrap.Service, *authmocks.Service, *sdkmocks.SDK) {
|
||||
func newService() (bootstrap.Service, *authmocks.AuthClient, *sdkmocks.SDK) {
|
||||
things := mocks.NewConfigsRepository()
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
sdk := new(sdkmocks.SDK)
|
||||
|
||||
return bootstrap.New(auth, things, sdk, encKey), auth, sdk
|
||||
|
||||
@@ -42,8 +42,8 @@ const (
|
||||
instanceID = "5de9b29a-feb9-11ed-be56-0242ac120002"
|
||||
)
|
||||
|
||||
func newService(t *testing.T) (certs.Service, *authmocks.Service, *sdkmocks.SDK) {
|
||||
auth := new(authmocks.Service)
|
||||
func newService(t *testing.T) (certs.Service, *authmocks.AuthClient, *sdkmocks.SDK) {
|
||||
auth := new(authmocks.AuthClient)
|
||||
|
||||
sdk := new(sdkmocks.SDK)
|
||||
repo := mocks.NewCertsRepository()
|
||||
|
||||
+1
-1
@@ -297,7 +297,7 @@ func createAdminPolicy(ctx context.Context, clientID string, authClient magistra
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !addPolicyRes.Authorized {
|
||||
if !addPolicyRes.Added {
|
||||
return errors.ErrAuthorization
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ func (tr testRequest) make() (*http.Response, error) {
|
||||
return tr.client.Do(req)
|
||||
}
|
||||
|
||||
func newService() (notifiers.Service, *authmocks.Service) {
|
||||
auth := new(authmocks.Service)
|
||||
func newService() (notifiers.Service, *authmocks.AuthClient) {
|
||||
auth := new(authmocks.AuthClient)
|
||||
repo := mocks.NewRepo(make(map[string]notifiers.Subscription))
|
||||
idp := uuid.NewMock()
|
||||
notif := mocks.NewNotifier()
|
||||
|
||||
@@ -29,9 +29,9 @@ const (
|
||||
validID = "d4ebb847-5d0e-4e46-bdd9-b6aceaaa3a22"
|
||||
)
|
||||
|
||||
func newService() (notifiers.Service, *authmocks.Service) {
|
||||
func newService() (notifiers.Service, *authmocks.AuthClient) {
|
||||
repo := mocks.NewRepo(make(map[string]notifiers.Subscription))
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
notifier := mocks.NewNotifier()
|
||||
idp := uuid.NewMock()
|
||||
from := "exampleFrom"
|
||||
|
||||
@@ -73,7 +73,7 @@ func (tr testRequest) make() (*http.Response, error) {
|
||||
}
|
||||
|
||||
func TestPublish(t *testing.T) {
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
chanID := "1"
|
||||
ctSenmlJSON := "application/senml+json"
|
||||
ctSenmlCBOR := "application/senml+cbor"
|
||||
|
||||
@@ -47,7 +47,7 @@ var (
|
||||
|
||||
func TestCreateGroup(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -88,7 +88,7 @@ func TestCreateGroup(t *testing.T) {
|
||||
Owner: testsutil.GenerateUUID(t),
|
||||
},
|
||||
addPolResp: &magistrala.AddPoliciesRes{
|
||||
Authorized: true,
|
||||
Added: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -183,7 +183,7 @@ func TestCreateGroup(t *testing.T) {
|
||||
Parent: testsutil.GenerateUUID(t),
|
||||
},
|
||||
addPolResp: &magistrala.AddPoliciesRes{
|
||||
Authorized: true,
|
||||
Added: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -210,7 +210,7 @@ func TestCreateGroup(t *testing.T) {
|
||||
Parent: testsutil.GenerateUUID(t),
|
||||
},
|
||||
addPolResp: &magistrala.AddPoliciesRes{
|
||||
Authorized: true,
|
||||
Added: true,
|
||||
},
|
||||
err: errors.ErrAuthorization,
|
||||
},
|
||||
@@ -299,7 +299,7 @@ func TestCreateGroup(t *testing.T) {
|
||||
|
||||
func TestViewGroup(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -367,7 +367,7 @@ func TestViewGroup(t *testing.T) {
|
||||
|
||||
func TestViewGroupPerms(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -451,7 +451,7 @@ func TestViewGroupPerms(t *testing.T) {
|
||||
|
||||
func TestUpdateGroup(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -528,7 +528,7 @@ func TestUpdateGroup(t *testing.T) {
|
||||
|
||||
func TestEnableGroup(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -628,7 +628,7 @@ func TestEnableGroup(t *testing.T) {
|
||||
|
||||
func TestDisableGroup(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -728,7 +728,7 @@ func TestDisableGroup(t *testing.T) {
|
||||
|
||||
func TestListMembers(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -864,7 +864,7 @@ func TestListMembers(t *testing.T) {
|
||||
|
||||
func TestListGroups(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -1616,7 +1616,7 @@ func TestListGroups(t *testing.T) {
|
||||
|
||||
func TestAssign(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -1656,7 +1656,7 @@ func TestAssign(t *testing.T) {
|
||||
Authorized: true,
|
||||
},
|
||||
addPoliciesRes: &magistrala.AddPoliciesRes{
|
||||
Authorized: true,
|
||||
Added: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1674,7 +1674,7 @@ func TestAssign(t *testing.T) {
|
||||
Authorized: true,
|
||||
},
|
||||
addPoliciesRes: &magistrala.AddPoliciesRes{
|
||||
Authorized: true,
|
||||
Added: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1699,7 +1699,7 @@ func TestAssign(t *testing.T) {
|
||||
},
|
||||
},
|
||||
addPoliciesRes: &magistrala.AddPoliciesRes{
|
||||
Authorized: true,
|
||||
Added: true,
|
||||
},
|
||||
repoParentGroupErr: nil,
|
||||
},
|
||||
@@ -1718,7 +1718,7 @@ func TestAssign(t *testing.T) {
|
||||
Authorized: true,
|
||||
},
|
||||
addPoliciesRes: &magistrala.AddPoliciesRes{
|
||||
Authorized: true,
|
||||
Added: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1804,7 +1804,7 @@ func TestAssign(t *testing.T) {
|
||||
},
|
||||
},
|
||||
addPoliciesRes: &magistrala.AddPoliciesRes{
|
||||
Authorized: false,
|
||||
Added: false,
|
||||
},
|
||||
addPoliciesErr: errors.ErrAuthorization,
|
||||
err: errors.ErrAuthorization,
|
||||
@@ -1831,7 +1831,7 @@ func TestAssign(t *testing.T) {
|
||||
},
|
||||
},
|
||||
addPoliciesRes: &magistrala.AddPoliciesRes{
|
||||
Authorized: true,
|
||||
Added: true,
|
||||
},
|
||||
repoParentGroupErr: errors.ErrConflict,
|
||||
err: errors.ErrConflict,
|
||||
@@ -1858,7 +1858,7 @@ func TestAssign(t *testing.T) {
|
||||
},
|
||||
},
|
||||
addPoliciesRes: &magistrala.AddPoliciesRes{
|
||||
Authorized: true,
|
||||
Added: true,
|
||||
},
|
||||
deleteParentPoliciesRes: &magistrala.DeletePoliciesRes{
|
||||
Deleted: false,
|
||||
@@ -1926,7 +1926,7 @@ func TestAssign(t *testing.T) {
|
||||
Authorized: true,
|
||||
},
|
||||
addPoliciesRes: &magistrala.AddPoliciesRes{
|
||||
Authorized: false,
|
||||
Added: false,
|
||||
},
|
||||
addPoliciesErr: errors.ErrAuthorization,
|
||||
err: errors.ErrAuthorization,
|
||||
@@ -2025,7 +2025,7 @@ func TestAssign(t *testing.T) {
|
||||
|
||||
func TestUnassign(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
@@ -2271,7 +2271,7 @@ func TestUnassign(t *testing.T) {
|
||||
},
|
||||
repoParentGroupErr: errors.ErrConflict,
|
||||
addParentPoliciesRes: &magistrala.AddPoliciesRes{
|
||||
Authorized: false,
|
||||
Added: false,
|
||||
},
|
||||
addParentPoliciesErr: errors.ErrAuthorization,
|
||||
err: errors.ErrConflict,
|
||||
@@ -2434,7 +2434,7 @@ func TestUnassign(t *testing.T) {
|
||||
|
||||
func TestDeleteGroup(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := groups.NewService(repo, idProvider, authsvc)
|
||||
|
||||
cases := []struct {
|
||||
|
||||
@@ -32,7 +32,7 @@ var (
|
||||
|
||||
func TestSendInvitation(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := invitations.NewService(repo, authsvc, nil)
|
||||
|
||||
cases := []struct {
|
||||
@@ -187,7 +187,7 @@ func TestSendInvitation(t *testing.T) {
|
||||
|
||||
func TestViewInvitation(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := invitations.NewService(repo, authsvc, nil)
|
||||
|
||||
validInvitation := invitations.Invitation{
|
||||
@@ -364,7 +364,7 @@ func TestViewInvitation(t *testing.T) {
|
||||
|
||||
func TestListInvitations(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := invitations.NewService(repo, authsvc, nil)
|
||||
|
||||
validPage := invitations.Page{
|
||||
@@ -542,7 +542,7 @@ func TestListInvitations(t *testing.T) {
|
||||
|
||||
func TestAcceptInvitation(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := invitations.NewService(repo, authsvc, nil)
|
||||
|
||||
userID := testsutil.GenerateUUID(t)
|
||||
@@ -615,7 +615,7 @@ func TestAcceptInvitation(t *testing.T) {
|
||||
|
||||
func TestDeleteInvitation(t *testing.T) {
|
||||
repo := new(mocks.Repository)
|
||||
authsvc := new(authmocks.Service)
|
||||
authsvc := new(authmocks.AuthClient)
|
||||
svc := invitations.NewService(repo, authsvc, nil)
|
||||
|
||||
cases := []struct {
|
||||
|
||||
@@ -441,12 +441,12 @@ func TestDisconnect(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func newHandler() (session.Handler, *authmocks.Service) {
|
||||
func newHandler() (session.Handler, *authmocks.AuthClient) {
|
||||
logger, err := mglog.New(&logBuffer, "debug")
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create logger: %s", err)
|
||||
}
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
eventStore := mocks.NewEventStore()
|
||||
return mqtt.NewHandler(mocks.NewPublisher(), eventStore, logger, auth), auth
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ var (
|
||||
cfgSignHoursValid = "24h"
|
||||
)
|
||||
|
||||
func setupCerts() (*httptest.Server, *authmocks.Service, *thmocks.Repository, error) {
|
||||
func setupCerts() (*httptest.Server, *authmocks.AuthClient, *thmocks.Repository, error) {
|
||||
server, trepo, _, auth, _ := setupThings()
|
||||
config := sdk.Config{
|
||||
ThingsURL: server.URL,
|
||||
|
||||
@@ -32,12 +32,12 @@ import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
func setupChannels() (*httptest.Server, *mocks.Repository, *authmocks.Service) {
|
||||
func setupChannels() (*httptest.Server, *mocks.Repository, *authmocks.AuthClient) {
|
||||
cRepo := new(thmocks.Repository)
|
||||
grepo := new(mocks.Repository)
|
||||
thingCache := new(thmocks.Cache)
|
||||
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
csvc := things.NewService(auth, cRepo, grepo, thingCache, idProvider)
|
||||
gsvc := groups.NewService(grepo, idProvider, auth)
|
||||
|
||||
@@ -148,7 +148,7 @@ func TestCreateChannel(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
repoCall := auth.On("Identify", mock.Anything, &magistrala.IdentityReq{Token: tc.token}).Return(&magistrala.IdentityRes{Id: validID, DomainId: testsutil.GenerateUUID(t)}, nil)
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Authorized: true}, nil)
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Added: true}, nil)
|
||||
repoCall2 := auth.On("Authorize", mock.Anything, mock.Anything).Return(&magistrala.AuthorizeRes{Authorized: true}, nil)
|
||||
repoCall3 := grepo.On("Save", mock.Anything, mock.Anything).Return(convertChannel(sdk.Channel{}), tc.err)
|
||||
rChannel, err := mgsdk.CreateChannel(tc.channel, validToken)
|
||||
|
||||
@@ -34,9 +34,9 @@ var (
|
||||
exampleUser1 = "email1@example.com"
|
||||
)
|
||||
|
||||
func setupSubscriptions() (*httptest.Server, *authmocks.Service) {
|
||||
func setupSubscriptions() (*httptest.Server, *authmocks.AuthClient) {
|
||||
repo := mocks.NewRepo(make(map[string]notifiers.Subscription))
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
notifier := mocks.NewNotifier()
|
||||
idp := uuid.NewMock()
|
||||
from := "exampleFrom"
|
||||
|
||||
@@ -30,11 +30,11 @@ import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
func setupGroups() (*httptest.Server, *mocks.Repository, *authmocks.Service) {
|
||||
func setupGroups() (*httptest.Server, *mocks.Repository, *authmocks.AuthClient) {
|
||||
crepo := new(umocks.Repository)
|
||||
grepo := new(mocks.Repository)
|
||||
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
csvc := users.NewService(crepo, auth, emailer, phasher, idProvider, passRegex, true)
|
||||
gsvc := groups.NewService(grepo, idProvider, auth)
|
||||
|
||||
@@ -146,7 +146,7 @@ func TestCreateGroup(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
repoCall := auth.On("Identify", mock.Anything, &magistrala.IdentityReq{Token: tc.token}).Return(&magistrala.IdentityRes{Id: validID, DomainId: testsutil.GenerateUUID(t)}, nil)
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Authorized: true}, nil)
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Added: true}, nil)
|
||||
repoCall2 := auth.On("Authorize", mock.Anything, mock.Anything).Return(&magistrala.AuthorizeRes{Authorized: true}, nil)
|
||||
repoCall3 := grepo.On("Save", mock.Anything, mock.Anything).Return(convertGroup(sdk.Group{}), tc.err)
|
||||
rGroup, err := mgsdk.CreateGroup(tc.group, tc.token)
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
func setupMessages() (*httptest.Server, *authmocks.Service) {
|
||||
auth := new(authmocks.Service)
|
||||
func setupMessages() (*httptest.Server, *authmocks.AuthClient) {
|
||||
auth := new(authmocks.AuthClient)
|
||||
pub := mocks.NewPublisher()
|
||||
handler := adapter.NewHandler(pub, mglog.NewMock(), auth)
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
func setupThings() (*httptest.Server, *mocks.Repository, *gmocks.Repository, *authmocks.Service, *mocks.Cache) {
|
||||
func setupThings() (*httptest.Server, *mocks.Repository, *gmocks.Repository, *authmocks.AuthClient, *mocks.Cache) {
|
||||
cRepo := new(mocks.Repository)
|
||||
gRepo := new(gmocks.Repository)
|
||||
thingCache := new(mocks.Cache)
|
||||
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
csvc := things.NewService(auth, cRepo, gRepo, thingCache, idProvider)
|
||||
gsvc := groups.NewService(gRepo, idProvider, auth)
|
||||
|
||||
@@ -46,12 +46,12 @@ func setupThings() (*httptest.Server, *mocks.Repository, *gmocks.Repository, *au
|
||||
return httptest.NewServer(mux), cRepo, gRepo, auth, thingCache
|
||||
}
|
||||
|
||||
func setupThingsMinimal() (*httptest.Server, *authmocks.Service) {
|
||||
func setupThingsMinimal() (*httptest.Server, *authmocks.AuthClient) {
|
||||
cRepo := new(mocks.Repository)
|
||||
gRepo := new(gmocks.Repository)
|
||||
thingCache := new(mocks.Cache)
|
||||
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
csvc := things.NewService(auth, cRepo, gRepo, thingCache, idProvider)
|
||||
gsvc := groups.NewService(gRepo, idProvider, auth)
|
||||
|
||||
@@ -187,7 +187,7 @@ func TestCreateThing(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
repoCall := auth.On("Identify", mock.Anything, &magistrala.IdentityReq{Token: tc.token}).Return(&magistrala.IdentityRes{Id: validID, DomainId: testsutil.GenerateUUID(t)}, nil)
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Authorized: true}, nil)
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Added: true}, nil)
|
||||
repoCall2 := auth.On("Authorize", mock.Anything, mock.Anything).Return(&magistrala.AuthorizeRes{Authorized: true}, nil)
|
||||
repoCall3 := cRepo.On("Save", mock.Anything, mock.Anything).Return(convertThings(tc.response), tc.repoErr)
|
||||
rThing, err := mgsdk.CreateThing(tc.client, tc.token)
|
||||
@@ -275,7 +275,7 @@ func TestCreateThings(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
repoCall := auth.On("Identify", mock.Anything, &magistrala.IdentityReq{Token: tc.token}).Return(&magistrala.IdentityRes{Id: validID, DomainId: testsutil.GenerateUUID(t)}, nil)
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Authorized: true}, nil)
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Added: true}, nil)
|
||||
repoCall2 := auth.On("Authorize", mock.Anything, mock.Anything).Return(&magistrala.AuthorizeRes{Authorized: true}, nil)
|
||||
repoCall3 := cRepo.On("Save", mock.Anything, mock.Anything).Return(convertThings(tc.response...), tc.err)
|
||||
if len(tc.things) > 0 {
|
||||
@@ -1263,11 +1263,11 @@ func TestShareThing(t *testing.T) {
|
||||
for _, tc := range cases {
|
||||
repoCall := auth.On("Identify", mock.Anything, &magistrala.IdentityReq{Token: tc.token}).Return(&magistrala.IdentityRes{Id: validID, DomainId: testsutil.GenerateUUID(t)}, nil)
|
||||
repoCall1 := auth.On("Authorize", mock.Anything, mock.Anything).Return(&magistrala.AuthorizeRes{Authorized: true}, tc.repoErr)
|
||||
repoCall2 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Authorized: true}, nil)
|
||||
repoCall2 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Added: true}, nil)
|
||||
if tc.token != validToken {
|
||||
repoCall1 = auth.On("Authorize", mock.Anything, mock.Anything).Return(&magistrala.AuthorizeRes{Authorized: false}, errors.ErrAuthorization)
|
||||
}
|
||||
repoCall3 := auth.On("AddPolicy", mock.Anything, mock.Anything).Return(&magistrala.AddPolicyRes{Authorized: true}, nil)
|
||||
repoCall3 := auth.On("AddPolicy", mock.Anything, mock.Anything).Return(&magistrala.AddPolicyRes{Added: true}, nil)
|
||||
req := sdk.UsersRelationRequest{
|
||||
Relation: "viewer",
|
||||
UserIDs: []string{tc.channelID},
|
||||
|
||||
@@ -37,11 +37,11 @@ var (
|
||||
wrongID = testsutil.GenerateUUID(&testing.T{})
|
||||
)
|
||||
|
||||
func setupUsers() (*httptest.Server, *umocks.Repository, *gmocks.Repository, *authmocks.Service) {
|
||||
func setupUsers() (*httptest.Server, *umocks.Repository, *gmocks.Repository, *authmocks.AuthClient) {
|
||||
crepo := new(umocks.Repository)
|
||||
gRepo := new(gmocks.Repository)
|
||||
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
csvc := users.NewService(crepo, auth, emailer, phasher, idProvider, passRegex, true)
|
||||
gsvc := groups.NewService(gRepo, idProvider, auth)
|
||||
|
||||
@@ -186,7 +186,7 @@ func TestCreateClient(t *testing.T) {
|
||||
if tc.token != validToken {
|
||||
repoCall = auth.On("Identify", mock.Anything, mock.Anything).Return(&magistrala.IdentityRes{}, errors.ErrAuthentication)
|
||||
}
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Authorized: true}, nil)
|
||||
repoCall1 := auth.On("AddPolicies", mock.Anything, mock.Anything).Return(&magistrala.AddPoliciesRes{Added: true}, nil)
|
||||
repoCall2 := auth.On("DeletePolicies", mock.Anything, mock.Anything).Return(&magistrala.DeletePoliciesRes{Deleted: true}, nil)
|
||||
repoCall3 := crepo.On("Save", mock.Anything, mock.Anything).Return(convertClient(tc.response), tc.err)
|
||||
rClient, err := mgsdk.CreateUser(tc.client, tc.token)
|
||||
@@ -946,7 +946,7 @@ func TestUpdateClientRole(t *testing.T) {
|
||||
}
|
||||
repoCall1 := auth.On("Authorize", mock.Anything, mock.Anything).Return(&magistrala.AuthorizeRes{Authorized: true}, nil)
|
||||
repoCall2 := auth.On("DeletePolicy", mock.Anything, mock.Anything).Return(&magistrala.DeletePolicyRes{Deleted: true}, nil)
|
||||
repoCall3 := auth.On("AddPolicy", mock.Anything, mock.Anything).Return(&magistrala.AddPolicyRes{Authorized: true}, nil)
|
||||
repoCall3 := auth.On("AddPolicy", mock.Anything, mock.Anything).Return(&magistrala.AddPolicyRes{Added: true}, nil)
|
||||
repoCall4 := crepo.On("UpdateRole", mock.Anything, mock.Anything).Return(convertClient(tc.response), tc.err)
|
||||
uClient, err := mgsdk.UpdateUserRole(tc.client, tc.token)
|
||||
assert.Equal(t, tc.err, err, fmt.Sprintf("%s: expected error %s, got %s", tc.desc, tc.err, err))
|
||||
|
||||
@@ -47,7 +47,7 @@ var (
|
||||
sum float64 = 42
|
||||
)
|
||||
|
||||
func newServer(repo readers.MessageRepository, ac *authmocks.Service, tc *thmocks.ThingAuthzService) *httptest.Server {
|
||||
func newServer(repo readers.MessageRepository, ac *authmocks.AuthClient, tc *thmocks.ThingAuthzService) *httptest.Server {
|
||||
mux := api.MakeHandler(repo, ac, tc, svcName, instanceID)
|
||||
return httptest.NewServer(mux)
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func TestReadAll(t *testing.T) {
|
||||
}
|
||||
|
||||
repo := mocks.NewMessageRepository(chanID, fromSenml(messages))
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
tauth := new(thmocks.ThingAuthzService)
|
||||
ts := newServer(repo, auth, tauth)
|
||||
defer ts.Close()
|
||||
|
||||
@@ -91,7 +91,7 @@ func toJSON(data interface{}) string {
|
||||
|
||||
func newThingsServer() (*httptest.Server, *mocks.Service) {
|
||||
gRepo := new(gmocks.Repository)
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
|
||||
svc := new(mocks.Service)
|
||||
gsvc := groups.NewService(gRepo, idProvider, auth)
|
||||
|
||||
+1
-1
@@ -413,7 +413,7 @@ func (svc service) Share(ctx context.Context, token, id, relation string, userid
|
||||
if err != nil {
|
||||
return errors.Wrap(errAddPolicies, err)
|
||||
}
|
||||
if !res.Authorized {
|
||||
if !res.Added {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
+17
-17
@@ -48,8 +48,8 @@ var (
|
||||
errRemovePolicies = errors.New("failed to remove the policies")
|
||||
)
|
||||
|
||||
func newService() (things.Service, *mocks.Repository, *authmocks.Service, *mocks.Cache) {
|
||||
auth := new(authmocks.Service)
|
||||
func newService() (things.Service, *mocks.Repository, *authmocks.AuthClient, *mocks.Cache) {
|
||||
auth := new(authmocks.AuthClient)
|
||||
thingCache := new(mocks.Cache)
|
||||
idProvider := uuid.NewMock()
|
||||
cRepo := new(mocks.Repository)
|
||||
@@ -100,7 +100,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@@ -113,7 +113,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
},
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
token: validToken,
|
||||
err: nil,
|
||||
},
|
||||
@@ -128,7 +128,7 @@ func TestCreateThings(t *testing.T) {
|
||||
Status: mgclients.EnabledStatus,
|
||||
},
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
token: validToken,
|
||||
err: nil,
|
||||
},
|
||||
@@ -144,7 +144,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@@ -159,7 +159,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@@ -173,7 +173,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@@ -186,7 +186,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@@ -200,7 +200,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@@ -219,7 +219,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@@ -233,7 +233,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
saveErr: repoerr.ErrMalformedEntity,
|
||||
err: repoerr.ErrCreateEntity,
|
||||
},
|
||||
@@ -247,7 +247,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
saveErr: repoerr.ErrMissingSecret,
|
||||
err: repoerr.ErrCreateEntity,
|
||||
},
|
||||
@@ -262,7 +262,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: svcerr.ErrInvalidStatus,
|
||||
},
|
||||
{
|
||||
@@ -303,7 +303,7 @@ func TestCreateThings(t *testing.T) {
|
||||
},
|
||||
token: validToken,
|
||||
authResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Authorized: false},
|
||||
addPolicyResponse: &magistrala.AddPoliciesRes{Added: false},
|
||||
addPolicyErr: svcerr.ErrInvalidPolicy,
|
||||
err: svcerr.ErrInvalidPolicy,
|
||||
},
|
||||
@@ -1788,7 +1788,7 @@ func TestShare(t *testing.T) {
|
||||
clientID: clientID,
|
||||
identifyResponse: &magistrala.IdentityRes{Id: validID, DomainId: testsutil.GenerateUUID(t)},
|
||||
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@@ -1824,7 +1824,7 @@ func TestShare(t *testing.T) {
|
||||
clientID: clientID,
|
||||
identifyResponse: &magistrala.IdentityRes{Id: validID, DomainId: testsutil.GenerateUUID(t)},
|
||||
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: false},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: false},
|
||||
err: nil,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ const publisher = "twins"
|
||||
var id = 0
|
||||
|
||||
// NewService use mock dependencies to create real twins service.
|
||||
func NewService() (twins.Service, *authmocks.Service) {
|
||||
auth := new(authmocks.Service)
|
||||
func NewService() (twins.Service, *authmocks.AuthClient) {
|
||||
auth := new(authmocks.AuthClient)
|
||||
twinsRepo := NewTwinRepository()
|
||||
twinCache := NewTwinCache()
|
||||
statesRepo := NewStateRepository()
|
||||
|
||||
@@ -82,7 +82,7 @@ func (tr testRequest) make() (*http.Response, error) {
|
||||
|
||||
func newUsersServer() (*httptest.Server, *mocks.Service) {
|
||||
gRepo := new(gmocks.Repository)
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
|
||||
svc := new(mocks.Service)
|
||||
gsvc := groups.NewService(gRepo, idProvider, auth)
|
||||
|
||||
+2
-2
@@ -617,7 +617,7 @@ func (svc service) addClientPolicy(ctx context.Context, userID string, role mgcl
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !resp.Authorized {
|
||||
if !resp.Added {
|
||||
return errors.ErrAuthorization
|
||||
}
|
||||
return nil
|
||||
@@ -666,7 +666,7 @@ func (svc service) updateClientPolicy(ctx context.Context, userID string, role m
|
||||
if err != nil {
|
||||
return errors.Wrap(errAddPolicies, err)
|
||||
}
|
||||
if !resp.Authorized {
|
||||
if !resp.Added {
|
||||
return errors.Wrap(svcerr.ErrAuthorization, err)
|
||||
}
|
||||
return nil
|
||||
|
||||
+22
-22
@@ -50,9 +50,9 @@ var (
|
||||
errDeletePolicies = errors.New("failed to delete policies")
|
||||
)
|
||||
|
||||
func newService(selfRegister bool) (users.Service, *mocks.Repository, *authmocks.Service, users.Emailer) {
|
||||
func newService(selfRegister bool) (users.Service, *mocks.Repository, *authmocks.AuthClient, users.Emailer) {
|
||||
cRepo := new(mocks.Repository)
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
e := mocks.NewEmailer()
|
||||
return users.NewService(cRepo, auth, e, phasher, idProvider, passRegex, selfRegister), cRepo, auth, e
|
||||
}
|
||||
@@ -76,14 +76,14 @@ func TestRegisterClient(t *testing.T) {
|
||||
{
|
||||
desc: "register new client successfully",
|
||||
client: client,
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
token: validToken,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
desc: "register existing client",
|
||||
client: client,
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
deletePoliciesResponse: &magistrala.DeletePoliciesRes{Deleted: true},
|
||||
token: validToken,
|
||||
saveErr: repoerr.ErrConflict,
|
||||
@@ -99,7 +99,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
},
|
||||
Status: mgclients.EnabledStatus,
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
token: validToken,
|
||||
},
|
||||
@@ -112,7 +112,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
Secret: secret,
|
||||
},
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
token: validToken,
|
||||
},
|
||||
@@ -130,7 +130,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
},
|
||||
Status: mgclients.EnabledStatus,
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
err: nil,
|
||||
token: validToken,
|
||||
},
|
||||
@@ -142,7 +142,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
Secret: secret,
|
||||
},
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
deletePoliciesResponse: &magistrala.DeletePoliciesRes{Deleted: true},
|
||||
saveErr: errors.ErrMalformedEntity,
|
||||
err: errors.ErrMalformedEntity,
|
||||
@@ -157,7 +157,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
Secret: "",
|
||||
},
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
deletePoliciesResponse: &magistrala.DeletePoliciesRes{Deleted: true},
|
||||
err: repoerr.ErrMissingSecret,
|
||||
},
|
||||
@@ -170,7 +170,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
Secret: "weak",
|
||||
},
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
deletePoliciesResponse: &magistrala.DeletePoliciesRes{Deleted: true},
|
||||
err: nil,
|
||||
},
|
||||
@@ -183,7 +183,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
Secret: strings.Repeat("a", 73),
|
||||
},
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
deletePoliciesResponse: &magistrala.DeletePoliciesRes{Deleted: true},
|
||||
err: repoerr.ErrMalformedEntity,
|
||||
},
|
||||
@@ -197,7 +197,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
},
|
||||
Status: mgclients.AllStatus,
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
deletePoliciesResponse: &magistrala.DeletePoliciesRes{Deleted: true},
|
||||
err: svcerr.ErrInvalidStatus,
|
||||
},
|
||||
@@ -211,7 +211,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
},
|
||||
Role: 2,
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
deletePoliciesResponse: &magistrala.DeletePoliciesRes{Deleted: true},
|
||||
err: svcerr.ErrInvalidRole,
|
||||
},
|
||||
@@ -225,7 +225,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
},
|
||||
Role: mgclients.AdminRole,
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: false},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: false},
|
||||
err: errors.ErrAuthorization,
|
||||
},
|
||||
{
|
||||
@@ -238,7 +238,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
},
|
||||
Role: mgclients.AdminRole,
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
addPoliciesResponseErr: errAddPolicies,
|
||||
err: errAddPolicies,
|
||||
},
|
||||
@@ -252,7 +252,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
},
|
||||
Role: mgclients.AdminRole,
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
deletePoliciesResponse: &magistrala.DeletePoliciesRes{Deleted: false},
|
||||
deletePoliciesResponseErr: errDeletePolicies,
|
||||
saveErr: repoerr.ErrConflict,
|
||||
@@ -268,7 +268,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
},
|
||||
Role: mgclients.AdminRole,
|
||||
},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
deletePoliciesResponse: &magistrala.DeletePoliciesRes{Deleted: false},
|
||||
saveErr: repoerr.ErrConflict,
|
||||
err: svcerr.ErrAuthorization,
|
||||
@@ -320,7 +320,7 @@ func TestRegisterClient(t *testing.T) {
|
||||
client: client,
|
||||
identifyResponse: &magistrala.IdentityRes{UserId: validID},
|
||||
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Authorized: true},
|
||||
addPoliciesResponse: &magistrala.AddPoliciesRes{Added: true},
|
||||
token: validToken,
|
||||
err: nil,
|
||||
},
|
||||
@@ -1003,7 +1003,7 @@ func TestUpdateClientRole(t *testing.T) {
|
||||
client: client,
|
||||
identifyResponse: &magistrala.IdentityRes{UserId: client.ID},
|
||||
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPolicyRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPolicyRes{Added: true},
|
||||
updateRoleResponse: client,
|
||||
token: validToken,
|
||||
err: nil,
|
||||
@@ -1038,7 +1038,7 @@ func TestUpdateClientRole(t *testing.T) {
|
||||
client: client,
|
||||
identifyResponse: &magistrala.IdentityRes{UserId: client.ID},
|
||||
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPolicyRes{Authorized: false},
|
||||
addPolicyResponse: &magistrala.AddPolicyRes{Added: false},
|
||||
token: validToken,
|
||||
err: errors.ErrAuthorization,
|
||||
},
|
||||
@@ -1086,7 +1086,7 @@ func TestUpdateClientRole(t *testing.T) {
|
||||
client: client,
|
||||
identifyResponse: &magistrala.IdentityRes{UserId: client.ID},
|
||||
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPolicyRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPolicyRes{Added: true},
|
||||
deletePolicyResponse: &magistrala.DeletePolicyRes{Deleted: true},
|
||||
updateRoleResponse: mgclients.Client{},
|
||||
token: validToken,
|
||||
@@ -1098,7 +1098,7 @@ func TestUpdateClientRole(t *testing.T) {
|
||||
client: client,
|
||||
identifyResponse: &magistrala.IdentityRes{UserId: client.ID},
|
||||
authorizeResponse: &magistrala.AuthorizeRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPolicyRes{Authorized: true},
|
||||
addPolicyResponse: &magistrala.AddPolicyRes{Added: true},
|
||||
deletePolicyResponse: &magistrala.DeletePolicyRes{Deleted: false},
|
||||
updateRoleResponse: mgclients.Client{},
|
||||
token: validToken,
|
||||
|
||||
+2
-2
@@ -34,9 +34,9 @@ var msg = messaging.Message{
|
||||
Payload: []byte(`[{"n":"current","t":-5,"v":1.2}]`),
|
||||
}
|
||||
|
||||
func newService() (ws.Service, *mocks.PubSub, *authmocks.Service) {
|
||||
func newService() (ws.Service, *mocks.PubSub, *authmocks.AuthClient) {
|
||||
pubsub := new(mocks.PubSub)
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
|
||||
return ws.New(auth, pubsub), pubsub, auth
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func handshake(tsURL, chanID, subtopic, thingKey string, addHeader bool) (*webso
|
||||
}
|
||||
|
||||
func TestHandshake(t *testing.T) {
|
||||
auth := new(authmocks.Service)
|
||||
auth := new(authmocks.AuthClient)
|
||||
svc, pubsub := newService(auth)
|
||||
target := newHTTPServer(svc)
|
||||
defer target.Close()
|
||||
|
||||
Reference in New Issue
Block a user