# NetPigeon.BugBug **Repository Path**: NetPigeon/NetPigeon.BugBug ## Basic Information - **Project Name**: NetPigeon.BugBug - **Description**: Bug管理平台 - 原雪娃娃团队开发并发布初版 - 现有雪鸽团队维护与后续开发 - **Primary Language**: C# - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-08 - **Last Updated**: 2026-05-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NetPigeon.BugBug - Bug Management Platform A lightweight Bug management platform based on ASP.NET Core Web API, supporting API integration, role-based access control, and complete test management functionality. ## Features - ✅ **User Authentication**: Email-based authentication with JWT Token - ✅ **Role Management**: Three roles - Admin, Tester, Developer - ✅ **Bug Management**: Complete bug lifecycle management including creation, assignment, status tracking, and comments - ✅ **Test Item Management**: Organize test items by module - ✅ **Test Case Management**: Detailed test case creation and management - ✅ **Test Execution Records**: Record test results and link to bugs - ✅ **RESTful API**: Complete API interface for third-party system integration - ✅ **Swagger Documentation**: Built-in API documentation for easy debugging and testing ## Technology Stack - **Backend Framework**: ASP.NET Core Web API (.NET 8.0 / .NET 10.0) - **ORM**: Dapper (High-performance lightweight ORM) - **Database**: MySQL (utf8mb4_unicode_ci encoding) - **Authentication**: JWT (JSON Web Token) - **Password Encryption**: BCrypt - **JSON Library**: Newtonsoft.Json - **API Documentation**: Swagger/OpenAPI ## Quick Start ### Prerequisites - .NET 8.0 SDK or .NET 10.0 SDK - MySQL 5.7+ or MariaDB 10.2+ - IDE: Visual Studio 2022 / VS Code / Rider ### Installation Steps #### 1. Clone the Repository ```bash git clone cd NetPigeon.BugBug ``` #### 2. Initialize Database Execute the initialization script using MySQL client (table structures and seed data are merged): ```bash # Create database, tables, and initial data mysql -u root -p < Source/NetPigeon.BugBug.Database/init.sql ``` **Note**: - All table definitions and seed data are integrated into `init.sql` - Table structures are organized modularly in `Source/NetPigeon.BugBug.Database/tables/` directory - Idempotent design allows safe repeated execution #### 3. Configure Database Connection Edit `Source/NetPigeon.BugBug.Web/appsettings.json` and modify the database connection string: ```json { "ConnectionStrings": { "DefaultConnection": "Server=localhost;Database=bugbug_db;Uid=root;Pwd=your_password;Charset=utf8mb4;" }, "Jwt": { "Key": "YourSuperSecretKeyForBugBugPlatform2026!", "Issuer": "BugBug", "Audience": "BugBugUsers" } } ``` **Important**: Change `Jwt.Key` to a strong random string for security! #### 4. Run the Application ```bash cd Source/NetPigeon.BugBug.Web dotnet run ``` The application will start at `https://localhost:5001` and `http://localhost:5000`. #### 5. Access Swagger Documentation Open your browser and visit: `https://localhost:5001/swagger` ## API Usage Guide ### Authentication Endpoints #### User Registration ```http POST /api/auth/register Content-Type: application/json { "email": "user@example.com", "password": "YourPassword123", "userName": "John Doe" } ``` #### User Login ```http POST /api/auth/login Content-Type: application/json { "email": "admin@bugbug.com", "password": "Admin@123" } ``` Response Example: ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "user": { "id": 1, "email": "admin@bugbug.com", "userName": "System Administrator", "role": "Admin" } } ``` ### Access Protected APIs with Token Add Authorization Header to all authenticated requests: ``` Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... ``` ### Bug Management Endpoints #### Get All Bugs ```http GET /api/bugs Authorization: Bearer {token} ``` #### Create Bug ```http POST /api/bugs Authorization: Bearer {token} Content-Type: application/json { "title": "Login page cannot submit", "description": "No response after clicking login button", "categoryId": 1, "statusId": 1, "priorityId": 3, "reportedBy": 1, "reproductionSteps": "1. Open login page\n2. Enter username and password\n3. Click login", "expectedResult": "Successfully login and redirect to home page", "actualResult": "Page unresponsive, console shows error" } ``` #### Add Bug Comment ```http POST /api/bugs/{id}/comments Authorization: Bearer {token} Content-Type: application/json { "userId": 1, "content": "Fixed, please test and verify" } ``` ### Test Item Management Endpoints #### Get All Test Items ```http GET /api/testitems Authorization: Bearer {token} ``` #### Create Test Item ```http POST /api/testitems Authorization: Bearer {token} Content-Type: application/json { "name": "User Login Module Test", "description": "Test user login related functions", "module": "Authentication", "createdBy": 1, "isActive": true } ``` ### Test Case Management Endpoints #### Get Test Cases by Test Item ```http GET /api/testcases/testitem/{testItemId} Authorization: Bearer {token} ``` #### Create Test Case ```http POST /api/testcases Authorization: Bearer {token} Content-Type: application/json { "testItemId": 1, "title": "Normal Login Flow Test", "description": "Verify that users can successfully log in with correct username and password", "preconditions": "User is registered and account is active", "testSteps": "[{\"step\": \"Open login page\", \"action\": \"Enter correct username and password\", \"expected\": \"Show login success\"}]", "expectedResult": "Successfully login and redirect to home page", "priority": "High", "status": "Active", "createdBy": 1 } ``` #### Add Test Execution Record ```http POST /api/testcases/{id}/executions Authorization: Bearer {token} Content-Type: application/json { "executedBy": 2, "result": "Pass", "notes": "Test passed" } ``` ## Default Accounts The system comes with three pre-configured test accounts (password: `Admin@123`): | Email | Username | Role | Description | |-------|----------|------|-------------| | admin@bugbug.com | System Administrator | Admin | Full access | | tester@bugbug.com | Test Engineer | Tester | Can manage test cases and execute tests | | developer@bugbug.com | Development Engineer | Developer | Can view and fix bugs | ## Role Permissions | Feature | Admin | Tester | Developer | |---------|-------|--------|-----------| | User Management | ✅ | ❌ | ❌ | | Bug View | ✅ | ✅ | ✅ | | Bug Creation | ✅ | ✅ | ✅ | | Bug Assignment | ✅ | ✅ | ❌ | | Bug Status Update | ✅ | ✅ | ✅ | | Test Item Management | ✅ | ✅ | ❌ | | Test Case Management | ✅ | ✅ | ❌ | | Test Execution | ✅ | ✅ | ❌ | ## Database Design ### Core Tables - **Users**: User table - **Bugs**: Bug table - **BugComments**: Bug comments table - **BugCategories**: Bug categories table - **BugStatuses**: Bug statuses table - **BugPriorities**: Bug priorities table - **TestItems**: Test items table - **TestCases**: Test cases table - **TestExecutions**: Test execution records table For detailed table structure, please refer to `Source/NetPigeon.BugBug.Database/init.sql`. ## FAQ ### 1. Database Connection Failed **Problem**: Cannot connect to database at runtime **Solution**: - Check if MySQL service is running - Verify connection string configuration in `appsettings.json` - Confirm database `bugbug_db` is created and initialization scripts are executed ### 2. JWT Token Expired **Problem**: API returns 401 Unauthorized **Solution**: - Token validity is 7 days by default, re-login to get new token after expiration - Adjust `expires` parameter in `DeepseekAuthController.cs` if needed ### 3. CORS Issues **Problem**: CORS errors when frontend calls API **Solution**: - Project is configured to allow all origins for cross-origin requests - For production, modify CORS policy in `Program.cs` to restrict allowed domains ### 4. Password Hash Mismatch **Problem**: Cannot login with default accounts **Solution**: - Default password hash corresponds to plaintext password `Admin@123` - To reset password, regenerate BCrypt hash and update database ## Development Guide ### Project Structure ``` Source/ ├── NetPigeon.BugBug.Core/ # Core Business Layer │ ├── DeepseekUser.cs # User entity │ ├── DeepseekBug.cs # Bug entity │ ├── DeepseekTestCase.cs # Test case entity │ └── ... # Other entities and enums ├── NetPigeon.BugBug.Data/ # Data Access Layer │ ├── DeepseekDatabaseContext.cs # Database context │ ├── IDeepseekUserRepository.cs # Repository interface │ ├── DeepseekUserRepository.cs # Repository implementation │ └── ... # Other repositories ├── NetPigeon.BugBug.Web/ # Web API Layer │ ├── Controllers/ # API controllers │ ├── Program.cs # Program entry point │ └── appsettings.json # Configuration file ├── NetPigeon.BugBug.MSTest/ # MSTest Test Project │ ├── DeepseekUserRoleEnumTests.cs │ ├── DeepseekUserTests.cs │ └── DeepseekBugTests.cs ├── NetPigeon.BugBug.Xunit/ # xUnit Test Project │ ├── DeepseekUserRoleEnumTests.cs │ ├── DeepseekUserTests.cs │ └── DeepseekBugTests.cs └── NetPigeon.BugBug.Database/ # Database Scripts ├── init.sql # Database initialization script └── seed.sql # Initial data script ``` ### Running Tests The project supports two testing frameworks: MSTest and xUnit. #### Run All Tests ```bash cd Source dotnet test ``` #### Run MSTest Tests ```bash cd Source/NetPigeon.BugBug.MSTest dotnet test ``` MSTest uses `[TestClass]` and `[TestMethod]` attributes to mark tests. #### Run xUnit Tests ```bash cd Source/NetPigeon.BugBug.Xunit dotnet test ``` xUnit uses `[Fact]` attribute to mark test methods. ### Adding New Features 1. Define entities and enums in `Core` layer 2. Create repository interfaces and implementations in `Data` layer 3. Create Controller in `Web` layer 4. Register new repository services in `Program.cs` 5. Add corresponding unit tests in test projects ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details ## Contributing Issues and Pull Requests are welcome! ## Contact For questions or suggestions, please contact us through: - Submit GitHub Issue - Send email to: support@bugbug.com --- **Note**: This project is for learning and reference purposes only. Please perform security hardening and performance optimization based on actual needs in production environments.