name: Pull Request Tests # Run tests on pull requests to master and when pushing to PRs on: pull_request: branches: - master push: branches-ignore: - master jobs: test: name: Run Tests runs-on: ubuntu-latest strategy: matrix: node-version: [18.x, 20.x, 22.x] steps: - name: Checkout code uses: actions/checkout@v4 # The test suite (require('../app')) needs a real LDAP directory + # Redis, seeded with the schema/groups the app expects -- the bundled # all-in-one image already does exactly that (docker-entrypoint.sh), # so build and run it here rather than reimplementing LDAP setup as # a separate CI-only script. - name: Build LDAP+Redis test image run: docker build -f Dockerfile.openldap -t sso-test:latest . - name: Start LDAP+Redis test container run: | mkdir -p /tmp/sso-test-config cp secrets.js.example /tmp/sso-test-config/sso-secrets.js docker run -d --name sso-test \ -p 389:389 -p 6379:6379 -p 3001:3001 \ -v /tmp/sso-test-config:/config:ro \ sso-test:latest for i in $(seq 1 30); do status=$(docker inspect --format='{{.State.Health.Status}}' sso-test 2>/dev/null || echo starting) [ "$status" = "healthy" ] && break sleep 2 done docker inspect --format='{{.State.Health.Status}}' sso-test # tests/setup.js logs in as uid 'test'; several suites (group/otp/ # impersonate/cache) assume a second, non-admin user 'wmantly' already # exists (documented in those test files: "wmantly is always present # in the test LDAP"). Seed both here so CI matches that assumption. - name: Seed test fixtures run: | HASH_TEST=$(timeout 20 docker exec sso-test node -e "console.log(require('/app/models/user_ldap.js').hashPasswordSSHA512('MyTestPassword!2'))" | tail -1) HASH_WMANTLY=$(timeout 20 docker exec sso-test node -e "console.log(require('/app/models/user_ldap.js').hashPasswordSSHA512('WmantlyPass!2'))" | tail -1) cat > /tmp/seed.ldif <