You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add extra e2e test safety improvements (production fail-safe, test DB credentials, AI agent rules) (#951)
* feat: add production fail-safe checks, test DB credential separation, and AI agent safety rules
- Add NODE_ENV=production and DATABASE_URL production-indicator checks
to tests/global-setup.js and tests/test-db-clean.js
- Support DB_USER_TEST / DB_PASS_TEST env vars for least-privilege
test database credential separation
- Add Database Safety Rules section to AGENTS.md and AI-GETTING-STARTED.md
- Create .cursorrules with database safety guidelines for AI agents
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* chore: bump version to 4.3.26-20260427 [version bump]
* remove .cursorrules — not used
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* fix: handle promise rejection from clean() safety checks
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* fix: remove DATABASE_URL check, update error wording, require explicit test creds in test-db-clean
- Remove DATABASE_URL production check (no such ENV exists)
- Change 'destructive test operations' to 'test operations' in error message
- test-db-clean.js now requires DB_USER_TEST/DB_PASS_TEST with no fallback
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* feat: add mmgis-stac-test DB isolation and STAC_DB_NAME env var
- Make STAC DB name configurable via STAC_DB_NAME in API/connection.js
and scripts/init-db.js (defaults to 'mmgis-stac')
- global-setup.js creates mmgis-stac-test when STAC services are enabled
and passes STAC_DB_NAME to the test server
- Adjacent server .env files rewritten to use mmgis-stac-test
- test-db-clean.js drops mmgis-stac-test alongside mmgis-test
- Add DB_USER_TEST, DB_PASS_TEST, STAC_DB_NAME to sample.env and ENVs.md
- Update safety rules in AGENTS.md and AI-GETTING-STARTED.md
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* fix: comment out empty env vars in sample.env, fix STAC cleanup independence
- Comment out DB_USER_TEST, DB_PASS_TEST, STAC_DB_NAME in sample.env to
prevent dotenv from setting them to empty/whitespace values
- Fix early return in test-db-clean.js so mmgis-stac-test cleanup runs
independently of whether mmgis-test exists
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* fix: move test env vars to Optional Variables section in ENVs.md
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* fix: require DB_USER_TEST/DB_PASS_TEST in global-setup.js (no fallback)
- Remove fallback to DB_USER/DB_PASS in global-setup.js credential resolution
- Add DB_USER_TEST/DB_PASS_TEST to CI workflow .env setup
- Update ENVs.md to reflect these are now required for tests
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* fix: remove STAC_DB_NAME env var, hardcode mmgis-stac and mmgis-stac-test
- Revert API/connection.js to hardcoded 'mmgis-stac'
- Revert scripts/init-db.js to hardcoded 'mmgis-stac'
- Test infrastructure uses hardcoded 'mmgis-stac-test' constant
- Remove STAC_DB_NAME from sample.env and ENVs.md
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* fix: update sample.env comment — test creds required in both files, no fallback
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
* fix: add windowsHide to suppress console windows on Windows
Prevents execSync and spawn calls in global-setup.js from flashing
empty terminal windows on Windows machines.
Co-Authored-By: tariq.k.soliman <tariqksoliman@gmail.com>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -717,6 +717,18 @@ ws.on("message", function (message) {
717
717
- Review `webpack.config.js` for misconfigurations
718
718
- Check Node.js version (requires 20+)
719
719
720
+
## Database Safety Rules for AI Agents
721
+
722
+
When writing or modifying code that interacts with the database, AI agents MUST follow these rules:
723
+
724
+
1.**NEVER use `DROP DATABASE` in application code.** The only place `DROP DATABASE` is permitted is in `tests/test-db-clean.js`, and only against the hardcoded `mmgis-test` and `mmgis-stac-test` databases.
725
+
2.**NEVER use `DROP TABLE` or `TRUNCATE TABLE` without proper authorization checks** and input sanitization via `Utils.forceAlphaNumUnder()`.
726
+
3.**NEVER hardcode production database names, hosts, or credentials** in test files or scripts.
727
+
4.**ALWAYS use the dedicated test databases** (`mmgis-test` and `mmgis-stac-test`) for any test-related database operations. Never modify the test database name constants.
728
+
5.**ALWAYS use `DB_USER_TEST` / `DB_PASS_TEST`** environment variables for test database credentials when available, to maintain least-privilege separation.
729
+
6.**NEVER remove or weaken** the `NODE_ENV === 'production'` safety checks in test setup files (`tests/global-setup.js`, `tests/test-db-clean.js`).
730
+
7. When writing database-related tests, **never use destructive commands** like `DROP` or `TRUNCATE` on the main schema. Always target the `mmgis-test` (or `mmgis-stac-test` for STAC) database and implement environment safety checks.
Copy file name to clipboardExpand all lines: AI-GETTING-STARTED.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,3 +144,17 @@ All options are documented in `sample.env`. The critical ones:
144
144
- Test files are located in `tests/e2e/`.
145
145
- The accessibility test (`tests/e2e/accessibility.spec.js`) scans the landing page and map interface for WCAG 2.1 AA violations.
146
146
- Use `npm run test:headed` to see tests run in a visible browser, or `npm run test:debug` to step through tests interactively.
147
+
148
+
---
149
+
150
+
## 9. Database Safety Rules for AI Agents
151
+
152
+
When writing or modifying code that interacts with the database, AI agents MUST follow these rules:
153
+
154
+
1.**NEVER use `DROP DATABASE` in application code.** The only place `DROP DATABASE` is permitted is in `tests/test-db-clean.js`, and only against the hardcoded `mmgis-test` and `mmgis-stac-test` databases.
155
+
2.**NEVER use `DROP TABLE` or `TRUNCATE TABLE` without proper authorization checks** and input sanitization via `Utils.forceAlphaNumUnder()`.
156
+
3.**NEVER hardcode production database names, hosts, or credentials** in test files or scripts.
157
+
4.**ALWAYS use the dedicated test databases** (`mmgis-test` and `mmgis-stac-test`) for any test-related database operations. Never modify the test database name constants.
158
+
5.**ALWAYS use `DB_USER_TEST` / `DB_PASS_TEST`** environment variables for test database credentials when available, to maintain least-privilege separation.
159
+
6.**NEVER remove or weaken** the `NODE_ENV === 'production'` safety checks in test setup files (`tests/global-setup.js`, `tests/test-db-clean.js`).
160
+
7. When writing database-related tests, **never use destructive commands** like `DROP` or `TRUNCATE` on the main schema. Always target the `mmgis-test` (or `mmgis-stac-test` for STAC) database and implement environment safety checks.
Copy file name to clipboardExpand all lines: docs/pages/Setup/ENVs/ENVs.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,14 @@ If `DB_SSL=true` and if needed, the path to a certificate for ssl | string | def
105
105
106
106
Alternatively, if `DB_SSL=true` and if needed, a base64 encoded certificate for ssl. `DB_SSL_CERT_BASE64` will take priority over `DB_SSL_CERT` | string | default `null`
107
107
108
+
#### `DB_USER_TEST=`
109
+
110
+
Test-specific database user. Required by test infrastructure (`tests/global-setup.js`, `tests/test-db-clean.js`) for least-privilege separation. No fallback — tests will not run without this | string | default `null`
111
+
112
+
#### `DB_PASS_TEST=`
113
+
114
+
Test-specific database password. Required by test infrastructure for least-privilege separation. No fallback — tests will not run without this | string | default `null`
115
+
108
116
#### `AUTH_LOCAL_ALLOW_SIGNUP=`
109
117
110
118
If AUTH=local and set to true, this allows all guests to the site to create user accounts otherwise, they just see a login page with no signup section | boolean | default `false`
0 commit comments