Skip to content

Commit 53c7f22

Browse files
committed
Merge pull request #8 from AshleyPoole/api-v2.1
v1.0.7 Release
2 parents 78af3bb + 09265a2 commit 53c7f22

File tree

10 files changed

+69
-57
lines changed

10 files changed

+69
-57
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ public enum All
189189
}
190190
```
191191

192+
### Development ToDo List
193+
- Increase testing around ignoreMismatch parameter on Analyze call
194+
- Increase testing around maxAge parameter on Analyze call
195+
- Increase integration tests around positive and negative outcomes
196+
197+
192198
### Author
193199
Ashley Poole - www.ashleypoole.co.uk.
194200

SSLLWrapper/Models/Response/BaseSubModels/Wrapper.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

SSLLabsApiWrapper.Tests/AnalyzeTests.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public static void Setup(TestContext testContext)
2828
":61046,\"eta\":2393,\"delegation\":3}]}",
2929
StatusCode = 200,
3030
StatusDescription = "Ok",
31-
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/analyze?host=" + TestHost)
31+
Url = ("https://api.ssllabs.com/api/v2/analyze?host=" + TestHost)
3232
};
3333

3434
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
3535

36-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
36+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
3737
Response = ssllService.Analyze(TestHost);
3838
}
3939

@@ -59,12 +59,12 @@ public static void Setup(TestContext testContext)
5959
"\"criteriaVersion\":\"2009i\"}",
6060
StatusCode = 200,
6161
StatusDescription = "Ok",
62-
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/analyze?host=" + TestHost)
62+
Url = ("https://api.ssllabs.com/api/v2/analyze?host=" + TestHost)
6363
};
6464

6565
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
6666

67-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
67+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
6868
Response = ssllService.Analyze(TestHost);
6969
}
7070

@@ -92,14 +92,14 @@ public static void Setup(TestContext testContext)
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&all=done")
95+
Url = ("https://api.ssllabs.com/api/v2/analyze?host=" + TestHost + "&publish=on&all=done")
9696
};
9797

9898
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
9999

100-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
101-
Response = ssllService.Analyze(TestHost, SSLLabsApiService.Publish.On, SSLLabsApiService.ClearCache.On,
102-
SSLLabsApiService.FromCache.Ignore, SSLLabsApiService.All.Done);
100+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
101+
Response = ssllService.Analyze(TestHost, SSLLabsApiService.Publish.On, SSLLabsApiService.startNew.On,
102+
SSLLabsApiService.FromCache.Ignore, null, SSLLabsApiService.All.Done, SSLLabsApiService.ignoreMismatch.Off);
103103
}
104104

105105
[TestMethod]
@@ -124,25 +124,25 @@ public static void Setup(TestContext testContext)
124124
"\"engineVersion\":\"1.12.8\",\"criteriaVersion\":\"2009i\",\"cacheExpiryTime\":1422478858017}",
125125
StatusCode = 200,
126126
StatusDescription = "Ok",
127-
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/analyze?host=" + TestHost)
127+
Url = ("https://api.ssllabs.com/api/v2/analyze?host=" + TestHost)
128128
};
129129

130130
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
131131

132-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
133-
Response = ssllService.Analyze(TestHost, SSLLabsApiService.Publish.On, SSLLabsApiService.ClearCache.On,
134-
SSLLabsApiService.FromCache.Ignore, SSLLabsApiService.All.Done);
132+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
133+
Response = ssllService.Analyze(TestHost, SSLLabsApiService.Publish.On, SSLLabsApiService.startNew.On,
134+
SSLLabsApiService.FromCache.Ignore, null, SSLLabsApiService.All.Done, SSLLabsApiService.ignoreMismatch.Off);
135135
}
136136

137137
[TestMethod]
138-
public void then_the_status_code_should_be_valid_for_response()
138+
public new void then_the_status_code_should_be_valid_for_response()
139139
{
140140
Response.Header.statusCode.Should().Be(200);
141141
}
142142
}
143143

144144
[TestClass]
145-
public class when_a_invalid_request_is_made_with_both_clearCache_and_fromCache : NegativeTests
145+
public class when_a_invalid_request_is_made_with_both_startNew_and_fromCache : NegativeTests
146146
{
147147
[ClassInitialize]
148148
public static void Setup(TestContext testContext)
@@ -151,17 +151,17 @@ public static void Setup(TestContext testContext)
151151
TestHost = "https://www.ashleypoole.co.uk";
152152
var webResponseModel = new WebResponseModel()
153153
{
154-
Payloay = "{\"errors\":[{\"message\":\"Parameters \u0027fromCache\u0027 and \u0027clearCache\u0027 cannot be used at the same time\"}]}",
154+
Payloay = "{\"errors\":[{\"message\":\"Parameters \u0027fromCache\u0027 and \u0027startNew\u0027 cannot be used at the same time\"}]}",
155155
StatusCode = 400,
156156
StatusDescription = "Ok",
157-
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/analyze?host=" + TestHost + "&clearCache=on&fromCache=on&all=done")
157+
Url = ("https://api.ssllabs.com/api/v2/analyze?host=" + TestHost + "&startNew=on&fromCache=on&all=done")
158158
};
159159

160160
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
161161

162-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
163-
Response = ssllService.Analyze(TestHost, SSLLabsApiService.Publish.On, SSLLabsApiService.ClearCache.On,
164-
SSLLabsApiService.FromCache.Ignore, SSLLabsApiService.All.Done);
162+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
163+
Response = ssllService.Analyze(TestHost, SSLLabsApiService.Publish.On, SSLLabsApiService.startNew.On,
164+
SSLLabsApiService.FromCache.Ignore, null, SSLLabsApiService.All.Done, SSLLabsApiService.ignoreMismatch.Off);
165165
}
166166
}
167167

@@ -174,7 +174,7 @@ public static void Setup(TestContext testContext)
174174
var mockedApiProvider = new Mock<IApiProvider>();
175175
TestHost = "www.ashleypoole.somereallybadurl";
176176

177-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
177+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
178178
Response = ssllService.Analyze(TestHost);
179179
}
180180

SSLLabsApiWrapper.Tests/GetEndpointDetailsTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ public static void Setup(TestContext testContext)
120120
",\"heartbleed\":false,\"heartbeat\":false,\"openSslCcs\":1,\"poodleTls\":1}}",
121121
StatusCode = 200,
122122
StatusDescription = "Ok",
123-
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/getEndpoint?host=" + TestHost + "%s=" + TestIP)
123+
Url = ("https://api.ssllabs.com/api/v2/getEndpoint?host=" + TestHost + "%s=" + TestIP)
124124
};
125125

126126
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
127127

128-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
128+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
129129
Response = ssllService.GetEndpointData(TestHost, TestIP);
130130
}
131131

@@ -174,12 +174,12 @@ public static void Setup(TestContext testContext)
174174
Payloay = "{\"errors\":[{\"message\":\"Endpoint not found\"}]}",
175175
StatusCode = 400,
176176
StatusDescription = "Bad Request",
177-
Url = ("https://api.dev.ssllabs.com/api/fa78d5a4/getEndpointData?host=" + TestHost + "s=" + TestIP)
177+
Url = ("https://api.ssllabs.com/api/v2/getEndpointData?host=" + TestHost + "s=" + TestIP)
178178
};
179179

180180
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
181181

182-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
182+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
183183
Response = ssllService.GetEndpointData(TestHost, TestIP);
184184
}
185185

@@ -197,7 +197,7 @@ public class when_a_invalid_request_is_made_with_malformed_url_hostname : Negati
197197
public static void Setup(TestContext testContext)
198198
{
199199
var mockedApiProvider = new Mock<IApiProvider>();
200-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
200+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
201201

202202
TestHost = "www.ashleypoole.somereallybadurl";
203203
TestIP = "111.111.111.111";

SSLLabsApiWrapper.Tests/InfoTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public static void Setup(TestContext testContext)
2121
Payloay = "{\"engineVersion\":\"1.11.4\",\"criteriaVersion\":\"2009i\",\"clientMaxAssessments\":5,\"notice\":\"Some notice goes here\"}",
2222
StatusCode = 200,
2323
StatusDescription = "Ok",
24-
Url = "https://api.dev.ssllabs.com/api/fa78d5a4/info"
24+
Url = "https://api.ssllabs.com/api/v2/info"
2525
};
2626

2727
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
2828

29-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
29+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
3030
Response = ssllService.Info();
3131
}
3232

@@ -61,12 +61,12 @@ public static void Setup(TestContext testContext)
6161
Payloay = null,
6262
StatusCode = 0,
6363
StatusDescription = null,
64-
Url = "https://api.dev.ssllabs.com/api/fa78d5a4/info"
64+
Url = "https://api.ssllabs.com/api/v2/info"
6565
};
6666

6767
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
6868

69-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
69+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
7070
Response = ssllService.Info();
7171
}
7272

SSLLabsApiWrapper.Tests/StatusCodesTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public static void Setup(TestContext testContext)
4141
"Testing Long Handshake (might take a while)\"}}",
4242
StatusCode = 200,
4343
StatusDescription = "Ok",
44-
Url = "https://api.dev.ssllabs.com/api/fa78d5a4/info"
44+
Url = "https://api.ssllabs.com/api/v2/info"
4545
};
4646

4747
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
4848

49-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
49+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
5050
Response = ssllService.GetStatusCodes();
5151
}
5252

@@ -69,12 +69,12 @@ public static void Setup(TestContext testContext)
6969
Payloay = null,
7070
StatusCode = 0,
7171
StatusDescription = null,
72-
Url = "https://api.dev.ssllabs.com/api/fa78d5a4/info"
72+
Url = "https://api.ssllabs.com/api/v2/info"
7373
};
7474

7575
mockedApiProvider.Setup(x => x.MakeGetRequest(It.IsAny<RequestModel>())).Returns(webResponseModel);
7676

77-
var ssllService = new SSLLabsApiService("https://api.dev.ssllabs.com/api/fa78d5a4/", mockedApiProvider.Object);
77+
var ssllService = new SSLLabsApiService("https://api.ssllabs.com/api/v2/", mockedApiProvider.Object);
7878
Response = ssllService.GetStatusCodes();
7979
}
8080

SSLLabsApiWrapper/Domain/RequestModelFactory.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ public RequestModel NewInfoRequestModel(string apiBaseUrl, string action)
99
return new RequestModel() {ApiBaseUrl = apiBaseUrl, Action = action};
1010
}
1111

12-
public RequestModel NewAnalyzeRequestModel(string apiBaseUrl, string action, string host, string publish, string clearCache,
13-
string fromCache, string all)
12+
public RequestModel NewAnalyzeRequestModel(string apiBaseUrl, string action, string host, string publish, string startNew,
13+
string fromCache, int? maxHours, string all, string ignoreMismatch)
1414
{
1515
var requestModel = new RequestModel() { ApiBaseUrl = apiBaseUrl, Action = action};
1616

1717
requestModel.Parameters.Add("host", host);
1818
requestModel.Parameters.Add("publish", publish);
1919
requestModel.Parameters.Add("all", all);
2020

21-
if (clearCache != "ignore") { requestModel.Parameters.Add("clearCache", clearCache); }
21+
if (startNew != "ignore") { requestModel.Parameters.Add("startNew", startNew); }
2222
if (fromCache != "ignore") { requestModel.Parameters.Add("fromCache", fromCache); }
23+
if (maxHours != null) { requestModel.Parameters.Add("maxHours", maxHours.ToString()); }
24+
if (ignoreMismatch != "off") { requestModel.Parameters.Add("ignoreMismatch", ignoreMismatch); }
2325

2426
return requestModel;
2527
}

SSLLabsApiWrapper/Models/Response/EndpointSubModels/Cert2.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ public class Cert2
44
{
55
public string subject { get; set; }
66
public string label { get; set; }
7+
public object notBefore { get; set; }
8+
public object notAfter { get; set; }
79
public string issuerSubject { get; set; }
810
public string issuerLabel { get; set; }
11+
public string sigAlg { get; set; }
12+
public string keyAlg { get; set; }
13+
public int keySize { get; set; }
14+
public int keyStrength { get; set; }
915
public string raw { get; set; }
1016
}
1117
}

SSLLabsApiWrapper/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.6")]
36-
[assembly: AssemblyFileVersion("1.0.6")]
35+
[assembly: AssemblyVersion("1.0.7")]
36+
[assembly: AssemblyFileVersion("1.0.7")]
3737
[assembly: InternalsVisibleTo("SSLLabsApiWrapper.Tests"), InternalsVisibleTo("DynamicProxyGenAssembly2")]

SSLLabsApiWrapper/SSLLabsApiService.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ public enum Publish
2424
Off
2525
}
2626

27-
public enum ClearCache
27+
public enum startNew
2828
{
2929
On,
30-
Off,
3130
Ignore
3231
}
3332

@@ -44,6 +43,12 @@ public enum All
4443
Done
4544
}
4645

46+
public enum ignoreMismatch
47+
{
48+
On,
49+
Off
50+
}
51+
4752
public SSLLabsApiService(string apiUrl) : this(apiUrl, new SSLLabsApi())
4853
{
4954
}
@@ -89,10 +94,10 @@ public Info Info()
8994
public Analyze Analyze(string host)
9095
{
9196
// overloaded method to provide a default set of options
92-
return Analyze(host, Publish.Off, ClearCache.On, FromCache.Ignore, All.On);
97+
return Analyze(host, Publish.Off, startNew.On, FromCache.Ignore, null, All.On, ignoreMismatch.Off);
9398
}
9499

95-
public Analyze Analyze(string host, Publish publish, ClearCache clearCache, FromCache fromCache, All all)
100+
public Analyze Analyze(string host, Publish publish, startNew startNew, FromCache fromCache, int? maxHours, All all, ignoreMismatch ignoreMismatch)
96101
{
97102
var analyzeModel = new Analyze();
98103

@@ -105,8 +110,8 @@ public Analyze Analyze(string host, Publish publish, ClearCache clearCache, From
105110
}
106111

107112
// Building request model
108-
var requestModel = _requestModelFactory.NewAnalyzeRequestModel(ApiUrl, "analyze", host, publish.ToString().ToLower(), clearCache.ToString().ToLower(),
109-
fromCache.ToString().ToLower(), all.ToString().ToLower());
113+
var requestModel = _requestModelFactory.NewAnalyzeRequestModel(ApiUrl, "analyze", host, publish.ToString().ToLower(), startNew.ToString().ToLower(),
114+
fromCache.ToString().ToLower(), maxHours, all.ToString().ToLower(), ignoreMismatch.ToString().ToLower());
110115

111116
try
112117
{
@@ -132,25 +137,26 @@ public Analyze AutomaticAnalyze(string host)
132137

133138
public Analyze AutomaticAnalyze(string host, int maxWaitInterval, int sleepInterval)
134139
{
135-
return AutomaticAnalyze(host, Publish.Off, ClearCache.On, FromCache.Ignore, All.On, maxWaitInterval, sleepInterval);
140+
return AutomaticAnalyze(host, Publish.Off, startNew.On, FromCache.Ignore, null, All.On, ignoreMismatch.Off, maxWaitInterval, sleepInterval);
136141
}
137142

138-
public Analyze AutomaticAnalyze(string host, Publish publish, ClearCache clearCache, FromCache fromCache, All all, int maxWaitInterval, int sleepInterval)
143+
public Analyze AutomaticAnalyze(string host, Publish publish, startNew startNew, FromCache fromCache, int? maxHours, All all, ignoreMismatch ignoreMismatch,
144+
int maxWaitInterval, int sleepInterval)
139145
{
140146
var startTime = DateTime.Now;
141147
var sleepIntervalMilliseconds = sleepInterval * 1000;
142148
var apiPassCount = 1;
143-
var analyzeModel = Analyze(host, publish, clearCache, fromCache, all);
149+
var analyzeModel = Analyze(host, publish, startNew, fromCache, maxHours, all, ignoreMismatch);
144150

145151
// Ignoring cache settings after first request to prevent loop
146-
clearCache = ClearCache.Ignore;
152+
startNew = startNew.Ignore;
147153

148154
// Shouldn't have to check status header as HasErrorOccurred should be enough
149155
while (analyzeModel.HasErrorOccurred == false && analyzeModel.status != "READY" && (DateTime.Now - startTime).TotalSeconds < maxWaitInterval)
150156
{
151157
Thread.Sleep(sleepIntervalMilliseconds);
152158
apiPassCount ++;
153-
analyzeModel = Analyze(host, publish, clearCache, fromCache, all);
159+
analyzeModel = Analyze(host, publish, startNew, fromCache, null, all, ignoreMismatch);
154160
}
155161

156162
analyzeModel.Wrapper.ApiPassCount = apiPassCount;

0 commit comments

Comments
 (0)