public async Task TestBasic() { var accessTokenInfo = new AccessToken(); await _accessTokenRepository.InsertAsync(accessTokenInfo); Assert.True(accessTokenInfo.Id > 0); var token = accessTokenInfo.Token; Assert.False(string.IsNullOrWhiteSpace(token)); accessTokenInfo = await _accessTokenRepository.GetAsync(accessTokenInfo.Id); Assert.NotNull(accessTokenInfo); accessTokenInfo.Title = "title"; var updated = await _accessTokenRepository.UpdateAsync(accessTokenInfo); Assert.True(updated); await _accessTokenRepository.RegenerateAsync(accessTokenInfo); Assert.NotEqual(token, accessTokenInfo.Token); var deleted = await _accessTokenRepository.DeleteAsync(accessTokenInfo.Id); Assert.True(deleted); }
public async Task RevokeTokenAsync(Guid tokenId) { var userInstallations = await _gitHubUserModelService.GetRepositoriesAsync(); var repositoryIds = userInstallations.Select(r => r.Id).ToList(); await _tokenRepository.DeleteAsync(tokenId, repositoryIds); }
public async Task <ActionResult <TokensResult> > Delete([FromBody] IdRequest request) { if (!await _authManager.HasAppPermissionsAsync(Types.AppPermissions.SettingsAdministratorsAccessTokens)) { return(Unauthorized()); } await _accessTokenRepository.DeleteAsync(request.Id); var list = await _accessTokenRepository.GetAccessTokensAsync(); return(new TokensResult { Tokens = list }); }