public async Task Execute(IJobExecutionContext context) { try { await _accessTokenClientRepo.DeleteExpiredTokensAsync(); _logger.Debug("Expired client access tokens have been deleted"); } catch (Exception e) { _logger.Error(e); } }
/// <summary> /// Loads the API client details for the supplied token from the Admin database. /// </summary> /// <param name="token">The OAuth security token for which API client details should be retrieved.</param> /// <returns>A populated <see cref="ApiClientDetails"/> instance.</returns> public async Task <ApiClientDetails> GetClientDetailsForTokenAsync(string token) { if (!Guid.TryParse(token, out Guid tokenAsGuid)) { return(new ApiClientDetails()); } // TODO SF ODS-3459: this ought to be running as an independent task, scheduled multiple times a day. await _accessTokenClientRepo.DeleteExpiredTokensAsync(); var clientForToken = await _accessTokenClientRepo.GetClientForTokenAsync(tokenAsGuid); return(ApiClientDetails.Create(clientForToken)); }
public void Then_delete_expired_tokens() { Act(TokenGuid); A.CallTo(() => _accessTokenClientRepo.DeleteExpiredTokensAsync()).MustHaveHappened(); }