Skip to content

feat: add Producto CRUD module with tests and security validation#23

Merged
edelmezamx merged 1 commit into
mainfrom
CrudProducto
Jul 15, 2026
Merged

feat: add Producto CRUD module with tests and security validation#23
edelmezamx merged 1 commit into
mainfrom
CrudProducto

Conversation

@edelomeza

Copy link
Copy Markdown
Owner

Cambios incluidos

Nuevo módulo Producto CRUD

  • Modelo de dominio, ViewModels y validaciones
  • Servicio HttpClient con 6 métodos (CRUD + búsqueda)
  • Controlador con 8 acciones
  • 5 vistas Razor (Index, Create, Details, Update, Delete)
  • Menú en _Layout y registro DI en Program.cs

Pruebas

  • 18 tests unitarios (Index, Create, Update, Delete)
  • 21 tests de integración (API client)
  • 13 tests de seguridad (autenticación, XSS, validación)

Build: 0 errors, 0 warnings

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

var httpClient = new HttpClient(mockHandler) { BaseAddress = new Uri(TestConstants.ApiBaseUrl) };

var httpContextAccessorMock = new Mock<IHttpContextAccessor>();
httpContextAccessorMock.Setup(x => x.HttpContext).Returns((HttpContext?)null);
{
private static WebApplicationFactory<Program> CreateFactory()
{
return new WebApplicationFactory<Program>()

serviceMock
.Setup(x => x.GetProductoByIdAsync(It.IsAny<int>(), It.IsAny<CancellationToken>()))
.ReturnsAsync((Producto?)null);

serviceMock
.Setup(x => x.GetProductosAsync(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<CancellationToken>()))
.ReturnsAsync((PaginatedResponse<Producto>?)null);

serviceMock
.Setup(x => x.GetProductosAsync(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<CancellationToken>()))
.ReturnsAsync((PaginatedResponse<Producto>?)null);
Comment on lines +106 to +110
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected error searching productos");
return null;
}
Comment on lines +152 to +156
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected error fetching producto {Id}", id);
return null;
}
Comment on lines +206 to +210
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected error creating producto");
return OperationResult.Fail("Error inesperado. Intente nuevamente.");
}
Comment on lines +264 to +268
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected error updating producto {Id}", id);
return OperationResult.Fail("Error inesperado. Intente nuevamente.");
}
Comment on lines +322 to +326
catch (Exception ex)
{
_logger.LogError(ex, "Unexpected error deleting producto {Id}", id);
return OperationResult.Fail("Error inesperado. Intente nuevamente.");
}

@edelmezamx edelmezamx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terminado

@edelmezamx
edelmezamx merged commit f1e0775 into main Jul 15, 2026
10 checks passed
@edelomeza
edelomeza deleted the CrudProducto branch July 15, 2026 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants