public void MSCPSWS_S04_TC08_Resolve_NullResolveInput()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] allProviders = TestSuiteBase.GetAllProviders();

            ArrayOfString   providerNames = new ArrayOfString();
            SPPrincipalType principalType = SPPrincipalType.User;

            foreach (SPProviderHierarchyTree provider in allProviders)
            {
                providerNames.Add(provider.ProviderName);
            }

            bool caughtException = false;

            try
            {
                // Call Resolve multiple method with resolveInput parameter sets to null.
                CPSWSAdapter.Resolve(providerNames, principalType, null);
            }
            catch (FaultException faultException)
            {
                caughtException = true;

                // If the server returns an ArgumentNullException<""value""> message, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    this.VerifyArgumentNullException(faultException, "value"),
                    616,
                    @"[In Resolve] If this [resolveInput] is NULL, the protocol server MUST return an ArgumentNullException<""value""> message.");
            }
            finally
            {
                this.Site.Assert.IsTrue(caughtException, "If resolveInput is NULL, the protocol server should return an ArgumentNullException<value> message.");
            }
        }
        public void MSCPSWS_S02_TC03_GetHierarchy_ValidNumberOfLevels()
        {
            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            SPPrincipalType principalType         = SPPrincipalType.SharePointGroup;
            string          providerName          = null;
            bool            isGetHierarchySuccess = false;

            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();

            foreach (SPProviderHierarchyTree provider in responseOfGetHierarchyAllResult)
            {
                // Filter the providers, hierarchy providers which name is started with "_HierarchyProvider_" are not supported by GetHierarchy method.
                if (provider.ProviderName != null && !provider.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    providerName = provider.ProviderName;

                    // Call GetHierarchy method to get a claims provider hierarchy tree with a valid numberOfLevels parameter in the request.
                    SPProviderHierarchyTree responseOfGetHierarchyResult = CPSWSAdapter.GetHierarchy(providerName, principalType, null, numberOfLevels);
                    Site.Assert.IsNotNull(responseOfGetHierarchyResult, "If the numberOfLevels is a valid value, the protocol server MUST use the current available claims providers.");
                    isGetHierarchySuccess = true;

                    // If the claims providers listed in the provider names in the input message is retrieved successfully, then the following requirement can be captured.
                    Site.CaptureRequirementIfIsTrue(
                        isGetHierarchySuccess,
                        194,
                        @"[In GetHierarchy] The protocol server MUST retrieve a claims provider hierarchy tree from the claims provider that meets all the following criteria:
The claims provider name is specified in the input message.
The claims provider is associated with the Web application (1) specified in the input message.
The claims provider supports hierarchy.");
                }
            }
        }
        public void MSCPSWS_S04_TC02_ResolveClaim_Valid()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] allProviders = TestSuiteBase.GetAllProviders();

            ArrayOfString   providerNames         = new ArrayOfString();
            SPPrincipalType principalType         = SPPrincipalType.SecurityGroup;
            SPClaim         resolveInput          = GenerateSPClaimResolveInput_Valid();
            bool            isResolveClaimSuccess = false;

            foreach (SPProviderHierarchyTree provider in allProviders)
            {
                if (provider.Children.Length != 0)
                {
                    providerNames.Add(provider.ProviderName);
                }

                // Call Resolve claim method to resolve an SPClaim to picker entities using a list of claims providers.
                PickerEntity[] responseOfResolveClaimResult = CPSWSAdapter.ResolveClaim(providerNames, principalType, resolveInput);
                Site.Assert.IsNotNull(responseOfResolveClaimResult, "The resolve claim result should not be null.");
                isResolveClaimSuccess = true;
            }

            // If the claims providers listed in the provider names in the input message is resolved successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isResolveClaimSuccess,
                303,
                @"[In ResolveClaim] The protocol server MUST resolve across all claims providers that meet all the following criteria:
The claims providers are associated with the Web application (1) specified in the input message.
The claims providers are listed in the provider names in the input message.
The claims providers support resolve.");
        }
        public void MSCPSWS_S05_TC02_Search_nullSearchPattern()
        {
            // Set principal type for Search.
            SPPrincipalType principalType = SPPrincipalType.SharePointGroup;

            // Set ArrayOfSPProviderSearchArguments for Search.
            List <SPProviderSearchArguments> arrayOfSPProviderSearchArguments = new List <SPProviderSearchArguments>();

            Site.Assume.IsNotNull(this.GenerateProviderSearchArgumentsInput_Valid(), "There should be a valid provider search arguments!");
            SPProviderSearchArguments providerSearchArguments = this.GenerateProviderSearchArgumentsInput_Valid();

            arrayOfSPProviderSearchArguments.Add(providerSearchArguments);

            bool caughtException = false;

            try
            {
                // Call the Search operation with searchPattern as null.
                CPSWSAdapter.Search(arrayOfSPProviderSearchArguments.ToArray(), principalType, null);
            }
            catch (System.ServiceModel.FaultException faultException)
            {
                caughtException = true;

                // Verify Requirement 652, if the server returns an ArgumentNullException<"searchPattern"> message.
                Site.CaptureRequirementIfIsTrue(this.VerifyArgumentNullException(faultException, "searchPattern"), 652, @"[In Search] If this [searchPattern] is NULL, the protocol server MUST return an ArgumentNullException<""searchPattern""> message.");
            }
            finally
            {
                this.Site.Assert.IsTrue(caughtException, "If searchPattern is NULL, the protocol server should return an ArgumentNullException<searchPattern> message.");
            }
        }
        public void MSCPSWS_S02_TC06_GetHierarchyAll_AllOfProviderNames()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] getAllProviders = TestSuiteBase.GetAllProviders();

            ArrayOfString   providerNames = new ArrayOfString();
            SPPrincipalType principalType = SPPrincipalType.User;

            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            foreach (SPProviderHierarchyTree provider in getAllProviders)
            {
                providerNames.Add(provider.ProviderName);
            }

            // Call GetHierarchyAll method to get a list of claims provider hierarchy trees with all of valid providerNames in the request.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = CPSWSAdapter.GetHierarchyAll(providerNames, principalType, numberOfLevels);
            Site.Assert.IsNotNull(responseOfGetHierarchyAllResult, "If the providerNames is all of valid providerNames, the protocol server MUST use all the available claims providers.");

            // If the claims providers listed in the provider names in the input message is retrieved successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                responseOfGetHierarchyAllResult.Length == providerNames.Count,
                219,
                @"[In GetHierarchyAll] The protocol server MUST retrieve claims provider hierarchy trees from claims providers that meet all the following criteria:
The claims providers are associated with the Web application (1) specified in the input message.
The claims providers are listed in the provider names in the input message.
The claims providers support hierarchy.");

            Site.CaptureRequirementIfIsTrue(
                responseOfGetHierarchyAllResult.Length == providerNames.Count,
                239,
                @"[In GetHierarchyAllResponse]The protocol server MUST return one claims provider hierarchy tree for each claims provider that match the criteria specified in the input message.");
        }
        public void MSCPSWS_S02_TC02_GetHierarchy_ValidHierarchyNodeID()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();

            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            SPPrincipalType principalType   = SPPrincipalType.SharePointGroup;
            string          providerName    = null;
            string          hierarchyNodeID = null;

            foreach (SPProviderHierarchyTree provider in responseOfGetHierarchyAllResult)
            {
                // Filter the providers, hierarchy providers which name is started with "_HierarchyProvider_" are not supported by GetHierarchy method.
                if (provider.ProviderName != null && !provider.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    providerName = provider.ProviderName;

                    foreach (SPProviderHierarchyNode children in provider.Children)
                    {
                        if (children.HierarchyNodeID != null)
                        {
                            hierarchyNodeID = children.HierarchyNodeID;
                        }
                    }

                    if (providerName != null && hierarchyNodeID != null)
                    {
                        break;
                    }
                }
            }

            Site.Assert.IsNotNull(providerName, "No such claim provider which have a hierarchyNodeID exists in the server!");
            Site.Assert.IsNotNull(hierarchyNodeID, "No such claim provider which have a hierarchyNodeID exists in the server!");

            // Call GetHierarchy method to get a claims provider hierarchy tree with a valid child hierarchyNodeID in the request.
            SPProviderHierarchyTree responseOfGetHierarchyResult = CPSWSAdapter.GetHierarchy(providerName, principalType, hierarchyNodeID, numberOfLevels);

            Site.Assert.AreEqual <string>("false", responseOfGetHierarchyResult.IsRoot.ToString().ToLower(CultureInfo.CurrentCulture), "Should return the hierarchyNodeID specified claims provider hierarchy tree, which is not existing root of current claims provider hierarchy tree.");

            // If the claims providers listed in the provider names in the input message is retrieved successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                responseOfGetHierarchyResult.IsRoot.ToString().ToLower(CultureInfo.CurrentCulture) == "false",
                194,
                @"[In GetHierarchy] The protocol server MUST retrieve a claims provider hierarchy tree from the claims provider that meets all the following criteria:
The claims provider name is specified in the input message.
The claims provider is associated with the Web application (1) specified in the input message.
The claims provider supports hierarchy.");

            // If the providerName is not null, then the protocol server retrieve a hierarchy provider hierarchy tree in the input message, then the following requirement can be captured.
            Site.CaptureRequirementIfIsNotNull(
                providerName,
                194001,
                @"[In GetHierarchy] The protocol server MUST retrieve a hierarchy provider hierarchy tree if the name of an available hierarchy provider is specified in the input message.");
        }
Exemplo n.º 7
0
        public PrincipalInfo[] ResolvePrincipals(string[] principalKeys, SPPrincipalType principalType, bool addToUserInfoList)
        {
            object[] results = this.Invoke("ResolvePrincipals", new object[] {
                principalKeys,
                principalType,
                addToUserInfoList
            });

            return((PrincipalInfo[])(results[0]));
        }
Exemplo n.º 8
0
        public PrincipalInfo[] SearchPrincipals(string searchText, int maxResults, SPPrincipalType principalType)
        {
            object[] results = this.Invoke("SearchPrincipals", new object[] {
                searchText,
                maxResults,
                principalType
            });

            return((PrincipalInfo[])(results[0]));
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectPermissionManagementModel" /> class.
 /// </summary>
 /// <param name="objectType">objectType.</param>
 /// <param name="objectInfo">objectInfo.</param>
 /// <param name="action">action.</param>
 /// <param name="permissions">permissions.</param>
 /// <param name="originalPermissions">originalPermissions.</param>
 /// <param name="externalUserType">externalUserType.</param>
 /// <param name="members">members.</param>
 /// <param name="grantPermissionSetting">grantPermissionSetting.</param>
 public ObjectPermissionManagementModel(SPPrincipalType objectType = default(SPPrincipalType), ApiUser objectInfo = default(ApiUser), ManagePermissionAction action = default(ManagePermissionAction), List <string> permissions = default(List <string>), List <string> originalPermissions = default(List <string>), ExternalUserType externalUserType = default(ExternalUserType), List <SharingEnabledUser> members = default(List <SharingEnabledUser>), GrantPermissionModel grantPermissionSetting = default(GrantPermissionModel))
 {
     this.ObjectType             = objectType;
     this.ObjectInfo             = objectInfo;
     this.Action                 = action;
     this.Permissions            = permissions;
     this.OriginalPermissions    = originalPermissions;
     this.ExternalUserType       = externalUserType;
     this.Members                = members;
     this.GrantPermissionSetting = grantPermissionSetting;
 }
        public void MSCPSWS_S02_TC05_GetHierarchyAll_NullProviderNames()
        {
            SPPrincipalType principalType = SPPrincipalType.User;

            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            // Call GetHierarchyAll method to get a list of claims provider hierarchy trees with a null providerNames in the request.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = CPSWSAdapter.GetHierarchyAll(null, principalType, numberOfLevels);
            Site.Assert.IsNotNull(responseOfGetHierarchyAllResult, "If the providerNames is NULL, the protocol server MUST use all the available claims providers.");
        }
Exemplo n.º 11
0
        /// <summary>
        /// A method used to get all existed claims providers hierarchy tree in the server.
        /// </summary>
        /// <returns>A return value represents the list of claim providers hierarchy tree.</returns>
        public static SPProviderHierarchyTree[] GetAllProviders()
        {
            SPPrincipalType principalType  = SPPrincipalType.All;
            int             numberOfLevels = 10;

            if (allProviders == null)
            {
                allProviders = CPSWSAdapter.GetHierarchyAll(null, principalType, numberOfLevels);
            }

            return(allProviders);
        }
Exemplo n.º 12
0
 /// <remarks/>
 public void ResolvePrincipalsAsync(string[] principalKeys, SPPrincipalType principalType, bool addToUserInfoList, object userState)
 {
     if ((this.ResolvePrincipalsOperationCompleted == null))
     {
         this.ResolvePrincipalsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnResolvePrincipalsOperationCompleted);
     }
     this.InvokeAsync("ResolvePrincipals", new object[] {
         principalKeys,
         principalType,
         addToUserInfoList
     }, this.ResolvePrincipalsOperationCompleted, userState);
 }
Exemplo n.º 13
0
 /// <remarks/>
 public void SearchPrincipalsAsync(string searchText, int maxResults, SPPrincipalType principalType, object userState)
 {
     if ((this.SearchPrincipalsOperationCompleted == null))
     {
         this.SearchPrincipalsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSearchPrincipalsOperationCompleted);
     }
     this.InvokeAsync("SearchPrincipals", new object[] {
         searchText,
         maxResults,
         principalType
     }, this.SearchPrincipalsOperationCompleted, userState);
 }
        /// <summary>
        /// Writes the object security.
        /// </summary>
        /// <param name="sourceObject">The source object.</param>
        /// <param name="xmlWriter">The XML writer.</param>
        public static void WriteObjectSecurity(SPSecurableObject sourceObject, XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteAttributeString("HasUniqueRoleAssignments", sourceObject.HasUniqueRoleAssignments.ToString());

            if (!sourceObject.HasUniqueRoleAssignments)
            {
                return;
            }

            //xmlWriter.WriteRaw(sourceObject.RoleAssignments.Xml);

            xmlWriter.WriteStartElement("RoleAssignments");
            foreach (SPRoleAssignment ra in sourceObject.RoleAssignments)
            {
                xmlWriter.WriteStartElement("RoleAssignment");
                xmlWriter.WriteAttributeString("Member", ra.Member.Name);

                SPPrincipalType pType = SPPrincipalType.None;
                if (ra.Member is SPUser)
                {
                    pType = SPPrincipalType.User;
                    xmlWriter.WriteAttributeString("LoginName", ((SPUser)ra.Member).LoginName);
                }
                else if (ra.Member is SPGroup)
                {
                    pType = SPPrincipalType.SharePointGroup;
                }

                xmlWriter.WriteAttributeString("PrincipalType", pType.ToString());

                xmlWriter.WriteStartElement("RoleDefinitionBindings");
                foreach (SPRoleDefinition rd in ra.RoleDefinitionBindings)
                {
                    if (rd.Name == "Limited Access")
                    {
                        continue;
                    }

                    xmlWriter.WriteStartElement("RoleDefinition");
                    xmlWriter.WriteAttributeString("Name", rd.Name);
                    xmlWriter.WriteAttributeString("Description", rd.Description);
                    xmlWriter.WriteAttributeString("Order", rd.Order.ToString());
                    xmlWriter.WriteAttributeString("BasePermissions", rd.BasePermissions.ToString());
                    xmlWriter.WriteEndElement(); //RoleDefinition
                }
                xmlWriter.WriteEndElement();     //RoleDefinitionBindings
                xmlWriter.WriteEndElement();     //RoleAssignment
            }
            xmlWriter.WriteEndElement();         //RoleAssignments
        }
        public void MSCPSWS_S02_TC01_GetHierarchy_NullHierarchyNodeID()
        {
            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            SPPrincipalType principalType = SPPrincipalType.SharePointGroup;
            string          providerName  = null;

            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();

            foreach (SPProviderHierarchyTree provider in responseOfGetHierarchyAllResult)
            {
                // Filter the providers, hierarchy providers which name is started with "_HierarchyProvider_" are not supported by GetHierarchy method.
                if (!provider.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)) && provider.Children.Length != 0)
                {
                    providerName = provider.ProviderName;
                    //Verify MS-CPSWS requirement: MS-CPSWS_R540001
                    Site.CaptureRequirementIfIsTrue(
                        provider.HierarchyNodeID.Length == 0,
                        540001,
                        @"[In SPProviderHierarchyElement] This value[HierarchyNodeID] is empty for the hierarchy provider and the root element of the hierarchy tree.");

                    if (providerName != null)
                    {
                        break;
                    }
                }
            }

            Site.Assume.IsNotNull(providerName, "The providerName should not be null!");

            // Call GetHierarchy method to get a claims provider hierarchy tree with a null hierarchyNodeID in the request.
            SPProviderHierarchyTree responseOfGetHierarchyResult = CPSWSAdapter.GetHierarchy(providerName, principalType, null, numberOfLevels);

            Site.Assert.AreEqual <string>("true", responseOfGetHierarchyResult.IsRoot.ToString().ToLower(CultureInfo.CurrentCulture), "Should return the existing root of current claims provider hierarchy tree.");

            // Verify MS-CPSWS requirement: MS-CPSWS_R209
            Site.CaptureRequirementIfAreEqual <string>(
                "true",
                responseOfGetHierarchyResult.IsRoot.ToString().ToLower(CultureInfo.CurrentCulture),
                209,
                @"[In GetHierarchy] hierarchyNodeID: If NULL is specified, then the protocol server MUST return the existing root of claims provider hierarchy tree.");
        }
        public void MSCPSWS_S02_TC07_GetHierarchyAll_ValidInputParameters()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] getAllProviders = TestSuiteBase.GetAllProviders();

            SPPrincipalType principalType = SPPrincipalType.User;

            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            foreach (SPProviderHierarchyTree provider in getAllProviders)
            {
                ArrayOfString providerNames = new ArrayOfString();
                providerNames.Add(provider.ProviderName);

                // Call GetHierarchyAll method to get a list of claims provider hierarchy trees with a valid providerNames in the request.
                SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = CPSWSAdapter.GetHierarchyAll(providerNames, principalType, numberOfLevels);
                Site.Assert.IsNotNull(responseOfGetHierarchyAllResult, "If the provider names are valid, the protocol server will return the hierarchy trees that match the claims providers.");
            }
        }
        public void MSCPSWS_S02_TC04_GetHierarchy_InvalidNumberOfLevels()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();

            SPPrincipalType principalType  = SPPrincipalType.SharePointGroup;
            int             numberOfLevels = 0;
            string          providerName   = null;

            foreach (SPProviderHierarchyTree provider in responseOfGetHierarchyAllResult)
            {
                // Filter the providers, hierarchy providers which name is started with "_HierarchyProvider_" are not supported by GetHierarchy method.
                if (provider.ProviderName != null && !provider.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    providerName = provider.ProviderName;
                    break;
                }
            }

            bool caughtException = false;

            try
            {
                // Call GetHierarchy method with numberOfLevels parameter sets to invalid.
                CPSWSAdapter.GetHierarchy(providerName, principalType, null, numberOfLevels);
            }
            catch (FaultException faultException)
            {
                caughtException = true;

                // If the server returns an ArgumentNullException<""numberOfLevels""> message, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    this.VerifyArgumentOutOfRangeException(faultException, "numberOfLevels"),
                    583,
                    @"[In GetHierarchy] The protocol server MUST return ArgumentOutOfRangeException<""numberOfLevels""> message if the value of this element [numberOfLevels] is less than 1.");
            }
            finally
            {
                this.Site.Assert.IsTrue(caughtException, "The protocol server should return ArgumentOutOfRangeException<numberOfLevels> message if the value of this element [numberOfLevels] is less than 1.");
            }
        }
        public void MSCPSWS_S04_TC06_ResolveMultipleClaim_SomeValid()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] allProviders = TestSuiteBase.GetAllProviders();

            ArrayOfString   providerNames = new ArrayOfString();
            SPPrincipalType principalType = SPPrincipalType.SecurityGroup;

            SPClaim[] resolveInput = new SPClaim[2];

            resolveInput[0] = this.GenerateSPClaimResolveInput_Valid();
            resolveInput[1] = this.GenerateSPClaimResolveInput_Invalid();

            foreach (SPProviderHierarchyTree provider in allProviders)
            {
                if (provider.Children.Length != 0)
                {
                    providerNames.Add(provider.ProviderName);
                }
            }

            // Call Resolve multiple claim method to resolve 2 claims to picker entities using a list of claims providers.
            PickerEntity[] responseOfResolveMultipleClaimResult = CPSWSAdapter.ResolveMultipleClaim(providerNames, principalType, resolveInput);
            Site.Assert.IsNotNull(responseOfResolveMultipleClaimResult, "The resolve multiple claim result should not be null.");

            // If the resolve multiple result contains 2 picker entities, that is to say, one picker entity in the response corresponding to one user in the request, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual <int>(
                responseOfResolveMultipleClaimResult.Length,
                2,
                369,
                @"[In ResolveMultipleClaimResponse] ResolveMultipleClaimResult: The list MUST contain one and only one picker entity per one claim in the input.");

            Site.CaptureRequirementIfAreEqual <int>(
                responseOfResolveMultipleClaimResult.Length,
                2,
                350,
                @"[In ResolveMultipleClaim] The protocol server MUST resolve across all claims providers that meet all the following criteria:
The claims providers are associated with the Web application (1) specified in the input message.
The claims providers are listed in the provider names in the input message.
The claims providers support resolve.");
        }
        public void MSCPSWS_S02_TC08_GetHierarchyAll_ValidNumberOfLevels()
        {
            // Get the valid numberOfLevels of claims provider hierarchy trees.
            int numberOfLevels = Convert.ToInt32(Common.GetConfigurationPropertyValue("numberOfLevels", Site));

            SPPrincipalType principalType            = SPPrincipalType.SharePointGroup;
            bool            isGetHierarchyAllSuccess = false;

            // Call GetHierarchy method to get a claims provider hierarchy tree with a valid numberOfLevels parameter in the request.
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = CPSWSAdapter.GetHierarchyAll(null, principalType, numberOfLevels);
            Site.Assert.IsNotNull(responseOfGetHierarchyAllResult, "If the numberOfLevels is a valid value, the protocol server MUST use the current available claims providers.");
            isGetHierarchyAllSuccess = true;

            // If the claims providers listed in the provider names in the input message is retrieved successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isGetHierarchyAllSuccess,
                219,
                @"[In GetHierarchyAll] The protocol server MUST retrieve claims provider hierarchy trees from claims providers that meet all the following criteria:
The claims providers are associated with the Web application (1) specified in the input message.
The claims providers are listed in the provider names in the input message.
The claims providers support hierarchy.");
        }
Exemplo n.º 20
0
        /// <summary>
        /// A method used to resolve a list of claims to picker entities using a list of claims providers.
        /// </summary>
        /// <param name="providerNames">A parameter represents a list of provider names.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the result.</param>
        /// <param name="resolveInput">A parameter represents a list of claims to be resolved.</param>
        /// <returns>A return value represents a list of picker entities.</returns>
        public PickerEntity[] ResolveMultipleClaim(ArrayOfString providerNames, SPPrincipalType principalType, SPClaim[] resolveInput)
        {
            PickerEntity[] responseOfResolveMultipleClaim = new PickerEntity[0];
            try
            {
                responseOfResolveMultipleClaim = this.cpswsClient.ResolveMultipleClaim(providerNames, principalType, resolveInput);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    @"There is an exception generated when calling [ResolveMultipleClaim] method:\r\n{0}",
                    faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.ValidateResolveMultipleClaimResponseData(responseOfResolveMultipleClaim);

            return(responseOfResolveMultipleClaim);
        }
Exemplo n.º 21
0
        /// <summary>
        /// A method used to perform a search for entities on a list of claims providers.
        /// </summary>
        /// <param name="providerNames">A parameter represents a list of provider names.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="searchPattern">A parameter represents the search string.</param>
        /// <param name="maxCount">A parameter represents the maximum number of matched entities to be returned in total across all the output claims provider hierarchy trees.</param>
        /// <returns>A return value represents a list of claims provider hierarchy trees.</returns>
        public SPProviderHierarchyTree[] SearchAll(ArrayOfString providerNames, SPPrincipalType principalType, string searchPattern, int maxCount)
        {
            SPProviderHierarchyTree[] responseOfSearchAll = new SPProviderHierarchyTree[0];
            try
            {
                responseOfSearchAll = this.cpswsClient.SearchAll(providerNames, principalType, searchPattern, maxCount);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    @"There is an exception generated when calling [SearchAll] method:\r\n{0}",
                    faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.VerifySearchAll(responseOfSearchAll);

            return(responseOfSearchAll);
        }
        public void MSCPSWS_S04_TC04_ResolveMultipleStrings_SomeValid()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] allProviders = TestSuiteBase.GetAllProviders();

            ArrayOfString   providerNames = new ArrayOfString();
            SPPrincipalType principalType = SPPrincipalType.User;
            ArrayOfString   resolveInput  = new ArrayOfString();

            resolveInput.Add(Common.GetConfigurationPropertyValue("OwnerLogin", this.Site));
            resolveInput.Add(this.GenerateInvalidUser());

            foreach (SPProviderHierarchyTree provider in allProviders)
            {
                providerNames.Add(provider.ProviderName);
            }

            // Call Resolve multiple method to resolve 2 users to picker entities, one valid and another invalid.
            PickerEntity[] responseOfResolveMultipleResult = CPSWSAdapter.ResolveMultiple(providerNames, principalType, resolveInput);
            Site.Assert.IsNotNull(responseOfResolveMultipleResult, "The resolve multiple result should not be null.");

            // If the resolve multiple result contains 2 picker entities, that is to say, one picker entity in the response corresponding to one user in the request, then the following requirement can be captured.
            Site.CaptureRequirementIfAreEqual <int>(
                responseOfResolveMultipleResult.Length,
                2,
                345,
                @"[In ResolveMultipleResponse] The list [ResolveMultipleResult] MUST contain one and only one picker entity per string in the input.");

            Site.CaptureRequirementIfAreEqual <int>(
                responseOfResolveMultipleResult.Length,
                2,
                325,
                @"[In ResolveMultiple] The protocol server MUST resolve across all claims providers that meet all the following criteria:
The claims providers are associated with the Web application (1) specified in the input message.
The claims providers are listed in the provider names in the input message.
The claims providers support resolve.");
        }
        public void MSCPSWS_S05_TC04_SearchAll_nullSearchPattern()
        {
            // Get the provider names of all the providers from the hierarchy
            ArrayOfString providerNames = new ArrayOfString();

            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();
            providerNames.AddRange(responseOfGetHierarchyAllResult.Select(root => root.ProviderName));
            foreach (SPProviderHierarchyNode node in responseOfGetHierarchyAllResult.SelectMany(root => root.Children))
            {
                this.DepthFirstTraverse(node, ref providerNames);
            }

            // Set search principal Type.
            SPPrincipalType principalType = SPPrincipalType.SharePointGroup;

            // Get max count of matched entities allowed to return for this search.
            int maxCount = Convert.ToInt32(Common.GetConfigurationPropertyValue("MaxCount", Site));

            bool caughtException = false;

            try
            {
                // Set searchPattern as null and call searchAll.
                CPSWSAdapter.SearchAll(providerNames, principalType, null, maxCount);
            }
            catch (System.ServiceModel.FaultException faultException)
            {
                caughtException = true;

                // Verify Requirement 650, if the server returns an ArgumentNullException<"searchPattern"> message.
                Site.CaptureRequirementIfIsTrue(this.VerifyArgumentNullException(faultException, "searchPattern"), 650, @"[In SearchAll] If this [searchPattern] is NULL, the protocol server MUST return an ArgumentNullException<""searchPattern""> message.");
            }
            finally
            {
                this.Site.Assert.IsTrue(caughtException, "If searchPattern is NULL, the protocol server MUST return an ArgumentNullException<searchPattern> message.");
            }
        }
        public void MSCPSWS_S04_TC01_ResolveString()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] allProviders = TestSuiteBase.GetAllProviders();

            ArrayOfString   providerNames    = new ArrayOfString();
            SPPrincipalType principalType    = SPPrincipalType.SecurityGroup;
            string          resolveInput     = string.Empty;
            bool            isResolveSuccess = false;

            foreach (SPProviderHierarchyTree provider in allProviders)
            {
                if (provider.EntityData.Length != 0)
                {
                    providerNames.Add(provider.ProviderName);

                    foreach (PickerEntity entityData in provider.EntityData)
                    {
                        resolveInput = entityData.DisplayText;

                        // Call Resolve method to resolve an input string to picker entities using a list of claims providers.
                        PickerEntity[] responseOfResolveResult = CPSWSAdapter.Resolve(providerNames, principalType, resolveInput);
                        Site.Assert.IsNotNull(responseOfResolveResult, "Resolve result should not null.");
                        isResolveSuccess = true;
                    }
                }
            }

            // If the claims providers listed in the provider names in the input message is resolved successfully, then the following requirement can be captured.
            Site.CaptureRequirementIfIsTrue(
                isResolveSuccess,
                280,
                @"[In Resolve] The protocol server MUST resolve across all claims providers that meet all the following criteria:
The claims providers are associated with the Web application specified in the input message.
The claims providers are listed in the provider names in the input message.
The claims providers support resolve.");
        }
Exemplo n.º 25
0
        /// <summary>
        /// A method used to retrieve a claims provider hierarchy tree from a claims provider.
        /// </summary>
        /// <param name="providerName">A parameter represents a provider name.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="hierarchyNodeID">A parameter represents the identifier of the node to be used as root of the returned claims provider hierarchy tree.</param>
        /// <param name="numberOfLevels">A parameter represents the maximum number of levels that can be returned by the protocol server in any of the output claims provider hierarchy tree.</param>
        /// <returns>A return value represents a claims provider hierarchy tree.</returns>
        public SPProviderHierarchyTree GetHierarchy(string providerName, SPPrincipalType principalType, string hierarchyNodeID, int numberOfLevels)
        {
            SPProviderHierarchyTree responseOfGetHierarchy = new SPProviderHierarchyTree();

            try
            {
                responseOfGetHierarchy = this.cpswsClient.GetHierarchy(providerName, principalType, hierarchyNodeID, numberOfLevels);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    @"There is an exception generated when calling [GetHierarchy] method:\r\n{0}",
                    faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.ValidateGetHierarchyResponseData(responseOfGetHierarchy);

            return(responseOfGetHierarchy);
        }
        public void MSCPSWS_S02_TC09_GetHierarchyAll_InvalidNumberOfLevels()
        {
            // Call the helper method to get all claims providers.
            SPProviderHierarchyTree[] getAllProviders = TestSuiteBase.GetAllProviders();

            ArrayOfString   providerNames  = new ArrayOfString();
            SPPrincipalType principalType  = SPPrincipalType.SharePointGroup;
            int             numberOfLevels = 0;

            foreach (SPProviderHierarchyTree provider in getAllProviders)
            {
                providerNames.Add(provider.ProviderName);
            }

            bool caughtException = false;

            try
            {
                // Call GetHierarchyAll method with numberOfLevels parameter sets to invalid.
                CPSWSAdapter.GetHierarchyAll(providerNames, principalType, numberOfLevels);
            }
            catch (FaultException faultException)
            {
                caughtException = true;

                // If the server returns an ArgumentNullException<""numberOfLevels""> message, then the following requirement can be captured.
                Site.CaptureRequirementIfIsTrue(
                    this.VerifyArgumentOutOfRangeException(faultException, "numberOfLevels"),
                    591,
                    @"[In GetHierarchyAll] The protocol server MUST return an ArgumentOutOfRangeException<""numberOfLevels""> message if the value of this element [numberOfLevels] is less than 1.");
            }
            finally
            {
                this.Site.Assert.IsTrue(caughtException, "The protocol server should return ArgumentOutOfRangeException<numberOfLevels> message if the value of this element [numberOfLevels] is less than 1.");
            }
        }
        /// <summary>
        /// A method used to retrieve a claims provider hierarchy tree from a claims provider.
        /// </summary>
        /// <param name="providerName">A parameter represents a provider name.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="hierarchyNodeID">A parameter represents the identifier of the node to be used as root of the returned claims provider hierarchy tree.</param>
        /// <param name="numberOfLevels">A parameter represents the maximum number of levels that can be returned by the protocol server in any of the output claims provider hierarchy tree.</param>
        /// <returns>A return value represents a claims provider hierarchy tree.</returns>
        public SPProviderHierarchyTree GetHierarchy(string providerName, SPPrincipalType principalType, string hierarchyNodeID, int numberOfLevels)
        {
            SPProviderHierarchyTree responseOfGetHierarchy = new SPProviderHierarchyTree();
            try
            {
                responseOfGetHierarchy = this.cpswsClient.GetHierarchy(providerName, principalType, hierarchyNodeID, numberOfLevels);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                                LogEntryKind.Debug,
                                @"There is an exception generated when calling [GetHierarchy] method:\r\n{0}",
                                faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.ValidateGetHierarchyResponseData(responseOfGetHierarchy);

            return responseOfGetHierarchy;
        }
Exemplo n.º 28
0
 /// <remarks/>
 public void SearchPrincipalsAsync(string searchText, int maxResults, SPPrincipalType principalType)
 {
     this.SearchPrincipalsAsync(searchText, maxResults, principalType, null);
 }
        /// <summary>
        /// A method used to resolve a list of claims to picker entities using a list of claims providers.
        /// </summary>
        /// <param name="providerNames">A parameter represents a list of provider names.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the result.</param>
        /// <param name="resolveInput">A parameter represents a list of claims to be resolved.</param>
        /// <returns>A return value represents a list of picker entities.</returns>
        public PickerEntity[] ResolveMultipleClaim(ArrayOfString providerNames, SPPrincipalType principalType, SPClaim[] resolveInput)
        {
            PickerEntity[] responseOfResolveMultipleClaim = new PickerEntity[0];
            try
            {
                responseOfResolveMultipleClaim = this.cpswsClient.ResolveMultipleClaim(providerNames, principalType, resolveInput);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                                LogEntryKind.Debug,
                                @"There is an exception generated when calling [ResolveMultipleClaim] method:\r\n{0}",
                                faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.ValidateResolveMultipleClaimResponseData(responseOfResolveMultipleClaim);

            return responseOfResolveMultipleClaim;
        }
        /// <summary>
        /// A method used to perform a search for entities on a list of claims providers.
        /// </summary>
        /// <param name="providerNames">A parameter represents a list of provider names.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="searchPattern">A parameter represents the search string.</param>
        /// <param name="maxCount">A parameter represents the maximum number of matched entities to be returned in total across all the output claims provider hierarchy trees.</param>
        /// <returns>A return value represents a list of claims provider hierarchy trees.</returns>
        public SPProviderHierarchyTree[] SearchAll(ArrayOfString providerNames, SPPrincipalType principalType, string searchPattern, int maxCount)
        {
            SPProviderHierarchyTree[] responseOfSearchAll = new SPProviderHierarchyTree[0];
            try
            {
                responseOfSearchAll = this.cpswsClient.SearchAll(providerNames, principalType, searchPattern, maxCount);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                                LogEntryKind.Debug,
                                @"There is an exception generated when calling [SearchAll] method:\r\n{0}",
                                faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.VerifySearchAll(responseOfSearchAll);

            return responseOfSearchAll;
        }
Exemplo n.º 31
0
 /// <remarks/>
 public void ResolvePrincipalsAsync(string[] principalKeys, SPPrincipalType principalType, bool addToUserInfoList)
 {
     this.ResolvePrincipalsAsync(principalKeys, principalType, addToUserInfoList, null);
 }
Exemplo n.º 32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SPRoleAssignment" /> class.
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="name">name.</param>
 /// <param name="loginName">loginName.</param>
 /// <param name="principalType">principalType.</param>
 /// <param name="permissionLevels">permissionLevels.</param>
 public SPRoleAssignment(int id = default(int), string name = default(string), string loginName = default(string), SPPrincipalType principalType = default(SPPrincipalType), List <string> permissionLevels = default(List <string>))
 {
     this.Name             = name;
     this.LoginName        = loginName;
     this.PermissionLevels = permissionLevels;
     this.Id               = id;
     this.Name             = name;
     this.LoginName        = loginName;
     this.PrincipalType    = principalType;
     this.PermissionLevels = permissionLevels;
 }
        public void MSCPSWS_S05_TC01_Search()
        {
            // Set principal type for search.
            SPPrincipalType principalType = SPPrincipalType.SecurityGroup;

            // Generate ArrayOfSPProviderSearchArguments.
            List <SPProviderSearchArguments> arrayOfSPProviderSearchArguments = new List <SPProviderSearchArguments>();

            Site.Assume.IsNotNull(this.GenerateProviderSearchArgumentsInput_Valid(), "There should be a valid provider search arguments!");
            SPProviderSearchArguments providerSearchArguments = this.GenerateProviderSearchArgumentsInput_Valid();

            arrayOfSPProviderSearchArguments.Add(providerSearchArguments);

            Site.Assume.IsNotNull(TestSuiteBase.SearchPattern, "The search pattern should not be null!");

            // Call Search operation.
            SPProviderHierarchyTree[] responseOfSearchResult = CPSWSAdapter.Search(arrayOfSPProviderSearchArguments.ToArray(), principalType, TestSuiteBase.SearchPattern);

            Site.Assert.IsNotNull(responseOfSearchResult, "The search result MUST be not null.");
            Site.Assert.IsTrue(responseOfSearchResult.Length >= 1, "The search result MUST contain at least one claims provider.");

            // Get the input provider names list.
            ArrayOfString providerNames = new ArrayOfString();

            providerNames.AddRange(arrayOfSPProviderSearchArguments.Select(root => root.ProviderName));

            // Requirement capture condition.
            bool searchSuccess = false;

            foreach (SPProviderHierarchyTree providerTree in responseOfSearchResult)
            {
                if (providerTree.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    if (providerNames.Contains(providerTree.ProviderName))
                    {
                        searchSuccess = true;
                    }
                    else
                    {
                        // Jump over the Hierarchy Provider tree that the server sees fit to return together with the result Claims provider trees.
                        continue;
                    }
                }
                else if (providerNames.Contains(providerTree.ProviderName))
                {
                    searchSuccess = true;
                }
                else
                {
                    Site.Assert.Fail("The provider names in the search result should be contained in the provider names in the input message!");
                }
            }

            // Capture requirement 378 by matching the input provider name with the result claims provider name,
            // The search input claims provider already satisfy the condition 1 and 3 in requirement 378 in test environment configuration.
            Site.CaptureRequirementIfIsTrue(
                searchSuccess,
                378,
                @"[In Search] The protocol server MUST search across all claims providers that meet all the following criteria:
                The claims providers are associated with the Web application (1) specified in the input message.
                The claims providers are listed in the provider search arguments in the input message.
                The claims providers support search.");

            // Capture requirement 398 by matching searchPattern with the result claims provider's Nm attribute.
            Site.CaptureRequirementIfIsTrue(searchSuccess, 398, @"[In Search] searchPattern: The protocol server MUST search for the string in each claims provider.");

            // Capture requirement 404 by matching searchPattern with the result claims provider's Nm attribute.
            Site.CaptureRequirementIfIsTrue(searchSuccess, 404, @"[In SearchResponse] The protocol server MUST return one claims provider hierarchy tree for each claims provider that contains entities that match the search string.");
        }
        /// <summary>
        /// A method used to retrieve a list of claims provider hierarchy trees from a list of claims providers.
        /// </summary>
        /// <param name="providerNames">A parameter represents a list of provider names.</param>
        /// <param name="principalType">A parameter represents which type of picker entities to be included in the output claims provider hierarchy tree.</param>
        /// <param name="numberOfLevels">A parameter represents the maximum number of levels that can be returned by the protocol server in any of the output claims provider hierarchy tree.</param>
        /// <returns>A return value represents a list of claims provider hierarchy trees.</returns>
        public SPProviderHierarchyTree[] GetHierarchyAll(ArrayOfString providerNames, SPPrincipalType principalType, int numberOfLevels)
        {
            SPProviderHierarchyTree[] responseOfGetHierarchyAll = new SPProviderHierarchyTree[0];
            try
            {
                responseOfGetHierarchyAll = this.cpswsClient.GetHierarchyAll(providerNames, principalType, numberOfLevels);
                this.CaptureTransportRelatedRequirements();
            }
            catch (FaultException faultEX)
            {
                this.Site.Log.Add(
                                LogEntryKind.Debug,
                                @"There is an exception generated when calling [GetHierarchyAll] method:\r\n{0}",
                                faultEX.Message);
                this.CaptureTransportRelatedRequirements();
                this.ValidateAndCaptureSOAPFaultRequirement(faultEX);
                throw;
            }

            this.ValidateGetHierarchyAllResponseData(responseOfGetHierarchyAll);

            return responseOfGetHierarchyAll;
        }