You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Navigate to /register
2. Fill registration form (email, password, confirm)
3. Click "Create Account"
4. Verify redirect to login
5. Login with credentials
6. Verify logged-in state
2. Product Search & Purchase
1. Navigate to /browse
2. Search for "IoT Sensor"
3. Click on product result
4. Verify product details page loads
5. Click "Add to Cart"
6. Navigate to /cart
7. Click "Checkout"
8. Fill checkout form
9. Verify order confirmation page
3. Admin Product Management
1. Login as admin
2. Navigate to /admin/products
3. Click "Add Product"
4. Fill product form
5. Click "Submit"
6. Verify product appears in product list
7. Edit product details
8. Verify changes saved
@TestpublicvoidtestSQLInjectionPrevention() {
// Attempt SQL injectionStringmaliciousInput = "' OR '1'='1";
// This should fail safelyUseruser = userService.findByEmail(maliciousInput);
assertNull(user);
}
@TestpublicvoidtestXSSPrevention() {
// Attempt XSS attackStringxssPayload = "<script>alert('XSS')</script>";
Productproduct = newProduct(1, xssPayload, xssPayload, 99.99);
// Verify script is escaped in HTML outputStringhtmlOutput = productDAO.getProductHtml(product);
assertTrue(htmlOutput.contains("<script>"));
assertFalse(htmlOutput.contains("<script>"));
}
@TestpublicvoidtestCSRFTokenValidation() throwsException {
mockMvc.perform(post("/checkout")
.param("amount", "99.99")
// Missing CSRF token
).andExpect(status().isForbidden());
}
Accessibility Testing
WCAG 2.1 Compliance
Criterion
Test
Status
Color Contrast
Minimum 4.5:1 ratio
✅ Pass
Keyboard Navigation
All functions accessible via keyboard
✅ Pass
Screen Reader
Page readable by assistive tech
✅ Pass
Text Alternatives
Alt text on all images
✅ Pass
Form Labels
Proper label associations
✅ Pass
Accessibility Test Example
<!-- ✅ GOOD - Proper labels --><labelfor="email">Email:</label><inputtype="email" id="email" name="email" required><!-- ✅ GOOD - Alt text --><imgsrc="product.jpg" alt="Red IoT Sensor Device"><!-- ✅ GOOD - ARIA attributes --><buttonaria-label="Add to cart" class="add-btn"><iclass="icon-cart"></i></button><!-- ❌ BAD - Missing label --><inputtype="email" placeholder="Email"><!-- ❌ BAD - No alt text --><imgsrc="product.jpg">
Test Execution
Running Tests
# Run all tests
mvn test# Run specific test class
mvn test -Dtest=ProductServiceTest
# Run tests matching pattern
mvn test -Dtest=*Service*# Run with coverage report
mvn test jacoco:report
# View coverage report
open target/site/jacoco/index.html
# Run E2E tests separately
mvn test -Dgroups=e2e
# Skip tests (faster build)
mvn clean install -DskipTests