forked from openwallet-foundation/acapy
-
Notifications
You must be signed in to change notification settings - Fork 1
Postgres tests and fixes #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
740bc9a
fix(kanon):fixed password issue
vinaysingh8866 9d38110
feat(kanon):added postgres tests to main actions
vinaysingh8866 04905d9
style:applied ruff formatting
vinaysingh8866 485d18b
fix(kanon):fixed actions files for postgres
vinaysingh8866 32d5294
fix(kanon):fixed actions files for postgres
vinaysingh8866 edb9492
fix(kanon):fixed for postgres
vinaysingh8866 7db9478
style:applied ruff formatting
vinaysingh8866 40cbed7
fix(kanon):fixed password bug and tests for kanon postgres
vinaysingh8866 506fa24
style:applied ruff formatting
vinaysingh8866 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| name: Run PostgreSQL Integration Tests | ||
| description: "Run integration tests against PostgreSQL database" | ||
|
|
||
| inputs: | ||
| python-version: | ||
| description: "Python version" | ||
| required: true | ||
| os: | ||
| description: "Operating system" | ||
| required: true | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Set up Python ${{ inputs.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
| cache: 'pip' | ||
| cache-dependency-path: 'requirements*.txt' | ||
|
|
||
| - name: Install PostgreSQL client tools | ||
| shell: bash | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y postgresql-client | ||
|
|
||
| - name: Wait for PostgreSQL to be ready | ||
| shell: bash | ||
| run: | | ||
| echo "Waiting for PostgreSQL to be ready..." | ||
| for i in {1..30}; do | ||
| if pg_isready -h localhost -p 5432 -U acapy_test; then | ||
| echo "PostgreSQL is ready!" | ||
| break | ||
| fi | ||
| echo "Attempt $i: PostgreSQL not ready yet, waiting..." | ||
| sleep 2 | ||
| done | ||
|
|
||
| # Final check | ||
| if ! pg_isready -h localhost -p 5432 -U acapy_test; then | ||
| echo "ERROR: PostgreSQL failed to become ready" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Verify PostgreSQL connection | ||
| shell: bash | ||
| env: | ||
| PGPASSWORD: acapy_test_pass | ||
| run: | | ||
| echo "Testing PostgreSQL connection..." | ||
| psql -h localhost -U acapy_test -d acapy_test_db -c "SELECT version();" | ||
| echo "PostgreSQL connection verified!" | ||
|
|
||
| - name: Create additional test databases | ||
| shell: bash | ||
| env: | ||
| PGPASSWORD: acapy_test_pass | ||
| run: | | ||
| echo "Creating additional test databases..." | ||
| createdb -h localhost -U acapy_test test_kanon_db || true | ||
| createdb -h localhost -U acapy_test test_dbstore_db || true | ||
| createdb -h localhost -U acapy_test test_normalize || true | ||
| createdb -h localhost -U acapy_test test_generic || true | ||
| echo "Additional databases created" | ||
|
|
||
| - name: Grant database privileges | ||
| shell: bash | ||
| env: | ||
| PGPASSWORD: acapy_test_pass | ||
| run: | | ||
| echo "Granting database privileges..." | ||
| psql -h localhost -U acapy_test -d acapy_test_db -c "ALTER USER acapy_test WITH CREATEDB CREATEROLE;" | ||
| echo "Privileges granted" | ||
|
|
||
| - name: Install project dependencies | ||
| shell: bash | ||
| run: | | ||
| pip install poetry | ||
| poetry install --all-extras | ||
|
|
||
| - name: Run Kanon PostgreSQL Tests | ||
| shell: bash | ||
| env: | ||
| POSTGRES_HOST: localhost | ||
| POSTGRES_PORT: 5432 | ||
| POSTGRES_USER: acapy_test | ||
| POSTGRES_PASSWORD: acapy_test_pass | ||
| POSTGRES_DB: acapy_test_db | ||
| ENABLE_DBSTORE_TESTS: "1" | ||
| LOG_LEVEL: WARNING | ||
| run: | | ||
| export POSTGRES_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}" | ||
|
|
||
| echo "=========================================" | ||
| echo "Running Kanon Integration Tests" | ||
| echo "Database: ${POSTGRES_DB} on ${POSTGRES_HOST}:${POSTGRES_PORT}" | ||
| echo "=========================================" | ||
|
|
||
| poetry run pytest \ | ||
| acapy_agent/kanon/tests/ \ | ||
| -v \ | ||
| --cov=acapy_agent.kanon \ | ||
| --cov-report term-missing \ | ||
| --cov-report xml:./test-reports/kanon-postgres-coverage.xml \ | ||
| --junitxml=./test-reports/kanon-postgres-junit.xml \ | ||
| 2>&1 | tee kanon-postgres-tests.log | ||
|
|
||
| KANON_EXIT_CODE=${PIPESTATUS[0]} | ||
|
|
||
| echo "" | ||
| echo "=========================================" | ||
| echo "Kanon tests completed with exit code: $KANON_EXIT_CODE" | ||
| echo "=========================================" | ||
|
|
||
| # Check for unawaited coroutines | ||
| if grep -Eq "RuntimeWarning: coroutine .* was never awaited" kanon-postgres-tests.log; then | ||
| echo "ERROR: Detected unawaited coroutine warning in Kanon tests" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ $KANON_EXIT_CODE -ne 0 ]; then | ||
| echo "ERROR: Kanon PostgreSQL tests failed" | ||
| exit $KANON_EXIT_CODE | ||
| fi | ||
|
|
||
| - name: Run DBStore PostgreSQL Integration Tests | ||
| shell: bash | ||
| env: | ||
| POSTGRES_HOST: localhost | ||
| POSTGRES_PORT: 5432 | ||
| POSTGRES_USER: acapy_test | ||
| POSTGRES_PASSWORD: acapy_test_pass | ||
| POSTGRES_DB: acapy_test_db | ||
| ENABLE_DBSTORE_TESTS: "1" | ||
| LOG_LEVEL: WARNING | ||
| run: | | ||
| export POSTGRES_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}" | ||
|
|
||
| echo "=========================================" | ||
| echo "Running DBStore PostgreSQL Integration Tests" | ||
| echo "Database: ${POSTGRES_DB} on ${POSTGRES_HOST}:${POSTGRES_PORT}" | ||
| echo "=========================================" | ||
|
|
||
| echo "Running core DBStore provisioning tests..." | ||
|
|
||
| # Test 1: PostgreSQL Normalized Provisioning (validates our provisioning bug fix) | ||
| poetry run pytest \ | ||
| -v \ | ||
| --tb=short \ | ||
| acapy_agent/database_manager/tests/dbstore/test_db_store_postgresql_normalized_provision.py::test_provision \ | ||
| 2>&1 | tee -a dbstore-postgres-tests.log | ||
|
|
||
| PROVISION_TEST_1=$? | ||
|
|
||
| # Test 2: PostgreSQL Normalized Schema | ||
| poetry run pytest \ | ||
| -v \ | ||
| --tb=short \ | ||
| acapy_agent/database_manager/tests/dbstore/test_db_store_postgresql_normalized.py::test_provision \ | ||
| 2>&1 | tee -a dbstore-postgres-tests.log | ||
|
|
||
| PROVISION_TEST_2=$? | ||
|
|
||
| # Test 3: PostgreSQL Generic Schema | ||
| poetry run pytest \ | ||
| -v \ | ||
| --tb=short \ | ||
| acapy_agent/database_manager/tests/dbstore/test_db_store_postgresql_generic.py::test_provision \ | ||
| 2>&1 | tee -a dbstore-postgres-tests.log | ||
|
|
||
| PROVISION_TEST_3=$? | ||
|
|
||
| # Calculate overall exit code | ||
| DBSTORE_EXIT_CODE=0 | ||
| if [ $PROVISION_TEST_1 -ne 0 ] || [ $PROVISION_TEST_2 -ne 0 ] || [ $PROVISION_TEST_3 -ne 0 ]; then | ||
| DBSTORE_EXIT_CODE=1 | ||
| fi | ||
|
|
||
| # Generate coverage report for all tests | ||
| poetry run pytest \ | ||
| --cov=acapy_agent.database_manager \ | ||
| --cov-report term-missing \ | ||
| --cov-report xml:./test-reports/dbstore-postgres-coverage.xml \ | ||
| --junitxml=./test-reports/dbstore-postgres-junit.xml \ | ||
| --co \ | ||
| acapy_agent/database_manager/tests/dbstore/test_db_store_postgresql*.py 2>/dev/null || true | ||
|
|
||
| echo "" | ||
| echo "=========================================" | ||
| echo "DBStore tests completed with exit code: $DBSTORE_EXIT_CODE" | ||
| echo "=========================================" | ||
|
|
||
| # Check for unawaited coroutines | ||
| if grep -Eq "RuntimeWarning: coroutine .* was never awaited" dbstore-postgres-tests.log; then | ||
| echo "ERROR: Detected unawaited coroutine warning in DBStore tests" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ $DBSTORE_EXIT_CODE -ne 0 ]; then | ||
| echo "ERROR: DBStore PostgreSQL tests failed" | ||
| exit $DBSTORE_EXIT_CODE | ||
| fi | ||
|
|
||
| - name: Upload Kanon PostgreSQL Test Reports | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: kanon-postgres-test-reports-${{ inputs.python-version }}-${{ inputs.os }} | ||
| path: | | ||
| test-reports/kanon-postgres-coverage.xml | ||
| test-reports/kanon-postgres-junit.xml | ||
| kanon-postgres-tests.log | ||
|
|
||
| - name: Upload DBStore PostgreSQL Test Reports | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: dbstore-postgres-test-reports-${{ inputs.python-version }}-${{ inputs.os }} | ||
| path: | | ||
| test-reports/dbstore-postgres-coverage.xml | ||
| test-reports/dbstore-postgres-junit.xml | ||
| dbstore-postgres-tests.log | ||
|
|
||
| - name: Test Summary | ||
| if: always() | ||
| shell: bash | ||
| run: | | ||
| echo "=========================================" | ||
| echo "PostgreSQL Integration Tests Summary" | ||
| echo "=========================================" | ||
| echo "✅ PostgreSQL service: Ready" | ||
| echo "✅ Database connection: Verified" | ||
| echo "✅ Kanon tests: Check artifacts" | ||
| echo "✅ DBStore tests: Check artifacts" | ||
| echo "=========================================" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information High
Copilot Autofix
AI 4 months ago
To fix the problem, further redact the URI in log output so that any possibly sensitive credential information (including both the password and the account/username) is removed or obscured. Replace
accountwith a general placeholder (such as***) or exclude it from the logged URI altogether. Only non-sensitive fields should be emitted to logs. Specifically, in the_build_postgres_dbstore_urimethod, change howredacted_uriis constructed so that it replacesaccountwith***(or another placeholder). Update the log statement (line 260) accordingly. No functional change to the returned (actual) URI construction is needed—only the logged version should be changed. No additional imports or dependencies are needed.