/// <summary> /// Validate the specific response type from the server. /// </summary> /// <param name="cellStorageResponseObjects">The server returned CellStorageResponse instance.</param> private void ValidateSpecificType(CellStorageResponse cellStorageResponseObjects) { // Validate each specific sub response type. if (cellStorageResponseObjects.ResponseCollection != null && cellStorageResponseObjects.ResponseCollection.Response != null && cellStorageResponseObjects.ResponseCollection.Response.Length != 0) { foreach (SubResponseValidationWrapper subResponseValidationWrapper in this.subResponseValidationWrappers) { // Try to validate sub response schema subResponseValidationWrapper.Validate(this.lastRawResponseXml.OuterXml, this.Site); } } }
public void MSFSSHTTP_FSSHTTPB_S03_TC02_GetLock_UrlNotSpecified() { // Initialize the service this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain); // Create a GetLock subRequest with all valid parameters. SchemaLockSubRequestType subRequest = SharedTestSuiteHelper.CreateSchemaLockSubRequestForGetLock(null); CellStorageResponse response = new CellStorageResponse(); bool isR3006Verified = false; try { // Send a GetLock for schema lock subRequest to the protocol server without specifying URL attribute. response = this.Adapter.CellStorageRequest(null, new SubRequestType[] { subRequest }); } catch (System.Xml.XmlException exception) { string message = exception.Message; isR3006Verified = message.Contains("Duplicate attribute"); isR3006Verified &= message.Contains("ErrorCode"); } if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3006 if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3006, this.Site)) { Site.Log.Add( LogEntryKind.Debug, "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists."); Site.CaptureRequirementIfIsTrue( isR3006Verified, "MS-FSSHTTP", 3006, @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element doesn't exist, the implementation does return two ErrorCode attributes in Response element. <3> Section 2.2.3.5: SharePoint Server 2010 will return 2 ErrorCode attributes in Response element."); } // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3007 if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3007, this.Site)) { Site.CaptureRequirementIfIsNull( response.ResponseCollection, "MS-FSSHTTP", 3007, @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element doesn't exist, the implementation does not return Response element. <3> Section 2.2.3.5: SharePoint Server 2013 will not return Response element."); } } else { if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3006, this.Site)) { Site.Log.Add( LogEntryKind.Debug, "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists."); Site.Assert.IsTrue( isR3006Verified, "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists."); } if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3007, this.Site)) { Site.Assert.IsNull( response.ResponseCollection, @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element doesn't exist, the implementation does not return Response element. <3> Section 2.2.3.5: SharePoint Server 2013 will not return Response element."); } } }
/// <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()); } } } } }
/// <summary> /// Used to parse the response message and retrieve the CellStorageResponse object /// </summary> /// <param name="responseMsg">Response message</param> /// <returns>CellStorageResponse object</returns> private CellStorageResponse GetCellStorageResponseObject(Message responseMsg) { CellStorageResponse cellStorageResponse = new CellStorageResponse(); XmlDocument xmlDoc = new XmlDocument(); MemoryStream ms = null; try { ms = new MemoryStream(); using (XmlWriter xw = XmlWriter.Create(ms)) { responseMsg.WriteMessage(xw); xw.Flush(); ms.Flush(); ms.Position = 0; xmlDoc.Load(ms); } } finally { if (ms != null) { ms.Dispose(); } } this.lastRawResponseXml = xmlDoc.DocumentElement; // Try to log the response body information this.Site.Log.Add(LogEntryKind.Debug, "The raw xml response message is:\r\n{0}", this.lastRawResponseXml.OuterXml); // De-serialize the ResponseVersion node XmlNodeList responseVersionNodeList = xmlDoc.GetElementsByTagName("ResponseVersion"); if (responseVersionNodeList.Count > 0) { XmlSerializer responseVersionNodeSerializer = new XmlSerializer(typeof(XmlNode)); MemoryStream responseVersionMemStream = new MemoryStream(); responseVersionNodeSerializer.Serialize(responseVersionMemStream, responseVersionNodeList[0]); responseVersionMemStream.Position = 0; XmlSerializer responseVersionSerializer = new XmlSerializer(typeof(ResponseVersion)); cellStorageResponse.ResponseVersion = (ResponseVersion)responseVersionSerializer.Deserialize(responseVersionMemStream); responseVersionMemStream.Dispose(); } // De-serialize the ResponseCollection node. XmlNodeList responseCollectionNodeList = xmlDoc.GetElementsByTagName("ResponseCollection"); if (responseCollectionNodeList.Count > 0) { XmlSerializer responseCollectionNodeSerializer = new XmlSerializer(typeof(XmlNode)); MemoryStream responseCollectionMemStream = new MemoryStream(); responseCollectionNodeSerializer.Serialize(responseCollectionMemStream, responseCollectionNodeList[0]); responseCollectionMemStream.Position = 0; XmlSerializer responseCollectionSerializer = new XmlSerializer(typeof(ResponseCollection)); cellStorageResponse.ResponseCollection = (ResponseCollection)responseCollectionSerializer.Deserialize(responseCollectionMemStream); responseCollectionMemStream.Dispose(); } return cellStorageResponse; }
/// <summary> /// Capture requirements related with Response message /// </summary> /// <param name="storageResponse">The storage response information</param> /// <param name="requestToken">The expected RequestToken</param> /// <param name="site">Instance of ITestSite</param> public static void ValidateResponse(CellStorageResponse storageResponse, string requestToken, ITestSite site) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R17 site.CaptureRequirement( "MS-FSSHTTP", 17, @"[In Response] The protocol response schema is specified by the following: <?xml version=""1.0"" encoding=""utf-8""?> <xs:schema xmlns:tns=""http://schemas.microsoft.com/sharepoint/soap/"" attributeFormDefault=""unqualified"" elementFormDefault=""qualified"" targetNamespace=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"" xmlns:i=""http://www.w3.org/2004/08/xop/include""> <xs:import namespace=""http://www.w3.org/2004/08/xop/include"" /> <xs:element name=""Envelope""> <xs:complexType> <xs:sequence> <xs:element name=""Body""> <xs:complexType> <xs:sequence> <xs:element ref=""tns:ResponseVersion"" minOccurs=""1"" maxOccurs=""1"" /> <xs:element ref=""tns:ResponseCollection"" minOccurs=""0"" maxOccurs=""1""/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element>"); // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R18 site.CaptureRequirement( "MS-FSSHTTP", 18, @"[In Response] The Body element of each SOAP response message MUST contain a ResponseVersion element."); // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R19 site.CaptureRequirement( "MS-FSSHTTP", 19, @"[In Response] [The Body element of each SOAP response message MUST contain] zero or more ResponseCollection elements."); // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1613 bool isVerifiedR1613 = storageResponse.ResponseVersion != null; site.Log.Add( LogEntryKind.Debug, "For requirement MS-FSSHTTP_R1613, [In Messages] Response: The detail element of the protocol response contains a ResponseVersion element, the actual ResponseVersion elements is: {0}", storageResponse.ResponseVersion != null ? storageResponse.ResponseVersion.ToString() : "NULL"); site.CaptureRequirementIfIsTrue( isVerifiedR1613, "MS-FSSHTTP", 1613, @"[In Messages] Response: The detail element of the protocol response contains a ResponseVersion element and zero or one ResponseCollection elements."); // Verify requirements related with ResponseVersion ValidateResponseVersion(storageResponse.ResponseVersion, site); // Verify requirements related with ResponseCollection if (storageResponse.ResponseCollection != null) { ValidateResponseCollection(storageResponse.ResponseCollection, requestToken, site); } }
public void MSFSSHTTP_FSSHTTPB_S04_TC09_ExclusiveLock_EmptyUrl() { // Initialize the service this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain); ExclusiveLockSubRequestType subRequest = SharedTestSuiteHelper.CreateExclusiveLockSubRequest(ExclusiveLockRequestTypes.GetLock); CellStorageResponse response = new CellStorageResponse(); bool isR3008Verified = false; try { // Send a GetLock for exclusive subRequest to the protocol server with empty URL. response = this.Adapter.CellStorageRequest(string.Empty, new SubRequestType[] { subRequest }); } catch (System.Xml.XmlException exception) { string message = exception.Message; isR3008Verified = message.Contains("Duplicate attribute"); isR3008Verified &= message.Contains("ErrorCode"); } if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3008 if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site)) { Site.Log.Add( LogEntryKind.Debug, "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is empty string."); Site.CaptureRequirementIfIsTrue( isR3008Verified, "MS-FSSHTTP", 3008, @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does return two ErrorCode attributes in Response element. <3> Section 2.2.3.5: SharePoint Server 2010 will return 2 ErrorCode attributes in Response element."); } // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3009 if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site)) { Site.CaptureRequirementIfIsNull( response.ResponseCollection, "MS-FSSHTTP", 3009, @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does not return Response element. <3> Section 2.2.3.5: SharePoint Server 2013 will not return Response element."); } } else { if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site)) { Site.Log.Add( LogEntryKind.Debug, "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is empty string."); Site.Assert.IsTrue( isR3008Verified, "[In Appendix B: Product Behavior] If the URL attribute of the corresponding Request element is an empty string, the implementation does return two ErrorCode attributes in Response element. <3> Section 2.2.3.5: SharePoint Server 2010 will return 2 ErrorCode attributes in Response element."); } if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site)) { Site.Assert.IsNull( response.ResponseCollection, @"[In Appendix B: Product Behavior] If the URL attribute of the corresponding Request element is an empty string, the implementation does not return Response element. <3> Section 2.2.3.5: SharePoint Server 2013 will not return Response element."); } } }
public void MSFSSHTTP_FSSHTTPB_S01_TC01_DownloadContents_EmptyUrl() { if ((!Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site)) && (!Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site))) { Site.Assume.Inconclusive("Implementation does not have same behaviors as Microsoft products."); } // Initialize the context using user01 and defaultFileUrl. this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain); CellStorageResponse response = new CellStorageResponse(); bool isR3008Verified = false; try { // Query the updated file content. CellSubRequestType queryChange = SharedTestSuiteHelper.CreateCellSubRequestEmbeddedQueryChanges(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID()); response = Adapter.CellStorageRequest(string.Empty, new SubRequestType[] { queryChange }); } catch (System.Xml.XmlException exception) { string message = exception.Message; isR3008Verified = message.Contains("Duplicate attribute"); isR3008Verified &= message.Contains("ErrorCode"); } if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3008 if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site)) { Site.Log.Add( LogEntryKind.Debug, "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is empty."); Site.CaptureRequirementIfIsTrue( isR3008Verified, "MS-FSSHTTP", 3008, @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does return two ErrorCode attributes in Response element. <3> Section 2.2.3.5: SharePoint Server 2010 will return 2 ErrorCode attributes in Response element."); } // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R3009 if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site)) { Site.CaptureRequirementIfIsNull( response.ResponseCollection, "MS-FSSHTTP", 3009, @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does not return Response element. <3> Section 2.2.3.5: SharePoint Server 2013 will not return Response element."); } } else { if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3008, this.Site)) { Site.Log.Add( LogEntryKind.Debug, "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists."); Site.Assert.IsTrue( isR3008Verified, "SharePoint server 2010 and SharePoint Foundation responses two ErrorCode attributes when the URL is non exists."); } if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 3009, this.Site)) { Site.Assert.IsNull( response.ResponseCollection, @"[In Appendix B: Product Behavior] If the Url attribute of the corresponding Request element is an empty string, the implementation does not return Response element. <3> Section 2.2.3.5: SharePoint Server 2013 will not return Response element."); } } }