/// <summary> /// Create PCCRTP request message. /// </summary> /// <param name="serverAddress">The server address.</param> /// <param name="port">The port.</param> /// <param name="requestFileName">The request uri.</param> /// <param name="version">Version of branch cache.</param> /// <param name="missingData">True if this is a missing data request; false otherwise.</param> /// <returns>Returns the HTTP response.</returns> public PccrtpRequest CreatePccrtpRequest( string serverAddress, int port, string requestFileName, BranchCacheVersion version = BranchCacheVersion.V1, bool missingData = false) { this.pccrtpRequest.ServerAddress = serverAddress; this.pccrtpRequest.Port = port; this.pccrtpRequest.RequestFileName = requestFileName; Dictionary <string, string> tempHttpHeader = new Dictionary <string, string>(); tempHttpHeader.Add(PccrtpConsts.AcceptEncodingHttpHeader, "peerdist"); switch (version) { case BranchCacheVersion.V1: tempHttpHeader.Add(PccrtpConsts.XP2PPeerDistHttpHeader, "Version=1.0" + (missingData ? ",MissingDataRequest=true" : "")); break; case BranchCacheVersion.V2: tempHttpHeader.Add(PccrtpConsts.XP2PPeerDistHttpHeader, "Version=1.1" + (missingData ? ",MissingDataRequest=true" : "")); tempHttpHeader.Add(PccrtpConsts.XP2PPeerDistExHttpHeader, "MinContentInformation=1.0, MaxContentInformation=2.0"); break; default: throw new NotImplementedException(); } this.pccrtpRequest.HttpHeader = tempHttpHeader; return(this.pccrtpRequest); }
public void ForceGenerateHashAndRetrieveHash(BranchCacheVersion version) { contentInformationUtility.ForceTriggerContentServerHashGeneration(); BaseTestSite.Log.Add( LogEntryKind.Debug, "Retrieve content information from content server"); contentInformationUtility.RetrieveContentInformation(version); }
public void ForceGenerateHashAndRetrieveHash(BranchCacheVersion version) { contentInformationUtility.ForceTriggerContentServerHashGeneration(); BaseTestSite.Log.Add( LogEntryKind.Debug, "Retrieve content information from content server"); contentInformationUtility.RetrieveContentInformation(version); }
public void RetrieveContentInformation(BranchCacheVersion version) { BaseTestSite.Log.Add( LogEntryKind.Debug, "Trigger hash generation on content server"); var content = contentInformationUtility.RetrieveContentData(); BaseTestSite.Log.Add( LogEntryKind.Debug, "Retrieve content information from content server"); var contentInformation = contentInformationUtility.RetrieveContentInformation(version); contentInformationUtility.VerifyContentInformation(content, contentInformation, version); }
public void RetrieveContentInformation(BranchCacheVersion version) { BaseTestSite.Log.Add( LogEntryKind.Debug, "Trigger hash generation on content server"); var content = contentInformationUtility.RetrieveContentData(); BaseTestSite.Log.Add( LogEntryKind.Debug, "Retrieve content information from content server"); var contentInformation = contentInformationUtility.RetrieveContentInformation(version); contentInformationUtility.VerifyContentInformation(content, contentInformation, version); }
public void RetrieveMissingContent(BranchCacheVersion branchCacheVersion) { BaseTestSite.Log.Add( LogEntryKind.Debug, "Trigger hash generation on content server"); var content = contentInformationUtility.RetrieveContentData(); BaseTestSite.Log.Add( LogEntryKind.Debug, "Wait until the hash is generated on content server"); TestUtility.DoUntilSucceed(() => sutControlAdapter.IsHTTPHashExisted(testConfig.ContentServerComputerFQDNOrNetBiosName), testConfig.Timeout, testConfig.RetryInterval); BaseTestSite.Log.Add( LogEntryKind.Debug, "Retrieve missing content"); var pccrtpClient = new PccrtpClient(); var pccrtpRequest = pccrtpClient.CreatePccrtpRequest( testConfig.ContentServerComputerName, testConfig.ContentServerHTTPListenPort, testConfig.NameOfFileWithMultipleBlocks, branchCacheVersion, true); var pccrtpResponse = pccrtpClient.SendHttpRequest( Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.HttpVersionType.HttpVersion11, pccrtpRequest, (int)testConfig.Timeout.TotalMilliseconds); BaseTestSite.Assert.AreNotEqual( "peerdist", pccrtpResponse.HttpResponse.ContentEncoding, "The content server should reply with the content"); byte[] retrievedContent = pccrtpResponse.PayloadData; BaseTestSite.Assert.IsTrue( Enumerable.SequenceEqual(content, retrievedContent), "The retrieved missing data should be the same as server data."); }
public void RetrieveMissingContent(BranchCacheVersion branchCacheVersion) { BaseTestSite.Log.Add( LogEntryKind.Debug, "Trigger hash generation on content server"); var content = contentInformationUtility.RetrieveContentData(); BaseTestSite.Log.Add( LogEntryKind.Debug, "Wait until the hash is generated on content server"); TestUtility.DoUntilSucceed(() => sutControlAdapter.IsHTTPHashExisted(testConfig.ContentServerComputerFQDNOrNetBiosName), testConfig.Timeout, testConfig.RetryInterval); BaseTestSite.Log.Add( LogEntryKind.Debug, "Retrieve missing content"); var pccrtpClient = new PccrtpClient(); var pccrtpRequest = pccrtpClient.CreatePccrtpRequest( testConfig.ContentServerComputerName, testConfig.ContentServerHTTPListenPort, testConfig.NameOfFileWithMultipleBlocks, branchCacheVersion, true); var pccrtpResponse = pccrtpClient.SendHttpRequest( Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.HttpVersionType.HttpVersion11, pccrtpRequest, (int)testConfig.Timeout.TotalMilliseconds); BaseTestSite.Assert.AreNotEqual( "peerdist", pccrtpResponse.HttpResponse.ContentEncoding, "The content server should reply with the content"); byte[] retrievedContent = pccrtpResponse.PayloadData; BaseTestSite.Assert.IsTrue( Enumerable.SequenceEqual(content, retrievedContent), "The retrieved missing data should be the same as server data."); }
/// <summary> /// Create PCCRTP request message. /// </summary> /// <param name="serverAddress">The server address.</param> /// <param name="port">The port.</param> /// <param name="requestFileName">The request uri.</param> /// <param name="version">Version of branch cache.</param> /// <param name="missingData">True if this is a missing data request; false otherwise.</param> /// <returns>Returns the HTTP response.</returns> public PccrtpRequest CreatePccrtpRequest( string serverAddress, int port, string requestFileName, BranchCacheVersion version = BranchCacheVersion.V1, bool missingData = false) { this.pccrtpRequest.ServerAddress = serverAddress; this.pccrtpRequest.Port = port; this.pccrtpRequest.RequestFileName = requestFileName; Dictionary<string, string> tempHttpHeader = new Dictionary<string, string>(); tempHttpHeader.Add(PccrtpConsts.AcceptEncodingHttpHeader, "peerdist"); switch (version) { case BranchCacheVersion.V1: tempHttpHeader.Add(PccrtpConsts.XP2PPeerDistHttpHeader, "Version=1.0" + (missingData ? ",MissingDataRequest=true" : "")); break; case BranchCacheVersion.V2: tempHttpHeader.Add(PccrtpConsts.XP2PPeerDistHttpHeader, "Version=1.1" + (missingData ? ",MissingDataRequest=true" : "")); tempHttpHeader.Add(PccrtpConsts.XP2PPeerDistExHttpHeader, "MinContentInformation=1.0, MaxContentInformation=2.0"); break; default: throw new NotImplementedException(); } this.pccrtpRequest.HttpHeader = tempHttpHeader; return this.pccrtpRequest; }
private void AddBranchCacheVersionInfo(BranchCacheVersion version) { AddResultItem(ref this.versionSupportedItems, version.ToString(), this.info.VersionInformation.branchCacheVersion.HasFlag(version)? DetectResult.Supported:DetectResult.UnSupported); }
public void VerifyContentInformation(byte[] content, byte[] contentInformation, BranchCacheVersion version) { switch (version) { case BranchCacheVersion.V1: VerifyHashGenerationV1(content, PccrcUtility.ParseContentInformation(contentInformation)); break; case BranchCacheVersion.V2: VerifyHashGenerationV2(content, PccrcUtility.ParseContentInformationV2(contentInformation)); break; default: throw new NotImplementedException(); } }
public byte[] RetrieveContentInformation(BranchCacheVersion version, string filename) { switch (testConfig.ContentTransport) { case ContentInformationTransport.PCCRTP: TestUtility.DoUntilSucceed(() => sutControlAdapter.IsHTTPHashExisted(testConfig.ContentServerComputerName), testConfig.Timeout, testConfig.RetryInterval); PccrtpClient pccrtpClient = new PccrtpClient(); PccrtpRequest pccrtpRequest = pccrtpClient.CreatePccrtpRequest( testConfig.ContentServerComputerName, testConfig.ContentServerHTTPListenPort, filename, version); var pccrtpResponse = pccrtpClient.SendHttpRequest( Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.HttpVersionType.HttpVersion11, pccrtpRequest, (int)testConfig.Timeout.TotalMilliseconds); testSite.Assert.AreEqual( "peerdist", pccrtpResponse.HttpResponse.ContentEncoding, "The content server should return peerdist encoded content information"); return(pccrtpResponse.PayloadData); case ContentInformationTransport.SMB2: using (BranchCacheSmb2ClientTransport smb2Client = new BranchCacheSmb2ClientTransport(testConfig.Timeout, testSite, testConfig.SupportBranchCacheV1, testConfig.SupportBranchCacheV2)) { smb2Client.OpenFile( testConfig.ContentServerComputerName, testConfig.SharedFolderName, filename, testConfig.SecurityPackageType, testConfig.DomainName, testConfig.UserName, testConfig.UserPassword, AccessMask.GENERIC_READ); HASH_HEADER hashHeader; byte[] hashData = null; TestUtility.DoUntilSucceed( () => smb2Client.ReadHash( SRV_READ_HASH_Request_HashType_Values.SRV_HASH_TYPE_PEER_DIST, version == BranchCacheVersion.V1 ? SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_1 : SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_2, version == BranchCacheVersion.V1 ? SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_HASH_BASED : SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_FILE_BASED, 0, uint.MaxValue, out hashHeader, out hashData) == Smb2Status.STATUS_SUCCESS, testConfig.Timeout, testConfig.RetryInterval); testSite.Assert.AreNotEqual( 0, hashData.Length, "The content server should return content information in READ_HASH_RESPONSE"); return(hashData); } default: throw new NotImplementedException(); } }
public byte[] RetrieveContentInformation(BranchCacheVersion version) { return(RetrieveContentInformation(version, testConfig.NameOfFileWithMultipleBlocks)); }
public void VerifyContentInformation(byte[] content, byte[] contentInformation, BranchCacheVersion version) { switch (version) { case BranchCacheVersion.V1: VerifyHashGenerationV1(content, PccrcUtility.ParseContentInformation(contentInformation)); break; case BranchCacheVersion.V2: VerifyHashGenerationV2(content, PccrcUtility.ParseContentInformationV2(contentInformation)); break; default: throw new NotImplementedException(); } }
public byte[] RetrieveContentInformation(BranchCacheVersion version, string filename) { switch (testConfig.ContentTransport) { case ContentInformationTransport.PCCRTP: TestUtility.DoUntilSucceed(() => sutControlAdapter.IsHTTPHashExisted(testConfig.ContentServerComputerName), testConfig.Timeout, testConfig.RetryInterval); PccrtpClient pccrtpClient = new PccrtpClient(); PccrtpRequest pccrtpRequest = pccrtpClient.CreatePccrtpRequest( testConfig.ContentServerComputerName, testConfig.ContentServerHTTPListenPort, filename, version); var pccrtpResponse = pccrtpClient.SendHttpRequest( Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.HttpVersionType.HttpVersion11, pccrtpRequest, (int)testConfig.Timeout.TotalMilliseconds); testSite.Assert.AreEqual( "peerdist", pccrtpResponse.HttpResponse.ContentEncoding, "The content server should return peerdist encoded content information"); return pccrtpResponse.PayloadData; case ContentInformationTransport.SMB2: using (BranchCacheSmb2ClientTransport smb2Client = new BranchCacheSmb2ClientTransport(testConfig.Timeout, testSite, testConfig.SupportBranchCacheV1, testConfig.SupportBranchCacheV2)) { smb2Client.OpenFile( testConfig.ContentServerComputerName, testConfig.SharedFolderName, filename, testConfig.SecurityPackageType, testConfig.DomainName, testConfig.UserName, testConfig.UserPassword, AccessMask.GENERIC_READ); HASH_HEADER hashHeader; byte[] hashData = null; TestUtility.DoUntilSucceed( () => smb2Client.ReadHash( SRV_READ_HASH_Request_HashType_Values.SRV_HASH_TYPE_PEER_DIST, version == BranchCacheVersion.V1 ? SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_1 : SRV_READ_HASH_Request_HashVersion_Values.SRV_HASH_VER_2, version == BranchCacheVersion.V1 ? SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_HASH_BASED : SRV_READ_HASH_Request_HashRetrievalType_Values.SRV_HASH_RETRIEVE_FILE_BASED, 0, uint.MaxValue, out hashHeader, out hashData) == Smb2Status.STATUS_SUCCESS, testConfig.Timeout, testConfig.RetryInterval); testSite.Assert.AreNotEqual( 0, hashData.Length, "The content server should return content information in READ_HASH_RESPONSE"); return hashData; } default: throw new NotImplementedException(); } }
public byte[] RetrieveContentInformation(BranchCacheVersion version) { return RetrieveContentInformation(version, testConfig.NameOfFileWithMultipleBlocks); }