Skip to content

Commit bb63d7d

Browse files
Merge pull request #4851 from linuxfoundation/unicron-v3-apis-test-coverage-dev-5
Unicron v3 apis test coverage dev 5
2 parents 814382b + c5eadcf commit bb63d7d

File tree

281 files changed

+11493
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+11493
-17
lines changed

tests/functional/cypress/e2e/v3/company.cy.ts

Lines changed: 575 additions & 0 deletions
Large diffs are not rendered by default.

tests/functional/cypress/e2e/v4/projects.cy.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,11 @@ describe('To Validate & get projects Activity Callback via API call', function (
379379
method: 'GET',
380380
url: `${claBaseEndpoint}project-info/${badProjectSFID}`,
381381
expectedStatusLocal: 422,
382-
expectedStatusRemote: 401,
382+
expectedStatusRemote: 422,
383383
expectedCodeLocal: 604,
384-
expectedCodeRemote: 401,
384+
expectedCodeRemote: 604,
385385
expectedMessageLocal: 'projectSFID in path should be at least 15 chars long',
386-
expectedMessageRemote: 'unauthenticated for invalid credentials',
386+
expectedMessageRemote: 'projectSFID in path should be at least 15 chars long',
387387
expectedMessageContainsLocal: false,
388388
expectedMessageContainsRemote: false,
389389
},
@@ -414,10 +414,7 @@ describe('To Validate & get projects Activity Callback via API call', function (
414414
method: 'GET',
415415
url: `${claBaseEndpoint}project-info/${exampleProjectSFID}`,
416416
expectedStatusLocal: 200,
417-
expectedStatusRemote: 401,
418-
expectedCodeRemote: 401,
419-
expectedMessageRemote: 'unauthenticated for invalid credentials',
420-
expectedMessageContainsRemote: false,
417+
expectedStatusRemote: 200,
421418
},
422419
];
423420

@@ -434,6 +431,7 @@ describe('To Validate & get projects Activity Callback via API call', function (
434431
if (c.body) opts.body = c.body;
435432

436433
cy.request(opts).then((response) => {
434+
cy.task('log', `title: ${c.title}`);
437435
return cy.logJson('response', response).then(() => {
438436
const es = local
439437
? (c.expectedStatusLocal ?? c.expectedStatus)

tests/functional/cypress/support/commands.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,27 @@ export function validate_expected_status(
161161
) {
162162
if (expectedStatus !== undefined && expectedStatus !== null) {
163163
const status = response.status ?? response.Status;
164-
expect(String(status)).to.eq(String(expectedStatus));
164+
if (Array.isArray(expectedStatus)) {
165+
expect(status).to.be.oneOf(expectedStatus);
166+
} else {
167+
expect(String(status)).to.eq(String(expectedStatus));
168+
}
165169
}
166170

167171
const statusText = response.statusText ?? response.StatusText;
172+
const actualStatus = response.status ?? response.Status;
168173

169-
if (expectedStatus === 400) {
174+
if (actualStatus === 400) {
170175
expect(statusText).to.eq('Bad Request');
171-
} else if (expectedStatus === 401) {
176+
} else if (actualStatus === 401) {
172177
expect(statusText).to.eq('Unauthorized');
173-
} else if (expectedStatus === 403) {
178+
} else if (actualStatus === 403) {
174179
expect(statusText).to.eq('Forbidden');
175-
} else if (expectedStatus === 404) {
180+
} else if (actualStatus === 404) {
176181
expect(statusText).to.eq('Not Found');
177-
} else if (expectedStatus === 405) {
182+
} else if (actualStatus === 405) {
178183
expect(statusText).to.eq('Method Not Allowed');
179-
} else if (expectedStatus === 422) {
184+
} else if (actualStatus === 422) {
180185
expect(statusText).to.eq('Unprocessable Entity');
181186
}
182187

utils/final_api_coverage_report.sh

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
3+
# Final comprehensive API coverage report for both V3 and V4 APIs
4+
# This script generates a complete summary of API test coverage
5+
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
8+
9+
echo "========================================"
10+
echo " EASYCLA API COVERAGE FINAL REPORT"
11+
echo "========================================"
12+
echo ""
13+
echo "Project root: $PROJECT_ROOT"
14+
echo "Generated on: $(date)"
15+
echo ""
16+
17+
# Change to project root for proper execution
18+
cd "$PROJECT_ROOT"
19+
20+
echo "=== V3 API Coverage Analysis ==="
21+
./utils/v3/check_api_coverage_v3.sh
22+
v3_result=$?
23+
echo ""
24+
25+
echo "=== V4 API Coverage Analysis ==="
26+
./utils/v4/check_api_coverage_v4.sh
27+
v4_result=$?
28+
echo ""
29+
30+
echo "=== Cypress Test Files Coverage ==="
31+
echo "V3 Cypress test files:"
32+
ls -1 tests/functional/cypress/e2e/v3/*.cy.ts | sed 's|.*/||' | sort
33+
echo ""
34+
echo "V4 Cypress test files:"
35+
ls -1 tests/functional/cypress/e2e/v4/*.cy.ts | sed 's|.*/||' | sort
36+
echo ""
37+
38+
echo "=== Script Counts ==="
39+
v3_scripts=$(find utils/v3 -name "*.sh" -not -path "*/shared/*" | wc -l)
40+
v4_scripts=$(find utils/v4 -name "*.sh" -not -path "*/shared/*" | wc -l)
41+
echo "V3 API scripts: $v3_scripts"
42+
echo "V4 API scripts: $v4_scripts"
43+
echo "Total scripts: $((v3_scripts + v4_scripts))"
44+
echo ""
45+
46+
echo "=== Directory Structure ==="
47+
echo "V3 API directories:"
48+
find utils/v3 -type d -not -path "*/shared" | grep -v "^utils/v3$" | sort
49+
echo ""
50+
echo "V4 API directories:"
51+
find utils/v4 -type d -not -path "*/shared" | grep -v "^utils/v4$" | sort
52+
echo ""
53+
54+
echo "=== Testing Quick Syntax Check ==="
55+
v3_syntax_errors=$(find utils/v3 -name "*.sh" -not -path "*/shared/*" -exec bash -n {} \; 2>&1 | wc -l)
56+
v4_syntax_errors=$(find utils/v4 -name "*.sh" -not -path "*/shared/*" -exec bash -n {} \; 2>&1 | wc -l)
57+
58+
echo "V3 scripts syntax errors: $v3_syntax_errors"
59+
echo "V4 scripts syntax errors: $v4_syntax_errors"
60+
echo ""
61+
62+
echo "=== API URL Configuration ==="
63+
echo "V3 shared config: utils/v3/shared/handle_api_url.sh"
64+
echo "V4 shared config: utils/v4/shared/handle_api_url.sh"
65+
echo ""
66+
67+
echo "=== Test Script Verification ==="
68+
echo "Testing a few key scripts..."
69+
70+
echo -n "V3 health endpoint: "
71+
if ./utils/v3/health/get_health.sh 2>&1 | grep -q '"Branch"'; then
72+
echo "✓ Working"
73+
else
74+
echo "✗ Failed"
75+
fi
76+
77+
echo -n "V4 health endpoint: "
78+
if ./utils/v4/health/get_health.sh 2>&1 | grep -q '"Branch"'; then
79+
echo "✓ Working"
80+
else
81+
echo "✗ Failed"
82+
fi
83+
84+
echo -n "V3 version endpoint: "
85+
if ./utils/v3/version/get_version.sh 2>&1 | grep -q '"branch"'; then
86+
echo "✓ Working"
87+
else
88+
echo "✗ Failed"
89+
fi
90+
91+
echo -n "V4 version endpoint: "
92+
if ./utils/v4/version/get_version.sh 2>&1 | grep -q '"branch"'; then
93+
echo "✓ Working"
94+
else
95+
echo "✗ Failed"
96+
fi
97+
98+
echo ""
99+
100+
echo "=== Summary ==="
101+
if [ $v3_result -eq 0 ] && [ $v4_result -eq 0 ] && [ $v3_syntax_errors -eq 0 ] && [ $v4_syntax_errors -eq 0 ]; then
102+
echo "🎉 ALL TESTS PASSED! 🎉"
103+
echo ""
104+
echo "✓ V3 APIs: 100% coverage"
105+
echo "✓ V4 APIs: 100% coverage"
106+
echo "✓ All scripts have valid syntax"
107+
echo "✓ API URL handling implemented for both local and remote modes"
108+
echo "✓ Comprehensive test coverage with Cypress tests"
109+
echo ""
110+
echo "The project now has complete API test coverage with shell scripts"
111+
echo "for all V3 and V4 endpoints, organized by swagger tags."
112+
echo ""
113+
echo "Usage examples:"
114+
echo " Local mode: ./utils/v3/health/get_health.sh"
115+
echo " Remote mode: REMOTE=1 ./utils/v3/health/get_health.sh"
116+
echo " With auth: TOKEN=\"\$(cat ./token.secret)\" XACL=\"\$(cat ./x-acl.secret)\" ./utils/v3/users/get_user.sh user_id"
117+
exit 0
118+
else
119+
echo "❌ SOME ISSUES FOUND"
120+
echo ""
121+
echo "V3 coverage: $([ $v3_result -eq 0 ] && echo '✓ PASS' || echo '✗ FAIL')"
122+
echo "V4 coverage: $([ $v4_result -eq 0 ] && echo '✓ PASS' || echo '✗ FAIL')"
123+
echo "V3 syntax: $([ $v3_syntax_errors -eq 0 ] && echo '✓ PASS' || echo "✗ FAIL ($v3_syntax_errors errors)")"
124+
echo "V4 syntax: $([ $v4_syntax_errors -eq 0 ] && echo '✓ PASS' || echo "✗ FAIL ($v4_syntax_errors errors)")"
125+
exit 1
126+
fi
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
# Comprehensive test script for all V3 and V4 shell scripts
3+
# Usage: ./test_all_scripts_comprehensive.sh [v3|v4|all]
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
7+
8+
VERSION="${1:-all}"
9+
ERRORS=0
10+
TESTED=0
11+
12+
echo "=========================================="
13+
echo "Comprehensive API Script Testing"
14+
echo "=========================================="
15+
echo "Version: ${VERSION}"
16+
echo "Project Root: ${PROJECT_ROOT}"
17+
echo ""
18+
19+
# Test function for a single script
20+
test_script() {
21+
local script_path="$1"
22+
local script_name="$(basename "$script_path")"
23+
local relative_path="${script_path#$PROJECT_ROOT/}"
24+
25+
echo -n "Testing: $relative_path ... "
26+
27+
# Skip test runner scripts
28+
if [[ "$script_name" == test_* ]]; then
29+
echo "SKIPPED (test runner)"
30+
return 0
31+
fi
32+
33+
# Test local mode
34+
if timeout 30 "$script_path" > /dev/null 2>&1; then
35+
echo -n "LOCAL:OK "
36+
else
37+
echo -n "LOCAL:FAIL "
38+
((ERRORS++))
39+
fi
40+
41+
# Test remote mode
42+
if timeout 30 REMOTE=1 "$script_path" > /dev/null 2>&1; then
43+
echo "REMOTE:OK"
44+
else
45+
echo "REMOTE:FAIL"
46+
((ERRORS++))
47+
fi
48+
49+
((TESTED++))
50+
}
51+
52+
# Test V3 scripts
53+
if [[ "$VERSION" == "v3" || "$VERSION" == "all" ]]; then
54+
echo "=========================================="
55+
echo "Testing V3 Scripts"
56+
echo "=========================================="
57+
58+
for script in $(find "${PROJECT_ROOT}/utils/v3" -name "*.sh" -type f | sort); do
59+
test_script "$script"
60+
done
61+
62+
echo ""
63+
fi
64+
65+
# Test V4 scripts
66+
if [[ "$VERSION" == "v4" || "$VERSION" == "all" ]]; then
67+
echo "=========================================="
68+
echo "Testing V4 Scripts"
69+
echo "=========================================="
70+
71+
for script in $(find "${PROJECT_ROOT}/utils/v4" -name "*.sh" -type f | sort); do
72+
test_script "$script"
73+
done
74+
75+
echo ""
76+
fi
77+
78+
echo "=========================================="
79+
echo "Test Summary"
80+
echo "=========================================="
81+
echo "Scripts tested: $TESTED"
82+
echo "Errors: $ERRORS"
83+
84+
if [[ $ERRORS -eq 0 ]]; then
85+
echo "✓ All scripts passed!"
86+
exit 0
87+
else
88+
echo "$ERRORS scripts failed"
89+
exit 1
90+
fi

0 commit comments

Comments
 (0)