/// <summary> /// Delete a user /// </summary> /// <param name="source"></param> /// <param name="user">The user to delete</param> /// <param name="cancellationToken"></param> public static void DeleteUser( [NotNull] this IManagementClient source, [NotNull] User user, CancellationToken cancellationToken = default ) { if (source == null) { throw new ArgumentNullException(nameof(source)); } source.DeleteUserAsync(user, cancellationToken) .GetAwaiter() .GetResult(); }
public async Task DeleteUserAsync(Models.User user) { await _logConsumerService.RemoveConsumerForUserAsync(user.Username); _logger.LogInformation($"Log consumer for user '{user.Username}' deleted"); await _userRepository.DeleteAsync(user.Username); _logger.LogInformation($"User '{user.Username}' deleted from MongoDB"); await _elasticsearchClient.DeleteIndexAsync(user.LogIndexName); _logger.LogInformation($"ElasticSearch index for '{user.Username}' deleted"); await _elasticsearchClient.DeleteUserAsync(user.Username); _logger.LogInformation($"ElasticSearch user '{user.Username}' deleted"); var vhost = await _managementClient.GetVhostAsync("/"); var errorQueue = await _managementClient.GetQueueAsync(user.ErrorQueueName, vhost); await _managementClient.DeleteQueueAsync(errorQueue); _logger.LogInformation($"RabbitMQ error queue for user '{user.Username}' deleted"); var logQueue = await _managementClient.GetQueueAsync(user.LogQueueName, vhost); await _managementClient.DeleteQueueAsync(logQueue); _logger.LogInformation($"RabbitMQ log queue for user '{user.Username}' deleted"); var logExchange = await _managementClient.GetExchangeAsync(user.LogExchangeName, vhost); await _managementClient.DeleteExchangeAsync(logExchange); _logger.LogInformation($"RabbitMQ exchange for user '{user.Username}' deleted"); var rabbitUser = await _managementClient.GetUserAsync(user.Username); await _managementClient.DeleteUserAsync(rabbitUser); _logger.LogInformation($"RabbitMQ user '{user.Username}' deleted"); }
public async Task Should_be_able_to_delete_a_user() { var user = await managementClient.GetUserAsync(testUser).ConfigureAwait(false); await managementClient.DeleteUserAsync(user).ConfigureAwait(false); }