Skip to content

Commit 42ac7f8

Browse files
committed
cosmetic changes
1 parent 8267242 commit 42ac7f8

File tree

4 files changed

+70
-69
lines changed

4 files changed

+70
-69
lines changed

SecureHttpClient.Test/CertificatePinnerTest.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ namespace SecureHttpClient.Test
77
{
88
public class CertificatePinnerTest : TestBase, IClassFixture<TestFixture>
99
{
10-
private const string Hostname = @"www.howsmyssl.com";
11-
private const string Wildcard1 = @"*.howsmyssl.com";
12-
private const string Wildcard2 = @"**.howsmyssl.com";
13-
private const string InvalidPattern = @"*.*.howsmyssl.com";
14-
private const string Page = @"https://www.howsmyssl.com/a/check";
15-
private static readonly string[] PinsOk = { @"sha256/kXo1ykvfYulcwtgnY1/sOcAF+b8pHUNGzYsXaNADPpE=" };
16-
private static readonly string[] PinsKo = { @"sha256/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=" };
17-
18-
private const string Hostname2 = @"github.com";
19-
private const string Page2 = @"https://github.com";
20-
private static readonly string[] Pins2Ok = { @"sha256/e4wu8h9eLNeNUg6cVb5gGWM0PsiM9M3i3E32qKOkBwY=" };
21-
private static readonly string[] Pins2Ko = { @"sha256/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy=" };
22-
23-
private const string Hostname3 = @"ecc256.badssl.com";
24-
private const string Page3 = @"https://ecc256.badssl.com/";
25-
private static readonly string[] Pins3Ok = { @"sha256/g67mY/cD6RvINsd1RSeQf9Ns4PIpUKUd+pw8XpUOf9E=" };
26-
private static readonly string[] Pins3Ko = { @"sha256/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz=" };
10+
private const string Hostname = "www.howsmyssl.com";
11+
private const string Wildcard1 = "*.howsmyssl.com";
12+
private const string Wildcard2 = "**.howsmyssl.com";
13+
private const string InvalidPattern = "*.*.howsmyssl.com";
14+
private const string Page = "https://www.howsmyssl.com/a/check";
15+
private static readonly string[] PinsOk = ["sha256/kXo1ykvfYulcwtgnY1/sOcAF+b8pHUNGzYsXaNADPpE="];
16+
private static readonly string[] PinsKo = ["sha256/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx="];
17+
18+
private const string Hostname2 = "github.com";
19+
private const string Page2 = "https://github.com";
20+
private static readonly string[] Pins2Ok = ["sha256/e4wu8h9eLNeNUg6cVb5gGWM0PsiM9M3i3E32qKOkBwY="];
21+
private static readonly string[] Pins2Ko = ["sha256/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy="];
22+
23+
private const string Hostname3 = "ecc256.badssl.com";
24+
private const string Page3 = "https://ecc256.badssl.com/";
25+
private static readonly string[] Pins3Ok = ["sha256/g67mY/cD6RvINsd1RSeQf9Ns4PIpUKUd+pw8XpUOf9E="];
26+
private static readonly string[] Pins3Ko = ["sha256/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz="];
2727

2828
public CertificatePinnerTest(TestFixture testFixture) : base(testFixture)
2929
{

SecureHttpClient.Test/Helpers/ResourceHelper.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ namespace SecureHttpClient.Test.Helpers
77
{
88
public static class ResourceHelper
99
{
10-
public static Task<string> GetStringAsync(string resource)
10+
public static async Task<string> GetStringAsync(string resource)
1111
{
12-
using var resourceStream = GetResourceStream(resource);
12+
await using var resourceStream = GetResourceStream(resource);
1313
using var reader = new StreamReader(resourceStream);
14-
return reader.ReadToEndAsync();
14+
var res = await reader.ReadToEndAsync();
15+
return res;
1516
}
1617

1718
public static async Task<byte[]> GetBytesAsync(string resource)
1819
{
19-
using var resourceStream = GetResourceStream(resource);
20+
await using var resourceStream = GetResourceStream(resource);
2021
using var memoryStream = new MemoryStream();
2122
await resourceStream.CopyToAsync(memoryStream);
2223
return memoryStream.ToArray();

SecureHttpClient.Test/HttpTest.cs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public HttpTest(TestFixture testFixture) : base(testFixture)
2121
[Fact]
2222
public async Task HttpTest_Get()
2323
{
24-
const string page = @"https://httpbingo.org/get";
24+
const string page = "https://httpbingo.org/get";
2525
var result = await GetAsync(page).ReceiveString();
2626
var json = JsonDocument.Parse(result);
2727
var url = json.RootElement.GetProperty("url").GetString();
@@ -31,7 +31,7 @@ public async Task HttpTest_Get()
3131
[Fact]
3232
public async Task HttpTest_Compression_Gzip_WithoutRequestHeader()
3333
{
34-
const string page = @"https://httpbingo.org/gzip";
34+
const string page = "https://httpbingo.org/gzip";
3535
var result = await GetAsync(page).ReceiveString();
3636
var json = JsonDocument.Parse(result);
3737
var url = json.RootElement.GetProperty("gzipped").GetBoolean();
@@ -43,7 +43,7 @@ public async Task HttpTest_Compression_Gzip_WithoutRequestHeader()
4343
[Fact]
4444
public async Task HttpTest_Compression_Gzip_WithRequestHeader()
4545
{
46-
const string page = @"https://httpbingo.org/gzip";
46+
const string page = "https://httpbingo.org/gzip";
4747
var req = new HttpRequestMessage(HttpMethod.Get, page);
4848
req.Headers.Add("Accept-Encoding", "gzip");
4949
var result = await SendAsync(req).ReceiveString();
@@ -57,7 +57,7 @@ public async Task HttpTest_Compression_Gzip_WithRequestHeader()
5757
[Fact]
5858
public async Task HttpTest_Compression_Deflate_WithoutRequestHeader()
5959
{
60-
const string page = @"https://httpbingo.org/deflate"; // has zlib header (RFC 1951)
60+
const string page = "https://httpbingo.org/deflate"; // has zlib header (RFC 1951)
6161
var result = await GetAsync(page).ReceiveString();
6262
var json = JsonDocument.Parse(result);
6363
var url = json.RootElement.GetProperty("deflated").GetBoolean();
@@ -69,7 +69,7 @@ public async Task HttpTest_Compression_Deflate_WithoutRequestHeader()
6969
[Fact]
7070
public async Task HttpTest_Compression_Deflate_WithRequestHeader()
7171
{
72-
const string page = @"https://httpbingo.org/deflate";
72+
const string page = "https://httpbingo.org/deflate";
7373
var req = new HttpRequestMessage(HttpMethod.Get, page);
7474
req.Headers.Add("Accept-Encoding", "deflate");
7575
var result = await SendAsync(req).ReceiveString();
@@ -83,7 +83,7 @@ public async Task HttpTest_Compression_Deflate_WithRequestHeader()
8383
[Fact]
8484
public async Task HttpTest_Compression_Brotli_WithoutRequestHeader()
8585
{
86-
const string page = @"https://httpbin.org/brotli";
86+
const string page = "https://httpbin.org/brotli";
8787
var result = await GetAsync(page).ReceiveString();
8888
var json = JsonDocument.Parse(result);
8989
var url = json.RootElement.GetProperty("brotli").GetBoolean();
@@ -95,7 +95,7 @@ public async Task HttpTest_Compression_Brotli_WithoutRequestHeader()
9595
[Fact]
9696
public async Task HttpTest_Compression_Brotli_WithRequestHeader()
9797
{
98-
const string page = @"https://httpbin.org/brotli";
98+
const string page = "https://httpbin.org/brotli";
9999
var req = new HttpRequestMessage(HttpMethod.Get, page);
100100
req.Headers.Add("Accept-Encoding", "br");
101101
var result = await SendAsync(req).ReceiveString();
@@ -109,7 +109,7 @@ public async Task HttpTest_Compression_Brotli_WithRequestHeader()
109109
[Fact]
110110
public async Task HttpTest_Headers()
111111
{
112-
const string page = @"https://postman-echo.com/get";
112+
const string page = "https://postman-echo.com/get";
113113
var req = new HttpRequestMessage(HttpMethod.Get, page);
114114
req.Headers.Add("header1", "value1");
115115
req.Headers.Add("header2", "value2");
@@ -127,7 +127,7 @@ public async Task HttpTest_HeadersOrder()
127127
{
128128
Skip.If(DeviceInfo.Platform != DevicePlatform.Android, "Only on Android");
129129

130-
const string page = @"https://postman-echo.com/get";
130+
const string page = "https://postman-echo.com/get";
131131
var req = new HttpRequestMessage(HttpMethod.Get, page);
132132
req.Headers.Add("header1", "value1");
133133
req.Headers.Add("header2", "value2");
@@ -146,16 +146,16 @@ public async Task HttpTest_HeadersOrder()
146146
[Fact]
147147
public async Task HttpTest_Utf8()
148148
{
149-
const string page = @"https://httpbingo.org/encoding/utf8";
149+
const string page = "https://httpbingo.org/encoding/utf8";
150150
var result = await GetAsync(page).ReceiveString();
151151
Assert.Contains("∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i)", result);
152152
}
153153

154154
[Fact]
155155
public async Task HttpTest_Redirect()
156156
{
157-
const string page = @"https://httpbingo.org/redirect/5"; // httpbingo replaces httpbin because of issue https://github.com/postmanlabs/httpbin/issues/617
158-
const string final = @"https://httpbingo.org/get";
157+
const string page = "https://httpbingo.org/redirect/5"; // httpbingo replaces httpbin because of issue https://github.com/postmanlabs/httpbin/issues/617
158+
const string final = "https://httpbingo.org/get";
159159

160160
var result = await GetAsync(page).ReceiveString();
161161
var json = JsonDocument.Parse(result);
@@ -172,7 +172,7 @@ public async Task HttpTest_Redirect()
172172
[Fact]
173173
public async Task HttpTest_DoNotFollowRedirects()
174174
{
175-
const string page = @"https://httpbingo.org/redirect/5"; // httpbingo replaces httpbin because of issue https://github.com/postmanlabs/httpbin/issues/617
175+
const string page = "https://httpbingo.org/redirect/5"; // httpbingo replaces httpbin because of issue https://github.com/postmanlabs/httpbin/issues/617
176176
DoNotFollowRedirects();
177177
var response = await GetAsync(page, false);
178178
Assert.Equal(HttpStatusCode.Found, response.StatusCode);
@@ -182,7 +182,7 @@ public async Task HttpTest_DoNotFollowRedirects()
182182
[Fact]
183183
public async Task HttpTest_Delay()
184184
{
185-
const string page = @"https://httpbingo.org/delay/5";
185+
const string page = "https://httpbingo.org/delay/5";
186186
var result = await GetAsync(page).ReceiveString();
187187
var json = JsonDocument.Parse(result);
188188
var url = json.RootElement.GetProperty("url").GetString();
@@ -192,7 +192,7 @@ public async Task HttpTest_Delay()
192192
[Fact]
193193
public async Task HttpTest_Stream()
194194
{
195-
const string page = @"https://httpbingo.org/stream/50";
195+
const string page = "https://httpbingo.org/stream/50";
196196
var result = await GetAsync(page).ReceiveString();
197197
var nbLines = result.Split('\n').Length - 1;
198198
Assert.Equal(50, nbLines);
@@ -201,23 +201,23 @@ public async Task HttpTest_Stream()
201201
[Fact]
202202
public async Task HttpTest_Bytes()
203203
{
204-
const string page = @"https://httpbingo.org/bytes/1024";
204+
const string page = "https://httpbingo.org/bytes/1024";
205205
var result = await GetAsync(page).ReceiveBytes();
206206
Assert.Equal(1024, result.Length);
207207
}
208208

209209
[Fact]
210210
public async Task HttpTest_StreamBytes()
211211
{
212-
const string page = @"https://httpbingo.org/stream-bytes/1024";
212+
const string page = "https://httpbingo.org/stream-bytes/1024";
213213
var result = await GetAsync(page).ReceiveBytes();
214214
Assert.Equal(1024, result.Length);
215215
}
216216

217217
[Fact]
218218
public async Task HttpTest_Cookies_SetCookie()
219219
{
220-
const string page = @"https://httpbingo.org/cookies/set?k1=v1";
220+
const string page = "https://httpbingo.org/cookies/set?k1=v1";
221221
var result = await GetAsync(page).ReceiveString();
222222
var json = JsonDocument.Parse(result);
223223
var cookies = json.RootElement.GetDictionary();
@@ -227,9 +227,9 @@ public async Task HttpTest_Cookies_SetCookie()
227227
[Fact]
228228
public async Task HttpTest_Cookies_SetCookieAgain()
229229
{
230-
const string page1 = @"https://httpbingo.org/cookies/set?k1=v1";
230+
const string page1 = "https://httpbingo.org/cookies/set?k1=v1";
231231
await GetAsync(page1);
232-
const string page2 = @"https://httpbingo.org/cookies/set?k1=v2";
232+
const string page2 = "https://httpbingo.org/cookies/set?k1=v2";
233233
var result = await GetAsync(page2).ReceiveString();
234234
var json = JsonDocument.Parse(result);
235235
var cookies = json.RootElement.GetDictionary();
@@ -241,11 +241,11 @@ public async Task HttpTest_Cookies_SetCookies()
241241
{
242242
const string cookie1 = "k1=v1; Path=/; expires=Sat, 01-Jan-2050 00:00:00 GMT";
243243
const string cookie2 = "k2=v2; Path=/; expires=Fri, 01-Jan-2049 00:00:00 GMT";
244-
var page1 = $@"https://httpbingo.org/response-headers?Set-Cookie={WebUtility.UrlEncode(cookie1)}&Set-Cookie={WebUtility.UrlEncode(cookie2)}";
244+
var page1 = $"https://httpbingo.org/response-headers?Set-Cookie={WebUtility.UrlEncode(cookie1)}&Set-Cookie={WebUtility.UrlEncode(cookie2)}";
245245
var response1 = await GetAsync(page1);
246246
response1.Headers.TryGetValues("set-cookie", out var respCookies);
247247
Assert.Equal(new List<string> { cookie1, cookie2 }, respCookies);
248-
const string page2 = @"https://httpbingo.org/cookies";
248+
const string page2 = "https://httpbingo.org/cookies";
249249
var result = await GetAsync(page2).ReceiveString();
250250
var json = JsonDocument.Parse(result);
251251
var cookies = json.RootElement.GetDictionary();
@@ -256,9 +256,9 @@ public async Task HttpTest_Cookies_SetCookies()
256256
[Fact]
257257
public async Task HttpTest_Cookies_DeleteCookie()
258258
{
259-
const string page1 = @"https://httpbingo.org/cookies/set?k1=v1";
259+
const string page1 = "https://httpbingo.org/cookies/set?k1=v1";
260260
await GetAsync(page1);
261-
const string page2 = @"https://httpbingo.org/cookies/delete?k1";
261+
const string page2 = "https://httpbingo.org/cookies/delete?k1";
262262
var result = await GetAsync(page2).ReceiveString();
263263
var json = JsonDocument.Parse(result);
264264
var cookies = json.RootElement.GetDictionary();
@@ -268,7 +268,7 @@ public async Task HttpTest_Cookies_DeleteCookie()
268268
[Fact]
269269
public async Task HttpTest_Cookies_DoNotUseCookies()
270270
{
271-
const string page = @"https://httpbingo.org/cookies/set?k1=v1";
271+
const string page = "https://httpbingo.org/cookies/set?k1=v1";
272272
DisableCookies();
273273
var result = await GetAsync(page).ReceiveString();
274274
var json = JsonDocument.Parse(result);
@@ -281,7 +281,7 @@ public async Task HttpTest_Protocol()
281281
{
282282
Skip.If(DeviceInfo.Platform == DevicePlatform.iOS, "Need help to get http version from NSHttpUrlResponse");
283283

284-
const string page = @"https://httpbingo.org/get";
284+
const string page = "https://httpbingo.org/get";
285285
var request = new HttpRequestMessage(HttpMethod.Get, page);
286286
if (DeviceInfo.Platform != DevicePlatform.Android && DeviceInfo.Platform != DevicePlatform.iOS)
287287
{
@@ -294,15 +294,15 @@ public async Task HttpTest_Protocol()
294294
[Fact]
295295
public async Task HttpTest_Timeout()
296296
{
297-
const string page = @"https://httpbingo.org/delay/5";
297+
const string page = "https://httpbingo.org/delay/5";
298298
SetTimeout(1);
299299
await Assert.ThrowsAsync<TaskCanceledException>(() => GetAsync(page));
300300
}
301301

302302
[Fact]
303303
public async Task HttpTest_UnknownHost()
304304
{
305-
const string page = @"https://nosuchhostisknown/";
305+
const string page = "https://nosuchhostisknown/";
306306
await Assert.ThrowsAsync<HttpRequestException>(() => GetAsync(page));
307307
}
308308

@@ -311,7 +311,7 @@ public async Task HttpTest_GetWithNonEmptyRequestBody()
311311
{
312312
Skip.If(DeviceInfo.Platform == DevicePlatform.Android || DeviceInfo.Platform == DevicePlatform.iOS, "GET method must not have a body");
313313

314-
const string page = @"https://httpbin.org/get";
314+
const string page = "https://httpbin.org/get";
315315
var request = new HttpRequestMessage(HttpMethod.Get, page)
316316
{
317317
Content = new StringContent("test request body")
@@ -325,7 +325,7 @@ public async Task HttpTest_GetWithNonEmptyRequestBody()
325325
[Fact]
326326
public async Task HttpTest_GetWithEmptyRequestBody()
327327
{
328-
const string page = @"https://httpbingo.org/get";
328+
const string page = "https://httpbingo.org/get";
329329
var request = new HttpRequestMessage(HttpMethod.Get, page)
330330
{
331331
Content = new StringContent("")

0 commit comments

Comments
 (0)