Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Jan 14, 2019
1 parent 9b6ce87 commit 2ca16da
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Hosting/TestHost/src/AsyncStreamWrapper.cs
Expand Up @@ -31,7 +31,7 @@ internal AsyncStreamWrapper(Stream inner, Func<bool> allowSynchronousIO)

public override void Flush()
{
// Not bocking Flush because things like StreamWriter.Dispose() always call it.
// Not blocking Flush because things like StreamWriter.Dispose() always call it.
_inner.Flush();
}

Expand Down
8 changes: 4 additions & 4 deletions src/Security/Authentication/test/CookieTests.cs
Expand Up @@ -1302,7 +1302,7 @@ public async Task CanSpecifyAndShareDataProtector()
app.Use(async (context, next) =>
{
var result = await context.AuthenticateAsync("Cookies");
await Describe(context.Response, result);
await DescribeAsync(context.Response, result);
});
})
.ConfigureServices(services => services.AddAuthentication().AddCookie("Cookies", o =>
Expand Down Expand Up @@ -1478,12 +1478,12 @@ private static TestServer CreateServerWithServices(Action<IServiceCollection> co
}
else if (req.Path == new PathString("/me"))
{
await Describe(res, AuthenticateResult.Success(new AuthenticationTicket(context.User, new AuthenticationProperties(), CookieAuthenticationDefaults.AuthenticationScheme)));
await DescribeAsync(res, AuthenticateResult.Success(new AuthenticationTicket(context.User, new AuthenticationProperties(), CookieAuthenticationDefaults.AuthenticationScheme)));
}
else if (req.Path.StartsWithSegments(new PathString("/me"), out remainder))
{
var ticket = await context.AuthenticateAsync(remainder.Value.Substring(1));
await Describe(res, ticket);
await DescribeAsync(res, ticket);
}
else if (req.Path == new PathString("/testpath") && testpath != null)
{
Expand All @@ -1510,7 +1510,7 @@ private static TestServer CreateServerWithServices(Action<IServiceCollection> co
return server;
}

private static Task Describe(HttpResponse res, AuthenticateResult result)
private static Task DescribeAsync(HttpResponse res, AuthenticateResult result)
{
res.StatusCode = 200;
res.ContentType = "text/xml";
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Authentication/test/DynamicSchemeTests.cs
Expand Up @@ -145,7 +145,7 @@ private static TestServer CreateServer(Action<IServiceCollection> configureServi
{
var name = (remainder.Value.Length > 0) ? remainder.Value.Substring(1) : null;
var result = await context.AuthenticateAsync(name);
await res.Describe(result?.Ticket?.Principal);
await res.DescribeAsync(result?.Ticket?.Principal);
}
else if (req.Path.StartsWithSegments(new PathString("/remove"), out remainder))
{
Expand Down
10 changes: 5 additions & 5 deletions src/Security/Authentication/test/GoogleTests.cs
Expand Up @@ -1177,26 +1177,26 @@ private static TestServer CreateServer(Action<GoogleOptions> configureOptions, F
{
var result = await context.AuthenticateAsync(TestExtensions.CookieAuthenticationScheme);
var tokens = result.Properties.GetTokens();
await res.Describe(tokens);
await res.DescribeAsync(tokens);
}
else if (req.Path == new PathString("/me"))
{
await res.Describe(context.User);
await res.DescribeAsync(context.User);
}
else if (req.Path == new PathString("/authenticate"))
{
var result = await context.AuthenticateAsync(TestExtensions.CookieAuthenticationScheme);
await res.Describe(result.Principal);
await res.DescribeAsync(result.Principal);
}
else if (req.Path == new PathString("/authenticateGoogle"))
{
var result = await context.AuthenticateAsync("Google");
await res.Describe(result?.Principal);
await res.DescribeAsync(result?.Principal);
}
else if (req.Path == new PathString("/authenticateFacebook"))
{
var result = await context.AuthenticateAsync("Facebook");
await res.Describe(result?.Principal);
await res.DescribeAsync(result?.Principal);
}
else if (req.Path == new PathString("/unauthorized"))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Authentication/test/MicrosoftAccountTests.cs
Expand Up @@ -270,7 +270,7 @@ private static TestServer CreateServer(Action<MicrosoftAccountOptions> configure
}
else if (req.Path == new PathString("/me"))
{
await res.Describe(context.User);
await res.DescribeAsync(context.User);
}
else if (req.Path == new PathString("/signIn"))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Authentication/test/PolicyTests.cs
Expand Up @@ -469,7 +469,7 @@ private static TestServer CreateServer(Action<IServiceCollection> configure = nu
{
var name = (remainder.Value.Length > 0) ? remainder.Value.Substring(1) : null;
var result = await context.AuthenticateAsync(name);
await res.Describe(result?.Ticket?.Principal);
await res.DescribeAsync(result?.Ticket?.Principal);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/Security/Authentication/test/TestExtensions.cs
Expand Up @@ -46,7 +46,7 @@ public static async Task<Transaction> SendAsync(this TestServer server, string u
return transaction;
}

public static Task Describe(this HttpResponse res, ClaimsPrincipal principal)
public static Task DescribeAsync(this HttpResponse res, ClaimsPrincipal principal)
{
res.StatusCode = 200;
res.ContentType = "text/xml";
Expand All @@ -65,7 +65,7 @@ public static Task Describe(this HttpResponse res, ClaimsPrincipal principal)
return res.Body.WriteAsync(xmlBytes, 0, xmlBytes.Length);
}

public static Task Describe(this HttpResponse res, IEnumerable<AuthenticationToken> tokens)
public static Task DescribeAsync(this HttpResponse res, IEnumerable<AuthenticationToken> tokens)
{
res.StatusCode = 200;
res.ContentType = "text/xml";
Expand Down
19 changes: 0 additions & 19 deletions src/Security/CookiePolicy/test/TestExtensions.cs
Expand Up @@ -45,24 +45,5 @@ public static async Task<Transaction> SendAsync(this TestServer server, string u
}
return transaction;
}

public static void Describe(this HttpResponse res, ClaimsPrincipal principal)
{
res.StatusCode = 200;
res.ContentType = "text/xml";
var xml = new XElement("xml");
if (principal != null)
{
foreach (var identity in principal.Identities)
{
xml.Add(identity.Claims.Select(claim =>
new XElement("claim", new XAttribute("type", claim.Type),
new XAttribute("value", claim.Value),
new XAttribute("issuer", claim.Issuer))));
}
}
var xmlBytes = Encoding.UTF8.GetBytes(xml.ToString());
res.Body.Write(xmlBytes, 0, xmlBytes.Length);
}
}
}

0 comments on commit 2ca16da

Please sign in to comment.