Esempio n. 1
0
        private static bool DocumentPermisionMatchesUser(DocumentPermission permission, AuthorizationUser user, string userId)
        {
            if (permission.User != null)
            {
                return(permission.User == userId);
            }
            if (permission.Role == null)
            {
                return(false);
            }

            return(GetHierarchicalNames(user.Roles).Any(role => permission.Role == role));
        }
Esempio n. 2
0
        private static bool DocumentPermissionMatchesUser(DocumentPermission permission, AuthorizationUser user, string userId)
        {
            if (permission.User != null)
            {
                return(string.Equals(permission.User, userId, StringComparison.InvariantCultureIgnoreCase));
            }
            if (permission.Role == null)
            {
                return(false);
            }

            return(GetHierarchicalNames(user.Roles).Any(role => permission.Role.Equals(role, StringComparison.InvariantCultureIgnoreCase)));
        }
        public void TestSaveDocumentPermissionValid()
        {
            var documentId   = Guid.NewGuid();
            var sessionToken = "asdasdasd";
            var permission   = new DocumentPermission()
            {
                AccountID = Guid.NewGuid(),
                TenantID  = Guid.NewGuid(),
            };
            var mockedResponse = new RestResponse()
            {
                StatusCode = HttpStatusCode.Created
            };

            mockedClient.Setup(c => c.Execute(It.IsAny <JSONRestRequest>())).Returns(mockedResponse);

            provider.CreateDocumentPermission(documentId, permission, sessionToken);
            mockedClient.Verify(c => c.Execute(It.IsAny <JSONRestRequest>()), Times.Once);
        }