Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 258dd42

Browse files
committed
React to StringSegment changes
1 parent 54469d8 commit 258dd42

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/Entropy.FunctionalTests/AntiforgeryTests/Antiforgery.Angular1Test.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System;
45
using System.Linq;
56
using System.Net;
67
using System.Net.Http;
78
using System.Threading.Tasks;
89
using Microsoft.AspNetCore.Antiforgery;
10+
using Microsoft.Extensions.Primitives;
911
using Microsoft.Net.Http.Headers;
1012
using Xunit;
1113

@@ -29,15 +31,15 @@ public async Task ItemsPage_SetsXSRFTokens()
2931
// Assert
3032
var setCookieHeaderValue = RetrieveAntiforgeryCookie(response);
3133
Assert.NotNull(setCookieHeaderValue);
32-
Assert.False(string.IsNullOrEmpty(setCookieHeaderValue.Value));
33-
Assert.Null(setCookieHeaderValue.Domain);
34+
Assert.False(StringSegment.IsNullOrEmpty(setCookieHeaderValue.Value));
35+
Assert.Null(setCookieHeaderValue.Domain.Value);
3436
Assert.Equal("/", setCookieHeaderValue.Path);
3537
Assert.False(setCookieHeaderValue.Secure);
3638

3739
setCookieHeaderValue = RetrieveAntiforgeryToken(response);
3840
Assert.NotNull(setCookieHeaderValue);
39-
Assert.False(string.IsNullOrEmpty(setCookieHeaderValue.Value));
40-
Assert.Null(setCookieHeaderValue.Domain);
41+
Assert.False(StringSegment.IsNullOrEmpty(setCookieHeaderValue.Value));
42+
Assert.Null(setCookieHeaderValue.Domain.Value);
4143
Assert.Equal("/", setCookieHeaderValue.Path);
4244
Assert.False(setCookieHeaderValue.Secure);
4345
}
@@ -73,7 +75,7 @@ public async Task PostItem_XSRFWorks()
7375
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/items");
7476

7577
httpRequestMessage.Headers.Add("Cookie", $"{cookie.Name}={cookie.Value}");
76-
httpRequestMessage.Headers.Add("X-XSRF-TOKEN", token.Value);
78+
httpRequestMessage.Headers.Add("X-XSRF-TOKEN", token.Value.Value);
7779

7880
// Act
7981
var response = await Client.SendAsync(httpRequestMessage);
@@ -94,7 +96,7 @@ private static SetCookieHeaderValue RetrieveAntiforgeryCookie(HttpResponseMessag
9496
{
9597
return response.Headers.GetValues(HeaderNames.SetCookie)
9698
.Select(setCookieValue => SetCookieHeaderValue.Parse(setCookieValue))
97-
.Where(setCookieHeaderValue => setCookieHeaderValue.Name.StartsWith(".AspNetCore.Antiforgery."))
99+
.Where(setCookieHeaderValue => setCookieHeaderValue.Name.StartsWith(".AspNetCore.Antiforgery.", StringComparison.Ordinal))
98100
.FirstOrDefault();
99101
}
100102
}

0 commit comments

Comments
 (0)