예제 #1
0
        public void MSFSSHTTP_FSSHTTPB_S03_TC01_GetLock_FileNotExistsOrCannotBeCreated()
        {
            // Get a schema lock with a nonexistent file, expect the server returns the error code "FileNotExistsOrCannotBeCreated".
            string fileUrlNotExit = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);

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

            SchemaLockSubRequestType  subRequest            = SharedTestSuiteHelper.CreateSchemaLockSubRequest(SchemaLockRequestTypes.GetLock, false, null);
            CellStorageResponse       response              = Adapter.CellStorageRequest(fileUrlNotExit, new SubRequestType[] { subRequest });
            SchemaLockSubResponseType schemaLockSubResponse = SharedTestSuiteHelper.ExtractSubResponse <SchemaLockSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1913
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.FileNotExistsOrCannotBeCreated,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(schemaLockSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1913,
                    @"[In SchemaLock Subrequest][The protocol server returns results based on the following conditions:] If the protocol server was unable to find the URL for the file specified in the Url attribute, the protocol server reports a failure by returning an error code value set to ""FileNotExistsOrCannotBeCreated"" in the ErrorCode attribute sent back in the SubResponse element.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.FileNotExistsOrCannotBeCreated,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(schemaLockSubResponse.ErrorCode, this.Site),
                    @"[In SchemaLock Subrequest][The protocol server returns results based on the following conditions:] If the protocol server was unable to find the URL for the file specified in the Url attribute, the protocol server reports a failure by returning an error code value set to ""FileNotExistsOrCannotBeCreated"" in the ErrorCode attribute sent back in the SubResponse element.");
            }
        }
예제 #2
0
        /// <summary>
        /// This method is used to record the schema lock status with specified client ID and schema lock ID for the file URL.
        /// </summary>
        /// <param name="fileUrl">Specify the file URL which get the schema lock.</param>
        /// <param name="clientId">Specify the client ID of the schema lock.</param>
        /// <param name="schemaLockId">Specify the schema ID of the schema lock.</param>
        /// <param name="userName">Specify the user name of the user who calls cell storage service.</param>
        /// <param name="password">Specify the password of the user who calls cell storage service.</param>
        /// <param name="domain">Specify the domain of the user who calls cell storage service.</param>
        public void RecordSchemaLock(string fileUrl, string clientId, string schemaLockId, string userName, string password, string domain)
        {
            Action function = () =>
            {
                SchemaLockSubRequestType schemaLockRequest = new SchemaLockSubRequestType();
                schemaLockRequest.SubRequestToken = SequenceNumberGenerator.GetCurrentToken().ToString();
                schemaLockRequest.SubRequestData  = new SchemaLockSubRequestDataType();
                schemaLockRequest.SubRequestData.SchemaLockRequestType          = SchemaLockRequestTypes.ReleaseLock;
                schemaLockRequest.SubRequestData.SchemaLockRequestTypeSpecified = true;
                schemaLockRequest.SubRequestData.SchemaLockID = schemaLockId;
                schemaLockRequest.SubRequestData.ClientID     = clientId;

                IMS_FSSHTTP_FSSHTTPBAdapter adapter = site.GetAdapter <IMS_FSSHTTP_FSSHTTPBAdapter>();
                this.intializeContext(fileUrl, userName, password, domain);

                SchemaLockSubResponseType subResponse = SharedTestSuiteHelper.ExtractSubResponse <SchemaLockSubResponseType>(adapter.CellStorageRequest(fileUrl, new SubRequestType[] { schemaLockRequest }), 0, 0, site);

                if (!string.Equals("Success", subResponse.ErrorCode, StringComparison.OrdinalIgnoreCase))
                {
                    this.errorMessage.Add(string.Format("Failed to release the schema lock for the client id {1} and schema lock id {5}on the file {0} using the following user: {2}/{3}and password:{4}", fileUrl, clientId, userName, domain, password, schemaLockId));
                    this.isEnvironmentRollbackSuccess = false;
                }
            };

            this.AddOrUpdate(new SharedLockKey(fileUrl, clientId, schemaLockId), function);
        }
        /// <summary>
        /// This method is used to prepare a schema lock on the file with the specified schema lock id and client id.
        /// </summary>
        /// <param name="fileUrl">Specify the file which is locked.</param>
        /// <param name="clientId">Specify the client ID.</param>
        /// <param name="schemaLockId">Specify the schemaLock ID.</param>
        /// <param name="userName">Specify the user name of the user who calls cell storage service.</param>
        /// <param name="password">Specify the password of the user who calls cell storage service.</param>
        /// <param name="domain">Specify the domain of the user who calls cell storage service.</param>
        /// <param name="timeout">Specify the timeout value.</param>
        protected void PrepareSchemaLock(string fileUrl, string clientId, string schemaLockId, string userName, string password, string domain, int timeout = SharedTestSuiteHelper.DefaultTimeOut)
        {
            this.InitializeContext(fileUrl, userName, password, domain);

            // Get a schema
            SchemaLockSubRequestType subRequest = SharedTestSuiteHelper.CreateSchemaLockSubRequest(SchemaLockRequestTypes.GetLock, false, null);

            subRequest.SubRequestData.SchemaLockID = schemaLockId;
            subRequest.SubRequestData.ClientID     = clientId;
            subRequest.SubRequestData.Timeout      = timeout.ToString();
            CellStorageResponse       response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
            SchemaLockSubResponseType schemaLockSubResponse = SharedTestSuiteHelper.ExtractSubResponse <SchemaLockSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(schemaLockSubResponse.ErrorCode, this.Site),
                "Test case cannot continue unless the user {0} Get schema lock id {1} with client id {3} sub request succeeds on the file {2}.",
                this.UserName01,
                schemaLockId,
                this.DefaultFileUrl,
                clientId);
            this.StatusManager.RecordSchemaLock(this.DefaultFileUrl, subRequest.SubRequestData.ClientID, subRequest.SubRequestData.SchemaLockID, userName, password, domain);
        }
예제 #4
0
        public void MSFSSHTTP_FSSHTTPB_S03_TC02_GetLock_UrlNotSpecified()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Create a GetLock subRequest with all valid parameters.
            SchemaLockSubRequestType subRequest = SharedTestSuiteHelper.CreateSchemaLockSubRequestForGetLock(null);

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

            try
            {
                // Send a GetLock for schema lock subRequest to the protocol server without specifying URL attribute.
                response = this.Adapter.CellStorageRequest(null, new SubRequestType[] { subRequest });
            }
            catch (System.Xml.XmlException exception)
            {
                string message = exception.Message;
                isR3006Verified  = message.Contains("Duplicate attribute");
                isR3006Verified &= message.Contains("ErrorCode");
            }

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3006
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3006, this.Site))
                {
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists.");

                    Site.CaptureRequirementIfIsTrue(
                        isR3006Verified,
                        "MS-FSSHTTP",
                        3006,
                        @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element doesn't exist, 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_R3007
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3007, this.Site))
                {
                    Site.CaptureRequirementIfIsNull(
                        response.ResponseCollection,
                        "MS-FSSHTTP",
                        3007,
                        @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element doesn't exist, the implementation does not return Response element. <8> Section 2.2.3.5:  SharePoint Server 2013 will not return Response element.");
                }
            }
            else
            {
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3006, this.Site))
                {
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists.");

                    Site.Assert.IsTrue(
                        isR3006Verified,
                        "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists.");
                }

                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3007, this.Site))
                {
                    Site.Assert.IsNull(
                        response.ResponseCollection,
                        @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element doesn't exist, the implementation does not return Response element. <8> Section 2.2.3.5:  SharePoint Server 2013 will not return Response element.");
                }
            }
        }
예제 #5
0
        public void MSFSSHTTP_FSSHTTPB_S03_TC04_GetLock_Success_ExclusiveLockReturnReason_CheckedOutByCurrentUser()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Check out one file by a specified user name.
            bool isCheckOutSuccess = SutManagedAdapter.CheckOutFile(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            Site.Assert.AreEqual(true, isCheckOutSuccess, "Cannot change the file {0} to check out status using the user name {1} and password{2}", this.DefaultFileUrl, this.UserName01, this.Password01);
            this.StatusManager.RecordFileCheckOut(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            CheckLockAvailability();

            // Get a schema lock with AllowFallbackToExclusive set to true, expect the server returns the error code "Success".
            SchemaLockSubRequestType  subRequest            = SharedTestSuiteHelper.CreateSchemaLockSubRequest(SchemaLockRequestTypes.GetLock, true, null);
            CellStorageResponse       response              = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
            SchemaLockSubResponseType schemaLockSubResponse = SharedTestSuiteHelper.ExtractSubResponse <SchemaLockSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(schemaLockSubResponse.ErrorCode, this.Site), "The test case cannot continue unless the server responses Success when the user get a schema lock with AllowFallBack attribute true on an already checked out file by the same account.");
            this.StatusManager.RecordExclusiveLock(this.DefaultFileUrl, subRequest.SubRequestData.ExclusiveLockID);

            #region Verify related requirements

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R404
                Site.CaptureRequirementIfAreEqual <string>(
                    "ExclusiveLock",
                    schemaLockSubResponse.SubResponseData.LockType,
                    "MS-FSSHTTP",
                    404,
                    @"[In LockTypes] ExclusiveLock: The string value ""ExclusiveLock"", indicating an exclusive lock on the file.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R406
                Site.CaptureRequirementIfAreEqual <string>(
                    "ExclusiveLock",
                    schemaLockSubResponse.SubResponseData.LockType,
                    "MS-FSSHTTP",
                    406,
                    @"[In LockTypes][ExclusiveLock or 2] In a cell storage service response message, an exclusive lock indicates that an exclusive lock is granted to the current client for that specific file.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1428
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    "For MS-FSSHTTP_R1428 and MS-FSSHTTP_R717, the ExclusiveLockReturnReason attribute in the response should be specified, actually it is {0}.",
                    schemaLockSubResponse.SubResponseData.ExclusiveLockReturnReasonSpecified ? "specified" : "not specified");

                Site.CaptureRequirementIfIsTrue(
                    schemaLockSubResponse.SubResponseData.ExclusiveLockReturnReasonSpecified,
                    "MS-FSSHTTP",
                    1428,
                    @"[In SubResponseDataOptionalAttributes][ExclusiveLockReturnReason] The ExclusiveLockReturnReason attribute MUST be specified in a subresponse that is generated in response to one of the following types of cell storage service subrequest operations when the LockType attribute in the subresponse is set to ""ExclusiveLock"": A schema lock subrequest of type ""Get lock"".");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R717
                Site.CaptureRequirementIfIsTrue(
                    schemaLockSubResponse.SubResponseData.ExclusiveLockReturnReasonSpecified,
                    "MS-FSSHTTP",
                    717,
                    @"[In SchemaLockSubResponseDataType] The ExclusiveLockReturnReason attribute MUST be specified in a schema lock subresponse that is generated in response to a schema lock subrequest of type ""Get lock"" when the LockType attribute in the subresponse is set to ""ExclusiveLock"".");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R715
                Site.CaptureRequirementIfAreEqual <ExclusiveLockReturnReasonTypes>(
                    ExclusiveLockReturnReasonTypes.CheckedOutByCurrentUser,
                    schemaLockSubResponse.SubResponseData.ExclusiveLockReturnReason,
                    "MS-FSSHTTP",
                    715,
                    @"[In SchemaLockSubResponseDataType] ExclusiveLockReturnReason: An ExclusiveLockReturnReasonTypes that specifies the reason why an exclusive lock is granted in a schema lock subresponse.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R350
                Site.CaptureRequirementIfAreEqual <ExclusiveLockReturnReasonTypes>(
                    ExclusiveLockReturnReasonTypes.CheckedOutByCurrentUser,
                    schemaLockSubResponse.SubResponseData.ExclusiveLockReturnReason,
                    "MS-FSSHTTP",
                    350,
                    @"[In ExclusiveLockReturnReasonTypes] CheckedOutByCurrentUser: The string value ""CheckedOutByCurrentUser"", indicating that an exclusive lock is granted on the file because the file is checked out by the current user who sent the cell storage service request message.");
            }
            else
            {
                Site.Assert.AreEqual <string>(
                    "ExclusiveLock",
                    schemaLockSubResponse.SubResponseData.LockType,
                    @"[In LockTypes] ExclusiveLock: The string value ""ExclusiveLock"", indicating an exclusive lock on the file.");

                Site.Assert.IsTrue(
                    schemaLockSubResponse.SubResponseData.ExclusiveLockReturnReasonSpecified,
                    @"[In SubResponseDataOptionalAttributes][ExclusiveLockReturnReason] The ExclusiveLockReturnReason attribute MUST be specified in a subresponse that is generated in response to one of the following types of cell storage service subrequest operations when the LockType attribute in the subresponse is set to ""ExclusiveLock"": A schema lock subrequest of type ""Get lock"".");

                Site.Assert.AreEqual <ExclusiveLockReturnReasonTypes>(
                    ExclusiveLockReturnReasonTypes.CheckedOutByCurrentUser,
                    schemaLockSubResponse.SubResponseData.ExclusiveLockReturnReason,
                    @"[In SchemaLockSubResponseDataType] ExclusiveLockReturnReason: An ExclusiveLockReturnReasonTypes that specifies the reason why an exclusive lock is granted in a schema lock subresponse.");
            }

            #endregion
        }
        /// <summary>
        /// This method is used to test whether the lock with the specified id exist on the file.
        /// </summary>
        /// <param name="file">Specify the file.</param>
        /// <param name="schemaLockId">Specify the schemaLock ID.</param>
        /// <param name="userName">Specify the user name of the user who calls cell storage service.</param>
        /// <param name="password">Specify the password of the user who calls cell storage service.</param>
        /// <param name="domain">Specify the domain of the user who calls cell storage service.</param>
        /// <returns>Return true if exist, otherwise return false.</returns>
        protected bool CheckSchemaLockExist(string file, string schemaLockId, string userName, string password, string domain)
        {
            this.InitializeContext(file, userName, password, domain);

            // Generate a new schema lock id value which is different with the given one.
            System.Guid newId;
            do
            {
                newId = System.Guid.NewGuid();
            }while (newId == new System.Guid(schemaLockId));

            if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 93101, this.Site))
            {
                // Check the schema lock availability using the new schema lock id.
                SchemaLockSubRequestType subRequest = SharedTestSuiteHelper.CreateSchemaLockSubRequest(SchemaLockRequestTypes.CheckLockAvailability, null, null);
                subRequest.SubRequestData.SchemaLockID = newId.ToString();
                CellStorageResponse       response = this.Adapter.CellStorageRequest(file, new SubRequestType[] { subRequest });
                SchemaLockSubResponseType schemaLockSubResponse = SharedTestSuiteHelper.ExtractSubResponse <SchemaLockSubResponseType>(response, 0, 0, this.Site);

                ErrorCodeType error = SharedTestSuiteHelper.ConvertToErrorCodeType(schemaLockSubResponse.ErrorCode, this.Site);
                if (error == ErrorCodeType.FileAlreadyLockedOnServer)
                {
                    // Now there could be kind of two conditions:
                    //  1) There is an exclusive lock
                    //  2) There is a schema lock
                    // So it is needed to check the schema lock with the given schema lock id should exist.
                    subRequest = SharedTestSuiteHelper.CreateSchemaLockSubRequest(SchemaLockRequestTypes.CheckLockAvailability, null, null);
                    subRequest.SubRequestData.SchemaLockID = schemaLockId;
                    response = this.Adapter.CellStorageRequest(file, new SubRequestType[] { subRequest });
                    schemaLockSubResponse = SharedTestSuiteHelper.ExtractSubResponse <SchemaLockSubResponseType>(response, 0, 0, this.Site);

                    return(SharedTestSuiteHelper.ConvertToErrorCodeType(schemaLockSubResponse.ErrorCode, this.Site) == ErrorCodeType.Success);
                }
                else
                {
                    if (error != ErrorCodeType.Success)
                    {
                        this.Site.Assert.Fail(
                            "If the schema lock {0} does not exist, check the schema lock using the id {0} should success, but actual the result is {2}",
                            schemaLockId,
                            newId.ToString(),
                            error.ToString());
                    }

                    return(false);
                }
            }
            else if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 93102, this.Site))
            {
                // Check the schema lock availability using the new schema lock id.
                CoauthSubRequestType  subRequest        = SharedTestSuiteHelper.CreateCoauthSubRequestForCheckLockAvailability(SharedTestSuiteHelper.DefaultClientID, newId.ToString());
                CellStorageResponse   response          = this.Adapter.CellStorageRequest(file, new SubRequestType[] { subRequest });
                CoauthSubResponseType coauthSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CoauthSubResponseType>(response, 0, 0, this.Site);

                ErrorCodeType error = SharedTestSuiteHelper.ConvertToErrorCodeType(coauthSubResponse.ErrorCode, this.Site);
                if (error == ErrorCodeType.FileAlreadyLockedOnServer)
                {
                    // Now there could be kind of two conditions:
                    //  1) There is an exclusive lock
                    //  2) There is a schema lock
                    // So it is needed to check the schema lock with the given schema lock id should exist.
                    subRequest        = SharedTestSuiteHelper.CreateCoauthSubRequestForCheckLockAvailability(SharedTestSuiteHelper.DefaultClientID, schemaLockId);
                    response          = this.Adapter.CellStorageRequest(file, new SubRequestType[] { subRequest });
                    coauthSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CoauthSubResponseType>(response, 0, 0, this.Site);

                    return(SharedTestSuiteHelper.ConvertToErrorCodeType(coauthSubResponse.ErrorCode, this.Site) == ErrorCodeType.Success);
                }
                else
                {
                    if (error != ErrorCodeType.Success)
                    {
                        this.Site.Assert.Fail(
                            "If the schema lock {0} does not exist, check the schema lock using the id {0} should success, but actual the result is {2}",
                            schemaLockId,
                            newId.ToString(),
                            error.ToString());
                    }

                    return(false);
                }
            }

            this.Site.Assert.Fail("The server should at least support one of operations: Coauthoring session and Schema Lock");
            return(false);
        }