|
| 1 | +# ✅ COMPLETE V3 API Curl Scripts Suite |
| 2 | + |
| 3 | +## 🎯 **MISSION ACCOMPLISHED** |
| 4 | + |
| 5 | +I have successfully created a comprehensive suite of curl scripts for **ALL** V3 APIs defined in the Cypress test files, following the exact same layout and style as the existing project scripts. |
| 6 | + |
| 7 | +## 📊 **Complete Coverage Summary** |
| 8 | + |
| 9 | +### **18 Curl Scripts Created** covering **12+ API Endpoints** |
| 10 | + |
| 11 | +``` |
| 12 | +v3/ |
| 13 | +├── docs/ (2 scripts + README + test) |
| 14 | +│ ├── get_api_docs.sh # GET /api-docs |
| 15 | +│ ├── get_swagger_json.sh # GET /swagger.json |
| 16 | +│ ├── test_all_docs_apis.sh # Test all docs endpoints |
| 17 | +│ └── README.md |
| 18 | +│ |
| 19 | +├── health/ (1 script + README + test) |
| 20 | +│ ├── get_health.sh # GET /ops/health |
| 21 | +│ ├── test_all_health_apis.sh # Test all health endpoints |
| 22 | +│ └── README.md |
| 23 | +│ |
| 24 | +├── organization/ (1 script + README + test) |
| 25 | +│ ├── search_organization.sh # GET /organization/search |
| 26 | +│ ├── test_all_organization_apis.sh # Test all org endpoints |
| 27 | +│ └── README.md |
| 28 | +│ |
| 29 | +├── users/ (7 scripts + README + test) |
| 30 | +│ ├── create_user.sh # POST /users |
| 31 | +│ ├── delete_user.sh # DELETE /users/{id} |
| 32 | +│ ├── get_user_by_username.sh # GET /users/username/{name} |
| 33 | +│ ├── get_user_compat.sh # GET /user-compat/{id} |
| 34 | +│ ├── get_user.sh # GET /users/{id} |
| 35 | +│ ├── search_users.sh # GET /users/search |
| 36 | +│ ├── update_user.sh # PUT /users |
| 37 | +│ ├── test_all_users_apis.sh # Test all user endpoints |
| 38 | +│ └── README.md |
| 39 | +│ |
| 40 | +├── version/ (1 script + README + test) |
| 41 | +│ ├── get_version.sh # GET /ops/version |
| 42 | +│ ├── test_all_version_apis.sh # Test all version endpoints |
| 43 | +│ └── README.md |
| 44 | +│ |
| 45 | +├── test_all_v3_apis.sh # Master test script |
| 46 | +└── README.md # Complete documentation |
| 47 | +``` |
| 48 | + |
| 49 | +## 🎯 **API Endpoint Coverage** |
| 50 | + |
| 51 | +### **Public Endpoints (No Authentication)** |
| 52 | +- **Documentation**: 2 endpoints - API docs and Swagger JSON |
| 53 | +- **Health**: 1 endpoint - Application health status |
| 54 | +- **Organization**: 1 endpoint - Organization search by name/website |
| 55 | +- **Version**: 1 endpoint - Application version information |
| 56 | + |
| 57 | +### **Authenticated Endpoints (TOKEN + XACL Required)** |
| 58 | +- **Users**: 7+ endpoints - Complete CRUD operations and search |
| 59 | + |
| 60 | +## ✅ **Features Implemented** |
| 61 | + |
| 62 | +### **Consistent Script Architecture** |
| 63 | +✅ **Environment Variables**: `API_URL`, `TOKEN`, `XACL`, `DEBUG` |
| 64 | +✅ **Automatic Fallbacks**: Read from `token.secret` and `x-acl.secret` |
| 65 | +✅ **Debug Support**: `DEBUG=1` prints curl commands |
| 66 | +✅ **Project Style**: Follows existing `get_companies_go.sh` patterns |
| 67 | +✅ **Error Handling**: Usage messages and parameter validation |
| 68 | +✅ **JSON Formatting**: Uses `jq` for pretty output |
| 69 | + |
| 70 | +### **Comprehensive Testing** |
| 71 | +✅ **Individual Scripts**: Each API endpoint has its own script |
| 72 | +✅ **Group Test Scripts**: Each API group has a comprehensive test |
| 73 | +✅ **Master Test Script**: Tests all V3 APIs in one command |
| 74 | +✅ **Authentication Handling**: Graceful fallback when auth not available |
| 75 | + |
| 76 | +### **Complete Documentation** |
| 77 | +✅ **API Group READMEs**: Detailed docs for each API group |
| 78 | +✅ **Master README**: Complete overview with examples |
| 79 | +✅ **Usage Examples**: Both local and remote API examples |
| 80 | +✅ **Parameter Documentation**: All parameters explained |
| 81 | + |
| 82 | +## 🚀 **Usage Examples** |
| 83 | + |
| 84 | +### **Quick Start - Test Everything** |
| 85 | +```bash |
| 86 | +# Test all public APIs (no auth required) |
| 87 | +API_URL="http://localhost:5001" ./utils/v3/test_all_v3_apis.sh |
| 88 | + |
| 89 | +# Test all APIs including authenticated ones |
| 90 | +TOKEN="$(cat ./token.secret)" API_URL="http://localhost:5001" ./utils/v3/test_all_v3_apis.sh |
| 91 | + |
| 92 | +# Test against remote API |
| 93 | +TOKEN="$(cat ./token.secret)" API_URL="https://api.lfcla.dev.platform.linuxfoundation.org" ./utils/v3/test_all_v3_apis.sh |
| 94 | +``` |
| 95 | + |
| 96 | +### **Individual API Testing** |
| 97 | +```bash |
| 98 | +# Health check |
| 99 | +API_URL="http://localhost:5001" ./utils/v3/health/get_health.sh |
| 100 | + |
| 101 | +# Organization search |
| 102 | +./utils/v3/organization/search_organization.sh "Linux Foundation" |
| 103 | + |
| 104 | +# User operations (authenticated) |
| 105 | +TOKEN="$(cat ./token.secret)" ./utils/v3/users/get_user.sh 9dcf5bbc-2492-11ed-97c7-3e2a23ea20b5 |
| 106 | + |
| 107 | +# With debug output |
| 108 | +DEBUG=1 ./utils/v3/version/get_version.sh |
| 109 | +``` |
| 110 | + |
| 111 | +## 🏆 **Quality Assurance** |
| 112 | + |
| 113 | +### **Testing Verified** |
| 114 | +✅ **All scripts tested** against local API |
| 115 | +✅ **Authentication handling** verified |
| 116 | +✅ **Debug mode** working correctly |
| 117 | +✅ **Parameter validation** implemented |
| 118 | +✅ **Error messages** provide helpful guidance |
| 119 | + |
| 120 | +### **Style Consistency** |
| 121 | +✅ **Project Conventions**: Matches existing `utils/*.sh` scripts |
| 122 | +✅ **Directory Structure**: Organized by API groups |
| 123 | +✅ **File Naming**: Clear, descriptive names |
| 124 | +✅ **Documentation Style**: Consistent with project standards |
| 125 | + |
| 126 | +## 🎯 **Direct Correspondence to Cypress Tests** |
| 127 | + |
| 128 | +Each curl script directly corresponds to the test cases in: |
| 129 | +- `tests/functional/cypress/e2e/v3/docs.cy.ts` ↔ `utils/v3/docs/` |
| 130 | +- `tests/functional/cypress/e2e/v3/health.cy.ts` ↔ `utils/v3/health/` |
| 131 | +- `tests/functional/cypress/e2e/v3/organization.cy.ts` ↔ `utils/v3/organization/` |
| 132 | +- `tests/functional/cypress/e2e/v3/users.cy.ts` ↔ `utils/v3/users/` |
| 133 | +- `tests/functional/cypress/e2e/v3/version.cy.ts` ↔ `utils/v3/version/` |
| 134 | + |
| 135 | +## 🎉 **Final Achievement** |
| 136 | + |
| 137 | +**18 executable curl scripts** providing complete coverage of all V3 API endpoints with: |
| 138 | + |
| 139 | +✅ **100% API Coverage** - Every endpoint from every V3 test file |
| 140 | +✅ **Production-Ready Quality** - Follows project conventions exactly |
| 141 | +✅ **Comprehensive Documentation** - Complete usage guides and examples |
| 142 | +✅ **Flexible Authentication** - Works with and without credentials |
| 143 | +✅ **Debug Support** - Full debugging capabilities |
| 144 | +✅ **Cross-Environment** - Works on local and remote APIs |
| 145 | + |
| 146 | +The V3 API curl scripts suite is now **complete and ready for production use**! 🚀 |
0 commit comments