Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
6e9016cf
Commit
6e9016cf
authored
Nov 02, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup integration tests
parent
2e0864c4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
42 deletions
+31
-42
setup.ps1
.build/setup.ps1
+1
-1
InterceptionTests.cs
.../Titanium.Web.Proxy.IntegrationTests/InterceptionTests.cs
+20
-22
SslTests.cs
tests/Titanium.Web.Proxy.IntegrationTests/SslTests.cs
+10
-19
No files found.
.build/setup.ps1
View file @
6e9016cf
tests/Titanium.Web.Proxy.IntegrationTests/InterceptionTests.cs
View file @
6e9016cf
...
@@ -15,11 +15,10 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -15,11 +15,10 @@ namespace Titanium.Web.Proxy.IntegrationTests
public
async
Task
Can_Intercept_Post_Requests
()
public
async
Task
Can_Intercept_Post_Requests
()
{
{
string
testUrl
=
"http://interceptthis.com"
;
string
testUrl
=
"http://interceptthis.com"
;
int
proxyPort
=
8086
;
var
proxy
=
new
ProxyTestController
();
proxy
.
StartProxy
(
proxyPort
);
using
(
var
client
=
TestHelper
.
CreateHttpClient
(
testUrl
,
proxyPort
))
using
(
var
proxy
=
new
ProxyTestController
())
{
using
(
var
client
=
TestHelper
.
CreateHttpClient
(
testUrl
,
proxy
.
ListeningPort
))
{
{
var
response
=
await
client
.
PostAsync
(
new
Uri
(
testUrl
),
new
StringContent
(
"hello!"
));
var
response
=
await
client
.
PostAsync
(
new
Uri
(
testUrl
),
new
StringContent
(
"hello!"
));
...
@@ -29,32 +28,23 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -29,32 +28,23 @@ namespace Titanium.Web.Proxy.IntegrationTests
Assert
.
IsTrue
(
body
.
Contains
(
"TitaniumWebProxy-Stopped!!"
));
Assert
.
IsTrue
(
body
.
Contains
(
"TitaniumWebProxy-Stopped!!"
));
}
}
}
}
}
private
class
ProxyTestController
private
class
ProxyTestController
:
IDisposable
{
{
private
readonly
ProxyServer
proxyServer
;
private
readonly
ProxyServer
proxyServer
;
public
int
ListeningPort
=>
proxyServer
.
ProxyEndPoints
[
0
].
Port
;
public
ProxyTestController
()
public
ProxyTestController
()
{
{
proxyServer
=
new
ProxyServer
();
proxyServer
=
new
ProxyServer
();
proxyServer
.
CertificateManager
.
RootCertificateName
=
"root-certificate-for-integration-test.pfx"
;
proxyServer
.
CertificateManager
.
RootCertificateName
=
"root-certificate-for-integration-test.pfx"
;
}
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
0
,
true
);
public
void
StartProxy
(
int
proxyPort
)
{
proxyServer
.
BeforeRequest
+=
OnRequest
;
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
proxyPort
,
true
);
proxyServer
.
AddEndPoint
(
explicitEndPoint
);
proxyServer
.
AddEndPoint
(
explicitEndPoint
);
proxyServer
.
BeforeRequest
+=
OnRequest
;
proxyServer
.
Start
();
proxyServer
.
Start
();
}
}
public
void
Stop
()
{
proxyServer
.
BeforeRequest
-=
OnRequest
;
proxyServer
.
Stop
();
proxyServer
.
Dispose
();
}
public
async
Task
OnRequest
(
object
sender
,
SessionEventArgs
e
)
public
async
Task
OnRequest
(
object
sender
,
SessionEventArgs
e
)
{
{
if
(
e
.
WebSession
.
Request
.
Url
.
Contains
(
"interceptthis.com"
))
if
(
e
.
WebSession
.
Request
.
Url
.
Contains
(
"interceptthis.com"
))
...
@@ -70,6 +60,14 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -70,6 +60,14 @@ namespace Titanium.Web.Proxy.IntegrationTests
await
Task
.
FromResult
(
0
);
await
Task
.
FromResult
(
0
);
}
}
public
void
Dispose
()
{
proxyServer
.
BeforeRequest
-=
OnRequest
;
proxyServer
.
Stop
();
proxyServer
.
Dispose
();
}
}
}
}
}
}
}
\ No newline at end of file
tests/Titanium.Web.Proxy.IntegrationTests/SslTests.cs
View file @
6e9016cf
using
System
;
using
System
;
using
System.Net
;
using
System.Net
;
using
System.Net.Http
;
using
System.Net.Security
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Titanium.Web.Proxy.EventArguments
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
namespace
Titanium.Web.Proxy.IntegrationTests
namespace
Titanium.Web.Proxy.IntegrationTests
...
@@ -16,41 +13,35 @@ namespace Titanium.Web.Proxy.IntegrationTests
...
@@ -16,41 +13,35 @@ namespace Titanium.Web.Proxy.IntegrationTests
public
async
Task
TestSsl
()
public
async
Task
TestSsl
()
{
{
string
testUrl
=
"https://google.com"
;
string
testUrl
=
"https://google.com"
;
int
proxyPort
=
8086
;
using
(
var
proxy
=
new
ProxyTestController
())
var
proxy
=
new
ProxyTestController
();
{
proxy
.
StartProxy
(
proxyPort
);
using
(
var
client
=
TestHelper
.
CreateHttpClient
(
testUrl
,
proxy
.
ListeningPort
))
using
(
var
client
=
TestHelper
.
CreateHttpClient
(
testUrl
,
proxyPort
))
{
{
var
response
=
await
client
.
GetAsync
(
new
Uri
(
testUrl
));
var
response
=
await
client
.
GetAsync
(
new
Uri
(
testUrl
));
Assert
.
IsNotNull
(
response
);
Assert
.
IsNotNull
(
response
);
}
}
}
}
}
private
class
ProxyTestController
:
IDisposable
private
class
ProxyTestController
{
{
private
readonly
ProxyServer
proxyServer
;
private
readonly
ProxyServer
proxyServer
;
public
int
ListeningPort
=>
proxyServer
.
ProxyEndPoints
[
0
].
Port
;
public
ProxyTestController
()
public
ProxyTestController
()
{
{
proxyServer
=
new
ProxyServer
();
proxyServer
=
new
ProxyServer
();
proxyServer
.
CertificateManager
.
RootCertificateName
=
"root-certificate-for-integration-test.pfx"
;
proxyServer
.
CertificateManager
.
RootCertificateName
=
"root-certificate-for-integration-test.pfx"
;
}
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
0
,
true
);
public
void
StartProxy
(
int
proxyPort
)
{
var
explicitEndPoint
=
new
ExplicitProxyEndPoint
(
IPAddress
.
Any
,
proxyPort
,
true
);
proxyServer
.
AddEndPoint
(
explicitEndPoint
);
proxyServer
.
AddEndPoint
(
explicitEndPoint
);
proxyServer
.
Start
();
proxyServer
.
Start
();
}
}
public
void
Stop
()
public
void
Dispose
()
{
{
proxyServer
.
Stop
();
proxyServer
.
Stop
();
proxyServer
.
Dispose
();
proxyServer
.
Dispose
();
}
}
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment