Beispiel #1
0
        public void ShouldGetScopesFromClaimsIfNoScopeFinderProvided(string[] userScopes, bool shouldSucceed)
        {
            var permissionData = new PermissionData()
            {
                Scopes = new List <PermissionScopeData>()
                {
                    new PermissionScopeData()
                    {
                        Scope = "Calendar.Write"
                    },
                    new PermissionScopeData()
                    {
                        Scope = "User.Write"
                    }
                }
            };

            var requirement = new ODataAuthorizationScopesRequirement(permissionData);
            var context     = CreateAuthContext("Scope", new[] { requirement }, userScopes);
            var handler     = new ODataAuthorizationHandler();

            handler.HandleAsync(context).Wait();

            Assert.Equal(shouldSucceed, context.HasSucceeded);
        }
Beispiel #2
0
        public void ShouldOnlySucceedIfUserHasAnAllowedScope(string[] userScopes, bool shouldSucceed)
        {
            var permissionData = new PermissionData()
            {
                Scopes = new List <PermissionScopeData>()
                {
                    new PermissionScopeData()
                    {
                        Scope = "Calendar.Write"
                    },
                    new PermissionScopeData()
                    {
                        Scope = "User.Write"
                    }
                }
            };
            var requirement = new ODataAuthorizationScopesRequirement(permissionData);
            var context     = CreateAuthContext("Permission", new[] { requirement }, userScopes);
            var handler     = new ODataAuthorizationHandler(FindScopes);

            handler.HandleAsync(context).Wait();

            Assert.Equal(shouldSucceed, context.HasSucceeded);
        }