Beispiel #1
0
        public void TestCase_S10_TC07_InvalidRequestDependencyType()
        {
            if (!Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 325, this.Site))
            {
                Site.Assume.Inconclusive("Implementation does not return InvalidRequestDependencyType when the sub-request dependency type that is not valid.");
            }

            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Create a serverTime subRequest with all valid parameters.
            ServerTimeSubRequestType serverTimeSubRequest = SharedTestSuiteHelper.CreateServerTimeSubRequest(SequenceNumberGenerator.GetCurrentToken());

            // Create a WhoAmI subRequest with all valid parameters and depends on the serverTime subRequest.
            WhoAmISubRequestType whoAmiSubRequest = SharedTestSuiteHelper.CreateWhoAmISubRequest(SequenceNumberGenerator.GetCurrentToken());

            whoAmiSubRequest.DependencyType          = DependencyTypes.Invalid;
            whoAmiSubRequest.DependencyTypeSpecified = true;
            whoAmiSubRequest.DependsOn = serverTimeSubRequest.SubRequestToken;

            // Send the subRequest to the protocol server, expect the protocol server returns error code "InvalidRequestDependencyType".
            CellStorageResponse       response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { serverTimeSubRequest, whoAmiSubRequest });
            ServerTimeSubResponseType serverTimeSubResponse = SharedTestSuiteHelper.ExtractSubResponse <ServerTimeSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(serverTimeSubResponse.ErrorCode, this.Site), "The serverTime operation should succeed.");
            SchemaLockSubResponseType subResponse = SharedTestSuiteHelper.ExtractSubResponse <SchemaLockSubResponseType>(response, 0, 1, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R325
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.InvalidRequestDependencyType,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    325,
                    @"[In DependencyCheckRelatedErrorCodeTypes] InvalidRequestDependencyType: 
                             Indicates an error when a subrequest dependency type that is not valid is specified. (Microsoft SharePoint Foundation 2010/Microsoft SharePoint Server 2010 follow this behavior.)");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.InvalidRequestDependencyType,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site),
                    @"[In DependencyCheckRelatedErrorCodeTypes] InvalidRequestDependencyType: 
                        Indicates an error when a subrequest dependency type that is not valid is specified. (Microsoft SharePoint Foundation 2010/Microsoft SharePoint Server 2010 follow this behavior.)");
            }
        }
        public void TestCase_S05_TC01_WhoAmI_Success()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Invoke "WhoAmI"sub-request with correct input parameters.
            WhoAmISubRequestType  whoAmISubRequest     = SharedTestSuiteHelper.CreateWhoAmISubRequest(SequenceNumberGenerator.GetCurrentToken());
            CellStorageResponse   cellStoreageResponse = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { whoAmISubRequest });
            WhoAmISubResponseType whoAmISubResponse    = SharedTestSuiteHelper.ExtractSubResponse <WhoAmISubResponseType>(cellStoreageResponse, 0, 0, this.Site);

            this.Site.Assert.IsNotNull(whoAmISubResponse, "The object 'whoAmISubResponse' should not be null.");
            this.Site.Assert.IsNotNull(whoAmISubResponse.ErrorCode, "The object 'whoAmISubResponse.ErrorCode' should not be null.");

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error code in the sub-response equals "Success", then capture MS-FSSHTTP_R1327, MS-FSSHTTP_R1434.
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(whoAmISubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1327,
                    @"[In WhoAmI Subrequest] The protocol server returns results based on the following conditions: Otherwise[except: the processing of the WhoAmI subrequest by the protocol server failed to get the client-specific user information or encountered an unknown exception], the protocol server sets the error code value to ""Success"" to indicate success in processing the WhoAmI subrequest.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1434
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(whoAmISubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1434,
                    @"[In WhoAmISubResponseType] The protocol server sets the value of the ErrorCode attribute to ""Success"" if the protocol server succeeds in processing the WhoAmI subrequest.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R7681
                Site.CaptureRequirementIfIsNotNull(
                    whoAmISubResponse.SubResponseData,
                    "MS-FSSHTTP",
                    7681,
                    @"[In WhoAmISubResponseType] As part of processing the WhoAmI subrequest, the SubResponseData element MUST be sent as part of the SubResponse element in a cell storage service response message if the following condition is true:
                         The ErrorCode attribute that is part of the SubResponse element is set to a value of ""Success"".");

                bool isVerifyR904 = whoAmISubResponse.SubResponseData.UserName.IndexOf(this.UserName01, System.StringComparison.OrdinalIgnoreCase) >= 0;
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    "For MS-FSSHTTP_R904, expect the UserName attribute contains the value {0}, the actual UserName attribute value is {1}",
                    this.UserName01,
                    whoAmISubResponse.SubResponseData.UserName);

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R904
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR904,
                    "MS-FSSHTTP",
                    904,
                    @"[In WhoAmISubResponseDataOptionalAttributes] UserName: [A UserNameType] that specifies the user name for the protocol client.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(whoAmISubResponse.ErrorCode, this.Site),
                    @"[In WhoAmI Subrequest] The protocol server returns results based on the following conditions: Otherwise[except: the processing of the WhoAmI subrequest by the protocol server failed to get the client-specific user information or encountered an unknown exception], the protocol server sets the error code value to ""Success"" to indicate success in processing the WhoAmI subrequest.");

                Site.Assert.IsNotNull(
                    whoAmISubResponse.SubResponseData,
                    @"[In WhoAmISubResponseType] As part of processing the WhoAmI subrequest, the SubResponseData element MUST be sent as part of the SubResponse element in a cell storage service response message if the following condition is true:
                        The ErrorCode attribute that is part of the SubResponse element is set to a value of ""Success"".");

                bool isVerifyR904 = whoAmISubResponse.SubResponseData.UserName.IndexOf(this.UserName01, System.StringComparison.OrdinalIgnoreCase) >= 0;
                Site.Assert.IsTrue(
                    isVerifyR904,
                    @"[In WhoAmISubResponseDataOptionalAttributes] UserName: [A UserNameType] that specifies the user name for the client.");
            }
        }
        public void MSFSSHTTP_FSSHTTPB_S05_TC01_WhoAmI_ClaimsBased()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3086, this.Site))
            {
                // Enable the windows-based authentication
                bool isSwitchedSuccessfully = SutPowerShellAdapter.SwitchClaimsAuthentication(false);
                this.Site.Assert.IsTrue(isSwitchedSuccessfully, "The windows-based authentication should be enabled successfully.");
                this.StatusManager.RecordDisableClaimsBasedAuthentication();
            }

            int waitTime   = Common.GetConfigurationPropertyValue <int>("WaitTime", this.Site);
            int retryCount = Common.GetConfigurationPropertyValue <int>("RetryCount", this.Site);

            WhoAmISubRequestType  subRequest  = null;
            CellStorageResponse   response    = null;
            WhoAmISubResponseType subResponse = null;

            while (retryCount > 0)
            {
                // Create a WhoAmI subRequest with all valid parameters
                subRequest  = SharedTestSuiteHelper.CreateWhoAmISubRequest(SequenceNumberGenerator.GetCurrentToken());
                response    = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
                subResponse = SharedTestSuiteHelper.ExtractSubResponse <WhoAmISubResponseType>(response, 0, 0, this.Site);
                Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site), "WhoAmI subRequest should be succeed.");

                Regex regex = new Regex(@"^[a-zA-Z]([a-zA-Z0-9\-_])*\\[a-zA-Z]([a-zA-Z0-9])*");
                if (regex.IsMatch(subResponse.SubResponseData.UserLogin))
                {
                    break;
                }

                retryCount--;
                if (retryCount == 0)
                {
                    Site.Assert.Fail("Additional authentication prefix should not exist in UserLogin if claim-based authentication mode is enabled");
                }

                System.Threading.Thread.Sleep(waitTime);
            }

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3087
                Regex regex           = new Regex(@"^[a-zA-Z]([a-zA-Z0-9\-_])*\\[a-zA-Z]([a-zA-Z0-9])*");
                bool  isVerifiedR3087 = regex.IsMatch(subResponse.SubResponseData.UserLogin);

                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"The UserLoginType will match pattern ^[a-zA-Z]([a-zA-Z0-9\-_])*\\[a-zA-Z]([a-zA-Z0-9])*, actually its value is {0}",
                    subResponse.SubResponseData.UserLogin);

                this.Site.CaptureRequirementIfIsTrue(
                    isVerifiedR3087,
                    "MS-FSSHTTP",
                    3087,
                    @"[In Appendix B: Product Behavior] If claims-based authentication mode isn't enabled, the implementation does return the UserLogin attribute which apply the following schema:
                              <xs:simpleType name=""UserLoginType"">
                                 <xs:restriction base=""xs:string"">
                                    <xs:pattern value=""^[a-zA-Z]([a-zA-Z0-9\-_])*\\[a-zA-Z]([a-zA-Z0-9])*""/>
                                 </xs:restriction>
                              </xs:simpleType>");
            }

            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3086
            if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3086, this.Site))
            {
                // Enable the claims-based authentication
                bool isSwitchedSuccessfully = SutPowerShellAdapter.SwitchClaimsAuthentication(true);
                this.Site.Assert.IsTrue(isSwitchedSuccessfully, "The claims-based authentication should be enabled successfully.");

                waitTime   = Common.GetConfigurationPropertyValue <int>("WaitTime", this.Site);
                retryCount = Common.GetConfigurationPropertyValue <int>("RetryCount", this.Site);

                while (retryCount > 0)
                {
                    // Send the WhoAmI subRequest to the protocol server
                    response    = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
                    subResponse = SharedTestSuiteHelper.ExtractSubResponse <WhoAmISubResponseType>(response, 0, 0, this.Site);
                    Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site), "WhoAmI subRequest should be succeed.");

                    Regex r2    = new Regex(@"([a-zA-Z]([a-zA-Z0-9\-_])*\\[a-zA-Z]([a-zA-Z0-9])*)$");
                    Match match = r2.Match(subResponse.SubResponseData.UserLogin);
                    if (r2.IsMatch(subResponse.SubResponseData.UserLogin) && match.Success && match.Index > 0)
                    {
                        break;
                    }

                    retryCount--;
                    if (retryCount == 0)
                    {
                        Site.Assert.Fail("Additional authentication prefix should not exist in UserLogin if claim-based authentication mode is enabled");
                    }

                    System.Threading.Thread.Sleep(waitTime);
                }

                Regex regex2 = new Regex(@"([a-zA-Z]([a-zA-Z0-9\-_])*\\[a-zA-Z]([a-zA-Z0-9])*)$");
                Match m      = regex2.Match(subResponse.SubResponseData.UserLogin);

                if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                {
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        string.Format("The UserLogin should have prefix when the authentication is claims based, actual the prefix {0}", m.Index > 0 ? "exists" : "does not exist"));

                    this.Site.CaptureRequirementIfIsTrue(
                        m.Success && m.Index > 0,
                        "MS-FSSHTTP",
                        3086,
                        @"[In Appendix B: Product Behavior] Implementation does add an additional authentication prefix for the UserLogin attribute. (Microsoft SharePoint Foundation 2016/Microsoft SharePoint Server 2016 and above follow this behavior.)");
                }
                else
                {
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        string.Format("The UserLogin should have prefix when the authentication is claims based, actual the prefix {0}", m.Index > 0 ? "exists" : "does not exist"));

                    this.Site.Assert.IsTrue(
                        m.Success && m.Index > 0,
                        @"[In Appendix B: Product Behavior] Implementation does add an additional authentication prefix for the UserLogin attribute. <28> Section 2.3.2.6: There is an additional authentication prefix if claims-based authentication mode is enabled. (Microsoft SharePoint Foundation 2016/Microsoft SharePoint Server 2016 and above follow this behavior.)");
                }
            }
        }
        public void MSFSSHTTP_FSSHTTPB_S05_TC03_WhoAmI_EmptyUrl()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Create a WhoAmI subRequest with all valid parameters.
            WhoAmISubRequestType subRequest = SharedTestSuiteHelper.CreateWhoAmISubRequest(SequenceNumberGenerator.GetCurrentToken());

            CellStorageResponse response = new CellStorageResponse();
            bool isR3008Verified         = false;

            try
            {
                // Send the serverTime subRequest to the protocol server with URL attribute set to en empty string.
                response = this.Adapter.CellStorageRequest(string.Empty, new SubRequestType[] { subRequest });
            }
            catch (System.Xml.XmlException e)
            {
                string message = e.Message;
                isR3008Verified  = message.Contains("Duplicate attribute");
                isR3008Verified &= message.Contains("ErrorCode");
            }

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site))
                {
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL does not exist");

                    Site.CaptureRequirementIfIsTrue(
                        isR3008Verified,
                        "MS-FSSHTTP",
                        3008,
                        @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does return two ErrorCode attributes in Response element. <11> Section 2.2.3.5:  SharePoint Server 2010 will return 2 ErrorCode attributes in Response element.");
                }

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3009
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site))
                {
                    Site.CaptureRequirementIfIsNull(
                        response.ResponseCollection,
                        "MS-FSSHTTP",
                        3009,
                        @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does not return Response element. <11> Section 2.2.3.5:  SharePoint Server 2013 will not return Response element.");
                }
            }
            else
            {
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site))
                {
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is empty string.");

                    Site.Assert.IsTrue(
                        isR3008Verified,
                        "[In Appendix B: Product Behavior] If the URL attribute of the corresponding Request element is an empty string, the implementation does return two ErrorCode attributes in Response element. &lt;3&gt; Section 2.2.3.5:  SharePoint Server 2010 will return 2 ErrorCode attributes in Response element.");
                }

                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site))
                {
                    Site.Assert.IsNull(
                        response.ResponseCollection,
                        @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does not return Response element. <8> Section 2.2.3.5:  SharePoint Server 2013 will not return Response element.");
                }
            }
        }