refacto: add build and cleanup file structure
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
# Test Organization
|
||||
|
||||
Tests are organized in the `tests/` directory:
|
||||
|
||||
- **00_setup.sql** - Common setup (organizations, roles, users, activities, views)
|
||||
- **01_authorization.sql** - Basic authorization tests
|
||||
- **02_hierarchies.sql** - Role, org, activity, view hierarchy tests
|
||||
- **03_delegation.sql** - Role delegation tests
|
||||
- **04_constraints.sql** - SoD and cardinality constraint tests
|
||||
- **05_temporal.sql** - Temporal validity tests
|
||||
- **06_cross_org.sql** - Cross-organization access tests
|
||||
- **07_audit.sql** - Audit logging tests
|
||||
- **08_admin.sql** - Administration permission tests
|
||||
- **09_utilities.sql** - Utility function tests
|
||||
|
||||
## Running Tests
|
||||
|
||||
```bash
|
||||
# Run all tests (creates temp database, runs tests, cleans up)
|
||||
make test
|
||||
|
||||
# Run tests manually with persistent database
|
||||
createdb morbac_test
|
||||
./tests/run_tests.sh morbac_test
|
||||
# Database remains for inspection
|
||||
dropdb morbac_test # when done
|
||||
|
||||
# Run individual test file
|
||||
psql -d morbac_test -f tests/01_authorization.sql
|
||||
```
|
||||
|
||||
## Test Data
|
||||
|
||||
All tests use common setup from `00_setup.sql`:
|
||||
|
||||
**Organizations:**
|
||||
- Acme Corp (11111111-1111-1111-1111-111111111111)
|
||||
- Beta Inc (22222222-2222-2222-2222-222222222222)
|
||||
- Acme Subsidiary (child of Acme Corp)
|
||||
|
||||
**Test Users:**
|
||||
- Alice: aaaaaaaa-0000-0000-0000-000000000001 (admin at Acme)
|
||||
- Bob: bbbbbbbb-0000-0000-0000-000000000002 (employee at Acme)
|
||||
- Charlie: cccccccc-0000-0000-0000-000000000003 (contractor at Acme, staff at Beta)
|
||||
- Dave: dddddddd-0000-0000-0000-000000000004 (manager at Beta)
|
||||
- Eve: eeeeeeee-0000-0000-0000-000000000005 (viewer at Acme)
|
||||
|
||||
**Activities:** read, write, delete, manage, export, approve
|
||||
|
||||
**Views:** documents, reports, confidential_data, public_data, financial_records, projects
|
||||
@@ -1,46 +0,0 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# Test Runner for morbac_pg Extension
|
||||
# =============================================================================
|
||||
# Runs all tests in order, loading setup data and executing each test file.
|
||||
# Usage: ./run_tests.sh [database_name]
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Database name (default: morbac_test)
|
||||
DB="${1:-morbac_test}"
|
||||
TEST_DIR="$(dirname "$0")"
|
||||
|
||||
echo "======================================"
|
||||
echo "morbac_pg Extension Test Suite"
|
||||
echo "======================================"
|
||||
echo "Database: $DB"
|
||||
echo ""
|
||||
|
||||
# Install extension
|
||||
echo "=== Installing Extension ==="
|
||||
psql -d "$DB" -f "$TEST_DIR/../morbac_pg.sql"
|
||||
|
||||
# Load common setup
|
||||
echo ""
|
||||
echo "=== Loading Test Setup ==="
|
||||
psql -d "$DB" -f "$TEST_DIR/00_setup.sql"
|
||||
|
||||
# Run all test files in order
|
||||
echo ""
|
||||
echo "=== Running Tests ==="
|
||||
|
||||
for test_file in "$TEST_DIR"/[0-9][0-9]_*.sql; do
|
||||
if [ -f "$test_file" ]; then
|
||||
test_name=$(basename "$test_file" .sql)
|
||||
echo ""
|
||||
echo "--- Running: $test_name ---"
|
||||
psql -d "$DB" -f "$test_file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "======================================"
|
||||
echo "All Tests Completed"
|
||||
echo "======================================"
|
||||
Reference in New Issue
Block a user