-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#283 "Without.." implementations for ModelState, Model, User, Distrib…
…uted Cache (#365) * #283 Initial implementation for without ModelState builder. * #283 Renaming of all related classes and interfaces to "With and without" model state. * #283 Adding xml comments and missing ComponentBuilderModelStateWithoutExtensions method for removing model state by key, without using the builder. * #283 Adding tests for without model state implementation. * #283 Rearranging the usings. * #283 Changing the interfaces and builders name to be consistent with the functionallity for With And WithoutUser. * #283 Adding Interfaces for without claims identity builder. * #283 WIthoutTempData class naming refactoring, adding the class shells without the implementation. * #283 Adding WithoutTempDataBuilder implementation. * #283 Adding ComponentBuilderTempDataWithoutExtensions implementation. Things left to be done: - Add xml documentation - Write tests * #283 Adding xml documentation for all public methods and classes. * #283 Adding tests for without temp data builder * #283 Adding initial structure of the with and without distributed cache. - Tidying up the structure of the memory cache and distributed cache folders in order to be more clear what and from where is used. * #283 Adding xml documentation for the interfaces and public/protected methods. * #283 Renaming several interfaces in order to match their corresponsing implementations. Added tests for without distributed cache logic. Added extension methods for the distributed cache component builder. * #283 Adding comments for the component builder distributed cache. * #283 Removing without claims identity builder in order for the PR to go to the main branch. * #283 Removing wrongly commited launchSettings.json files. * #283 Adding small refactoring of the authentication builders in order to continue with the WithoutUser implementation. * #283 Adding couple of tests for WithoutUser * #283 Added missed inferface method that was removed by mistake. * #283 Fixing broken build. * #283 Sets comments where such are missing. - Fixing ignored test, added one more. * Updated README * Update README * Updated README * #365, #283 Resolving PR comments
- Loading branch information
Showing
63 changed files
with
1,727 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
samples/Autofac/Autofac.NoContainerBuilder.Web/Properties/launchSettings.json
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
...ted.AspNetCore.Mvc.Abstractions/Builders/Authentication/BaseClaimsPrincipalUserBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
namespace MyTested.AspNetCore.Mvc.Builders.Authentication | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Security.Claims; | ||
|
||
/// <summary> | ||
/// Base class for creating mocked authenticated <see cref="ClaimsPrincipal"/>. | ||
/// </summary> | ||
public class BaseClaimsPrincipalUserBuilder : BaseUserBuilder | ||
{ | ||
private readonly ICollection<ClaimsIdentity> identities; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BaseClaimsPrincipalUserBuilder"/> class. | ||
/// </summary> | ||
public BaseClaimsPrincipalUserBuilder() | ||
=> this.identities = new List<ClaimsIdentity>(); | ||
|
||
/// <summary> | ||
/// Returns the principle based on provided identities and claims. | ||
/// </summary> | ||
/// <returns>This <see cref="ClaimsPrincipal"/>.</returns> | ||
public ClaimsPrincipal GetClaimsPrincipal() | ||
{ | ||
var claimIdentities = this.identities.Reverse().ToList(); | ||
claimIdentities.Add(this.GetAuthenticatedClaimsIdentity()); | ||
|
||
var claimsPrincipal = new ClaimsPrincipal(claimIdentities); | ||
|
||
return claimsPrincipal; | ||
} | ||
|
||
/// <summary> | ||
/// Returns the principle based on provided claims only. | ||
/// </summary> | ||
/// <returns>This <see cref="ClaimsPrincipal"/>.</returns> | ||
public ClaimsPrincipal GetClaimsPrincipalBasedOnClaimsOnly() | ||
{ | ||
var claimsPrincipal = new ClaimsPrincipal(this.GetAuthenticatedClaimsIdentity()); | ||
|
||
return claimsPrincipal; | ||
} | ||
|
||
/// <summary> | ||
/// Static constructor for creating default authenticated claims principal with "TestId" identifier and "TestUser" username. | ||
/// </summary> | ||
/// <returns>Authenticated <see cref="ClaimsPrincipal"/>.</returns> | ||
/// <value>Result of type <see cref="ClaimsPrincipal"/>.</value> | ||
public static ClaimsPrincipal DefaultAuthenticated { get; } | ||
= new ClaimsPrincipal(CreateAuthenticatedClaimsIdentity()); | ||
|
||
protected void AddIdentity(ClaimsIdentity identity) | ||
=> this.identities.Add(identity); | ||
|
||
protected void AddIdentities(IEnumerable<ClaimsIdentity> identities) | ||
{ | ||
foreach (var identity in identities) | ||
{ | ||
this.AddIdentity(identity); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 0 additions & 140 deletions
140
src/MyTested.AspNetCore.Mvc.Abstractions/Builders/Authentication/ClaimsPrincipalBuilder.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.