This partial part of MsfsshttpAdapterCapture class is used to test Get docMetaInfo response related requirements.
        /// <summary>
        /// This method is used to validate the sub response according to the current record sub request token and sub request type.
        /// </summary>
        /// <param name="rawResponse">Specify the raw XML string response returned by the protocol server.</param>
        /// <param name="site">An object provides logging, assertions, and SUT adapters for test code onto its execution context.</param>
        public void Validate(string rawResponse, ITestSite site)
        {
            // Extract the sub response whose token equals the SubToken value.
            XmlDocument subResponseDocument = this.ExtractSubResponseNode(rawResponse);

            // De-serialize the sub response to instance
            object subResponse = this.SerializeSubResponse(subResponseDocument, site);

            // Try to parse the MS-FSSHTTPB structure
            if (subResponse is CellSubResponseType)
            {
                // If the sub request type is CellSubRequestType, then indicating that there is one MS-FSSHTTPB response embedded. Try parse this an capture all the related requirements.
                CellSubResponseType cellSubResponse = subResponse as CellSubResponseType;
                if (cellSubResponse.SubResponseData != null && cellSubResponse.SubResponseData.Text.Length == 1)
                {
                    string           subResponseBase64 = cellSubResponse.SubResponseData.Text[0];
                    byte[]           subResponseBinary = Convert.FromBase64String(subResponseBase64);
                    FsshttpbResponse fsshttpbResponse  = FsshttpbResponse.DeserializeResponseFromByteArray(subResponseBinary, 0);

                    if (fsshttpbResponse.DataElementPackage != null && fsshttpbResponse.DataElementPackage.DataElements != null)
                    {
                        // If the response data elements is complete, then try to verify the requirements related in the MS-FSSHTPD
                        foreach (DataElement storageIndex in fsshttpbResponse.DataElementPackage.DataElements.Where(dataElement => dataElement.DataElementType == DataElementType.StorageIndexDataElementData))
                        {
                            // Just build the root node to try to parse the signature related requirements, no need to restore the result.
                            new RootNodeObject.RootNodeObjectBuilder().Build(
                                fsshttpbResponse.DataElementPackage.DataElements,
                                storageIndex.DataElementExtendedGUID);
                        }
                    }

                    if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                    {
                        new MsfsshttpbAdapterCapture().VerifyTransport(site);

                        // Capture the response related requirements
                        new MsfsshttpbAdapterCapture().VerifyFsshttpbResponse(fsshttpbResponse, site);
                    }
                }
            }

            // Validating the fragment of the sub response
            // Record the validation errors and warnings.
            ValidationResult result = SchemaValidation.ValidateXml(subResponseDocument.OuterXml);

            if (!SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                if (result != ValidationResult.Success)
                {
                    // Add error log
                    site.Assert.Fail("Schema validation fails, the reason is " + SchemaValidation.GenerateValidationResult());
                }

                // No need to run the capture code, just return.
                return;
            }

            if (result == ValidationResult.Success)
            {
                // Capture the requirement related to the sub response token.
                MsfsshttpAdapterCapture.ValidateSubResponseToken(site);

                // Call corresponding sub response capture code.
                this.InvokeCaptureCode(subResponse, site);
            }
            else
            {
                // Add error log
                site.Assert.Fail("Schema validation fails, the reason is " + SchemaValidation.GenerateValidationResult());
            }
        }
Пример #2
0
        /// <summary>
        /// Validate the generic response type from the server.
        /// </summary>
        /// <param name="cellStorageResponseObjects">The server returned CellStorageResponse instance.</param>
        /// <param name="requestToken">The expected RequestToken</param>
        private void ValidateGenericType(CellStorageResponse cellStorageResponseObjects, string requestToken)
        {
            // Do the generic schema validation based on the different operation type.
            if (SharedContext.Current.OperationType == OperationType.FSSHTTPCellStorageRequest)
            {
                SchemaValidation.ValidateXml(this.lastRawResponseXml.OuterXml);

                // Validate the generic part schema
                if (SchemaValidation.ValidationResult == ValidationResult.Success)
                {
                    MsfsshttpAdapterCapture.ValidateResponse(cellStorageResponseObjects, requestToken, this.Site);
                    MsfsshttpAdapterCapture.ValidateTransport(this.Site);
                }
                else
                {
                    this.Site.Assert.Fail("The schema validation fails, the reason is " + SchemaValidation.GenerateValidationResult());
                }
            }
            else
            {
                XmlNodeList responseVersionNodeList = this.lastRawResponseXml.GetElementsByTagName("ResponseVersion");
                if (responseVersionNodeList.Count > 0)
                {
                    SchemaValidation.ValidateXml(responseVersionNodeList[0].OuterXml);

                    if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                    {
                        if (SchemaValidation.ValidationResult == ValidationResult.Success)
                        {
                            MsfsshttpAdapterCapture.ValidateResponseVersion(cellStorageResponseObjects.ResponseVersion, this.Site);
                        }
                        else
                        {
                            this.Site.Assert.Fail("The schema validation fails, the reason is " + SchemaValidation.GenerateValidationResult());
                        }
                    }
                    else
                    {
                        if (SchemaValidation.ValidationResult != ValidationResult.Success)
                        {
                            this.Site.Assert.Fail("The schema validation fails, the reason is " + SchemaValidation.GenerateValidationResult());
                        }
                    }
                }

                // De-serialize the ResponseCollection node.
                XmlNodeList responseCollectionNodeList = this.lastRawResponseXml.GetElementsByTagName("ResponseCollection");
                if (responseCollectionNodeList.Count > 0)
                {
                    SchemaValidation.ValidateXml(responseCollectionNodeList[0].OuterXml);

                    if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                    {
                        if (SchemaValidation.ValidationResult == ValidationResult.Success)
                        {
                            MsfsshttpAdapterCapture.ValidateResponseCollection(cellStorageResponseObjects.ResponseCollection, requestToken, this.Site);
                        }
                        else
                        {
                            this.Site.Assert.Fail("The schema validation fails, the reason is " + SchemaValidation.GenerateValidationResult());
                        }
                    }
                    else
                    {
                        if (SchemaValidation.ValidationResult != ValidationResult.Success)
                        {
                            this.Site.Assert.Fail("The schema validation fails, the reason is " + SchemaValidation.GenerateValidationResult());
                        }
                    }
                }
            }
        }