public void AccessToken_CreateToken_NotNull() { var token = new AccessToken(Repository.Instance, 1, 0, cacheProvider); token.UpdateUserLogin(Repository.Instance); token.WriteToCache(cacheProvider); Assert.IsNotNull(token); }
private ApiToken CreateSecretToken(int applicationId, int userId, string tokenKeyName) { var accessToken = new AccessToken( applicationId, userId);//, cacheProvider); accessToken.UpdateUserLogin(); accessToken.WriteToCache(); return new ApiToken { TokenKey = accessToken.Secret, TokenKeyName = tokenKeyName, ExpiryUtc = accessToken.Expiry.ToUniversalTime().ToString(@"o") }; }
public void AccessToken_ValidateCaching() { var token = new AccessToken(Repository.Instance, 1, 0, cacheProvider); token.UpdateUserLogin(Repository.Instance); token.WriteToCache(cacheProvider); var secret = token.Secret; var token2 = AccessToken.ReadFromCache(secret, cacheProvider); Assert.IsNotNull(token, "Token not set."); Assert.IsNotNull(token2, "Deserialized token is null."); Assert.IsTrue(token.UserId == token2.UserId, "UserId is not the same for the token after caching."); Assert.IsTrue(token.ApplicationId == token2.ApplicationId, "ApplicationId is not the same for the token after caching."); Assert.IsTrue(token.Expiry.ToString(CultureInfo.InvariantCulture) == token2.Expiry.ToString(CultureInfo.InvariantCulture), "Expiry is not the same for the token after caching."); }