Пример #1
0
        public void MSFSSHTTP_FSSHTTPB_S04_TC06_ExclusiveLock_FileNotExistsOrCannotBeCreated()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);
            string notExistsFileUrl = this.DefaultFileUrl.Substring(0, this.DefaultFileUrl.LastIndexOf('/')) + "/noexistsFile.txt";
            ExclusiveLockSubRequestType subRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);

            // Get the exclusive lock with nonexistent file URL and expect the server returns error code "LockRequestFail" or "Unknown".
            CellStorageResponse          response          = this.Adapter.CellStorageRequest(notExistsFileUrl, new SubRequestType[] { subRequest });
            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

            ErrorCodeType errorType       = SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site);
            bool          isR1926Verified = errorType == ErrorCodeType.LockRequestFail || errorType == ErrorCodeType.Unknown || errorType == ErrorCodeType.FileNotExistsOrCannotBeCreated;

            this.Site.Log.Add(
                LogEntryKind.Debug,
                "For requirement MS-FSSHTTP_R1926, expect the error code LockRequestFail or Unknown or FileNotExistsOrCannotBeCreated, but actually error code is " + errorType);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1926
                Site.CaptureRequirementIfIsTrue(
                    isR1926Verified,
                    "MS-FSSHTTP",
                    1926,
                    @"[In ExclusiveLock Subrequest][The protocol 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 ""LockRequestFail "" or ""Unknown"" or ""FileNotExistsOrCannotBeCreated""  in the ErrorCode attribute sent back in the SubResponse element.");
            }
            else
            {
                Site.Assert.IsTrue(
                    isR1926Verified,
                    @"[In ExclusiveLock Subrequest][The protocol 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 ""LockRequestFail "" or ""Unknown"" or ""FileNotExistsOrCannotBeCreated""  in the ErrorCode attribute sent back in the SubResponse element.");
            }
        }
        public void TestCase_S10_TC01_SubRequestToken()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            ExclusiveLockSubRequestType exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);

            // Update the file contents when the coalesce is true.
            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), System.Text.Encoding.Unicode.GetBytes(SharedTestSuiteHelper.GenerateRandomString(10)));

            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            CellStorageResponse response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest, putChange });
            int exclusiveIndex           = 0;
            int putchangeIndex           = 0;

            for (int i = 0; i < response.ResponseCollection.Response[0].SubResponse.Length; i++)
            {
                if (response.ResponseCollection.Response[0].SubResponse[i].SubRequestToken == exclusiveLocksubRequest.SubRequestToken)
                {
                    exclusiveIndex = i;
                }
                else if (response.ResponseCollection.Response[0].SubResponse[i].SubRequestToken == putChange.SubRequestToken)
                {
                    putchangeIndex = i;
                }
            }

            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, exclusiveIndex, this.Site);
            CellSubResponseType          putChangeResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, putchangeIndex, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site), "Test case cannot continue unless the get lock sub request succeeds.");
            this.StatusManager.RecordExclusiveLock(this.DefaultFileUrl, exclusiveLocksubRequest.SubRequestData.ExclusiveLockID);
            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(putChangeResponse.ErrorCode, this.Site), "Test case cannot continue unless the put changes sub request succeeds.");

            this.Site.Assert.AreEqual <int>(
                int.Parse(exclusiveLocksubRequest.SubRequestToken),
                int.Parse(exclusiveResponse.SubRequestToken),
                "Test case cannot run unless the put change response token equals the expected sub request token.");
            this.Site.Assert.AreEqual <int>(
                int.Parse(putChange.SubRequestToken),
                int.Parse(putChangeResponse.SubRequestToken),
                "Test case cannot run unless the put change response token equals the expected sub request token.");

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If both the subRequest tokens are mapping, then MS-FSSHTTP_R1484 and MS-FSSHTTP_R283 can be captured.
                Site.CaptureRequirement(
                    "MS-FSSHTTP",
                    1484,
                    @"[In SubResponseType] SubRequestToken: If client sends 2 SubRequest elements in the Request, in the server response, SubRequestToken uniquely identifies the 2 SubRequest element whose subresponse is being generated as part of the SubResponse element.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R283
                Site.CaptureRequirement(
                    "MS-FSSHTTP",
                    283,
                    @"[In SubResponseType][SubRequestToken] The mapping subresponse that gets generated for the subrequest references the SubRequestToken to indicate that it is the response for that subrequest.");
            }
        }
Пример #3
0
        public void MSFSSHTTP_FSSHTTPB_S04_TC05_ConvertToSchema_ConvertToSchemaFailedFileCheckedOutByCurrentUser()
        {
            // Check out one file by a specified user name.
            if (!this.SutManagedAdapter.CheckOutFile(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain))
            {
                this.Site.Assert.Fail("Cannot change the file {0} to check out status using the user name {1} and password{2}", this.DefaultFileUrl, this.UserName01, this.UserName01);
            }

            // Record the file check out status.
            this.StatusManager.RecordFileCheckOut(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

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

            CheckLockAvailability();

            // Get the exclusive lock with same user name on the checked out file.
            this.PrepareExclusiveLock(this.DefaultFileUrl, SharedTestSuiteHelper.DefaultExclusiveLockID);

            // Convert the current exclusive lock to a coauthoring shared lock on the already check out file, expect the server returns the error code "ConvertToSchemaFailedFileCheckedOutByCurrentUser".
            ExclusiveLockSubRequestType  subRequest        = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.ConvertToSchema);
            CellStorageResponse          response          = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error code equals "FailedFileCheckedOutByCurrentUser", then capture MS-FSSHTTP_R1230,MS-FSSHTTP_R1949
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.ConvertToSchemaFailedFileCheckedOutByCurrentUser,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1230,
                    @"[In ExclusiveLock Subrequest][If the protocol server gets an exclusive lock subrequest of type ""Convert to schema lock with] ""Convert to schema lock"" for a file, and the conversion fails because the file is checked out by the current client, the protocol server returns an error code value set to ""ConvertToSchemaFailedFileCheckedOutByCurrentUser"".");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1299
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.ConvertToSchemaFailedFileCheckedOutByCurrentUser,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1299,
                    @"[In Convert to Schema Lock] The protocol server returns error codes according to the following rules: If the protocol server is unable to convert the exclusive lock to a shared lock on the file because the file is checked out by the current user, the protocol server returns an error code value set to ""ConvertToSchemaFailedFileCheckedOutByCurrentUser"".");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R387
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.ConvertToSchemaFailedFileCheckedOutByCurrentUser,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    387,
                    @"[In LockAndCoauthRelatedErrorCodeTypes] ConvertToSchemaFailedFileCheckedOutByCurrentUser indicates an error when converting to a shared lock fails because the file is checked out by the current client.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.ConvertToSchemaFailedFileCheckedOutByCurrentUser,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    @"[In ExclusiveLock Subrequest][If the protocol server gets an exclusive lock subrequest of type ""Convert to schema lock with] ""Convert to schema lock"" for a file, and the conversion fails because the file is checked out by the current client, the protocol server returns an error code value set to ""ConvertToSchemaFailedFileCheckedOutByCurrentUser"".");
            }
        }
        public void TestCase_S17_TC01_FileOperation_Success()
        {
            // Initialize the context using user01 and defaultFileUrl.
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Get the exclusive lock with all valid parameters, expect the server responses the error code "Success".
            ExclusiveLockSubRequestType  subRequest           = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);
            CellStorageResponse          cellStoreageResponse = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
            ExclusiveLockSubResponseType exclusiveResponse    = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(cellStoreageResponse, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                "Test case cannot continue unless the Get Lock of ExclusiveLock sub request succeeds.");

            // Record the current file status.
            this.StatusManager.RecordExclusiveLock(this.DefaultFileUrl, subRequest.SubRequestData.ExclusiveLockID);

            string fileName = this.DefaultFileUrl.Substring(this.DefaultFileUrl.LastIndexOf("/", StringComparison.OrdinalIgnoreCase) + 1);
            string newName  = Common.GenerateResourceName(this.Site, "fileName") + ".txt";

            FileOperationSubRequestType fileOperationSubRequest = SharedTestSuiteHelper.CreateFileOperationSubRequest(FileOperationRequestTypes.Rename, newName, SharedTestSuiteHelper.DefaultExclusiveLockID, this.Site);

            cellStoreageResponse = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { fileOperationSubRequest });

            FileOperationSubResponseType fileOperationSubResponse = SharedTestSuiteHelper.ExtractSubResponse <FileOperationSubResponseType>(cellStoreageResponse, 0, 0, this.Site);

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

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R11146
                Site.CaptureRequirementIfAreEqual <string>(
                    "Success",
                    fileOperationSubResponse.ErrorCode,
                    "MS-FSSHTTP",
                    11109,
                    @"[In FileOperationSubRequestDataType] This parameter [ExclusiveLockID] is used to validate that the file operation can be performed even though the file is under exclusive lock.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R11120
                // This requirement can be captured directly after capturing MS-FSSHTTP_R11109
                Site.CaptureRequirement(
                    "MS-FSSHTTP",
                    11120,
                    @"[In FileOperationSubResponseType] In the case of success, it contains information requested as part of a file operation subrequest.");
            }
            else
            {
                Assert.AreEqual <string>(
                    "Success",
                    fileOperationSubResponse.ErrorCode,
                    "MS-FSSHTTP",
                    @"[In FileOperationSubRequestDataType] This parameter [ExclusiveLockID] is used to validate that the file operation can be performed even though the file is under exclusive lock.");
            }
        }
Пример #5
0
        public void MSFSSHTTP_FSSHTTPB_S04_TC02_GetExclusiveLock_CheckoutByCurrentClient()
        {
            // Check out one file by a specified user name.
            if (!this.SutManagedAdapter.CheckOutFile(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain))
            {
                this.Site.Assert.Fail("Cannot change the file {0} to check out status using the user name {1} and password{2}", this.DefaultFileUrl, this.UserName01, this.Password01);
            }

            // Record the file check out status.
            this.StatusManager.RecordFileCheckOut(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3086, this.Site))
            {
                // Change the authentication mode
                if (!this.SutPowerShellAdapter.SwitchClaimsAuthentication(false))
                {
                    this.Site.Assert.Fail("Cannot change the authentication mode to windows based.");
                }

                this.StatusManager.RecordDisableClaimsBasedAuthentication();
            }

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

            CheckLockAvailability();

            // Get the exclusive lock using the same user name comparing with the previous step for the already checked out file, expect the server responds the error code "Success".
            // Now the service channel is initialized using the userName01 account by default.
            ExclusiveLockSubRequestType  subRequest        = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);
            CellStorageResponse          response          = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error code equals "Success", then capture MS-FSSHTTP_R1247
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1247,
                    @"[In Get Lock] If the checkout of the file has been done by the current client, the protocol server MUST allow an exclusive lock on the file.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    @"[In Get Lock] If the checkout of the file has been done by the current client, the protocol server MUST allow an exclusive lock on the file.");
            }

            // Record the file exclusive lock status.
            this.StatusManager.RecordExclusiveLock(this.DefaultFileUrl, subRequest.SubRequestData.ExclusiveLockID);
        }
Пример #6
0
        public void TestCase_S10_TC04_DependencyTypeOnNotSupported_Support()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            ExclusiveLockSubRequestType exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);

            // Update the file contents when the coalesce is true.
            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), System.Text.Encoding.Unicode.GetBytes(SharedTestSuiteHelper.GenerateRandomString(10)));

            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            // Make a putChanges subRequest dependent on the exclusive lock and the dependency type is OnNotSupported.
            putChange.DependencyTypeSpecified = true;
            putChange.DependencyType          = DependencyTypes.OnNotSupported;
            putChange.DependsOn = exclusiveLocksubRequest.SubRequestToken;

            CellStorageResponse response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest, putChange });

            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);
            CellSubResponseType          putChanges        = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 1, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site), "Test case cannot continue unless the get lock sub request succeeds.");
            this.StatusManager.RecordExclusiveLock(this.DefaultFileUrl, exclusiveLocksubRequest.SubRequestData.ExclusiveLockID);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error code equals DependentOnlyOnNotSupportedRequestGetSupported, then capture R324 and R2244
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnNotSupportedRequestGetSupported,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    324,
                    @"[In DependencyCheckRelatedErrorCodeTypes] DependentOnlyOnNotSupportedRequestGetSupported:
                         Indicates an error when the subrequest on which this specific subrequest is dependent is supported and the DependencyType attribute in this subrequest is set to ""OnNotSupported"" or [""OnSuccessOrOnNotSupported""].");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R2244
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnNotSupportedRequestGetSupported,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    2244,
                    @"[In DependencyTypes] OnNotSupported: Indicates that the subrequest MUST NOT be processed if the other subrequest is supported.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnNotSupportedRequestGetSupported,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    @"[In DependencyCheckRelatedErrorCodeTypes] DependentOnlyOnNotSupportedRequestGetSupported:
                        Indicates an error when the subrequest on which this specific subrequest is dependent is supported and the DependencyType attribute in this subrequest is set to ""OnNotSupported"" or [""OnSuccessOrOnNotSupported""].");
            }
        }
        /// <summary>
        /// This method is used to test whether the exclusive lock with the specified id exist on the file.
        /// </summary>
        /// <param name="file">Specify the file.</param>
        /// <param name="exclusiveLockId">Specify the exclusive 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>
        /// <returns>Return true if exist, otherwise return false.</returns>
        protected bool CheckExclusiveLockExist(string file, string exclusiveLockId, 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(exclusiveLockId));

            ExclusiveLockSubRequestType exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.CheckLockAvailability);

            exclusiveLocksubRequest.SubRequestData.ExclusiveLockID = newId.ToString();
            CellStorageResponse          response          = this.Adapter.CellStorageRequest(file, new SubRequestType[] { exclusiveLocksubRequest });
            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

            ErrorCodeType error = SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.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 exclusive lock with the given exclusive lock id should exist.
                exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.CheckLockAvailability);
                exclusiveLocksubRequest.SubRequestData.ExclusiveLockID = exclusiveLockId;
                response          = this.Adapter.CellStorageRequest(file, new SubRequestType[] { exclusiveLocksubRequest });
                exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

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

                return(false);
            }
        }
        /// <summary>
        /// This method is used to prepare an exclusive lock on the file with the specified exclusive lock id.
        /// </summary>
        /// <param name="fileUrl">Specify the file which is locked.</param>
        /// <param name="exclusiveLockId">Specify the exclusive lock 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 PrepareExclusiveLock(string fileUrl, string exclusiveLockId, string userName, string password, string domain, int timeout = SharedTestSuiteHelper.DefaultTimeOut)
        {
            this.InitializeContext(fileUrl, userName, password, domain);

            // Get an exclusive lock
            ExclusiveLockSubRequestType getExclusiveLockSubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);

            getExclusiveLockSubRequest.SubRequestData.ExclusiveLockID = exclusiveLockId;
            getExclusiveLockSubRequest.SubRequestData.Timeout         = timeout.ToString();
            CellStorageResponse          response          = this.Adapter.CellStorageRequest(fileUrl, new SubRequestType[] { getExclusiveLockSubRequest });
            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                "Get an exclusive lock with identifier {0} by the user {1}@{2} on the file {3} should succeed.",
                exclusiveLockId,
                userName,
                domain,
                fileUrl);

            this.StatusManager.RecordExclusiveLock(fileUrl, exclusiveLockId, userName, password, domain);
        }
Пример #9
0
        public void MSFSSHTTP_FSSHTTPB_S04_TC04_ConvertToSchemaJoinCoauth_ConvertToSchemaFailedFileCheckedOutByCurrentUser()
        {
            // Check out one file by a specified user name.
            if (!this.SutManagedAdapter.CheckOutFile(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain))
            {
                this.Site.Assert.Fail("Cannot change the file {0} to check out status using the user name {1} and password{2}", this.DefaultFileUrl, this.UserName01, this.Password01);
            }

            // Record the file check out status.
            this.StatusManager.RecordFileCheckOut(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3086, this.Site))
            {
                // Change the authentication mode
                if (!this.SutPowerShellAdapter.SwitchClaimsAuthentication(false))
                {
                    this.Site.Assert.Fail("Cannot change the authentication mode to windows based.");
                }

                this.StatusManager.RecordDisableClaimsBasedAuthentication();
            }

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

            CheckLockAvailability();

            // Get the exclusive lock using the same user name on the already checked out file, expect the server response the error code "Success".
            this.PrepareExclusiveLock(this.DefaultFileUrl, SharedTestSuiteHelper.DefaultExclusiveLockID);

            // Convert current exclusive lock to a coauthoring shared lock with the same exclusive lock id as the previous step on the already checked out file, expect the server returns the error code "ConvertToSchemaFailedFileCheckedOutByCurrentUser".
            ExclusiveLockSubRequestType  subRequest        = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.ConvertToSchemaJoinCoauth);
            CellStorageResponse          response          = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error code equals ConvertToSchemaFailedFileCheckedOutByCurrentUser, then capture MS-FSSHTTP requirement: MS-FSSHTTP_R1229, MS-FSSHTTP_R1279
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.ConvertToSchemaFailedFileCheckedOutByCurrentUser,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1229,
                    @"[In ExclusiveLock Subrequest][The protocol returns results based on the following conditions: ] If the protocol server gets an exclusive lock subrequest of type ""Convert to schema lock with coauthoring transition tracked"" for a file, and the conversion fails because the file is checked out by the current client, the protocol server returns an error code value set to ""ConvertToSchemaFailedFileCheckedOutByCurrentUser"".");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1279
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.ConvertToSchemaFailedFileCheckedOutByCurrentUser,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1279,
                    @"[In Convert to Schema Lock with Coauthoring Transition Tracked] The protocol server returns error codes according to the following rules: If the protocol server is unable to convert the exclusive lock to a shared lock on the file because the file is checked out by the current user, the protocol server returns an error code value set to ""ConvertToSchemaFailedFileCheckedOutByCurrentUser"".");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R387
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.ConvertToSchemaFailedFileCheckedOutByCurrentUser,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    387,
                    @"[In LockAndCoauthRelatedErrorCodeTypes] ConvertToSchemaFailedFileCheckedOutByCurrentUser indicates an error when converting to a shared lock fails because the file is checked out by the current client.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.ConvertToSchemaFailedFileCheckedOutByCurrentUser,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    @"[In ExclusiveLock Subrequest][The protocol returns results based on the following conditions: ] If the protocol server gets an exclusive lock subrequest of type ""Convert to schema lock with coauthoring transition tracked"" for a file, and the conversion fails because the file is checked out by the current client, the protocol server returns an error code value set to ""ConvertToSchemaFailedFileCheckedOutByCurrentUser"".");
            }
        }
Пример #10
0
        public void MSFSSHTTP_FSSHTTPB_S04_TC03_CheckExclusiveLockAvailability_Success()
        {
            // Initialize the service.
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            ExclusiveLockSubRequestType exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.CheckLockAvailability);

            // Check the exclusive lock availability with all valid parameters on a file on which there is no lock, expect the server responds the error code "Success".
            CellStorageResponse          response          = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest });
            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error code equals "Success", then capture MS-FSSHTTP_RR13122
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    13122,
                    @"[In Check Lock Availability] The protocol server returns error codes according to the following rules: In all other cases[the file is not checked out and there is no current exclusive lock and shared lock on the file], the protocol server returns an error code value set to ""Success"" to indicate the availability of the file for locking.");

                // If the error code equals "Success", then capture MS-FSSHTTP_R1236
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1236,
                    @"[In ExclusiveLock Subrequest] An ErrorCode value of ""Success"" indicates success in processing the exclusive lock request.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    @"[In Check Lock Availability] The protocol server returns error codes according to the following rules: In all other cases[the file is not checked out and there is no current exclusive lock and shared lock on the file], the protocol server returns an error code value set to ""Success"" to indicate the availability of the file for locking.");
            }

            // Prepare an exclusive lock
            this.PrepareExclusiveLock(this.DefaultFileUrl, SharedTestSuiteHelper.DefaultExclusiveLockID);

            // Check the exclusive lock availability with all valid parameters on a file which is locked by the same exclusive lock id, expect the server responds the error code "Success".
            exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.CheckLockAvailability);
            response          = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest });
            exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error code equals "Success", then capture MS-FSSHTTP_R13121
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    13121,
                    @"[In Check Lock Availability] The protocol server returns error codes according to the following rules: In all other cases[there is a current exclusive lock on the file with a same exclusive lock identifier with the one specified by the current client], the protocol server returns an error code value set to ""Success"" to indicate the availability of the file for locking.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    @"[In Check Lock Availability] The protocol server returns error codes according to the following rules: In all other cases[there is a current exclusive lock on the file with a same exclusive lock identifier with the one specified by the current client], the protocol server returns an error code value set to ""Success"" to indicate the availability of the file for locking.");
            }

            if (!this.StatusManager.RollbackStatus())
            {
                this.Site.Assert.Fail("Cannot release the exclusive lock {0}", SharedTestSuiteHelper.DefaultExclusiveLockID);
            }

            // Check out one file by a specified user name.
            if (!this.SutManagedAdapter.CheckOutFile(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain))
            {
                this.Site.Assert.Fail("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);

            if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3086, this.Site))
            {
                // Change the authentication mode
                if (!this.SutPowerShellAdapter.SwitchClaimsAuthentication(false))
                {
                    this.Site.Assert.Fail("Cannot change the authentication mode to windows based.");
                }

                this.StatusManager.RecordDisableClaimsBasedAuthentication();
            }

            CheckLockAvailability();

            // Check the exclusive lock availability with all valid parameters on a file which is checked out by the same user, expect the server responds the error code "Success".
            exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.CheckLockAvailability);
            response          = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest });
            exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error code equals "Success", then capture MS-FSSHTTP_R13123
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    13123,
                    @"[In Check Lock Availability] The protocol server returns error codes according to the following rules: In all other cases[the file has been checked out by the current user and there is no current exclusive lock and shared lock on the file], the protocol server returns an error code value set to ""Success"" to indicate the availability of the file for locking.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site),
                    @"[In Check Lock Availability] The protocol server returns error codes according to the following rules: In all other cases[the file has been checked out by the current user and there is no current exclusive lock and shared lock on the file], the protocol server returns an error code value set to ""Success"" to indicate the availability of the file for locking.");
            }
        }
        /// <summary>
        /// Capture requirements related to exclusive lock sub request of type, "Convert to schema lock with co-authoring transition tracked".
        /// </summary>
        /// <param name="exclusiveLockSubResponse">Containing the subResponse information.</param>
        /// <param name="site">An object provides logging, assertions, and SUT adapters for test code onto its execution context.</param>
        public static void ValidateExclusiveLockSubResponse(ExclusiveLockSubResponseType exclusiveLockSubResponse, ITestSite site)
        {
            ValidateSubResponseType(exclusiveLockSubResponse as SubResponseType, site);

            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R659
            // if can launch this method, the schema matches.
            site.CaptureRequirement(
                "MS-FSSHTTP",
                659,
                @"[In ExclusiveLockSubResponseType][ExclusiveLockSubResponseType schema is:]
                     <xs:complexType name=""ExclusiveLockSubResponseType"">
                      <xs:complexContent>
                        <xs:extension base=""tns:SubResponseType"">
                         <xs:sequence minOccurs=""1"" maxOccurs=""1"">
                          <xs:element name=""SubResponseData"" type=""tns:ExclusiveLockSubResponseDataType"" />
                         </xs:sequence>
                        </xs:extension>
                       </xs:complexContent>
                     </xs:complexType>");

            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1216
            // if can launch this method, the schema matches.
            site.CaptureRequirement(
                "MS-FSSHTTP",
                1216,
                @"[In ExclusiveLock Subrequest][The protocol client sends an exclusive lock SubRequest message] The protocol server responds with an exclusive lock SubResponse message, which is of type ExclusiveLockSubResponseType as specified in section 2.3.1.12.");

            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R4689
            // if can launch this method, the schema matches.
            site.CaptureRequirementIfAreEqual <Type>(
                typeof(ExclusiveLockSubResponseType),
                exclusiveLockSubResponse.GetType(),
                "MS-FSSHTTP",
                4689,
                @"[In SubResponseElementGenericType] Depending on the Type attribute specified in the SubRequest element, the SubResponseElementGenericType MUST take one of the forms: ExclusiveLockSubResponseType.");

            // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R5744
            // if can launch this method, the schema matches.
            site.CaptureRequirementIfAreEqual <Type>(
                typeof(ExclusiveLockSubResponseType),
                exclusiveLockSubResponse.GetType(),
                "MS-FSSHTTP",
                5744,
                @"[In SubResponseType] The SubResponseElementGenericType takes one of the following forms: ExclusiveLockSubResponseType.");

            if (string.Compare("Success", exclusiveLockSubResponse.ErrorCode, StringComparison.OrdinalIgnoreCase) == 0)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R264
                // if can launch this method, the schema matches
                bool isVerifyR264 = exclusiveLockSubResponse.SubResponseData != null;

                // If popup the assert, the case run fail.
                site.Assert.IsTrue(
                    isVerifyR264,
                    "For requirement MS-FSSHTTPB_R264, the SubResponseData should not be NULL.");

                // If the above logic is right, MS-FSSHTTP_R264 can be captured.
                site.CaptureRequirement(
                    "MS-FSSHTTP",
                    264,
                    @"[In SubResponseElementGenericType][The SubResponseData element MUST be sent as part of the SubResponse element in a cell storage service response message if the ErrorCode attribute that is part of the SubResponse element is set to a value of ""Success"" and one of the following conditions is true:] The Type attribute that is specified in the SubRequest element is set to a value of ""ExclusiveLock"".");
            }

            if (exclusiveLockSubResponse.SubResponseData != null)
            {
                ValidateExclusiveLockSubResponseDataType(exclusiveLockSubResponse.SubResponseData, site);
            }
        }
Пример #12
0
        public void TestCase_S10_TC05_DependencyTypeOnSuccessOrNotSupported_OnSuccess()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            ExclusiveLockSubRequestType exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);

            // Update the file contents when the coalesce is true.
            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), System.Text.Encoding.Unicode.GetBytes(SharedTestSuiteHelper.GenerateRandomString(10)));

            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            // Make a putChanges subRequest dependent on the exclusive lock and the dependency type is success.
            putChange.DependencyTypeSpecified = true;
            putChange.DependencyType          = DependencyTypes.OnSuccessOrNotSupported;
            putChange.DependsOn = exclusiveLocksubRequest.SubRequestToken;

            CellStorageResponse response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest, putChange });

            ExclusiveLockSubResponseType exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);
            CellSubResponseType          putChanges        = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 1, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site), "Test case cannot continue unless the get lock sub request succeeds.");
            this.StatusManager.RecordExclusiveLock(this.DefaultFileUrl, exclusiveLocksubRequest.SubRequestData.ExclusiveLockID);

            this.Site.Assert.AreEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site), "Test case cannot continue unless the put changes sub request succeeds.");

            // Make another GetLock request with a different exclusive lock ID.
            exclusiveLocksubRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock);
            exclusiveLocksubRequest.SubRequestData.ExclusiveLockID = System.Guid.NewGuid().ToString();

            // Also make another putChange request dependent on the new GetLock request.
            putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), System.Text.Encoding.Unicode.GetBytes(SharedTestSuiteHelper.GenerateRandomString(10)));
            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            // Make a putChanges subRequest dependent on the exclusive lock and the dependency type is success.
            putChange.DependencyTypeSpecified = true;
            putChange.DependencyType          = DependencyTypes.OnSuccessOrNotSupported;
            putChange.DependsOn = exclusiveLocksubRequest.SubRequestToken;

            response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { exclusiveLocksubRequest, putChange });

            exclusiveResponse = SharedTestSuiteHelper.ExtractSubResponse <ExclusiveLockSubResponseType>(response, 0, 0, this.Site);
            putChanges        = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 1, this.Site);

            this.Site.Assert.AreNotEqual <ErrorCodeType>(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(exclusiveResponse.ErrorCode, this.Site), "Test case cannot continue unless the get lock sub request fails.");

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the first putChanges request succeed and the second putChanges request fails, then capture requirement R336 and R32201.
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnSuccessRequestFailed,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    336,
                    @"[In DependencyTypes] OnSuccessOrNotSupported: Indicates that the subrequest MUST be processed only when one of the following conditions is true:
                         On the successful execution of the other subrequest.");

                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R32201
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnSuccessRequestFailed,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    32201,
                    @"[In DependencyCheckRelatedErrorCodeTypes] DependentOnlyOnSuccessRequestFailed: Indicates an error when the subrequest on which this specific subrequest is dependent has failed and the DependencyType attribute in this subrequest is set to [""OnSuccess""] or ""OnSuccessOrNotSupported"".");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.DependentOnlyOnSuccessRequestFailed,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(putChanges.ErrorCode, this.Site),
                    @"[In DependencyTypes] OnSuccessOrNotSupported: Indicates that the subrequest MUST be processed only when one of the following conditions is true:
                    On the successful execution of the other subrequest.");
            }
        }