Conversation
Separated the client registration POST endpoint from ClientsController and placed it in a new RegisterController for improved organization and clearer separation of concerns. No changes to endpoint logic.
- Changed password validation error to use LOGIN_INVALID message. - Added email uniqueness check when updating client info; throws EmailAlreadyExistsException if email is already in use.
Replaced PASSWORD_INVALID with LOGIN_INVALID in all resource files and code. Updated InvalidLoginException to use the new resource, ensuring error messages indicate either email or password may be invalid. Improved localization and clarity of login error handling across supported languages.
Removed explicit clientId parameters from product endpoints and use cases. Now, the authenticated user's ID is obtained via the ILoggedUser service for all product operations. Updated controller routes, use case interfaces, and implementations accordingly. This enhances security and maintainability by ensuring actions are always performed in the context of the logged-in user. Also simplified UpdateClientUseCase with null-coalescing exception handling.
Added three unit tests covering success, client not found, and email already exists scenarios for UpdateClientUseCase. Refactored the CreateUseCase helper to accept a clientExist parameter and improved repository setup logic. Included necessary using statements for test utilities and exception handling.
Added RabbitMQ support with configuration in appsettings, a new IMessagePublisher abstraction, and implementations for publishing (RabbitMqPublisher) and consuming (ClientCreatedConsumer) messages. RegisterClientUseCase now publishes to the clients.created queue after registration. Updated dependency injection and tests to support messaging. Added RabbitMQ.Client NuGet package and RabbitMqOptions for configuration binding. Enables event-driven communication for client creation.
Add EnableConsumer option to control RabbitMQ consumer Introduced an EnableConsumer setting in RabbitMQ config (default true) to allow enabling or disabling the ClientCreatedConsumer hosted service via configuration. Updated RabbitMqOptions and conditional service registration accordingly.
Add RabbitMQ fanout exchange and multi-queue consumers Refactor messaging to use a fanout exchange with separate audit and welcome queues for client events. Update configuration and options to support ExchangeName, ClientCreatedQueueName, and ClientWelcomeQueueName. Modify ClientCreatedConsumer to bind to the exchange and consume from the audit queue. Add ClientWelcomeConsumer to process welcome messages. Update publisher to publish to the exchange. Register both consumers as hosted services. Enables multiple consumers to independently process client creation events.
Fix ChangePassword logic and add unit tests Corrected password verification in ChangePasswordUseCase to validate the current password instead of the new one. Added RequestChangePasswordBuilder for test data creation. Introduced ChangePasswordUseCaseTest with cases for success, client not found, and invalid password scenarios.
Add integration tests for Get All Clients endpoint Introduce integration testing setup for the ProductClientHub API, including a custom WebApplicationFactory with in-memory configuration and fake dependencies. Add integration tests for the GET /api/clients endpoint, covering both success and no-content scenarios. Update Program.cs to skip DB migration in testing, add a partial Program class for test referencing, and update the test project file to reference the API. Remove minor unrelated/conflicting code.
Implement GetById logic and add integration tests
Updated CustomWebApplicationFactory to return clients by ID from the in-memory store. Added GetByIdClientIntegrationTest to verify GET /api/clients/{id} returns 200 OK for existing clients and 404 Not Found for missing clients, using xUnit and Shouldly.
Add integration test for client deletion endpoint Introduce DeleteClientIntegrationTest to verify client deletion via the API using an in-memory store and fake authentication. Update CustomWebApplicationFactory to support test isolation by removing hosted services and providing a FakeDeleteClientRepository. This enables reliable, database-independent integration testing for client deletion.
… pra o atual, estava disparando erro, o que nao faz sentido, se o e-mail é dele, pode permanecer asssim.
Refactor ILoggedUser to ILoggedClient and update tests Renamed ILoggedUser/LoggedUser to ILoggedClient/loggedClient across the codebase, including namespaces, DI, and test utilities. Updated use cases and tests to use the new interface. Enhanced test builders for clients and products, added ProductsReadOnlyRepositoryBuild for product mocks, and introduced GetAllProductsUseCaseTest. Improved ClientReadOnlyRepositoryBuilder for flexible email existence checks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.