Example #1
0
        public void TestCase_S14_TC02_AllocateExtendedGuidRange_ReservedIgnore()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            FsshttpbCellRequest fsshttpRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
            AllocateExtendedGuidRangeCellSubRequest allocateExtendedGuidRange = new AllocateExtendedGuidRangeCellSubRequest(new Compact64bitInt(8000), SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());

            // Make the reserved value equal to 0.
            allocateExtendedGuidRange.Reserved = 0;
            fsshttpRequest.AddSubRequest(allocateExtendedGuidRange, null);
            CellSubRequestType  cellSubRequest  = SharedTestSuiteHelper.CreateCellSubRequest((ulong)SequenceNumberGenerator.GetCurrentToken(), fsshttpRequest.ToBase64());
            CellStorageResponse response        = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { cellSubRequest });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "Test case cannot continue unless the allocate extended guid range operation on the file {0} succeed.",
                this.DefaultFileUrl);

            FsshttpbResponse fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site);

            SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponse, this.Site);

            FsshttpbCellRequest fsshttpRequestSecond = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
            AllocateExtendedGuidRangeCellSubRequest allocateExtendedGuidRangeSecond = new AllocateExtendedGuidRangeCellSubRequest(new Compact64bitInt(8000), SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());

            // Make the reserved value equal to 1.
            allocateExtendedGuidRangeSecond.Reserved = 1;
            fsshttpRequestSecond.AddSubRequest(allocateExtendedGuidRangeSecond, null);
            CellSubRequestType  cellSubRequestSecond  = SharedTestSuiteHelper.CreateCellSubRequest((ulong)SequenceNumberGenerator.GetCurrentToken(), fsshttpRequestSecond.ToBase64());
            CellStorageResponse responseSecond        = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { cellSubRequestSecond });
            CellSubResponseType cellSubResponseSecond = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(responseSecond, 0, 0, this.Site);

            this.Site.Assert.AreEqual <ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponseSecond.ErrorCode, this.Site),
                "Test case cannot continue unless the allocate extended guid range operation on the file {0} succeed.",
                this.DefaultFileUrl);

            FsshttpbResponse fsshttpbResponseSecond = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponseSecond, this.Site);

            SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(fsshttpbResponseSecond, this.Site);

            // Compare this two responses roughly, and if these two responses are identical in main part, then capture the requirement MS-FSSHTTPB_R2189
            bool isVerifyR2189 = SharedTestSuiteHelper.ComapreSucceedFsshttpAllocateExtendedGuidRangeResposne(fsshttpbResponse, fsshttpbResponseSecond, this.Site);

            this.Site.Log.Add(TestTools.LogEntryKind.Debug, "Expect the two allocate extended GUID range responses are same, actual {0}", isVerifyR2189);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTPB requirement: MS-FSSHTTPB_R2189
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR2189,
                    "MS-FSSHTTPB",
                    2189,
                    @"[In Allocate Extended GUID Range] A - Reserved (8 bits): Whenever A - Reserved is set to one or zero, the protocol server must return the same response.");
            }
            else
            {
                Site.Assert.IsTrue(
                    isVerifyR2189,
                    @"[In Allocate Extended GUID Range] A - Reserved (8 bits): Whenever A - Reserved is set to one or zero, the protocol server must return the same response.");
            }
        }
        public void TestCase_S11_TC01_QueryAccessReadWrite()
        {
            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Query changes from the protocol server
            CellSubRequestType  queryChange      = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID());
            CellStorageResponse queryResponse    = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { queryChange });
            CellSubResponseType querySubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(queryResponse, 0, 0, this.Site);

            this.Site.Assert.AreEqual(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(querySubResponse.ErrorCode, this.Site), "The operation QueryChanges should succeed.");
            FsshttpbResponse fsshttpbResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(querySubResponse, this.Site);
            ExGuid           storageIndex     = fsshttpbResponse.CellSubResponses[0].GetSubResponseData <QueryChangesSubResponseData>().StorageIndexExtendedGUID;

            // Create a putChanges cellSubRequest
            FsshttpbCellRequest cellRequest = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
            ExGuid                   storageIndexExGuid;
            List <DataElement>       dataElements = DataElementUtils.BuildDataElements(System.Text.Encoding.Unicode.GetBytes("bad"), out storageIndexExGuid);
            PutChangesCellSubRequest putChange    = new PutChangesCellSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), storageIndexExGuid);

            putChange.ExpectedStorageIndexExtendedGUID = storageIndex;
            dataElements.AddRange(fsshttpbResponse.DataElementPackage.DataElements);
            cellRequest.AddSubRequest(putChange, dataElements);
            CellSubRequestType putChangesSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequest.ToBase64());

            // Put changes to the protocol server
            CellStorageResponse response        = Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { putChangesSubRequest });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(response, 0, 0, this.Site);

            // Expect the Put changes operation succeeds
            this.Site.Assert.AreEqual(ErrorCodeType.Success, SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site), "The PutChanges operation should succeed.");
            SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site), this.Site);

            // Call QueryAccess.
            CellSubRequestType  cellSubRequest      = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryAccess(0);
            CellStorageResponse cellStorageResponse = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { cellSubRequest });
            CellSubResponseType subResponse         = SharedTestSuiteHelper.ExtractSubResponse <CellSubResponseType>(cellStorageResponse, 0, 0, this.Site);
            FsshttpbResponse    queryAccessResponse = SharedTestSuiteHelper.ExtractFsshttpbResponse(subResponse, this.Site);

            // Get readAccessResponse and writeAccessResponse Data.
            HRESULTError dataRead = queryAccessResponse.CellSubResponses[0]
                                    .GetSubResponseData <QueryAccessSubResponseData>()
                                    .ReadAccessResponse.ReadResponseError
                                    .GetErrorData <HRESULTError>();

            this.Site.Assert.AreEqual <int>(
                0,
                dataRead.ErrorCode,
                "Test case cannot continue unless the read HRESULTError code equals 0 when the user have read/write permission.");

            HRESULTError dataWrite = queryAccessResponse.CellSubResponses[0]
                                     .GetSubResponseData <QueryAccessSubResponseData>()
                                     .WriteAccessResponse.WriteResponseError
                                     .GetErrorData <HRESULTError>();

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // If the error type is HRESULTError, then capture R946.
                Site.CaptureRequirementIfIsNotNull(
                    dataWrite,
                    "MS-FSSHTTPB",
                    946,
                    @"[In Query Access] Response Error (variable): If the Put Changes operation will succeed, the response error will have an error type of HRESULT error.");

                // If the error type is HRESULTError and error code equals 0, then capture R2229.
                Site.CaptureRequirementIfAreEqual <int>(
                    0,
                    dataWrite.ErrorCode,
                    "MS-FSSHTTPB",
                    2229,
                    @"[In Query Access] Response Error (variable): [If the Put Changes operation will succeed, ]the HRESULT error code will be zero.");

                // If error code equals 0, then capture R2231.
                Site.CaptureRequirementIfAreEqual <int>(
                    0,
                    dataWrite.ErrorCode,
                    "MS-FSSHTTPB",
                    2231,
                    @"[In HRESULT Error] Error Code (4 bytes): Zero means that no error occurred.");
            }
            else
            {
                Site.Assert.IsNotNull(
                    dataWrite,
                    @"[In Query Access] Response Error (variable): If the Put Changes operation will succeed, the response error will have an error type of HRESULT error.");

                Site.Assert.AreEqual <int>(
                    0,
                    dataWrite.ErrorCode,
                    @"[In Query Access] Response Error (variable): [If the Put Changes operation will succeed, ]the HRESULT error code will be zero.");
            }
        }
        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);
        }