Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

[Core Web API]: From SQL Server tables can ASP.NET Core Identity reveal whether test user is logged on?

$
0
0

Sorry for cross posting; this was posted September 2nd here http://stackoverflow.com/questions/39300797/core-web-api-from-sql-server-tables-can-asp-net-core-identity-reveal-whether [no answers yet].

Goal:
By inspecting ASP.NET Core 1.0 Identity tables,
determine whether a given user is logged on.

A test application can be created from the reference at the bottom of this question.

Before testing, a single user is created.

Before and after running the test, the 7 ASP.NET Core Identity tables are inspected; all except AspNetUsers have zero rows; AspNetUsers has one row.

Purpose(s):
unit testing; reporting

Test idea (pseudo-code):

// Arrange
prepare to logon a known test user   
// Act   
POST         // POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<IActionResult>
     Login(LoginViewModel model, string returnUrl = null)

// Assert    
??????? how to explicitly verify that our known user is logged on ???????

The Problem
The contents of the AspNetUsers row for our known user BEFORE and AFTER is identical.

Reference:
Building Your First Web API with ASP.NET Core MVC and Visual Studio

Note:
The 7 ASP.NET Core Identity tables are:

AspNetUsers
AspNetUserTokens
AspNetUserLogins
AspNetUserRoles
AspNetUserClaims
AspNetRoles
AspNetRoleClaims

Tags used as stackoverflow:      


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>