Skip to content

Commit 498137c

Browse files
committed
Finishing analyze tests
1 parent 9c457fb commit 498137c

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

SSLLWrapper.Tests/AnalyzeTests.cs

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static void Setup(TestContext testContext)
2020
TestHost = "https://www.ashleypoole.co.uk";
2121
var webResponseModel = new WebResponseModel()
2222
{
23-
Payloay = "{\"host\":\"www.ashleypoole.co.uk\",\"port\":443,\"protocol\":\"HTTPS\",\"isPublic\":true,\"status\":\"READY\",\"" +
23+
Payloay = "{\"host\":\"https://www.ashleypoole.co.uk\",\"port\":443,\"protocol\":\"HTTPS\",\"isPublic\":true,\"status\":\"READY\",\"" +
2424
"startTime\":1422115006431,\"testTime\":1422115131804,\"engineVersion\":\"1.12.8\",\"criteriaVersion\":\"2009i\",\"" +
2525
"endpoints\":[{\"ipAddress\":\"104.28.6.2\",\"statusMessage\":\"Ready\",\"grade\":\"A\",\"hasWarnings\":false,\"" +
2626
"isExceptional\":false,\"progress\":100,\"duration\":64286,\"eta\":2393,\"delegation\":3},{\"ipAddress\":\"104.28.7.2\"" +
@@ -54,7 +54,7 @@ public static void Setup(TestContext testContext)
5454
TestHost = "https://www.ashleypoole.co.uk";
5555
var webResponseModel = new WebResponseModel()
5656
{
57-
Payloay = "{\"host\":\"www.ashleypoole.co.uk\",\"port\":443,\"protocol\":\"HTTP\",\"isPublic\":false,\"status\":\"DNS\"" +
57+
Payloay = "{\"host\":\"https://www.ashleypoole.co.uk\",\"port\":443,\"protocol\":\"HTTP\",\"isPublic\":false,\"status\":\"DNS\"" +
5858
",\"statusMessage\":\"Resolving domain names\",\"startTime\":1422475200798,\"engineVersion\":\"1.12.8\"," +
5959
"\"criteriaVersion\":\"2009i\"}",
6060
StatusCode = 200,
@@ -85,14 +85,14 @@ public static void Setup(TestContext testContext)
8585
TestHost = "https://www.ashleypoole.co.uk";
8686
var webResponseModel = new WebResponseModel()
8787
{
88-
Payloay = "{\"host\":\"www.ashleypoole.co.uk\",\"port\":443,\"protocol\":\"HTTP\",\"isPublic\":false,\"" +
88+
Payloay = "{\"host\":\"https://www.ashleypoole.co.uk\",\"port\":443,\"protocol\":\"HTTP\",\"isPublic\":true,\"" +
8989
"status\":\"IN_PROGRESS\",\"startTime\":1422479488403,\"engineVersion\":\"1.12.8\",\"criteriaVersion\":\"2009i\"" +
9090
",\"endpoints\":[{\"ipAddress\":\"104.28.6.2\",\"statusMessage\":\"In progress\",\"statusDetails\":\"TESTING_HTTPS\"" +
9191
",\"statusDetailsMessage\":\"Sending one complete HTTPS request\",\"progress\":-1,\"eta\":-1,\"delegation\":3}," +
9292
"{\"ipAddress\":\"104.28.7.2\",\"statusMessage\":\"Pending\",\"progress\":-1,\"eta\":-1,\"delegation\":3}]}",
9393
StatusCode = 200,
9494
StatusDescription = "Ok",
95-
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/analyze?host=" + TestHost + "&publish=on&clearCache=on&all=done")
95+
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/analyze?host=" + TestHost + "&publish=on&all=done")
9696
};
9797

9898
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
@@ -116,14 +116,14 @@ public class when_a_invalid_request_is_made_with_all_the_inputs_and_the_scan_is_
116116
public static void Setup(TestContext testContext)
117117
{
118118
var mockedApiProvider = new Mock<IApiProvider>();
119-
TestHost = "https://www.ashleypoole.co.uk";
119+
TestHost = "https://www2.ashleypoole.co.uk";
120120
var webResponseModel = new WebResponseModel()
121121
{
122-
Payloay = "{\"host\":\"www2.ashleypoole.co.uk\",\"port\":443,\"protocol\":\"HTTP\",\"isPublic\":false,\"status\":\"ERROR\"," +
122+
Payloay = "{\"host\":\"https://www2.ashleypoole.co.uk\",\"port\":443,\"protocol\":\"HTTP\",\"isPublic\":false,\"status\":\"ERROR\"," +
123123
"\"statusMessage\":\"Unable to resolve domain name\",\"startTime\":1422478797953,\"testTime\":1422478798017," +
124124
"\"engineVersion\":\"1.12.8\",\"criteriaVersion\":\"2009i\",\"cacheExpiryTime\":1422478858017}",
125-
StatusCode = 500,
126-
StatusDescription = "Bad Request",
125+
StatusCode = 200,
126+
StatusDescription = "Ok",
127127
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/analyze?host=" + TestHost)
128128
};
129129

@@ -135,14 +135,38 @@ public static void Setup(TestContext testContext)
135135
}
136136
}
137137

138+
[TestClass]
139+
public class when_a_invalid_request_is_made_with_both_clearCache_and_fromCache : NegativeTests
140+
{
141+
[ClassInitialize]
142+
public static void Setup(TestContext testContext)
143+
{
144+
var mockedApiProvider = new Mock<IApiProvider>();
145+
TestHost = "https://www.ashleypoole.co.uk";
146+
var webResponseModel = new WebResponseModel()
147+
{
148+
Payloay = "{\"errors\":[{\"message\":\"Parameters \u0027fromCache\u0027 and \u0027clearCache\u0027 cannot be used at the same time\"}]}",
149+
StatusCode = 400,
150+
StatusDescription = "Ok",
151+
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/analyze?host=" + TestHost + "&clearCache=on&fromCache=on&all=done")
152+
};
153+
154+
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
155+
156+
var ssllService = new SSLLService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
157+
Response = ssllService.Analyze(TestHost, SSLLService.Publish.On, SSLLService.ClearCache.On,
158+
SSLLService.FromCache.Ignore, SSLLService.All.Done);
159+
}
160+
}
161+
138162
public abstract class PositiveTests : GenericPositiveTests<Analyze>
139163
{
140164
public static string TestHost;
141165

142166
[TestMethod]
143167
public void then_the_host_property_should_match_the_requested_hostname()
144168
{
145-
Response.host.Should().Be(TestHost.Substring(8));
169+
Response.host.Should().Be(TestHost);
146170
}
147171

148172
[TestMethod]

SSLLWrapper.Tests/GenericNegativeTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ public void then_the_HasErrorOccurred_should_be_true()
1919
{
2020
Response.HasErrorOccurred.Should().BeTrue();
2121
}
22+
23+
[TestMethod]
24+
public void then_the_status_code_should_not_be_ok_200()
25+
{
26+
Response.Header.statusCode.Should().NotBe(200);
27+
}
2228
}
2329
}

0 commit comments

Comments
 (0)