Skip to content

Commit

Permalink
Merge pull request #32 from IamWenboZhang/master
Browse files Browse the repository at this point in the history
Updated FSSHTTPWOPIInspector project
  • Loading branch information
IamWenboZhang authored Sep 29, 2018
2 parents 3181ee5 + 80db6ba commit 75196d8
Show file tree
Hide file tree
Showing 25 changed files with 369 additions and 124 deletions.
Binary file modified FSSHTTPWOPIInspector/FSSHTTPAndWOPIFiddlerInspector.dll
Binary file not shown.
Binary file not shown.
38 changes: 31 additions & 7 deletions FSSHTTPWOPIInspector/Source/FSSHTTPandWOPIInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,39 @@ public object ParseHTTPPayloadForWOPI(HTTPHeaders requestHeaders, HTTPHeaders re
{
res = string.Format("{0}{1}{2}", @"<Body>", text, "</Body>");
}
ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(res ?? ""));
XmlSerializer serializer = new XmlSerializer(typeof(ResponseEnvelopeBody));
ResponseEnvelopeBody body = (ResponseEnvelopeBody)serializer.Deserialize(ms);
objectOut = body;

// if SubResponseData has fsshttpb messages do parser.
if (body.ResponseCollection != null)
try
{
ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(res ?? ""));
XmlSerializer serializer = new XmlSerializer(typeof(ResponseEnvelopeBody));
ResponseEnvelopeBody body = (ResponseEnvelopeBody)serializer.Deserialize(ms);
objectOut = body;

// if SubResponseData has fsshttpb messages do parser.
if (body.ResponseCollection != null)
{
TryParseFSSHTTPBResponseMessage(body.ResponseCollection.Response, bytesFromHTTP);
}
}
catch
{
TryParseFSSHTTPBResponseMessage(body.ResponseCollection.Response, bytesFromHTTP);
Regex SOAPRegex = new Regex(@"\<s:Envelop.*\<\/s:Envelope\>"); // extract envelop from http payload.
if (SOAPRegex.Match(res).Success)
{
XmlDocument doc = new XmlDocument();
string soapbody = SOAPRegex.Match(res).Value;

MemoryStream memoryStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(soapbody ?? ""));
XmlSerializer serializer = new XmlSerializer(typeof(ResponseEnvelope));
ResponseEnvelope responseEnvelop = (ResponseEnvelope)serializer.Deserialize(memoryStream);
objectOut = responseEnvelop.Body;

// if SubResponseData has fsshttpb messages do parser.
if (responseEnvelop.Body.ResponseCollection != null)
{
TryParseFSSHTTPBResponseMessage(responseEnvelop.Body.ResponseCollection.Response, bytesFromHTTP);
}
}
}
break;
}
Expand Down
15 changes: 6 additions & 9 deletions FSSHTTPWOPIInspector/Source/FSSHTTPandWOPIInspector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,11 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Be.Windows.Forms.HexBox, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\Program Files\Fiddler2\Be.Windows.Forms.HexBox.dll</HintPath>
<Reference Include="Be.Windows.Forms.HexBox">
<HintPath>..\..\..\..\..\..\Software\DevelopTool\Fiddler\Be.Windows.Forms.HexBox.dll</HintPath>
</Reference>
<Reference Include="Fiddler, Version=4.6.0.2, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\Program Files\Fiddler2\Fiddler.exe</HintPath>
<Reference Include="Fiddler">
<HintPath>..\..\..\..\..\..\Software\DevelopTool\Fiddler\Fiddler.exe</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand All @@ -106,9 +104,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Xceed.Compression.Formats.v5.4, Version=5.4.13572.13590, Culture=neutral, PublicKeyToken=ba83ff368b7563c6, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\Program Files\Fiddler2\Inspectors\Xceed.Compression.Formats.v5.4.dll</HintPath>
<Reference Include="Xceed.Compression.Formats.v5.4">
<HintPath>..\..\..\..\..\..\Software\DevelopTool\Fiddler\Xceed.Compression.Formats.v5.4.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions FSSHTTPWOPIInspector/Source/Parsers/FSSHTTP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ public class ResponseCollection

[XmlAttribute()]
public string WebUrl { get; set; }

[XmlAttribute()]
public string WebUrlIsEncoded { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -424,6 +427,9 @@ public class Response

[XmlAttribute()]
public string ResourceID { get; set; }

[XmlAttribute()]
public string UrlIsEncoded { get; set; }
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion FSSHTTPWOPIInspector/Source/Parsers/WOPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public enum st_wopiactionvalues
edit,

/// <remarks/>
mobileview,
mobileView,

/// <remarks/>
embedview,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
37 changes: 19 additions & 18 deletions FSSHTTPWOPIInspector/Test/WOPIautomation/WOPIautomation/App.config
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- Note: Property values are case-insensitive unless otherwise specified.-->
<appSettings>
<!-- The browser used to access the site. The value should be one of following: IE32, IE64, Chrome, Firefox.-->
<add key="Browser" value="ie32" />
<add key="UserName" value="contoso\user1"/>
<add key="Password" value="Password01!"/>
<add key="OtherUserName" value="contoso\user2"/>
<add key="OtherPassword" value="Password01!"/>
<add key="BaseAddress" value="https://sut04/" />
<add key="Excel" value="..\..\..\Resource\Excel.xlsx" />
<add key="Word" value="..\..\..\Resource\Word.docx" />
<add key="Browser" value="ie32"/>
<add key="UserName" value="Contoso\plugdevuser18"/>
<add key="Password" value="[Ww47Iwa#Q6dA"/>
<add key="OtherUserName" value="sut02\plugdevuser11"/>
<add key="OtherPassword" value="4SO3kO%iZ|U4X"/>
<add key="BaseAddress" value="http://192.168.0.22"/>
<add key="DocumentAddress" value="http://192.168.0.22/Shared%20Documents/Forms/AllItems.aspx"/>
<add key="Excel" value="..\..\..\Resource\Excel.xlsx"/>
<add key="Word" value="..\..\..\Resource\Doc.docx"/>
<!-- The default wait time when finding element.-->
<add key="DefaultWaitTime" value="15"/>
<add key="UIWaitTime" value="30" />
<add key="UIWaitTime" value="30"/>

<!-- The capture tool setting.-->
<add key="StartScriptPath" value="..\..\..\Resource\StartRemoteRun.ps1" />
<add key="StopScriptPath" value="..\..\..\Resource\StopRemoteRun.ps1" />
<add key="Powershell_Path" value="%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" />
<add key="path" value="\\sut04\v-huid3\aa.cap" />
<add key="defaultUserNameForFiddler" value="user1" />
<add key="FiddlerPath" value="C:\Program Files (x86)\Fiddler2" />
<add key="BatPath" value="..\..\..\Resource\Converter.bat" />
<add key="StartScriptPath" value="..\..\..\Resource\StartRemoteRun.ps1"/>
<add key="StopScriptPath" value="..\..\..\Resource\StopRemoteRun.ps1"/>
<add key="Powershell_Path" value="%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"/>
<add key="path" value="\\sut02\C$\Wenbo\aa.cap"/>
<add key="defaultUserNameForFiddler" value="plugdevuser15"/>
<add key="FiddlerPath" value="C:\Users\plugdevuser15\AppData\Local\Programs\Fiddler"/>
<add key="BatPath" value="..\..\..\Resource\Converter.bat"/>
</appSettings>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
56 changes: 41 additions & 15 deletions FSSHTTPWOPIInspector/Test/WOPIautomation/WOPIautomation/Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using System.Windows.Forms;
using System.Configuration;
using OpenQA.Selenium.Support.Events;
using OpenQA.Selenium.Interactions;

namespace WOPIautomation
{
public static class Browser
Expand All @@ -33,25 +35,34 @@ public static string BaseAddress
}
}

public static string DocumentAddress
{
get
{
string address = ConfigurationManager.AppSettings["DocumentAddress"];
return address.EndsWith("/") ? address.Substring(0, address.Length - 1) : address;
}
}

/// <summary>
/// Browser initialize
/// </summary>
/// <param name="postfix">string value indicate address postfix</param>
public static void Initialize(string postfix = "")
public static void Initialize(string postfix = "Shared%20Documents/Forms/AllItems.aspx")
{
switch (ConfigurationManager.AppSettings["Browser"].ToLower())
{
case ("ie32"):
InternetExplorerOptions IEOption32 = new InternetExplorerOptions();
IEOption32.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
IEOption32.RequireWindowFocus = true;
webDriver = new InternetExplorerDriver(System.IO.Directory.GetCurrentDirectory().Replace(@"\bin\Debug", "") + @"\Drivers\IE32\", IEOption32);
webDriver = new InternetExplorerDriver(System.IO.Directory.GetCurrentDirectory().Replace(@"\bin\Debug", "") + @"\Drivers\IE32\", IEOption32, TimeSpan.FromSeconds(30));
break;
case ("ie64"):
InternetExplorerOptions IEOption64 = new InternetExplorerOptions();
IEOption64.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
IEOption64.RequireWindowFocus = true;
webDriver = new InternetExplorerDriver(System.IO.Directory.GetCurrentDirectory().Replace(@"\bin\Debug", "") + @"\Drivers\IE64\", IEOption64);
webDriver = new InternetExplorerDriver(System.IO.Directory.GetCurrentDirectory().Replace(@"\bin\Debug", "") + @"\Drivers\IE64\", IEOption64, TimeSpan.FromSeconds(60));
break;
default:
break;
Expand All @@ -65,9 +76,10 @@ public static void Initialize(string postfix = "")
{
address = BaseAddress + "/" + postfix;
}
webDriver.Manage().Window.Maximize();
webDriver.Navigate().GoToUrl(address);
checkAlert();
signIncheckAlert();

}

/// <summary>
Expand Down Expand Up @@ -136,8 +148,9 @@ public static void Wait(By by)
public static void SetWaitTime(TimeSpan timeSpan)
{
webDriver.Manage().Timeouts().ImplicitlyWait(timeSpan);
webDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(timeSpan.TotalSeconds * 2));
webDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(timeSpan.TotalSeconds * 2));
webDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(timeSpan.TotalSeconds * 3));
webDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(timeSpan.TotalSeconds * 3));

}

/// <summary>
Expand Down Expand Up @@ -191,7 +204,8 @@ internal static void Click(IWebElement element)
{
try
{
(webDriver as IJavaScriptExecutor).ExecuteScript("arguments[0].click();", element);
OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(webDriver);
action.Click(element).Perform();
}
catch (WebDriverException)
{
Expand All @@ -207,14 +221,28 @@ internal static void RClick(IWebElement element)
{
try
{
(webDriver as IJavaScriptExecutor).ExecuteScript("arguments[0].fireEvent('oncontextmenu');", element);
OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(webDriver);
action.ContextClick(element).Perform();
}
catch (WebDriverException)
{
Wait(TimeSpan.FromSeconds(15));
}
}


internal static void MovetoElement(IWebElement element)
{
try
{
OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(webDriver);
action.MoveToElement(element).Perform();
}
catch (WebDriverException)
{
Wait(TimeSpan.FromSeconds(15));
}
}
/// <summary>
/// Find an iframe element
/// </summary>
Expand Down Expand Up @@ -269,7 +297,9 @@ public static void checkAlert()
{
throw new Exception(e.Message);
}

}


/// <summary>
/// Check a Alert with sign in
Expand All @@ -278,18 +308,14 @@ public static void signIncheckAlert()
{
try
{
WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(30));
wait.Until(ExpectedConditions.AlertIsPresent());
IAlert alert = webDriver.SwitchTo().Alert();
string username = ConfigurationManager.AppSettings["UserName"];
string password = ConfigurationManager.AppSettings["Password"];
alert.SetAuthenticationCredentials(username, password);
alert.Accept();
Utility.SigninWindowsSecurity(username, password);
}
catch (Exception e)
{
throw new Exception(e.Message);
}
throw e;
}
}
}
}
Loading

0 comments on commit 75196d8

Please sign in to comment.