Пример #1
0
        public void MSFSSHTTP_FSSHTTPB_TestCase_S16_TC02_Versioning_FileNotExistsOrCannotBeCreated()
        {
            string fileUrlNotExit = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);

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

            VersioningSubRequestType  versioningSubRequest  = SharedTestSuiteHelper.CreateVersioningSubRequest(SequenceNumberGenerator.GetCurrentToken(), VersioningRequestTypes.GetVersionList, null, this.Site);
            CellStorageResponse       cellStoreageResponse  = Adapter.CellStorageRequest(fileUrlNotExit, new SubRequestType[] { versioningSubRequest });
            VersioningSubResponseType versioningSubResponse = SharedTestSuiteHelper.ExtractSubResponse <VersioningSubResponseType>(cellStoreageResponse, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R11246
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.FileNotExistsOrCannotBeCreated,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(versioningSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    11246,
                    @"[In Versioning 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 ""FileNotExistsOrCannotBeCreated"" in the ErrorCode attribute sent back in the SubResponse element.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.FileNotExistsOrCannotBeCreated,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(versioningSubResponse.ErrorCode, this.Site),
                    "Error FileNotExistsOrCannotBeCreated should be returned if the protocol server was unable to find the URL for the file.");
            }
        }
Пример #2
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.");
            }
        }
        public void MSFSSHTTP_FSSHTTPB_S02_TC04_JoinCoauthSession_FileNotExistsOrCannotBeCreated()
        {
            // Join a coauthoring session on 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);

            // Join a Coauthoring session with the non-exist URL.
            CoauthSubRequestType  subRequest   = SharedTestSuiteHelper.CreateCoauthSubRequestForJoinCoauthSession(SharedTestSuiteHelper.DefaultClientID, SharedTestSuiteHelper.ReservedSchemaLockID, null, null, 3600);
            CellStorageResponse   cellResponse = this.Adapter.CellStorageRequest(fileUrlNotExit, new SubRequestType[] { subRequest });
            CoauthSubResponseType joinResponse = SharedTestSuiteHelper.ExtractSubResponse <CoauthSubResponseType>(cellResponse, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the ErrorCode attribute returned equals "FileNotExistsOrCannotBeCreated", MS-FSSHTTP_R4003 can be covered.
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.FileNotExistsOrCannotBeCreated,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(joinResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    4003,
                    @"[In Coauth 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(joinResponse.ErrorCode, this.Site),
                    @"[In Coauth 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.");
            }
        }
        public void MSFSSHTTP_FSSHTTPB_S02_TC06_JoinCoauthoringSession_PathNotFound()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(11265, this.Site), "This test case only runs PathNotFound is returned when the file path is not found.");

            string fileUrlNotExit = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);
            string path           = fileUrlNotExit.Substring(0, fileUrlNotExit.LastIndexOf('/'));

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

            CoauthSubRequestType  subRequest   = SharedTestSuiteHelper.CreateCoauthSubRequestForJoinCoauthSession(SharedTestSuiteHelper.DefaultClientID, SharedTestSuiteHelper.ReservedSchemaLockID, null, null, 3600);
            CellStorageResponse   cellResponse = this.Adapter.CellStorageRequest(path, new SubRequestType[] { subRequest });
            CoauthSubResponseType joinResponse = SharedTestSuiteHelper.ExtractSubResponse <CoauthSubResponseType>(cellResponse, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.PathNotFound,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(joinResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    11265,
                    @"[In Appendix B: Product Behavior] Implementation does return the value ""PathNotFound"" of GenericErrorCodeTypes when the file path is not found. (Microsoft Office 2016/Microsoft SharePoint Server 2016 follow this behavior.)");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.PathNotFound,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(joinResponse.ErrorCode, this.Site),
                    @"Error ""PathNotFound"" should be returned when the file path is not found.");
            }
        }
        /// <summary>
        /// This method is used to upload a new Txt file to a random generated URL which is based on the current test case name.
        /// </summary>
        /// <returns>Return the full URL of the Txt file target location.</returns>
        protected string PrepareFile()
        {
            string fileUri  = SharedTestSuiteHelper.GenerateNonExistFileUrl(Site);
            string fileUrl  = fileUri.Substring(0, fileUri.LastIndexOf("/", StringComparison.OrdinalIgnoreCase));
            string fileName = fileUri.Substring(fileUri.LastIndexOf("/", StringComparison.OrdinalIgnoreCase) + 1);

            bool ret = this.SutManagedAdapter.UploadTextFile(fileUrl, fileName);

            if (ret == false)
            {
                this.Site.Assert.Fail("Cannot upload a file in the URL {0}", fileUri);
            }

            this.StatusManager.RecordFileUpload(fileUri);

            return(fileUri);
        }
Пример #6
0
        public void MSFSSHTTP_FSSHTTPB_S07_TC01_EditorsTable_FileNotExistsOrCannotBeCreated()
        {
            if (!Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 9001, this.Site))
            {
                Site.Assume.Inconclusive("Implementation does not support the editors table.");
            }

            // Create a join editor session with the URL which could not be found.
            string url = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);

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

            EditorsTableSubRequestType join = SharedTestSuiteHelper.CreateEditorsTableSubRequestForJoinSession(SharedTestSuiteHelper.DefaultClientID, SharedTestSuiteHelper.DefaultTimeOut);

            // Call protocol adapter operation CellStorageRequest to join the editing session.
            CellStorageResponse         cellStorageResponseJoin = this.Adapter.CellStorageRequest(url, new SubRequestType[] { join });
            EditorsTableSubResponseType subResponseJoin         = SharedTestSuiteHelper.ExtractSubResponse <EditorsTableSubResponseType>(cellStorageResponseJoin, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the ErrorCode attribute returned equals "FileNotExistsOrCannotBeCreated", MS-FSSHTTP_R1971 and MS-FSSHTTP_R358 can be covered.
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.FileNotExistsOrCannotBeCreated,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(subResponseJoin.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1971,
                    @"[In EditorsTable Subrequest] 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.");

                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.FileNotExistsOrCannotBeCreated,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(subResponseJoin.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    358,
                    @"[In GenericErrorCodeTypes] FileNotExistsOrCannotBeCreated indicates an error when either the targeted URL for the file specified as part of the Request element does not exist or file creation failed on the protocol server.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.FileNotExistsOrCannotBeCreated,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(subResponseJoin.ErrorCode, this.Site),
                    @"[In GenericErrorCodeTypes] FileNotExistsOrCannotBeCreated indicates an error when either the targeted URL for the file specified as part of the Request element does not exist or file creation failed on the protocol server.");
            }
        }
Пример #7
0
        public void TestCase_S15_TC02_UploadContents_CreateFile_ExclusiveLock()
        {
            string randomFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);

            // Initialize the context using user01 and defaultFileUrl.
            this.InitializeContext(randomFileUrl, this.UserName01, this.Password01, this.Domain);

            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), SharedTestSuiteHelper.GenerateRandomFileContent(this.Site));

            putChange.SubRequestData.CoalesceSpecified           = true;
            putChange.SubRequestData.Coalesce                    = true;
            putChange.SubRequestData.ExpectNoFileExistsSpecified = true;
            putChange.SubRequestData.ExpectNoFileExists          = true;
            putChange.SubRequestData.ExclusiveLockID             = SharedTestSuiteHelper.DefaultExclusiveLockID;
            putChange.SubRequestData.Timeout = "3600";

            CellStorageResponse response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "When uploading contents if the protocol server was unable to find the URL for the file specified in the Url attribute,, the server returns success and create a new file using the specified contents in the file URI.");

            bool isExclusiveLock = this.CheckExclusiveLockExist(randomFileUrl, SharedTestSuiteHelper.DefaultExclusiveLockID, this.UserName01, this.Password01, this.Domain);

            Site.Log.Add(
                TestTools.LogEntryKind.Debug,
                "When creating a new file with ExclusiveLockID specified, the server will lock the new created file, but actually it {0}",
                isExclusiveLock ? "locks" : "does not lock");

            Site.Assert.IsTrue(
                isExclusiveLock,
                "When creating a new file with ExclusiveLockID specified, the server will lock the new created file");

            this.StatusManager.RecordExclusiveLock(randomFileUrl, SharedTestSuiteHelper.DefaultExclusiveLockID, this.UserName01, this.Password01, this.Domain);
            this.StatusManager.RecordFileUpload(randomFileUrl);
        }
Пример #8
0
        public void MSFSSHTTP_FSSHTTPB_S04_TC06_ExclusiveLock_FileNotExistsOrCannotBeCreated()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            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(SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site), 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.");
            }
        }
Пример #9
0
        public void TestCase_S15_TC01_CreateFile()
        {
            string randomFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);

            // Initialize the context using user01 and defaultFileUrl.
            this.InitializeContext(randomFileUrl, this.UserName01, this.Password01, this.Domain);

            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), SharedTestSuiteHelper.GenerateRandomFileContent(this.Site));

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

            CellStorageResponse response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "When uploading contents if the protocol server was unable to find the URL for the file specified in the Url attribute,, the server returns success and create a new file using the specified contents in the file URI.");

            // Query the updated file content.
            CellSubRequestType queryChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());

            response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { queryChange });
            cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3103
                // If queryChange subrequest can download a file from randomFileUrl, then capture MS-FSSHTTP_R3103.
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    3103,
                    @"[In Cell Subrequest] But for Put Changes subrequest, as described in [MS-FSSHTTPB] section 2.2.2.1.4, [If the protocol server was unable to find the URL for the file specified in the Url attribute] the protocol server creates a new file using the specified Url.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    @"[In Cell Subrequest] But for Put Changes subrequest, as described in [MS-FSSHTTPB] section 2.2.2.1.4, [If the protocol server was unable to find the URL for the file specified in the Url attribute] the protocol server creates a new file using the specified Url.");
            }

            this.StatusManager.RecordFileUpload(randomFileUrl);

            // Re-generate the non-exist file URL again.
            randomFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);
            this.InitializeContext(randomFileUrl, this.UserName01, this.Password01, this.Domain);

            putChange.SubRequestData.ExpectNoFileExistsSpecified = true;
            putChange.SubRequestData.ExpectNoFileExists          = true;
            putChange.SubRequestData.Etag = string.Empty;
            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;
            response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R2252
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    2252,
                    @"[In Cell Subrequest] In this case[If the ExpectNoFileExists attribute is set to true in a file content upload cell subrequest, the Etag attribute MUST be an empty string], the protocol server MUST NOT cause the cell subrequest to fail with a coherency error if the file does not exist on the server.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    @"[In Cell Subrequest] In this case[If the ExpectNoFileExists attribute is set to true in a file content upload cell subrequest, the Etag attribute MUST be an empty string], the protocol server MUST NOT cause the cell subrequest to fail with a coherency error if the file does not exist on the server.");
            }

            this.StatusManager.RecordFileUpload(randomFileUrl);
        }
Пример #10
0
        public void TestCase_S15_TC04_UploadContents_ExclusiveLockSuccess()
        {
            string randomFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(this.Site);

            // Initialize the context using user01 and defaultFileUrl.
            this.InitializeContext(randomFileUrl, this.UserName01, this.Password01, this.Domain);

            CellSubRequestType putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), SharedTestSuiteHelper.GenerateRandomFileContent(this.Site));

            putChange.SubRequestData.CoalesceSpecified           = true;
            putChange.SubRequestData.Coalesce                    = true;
            putChange.SubRequestData.ExpectNoFileExistsSpecified = true;
            putChange.SubRequestData.ExpectNoFileExists          = true;
            putChange.SubRequestData.ExclusiveLockID             = SharedTestSuiteHelper.DefaultExclusiveLockID;
            putChange.SubRequestData.BypassLockID                = putChange.SubRequestData.ExclusiveLockID;
            putChange.SubRequestData.Timeout = "3600";

            CellStorageResponse response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "When the file is locked by exclusive lock and the ByPassLockID is specified by the valid exclusive lock id, the server returns the error code success.");

            this.StatusManager.RecordExclusiveLock(randomFileUrl, SharedTestSuiteHelper.DefaultExclusiveLockID, this.UserName01, this.Password01, this.Domain);
            this.StatusManager.RecordFileUpload(randomFileUrl);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the server responds with the error code "Success",
                // when the above steps show that the client has got an exclusive lock and the PutChange subrequest was sent with BypassLockID equal to ExclusiveLockID,
                // then requirement MS-FSSHTTP_R833 is captured.
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    833,
                    @"[In CellSubRequestDataOptionalAttributes][BypassLockID] If a client has got an exclusive lock, this value[BypassLockID] MUST be the same as the value of ExclusiveLockID, as specified in section 2.3.1.1.");

                // If the server responds with "ExclusiveLock" in LockType attribute, the requirement MS-FSSHTTP_R1533 is captured.
                Site.CaptureRequirementIfAreEqual <string>(
                    "ExclusiveLock",
                    cellSubResponse.SubResponseData.LockType.ToString(),
                    "MS-FSSHTTP",
                    1533,
                    @"[In CellSubResponseDataType] The LockType attribute MUST be set to ""ExclusiveLock"" in the cell subresponse if the ExclusiveLockID attribute is sent in the cell subrequest and the protocol server is successfully able to take an exclusive lock.");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                    @"[In CellSubRequestDataOptionalAttributes][BypassLockID] If a client has got an exclusive lock, this value[BypassLockID] MUST be the same as the value of ExclusiveLockID, as specified in section 2.3.1.1.");

                Site.Assert.AreEqual <string>(
                    "ExclusiveLock",
                    cellSubResponse.SubResponseData.LockType.ToString(),
                    @"[In CellSubResponseDataType] The LockType attribute MUST be set to ""ExclusiveLock"" in the cell subresponse if the ExclusiveLockID attribute is sent in the cell subrequest and the protocol server is successfully able to take an exclusive lock.");
            }

            // Update contents without the ByPassLockID and coalesce true.
            putChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedPutChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), SharedTestSuiteHelper.GenerateRandomFileContent(this.Site));
            putChange.SubRequestData.BypassLockID      = null;
            putChange.SubRequestData.CoalesceSpecified = true;
            putChange.SubRequestData.Coalesce          = true;

            response        = Adapter.CellStorageRequest(randomFileUrl, new SubRequestType[] { putChange });
            cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "When the file is locked by exclusive lock and the ByPassLockID is not specified, the server returns the error code success.");
        }
Пример #11
0
        public void TestCase_S15_TC03_Download_UploadPartial()
        {
            string fileUrl       = Common.GetConfigurationPropertyValue("BigFile", this.Site);
            string uploadFileUrl = SharedTestSuiteHelper.GenerateNonExistFileUrl(Site);
            bool   partial       = false;

            Knowledge knowledge = null;

            // Set the limit number of upload tries, this will allow 500000 * 10 bytes size file to be download and complete upload.
            int limitNumberOfPartialUpload = 10;

            do
            {
                this.InitializeContext(fileUrl, this.UserName01, this.Password01, this.Domain);

                // Create query changes request with allow fragments flag with the value false.
                FsshttpbCellRequest        cellRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
                QueryChangesCellSubRequest queryChange = SharedTestSuiteHelper.BuildFsshttpbQueryChangesSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), 0, false, false, true, 0, true, true, 0, null, 500000, null, knowledge);
                cellRequest.AddSubRequest(queryChange, null);
                CellSubRequestType cellSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequest.ToBase64());

                CellStorageResponse cellStorageResponse = this.Adapter.CellStorageRequest(fileUrl, new SubRequestType[] { cellSubRequest });
                CellSubResponseType subResponse         = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(cellStorageResponse, 0, 0, this.Site);
                this.Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site),
                    "Test case cannot continue unless the query changes succeed.");

                FsshttpbResponse queryResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(subResponse, this.Site);
                SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(queryResponse, this.Site);
                QueryChangesSubResponseData data = queryResponse.CellSubResponses[0].GetSubResponseData <QueryChangesSubResponseData>();
                partial   = data.PartialResult;
                knowledge = data.Knowledge;

                this.InitializeContext(uploadFileUrl, this.UserName01, this.Password01, this.Domain);
                cellRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
                PutChangesCellSubRequest putChange = new PutChangesCellSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), null);
                putChange.Partial     = partial ? 1 : 0;
                putChange.PartialLast = partial ? 0 : 1;
                putChange.StorageIndexExtendedGUID = partial ? null : data.StorageIndexExtendedGUID;

                if (partial)
                {
                    var storageIndex = queryResponse.DataElementPackage.DataElements.FirstOrDefault(e => e.DataElementType == DataElementType.StorageIndexDataElementData);
                    if (storageIndex != null)
                    {
                        queryResponse.DataElementPackage.DataElements.Remove(storageIndex);
                    }
                }

                cellRequest.AddSubRequest(putChange, queryResponse.DataElementPackage.DataElements);
                cellSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequest.ToBase64());

                cellStorageResponse = this.Adapter.CellStorageRequest(uploadFileUrl, new SubRequestType[] { cellSubRequest });
                subResponse         = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(cellStorageResponse, 0, 0, this.Site);
                this.Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.Success,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(subResponse.ErrorCode, this.Site),
                    "Test case cannot continue unless the query changes succeed.");

                FsshttpbResponse putResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(subResponse, this.Site);
                SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(putResponse, this.Site);

                // Decrease the number of upload tries.
                limitNumberOfPartialUpload--;
            }while (partial && limitNumberOfPartialUpload > 0);

            this.StatusManager.RecordFileUpload(uploadFileUrl);
        }