-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSecuritytestsBase.cs
More file actions
54 lines (48 loc) · 1.64 KB
/
Copy pathSecuritytestsBase.cs
File metadata and controls
54 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Threading;
using NUnit.Framework;
using NZap;
using OpenQA.Selenium;
using Securitytesting.Enums;
using Securitytesting.Factories;
using Securitytesting.Helpers;
namespace Securitytesting
{
public class SecuritytestsBase
{
protected IWebDriver Driver;
protected IZapClient Client;
protected string Target;
protected string ApiKey;
[OneTimeSetUp]
public void OneTimeSetUp()
{
var proxy = AppSettingsHelper.ReadString(AppSettings.Proxy);
var proxyPort = AppSettingsHelper.ReadInt(AppSettings.ProxyPort);
Target = AppSettingsHelper.ReadString(AppSettings.Target);
ApiKey = AppSettingsHelper.ReadString(AppSettings.ApiKey);
Client = new ZapClient(proxy, proxyPort);
Client.Core.DeleteAllAlerts(ApiKey);
Driver = DriverFactory.CreateWebDriver();
}
[OneTimeTearDown]
public void OneTimeTearDown()
{
Thread.Sleep(5000);
var reportResponse = Client.Core.GetHtmlReport(ApiKey);
FileWriterHelper.WriteReport(AppSettingsHelper.ReadString(AppSettings.ReportPath), reportResponse.ReportData);
Client.Core.DeleteAllAlerts(ApiKey);
}
[SetUp]
public void SetUp()
{
Client.HttpSessions.CreateEmptySession(ApiKey, Target);
}
[TearDown]
public void TearDown()
{
var activeSession = Client.HttpSessions.GetActiveSession(Target);
Client.HttpSessions.RemoveSession(ApiKey, Target, activeSession.Value);
Driver.Dispose();
}
}
}