Skip to content

feat: add E2E sandbox tests and regenerate-iam endpoint - #25

Merged
neuromechanist merged 7 commits into
devfrom
feature/e2e-sandbox-tests
Jan 17, 2026
Merged

neuromechanist merged 7 commits into
devfrom
feature/e2e-sandbox-tests

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Jan 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add E2E sandbox tests that install CLI from npm and run real commands
  • Add admin endpoint to regenerate IAM credentials for existing users
  • Add sandbox restrictions: file size limit (10MB) and DOI blocking
  • Update test workflow to run E2E tests on PRs
  • Add sandbox upload support to e2e-upload tests

Changes

E2E Sandbox Tests (test/e2e-sandbox.test.ts)

Tests that install CLI from npm (PR tag or dev) and run:

  • nemar --version and --help
  • nemar auth status
  • nemar dataset validate on sample BIDS dataset
  • nemar dataset list and --mine
  • nemar sandbox --help

E2E Upload Tests (test/e2e-upload.test.ts)

  • Added TEST_SANDBOX_DATASET_ID env var to target specific sandbox dataset
  • Added TEST_CREATE_SANDBOX env var to enable actual sandbox uploads
  • Default behavior remains dry-run only (safe for CI)

Test Workflow (.github/workflows/test.yml)

  • Added e2e-sandbox job on PRs
  • Waits for npm publish before installing CLI
  • Installs Deno for BIDS validation
  • Added warning annotation for fallback to dev tag

Admin Endpoint (backend/src/routes/admin.ts)

  • POST /admin/regenerate-iam/:username
  • Regenerates IAM credentials for existing users
  • Restores access to all existing datasets

Sandbox Restrictions

  • File size limit: Sandbox datasets limited to 10MB total (backend/src/routes/datasets.ts)
  • DOI blocking: Cannot create/publish DOIs for sandbox datasets (backend/src/routes/admin.ts)

Related

Addresses items from #16

Test plan

  • E2E tests run on this PR (all 8 pass)
  • Type checking passes
  • PR review findings addressed
  • Manually test regenerate-iam endpoint
  • Test sandbox file size limit with large files
  • Test DOI blocking on sandbox datasets

E2E Tests:
- Add e2e-sandbox.test.ts that installs CLI from npm and tests
- Update test workflow to run on PRs to dev and main
- Test basic CLI commands, validation, and sandbox training

Admin Endpoint:
- Add POST /admin/regenerate-iam/:username endpoint
- Regenerates IAM credentials for existing users
- Restores access to all existing datasets
- Useful for fixing IAM setup issues or rotating credentials

API:
- Add regenerateUserIam function to CLI API lib
@github-actions

github-actions Bot commented Jan 17, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR25

Version: 0.2.8-PR25.9658980
Commit: 9658980


🤖 Updated on each push.

- Fix config directory path (nemar-cli -> nemar)
- Fix config key name (apiToken -> apiKey)
- Add username to config for --mine filter
- Simplify BIDS dataset to minimal valid structure
- Add Deno setup to e2e-sandbox job for BIDS validation
- Add retry loop to wait for npm publish before installing
- Add stderr output on test failures for debugging
- Limit sandbox datasets to 10MB total file size
- Return 400 error if sandbox file size exceeds limit
- Block DOI concept creation for sandbox datasets (xx prefix)
- Block DOI version publishing for sandbox datasets
- Sandbox datasets are for testing only, not real data storage
@neuromechanist

Copy link
Copy Markdown
Contributor Author

PR Review Findings

Critical Issues

1. Silent workflow fallback to dev tag (.github/workflows/test.yml)

  • The npm package wait loop falls back to dev tag without surfacing this as a visible warning
  • This could mask npm-publish failures and give false confidence that PR changes were tested

2. Swallowed IAM revocation errors (backend/src/routes/admin.ts)

  • The catch block in regenerate-iam catches ALL errors including decrypt failures
  • Decrypt failures indicate data corruption and should be handled differently

High Severity Issues

3. Empty catch block in test cleanup (test/e2e-sandbox.test.ts)

  • Violates NO EMPTY CATCH policy from project rules
  • Hides actual cleanup failure reasons

4. Missing datasets_restored in TypeScript interface (src/lib/api.ts)

  • Backend returns this field but client interface doesn't include it
  • Causes type mismatch

Test Coverage Gaps

5. New backend features lack API tests:

  • POST /admin/regenerate-iam/:username - untested
  • Sandbox DOI blocking - untested
  • Sandbox file size validation - untested

Positive Observations

  • Good test structure following NO MOCKS policy
  • Proper Zod validation
  • Audit logging in admin endpoints
  • Defensive sandbox checks (both is_sandbox flag and xx prefix)

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Resolutions

Addressing the review findings:

Fixed in this PR:

  1. Workflow fallback warning - Added ::warning:: annotation so the fallback is visible in PR checks

  2. Empty catch block - Now logs actual error message in cleanup

  3. TypeScript interface - Added missing datasets_restored field to RegenerateIamResponse

Deferred to follow-up:

  1. IAM revocation error handling - The current behavior (continue on failure) is intentional for regeneration. Will add better logging to distinguish decrypt vs IAM failures.

  2. API tests for new backend features - The PR body already notes these as manual test items. Will add automated tests in a follow-up PR.

Separate issue raised by user:

  1. e2e-upload should use sandbox datasets - The current tests only use --dry-run. For actual upload testing, we should target sandbox datasets (xx prefix) to avoid creating real datasets on every push to main. Will update the test to support a TEST_SANDBOX_DATASET_ID parameter.

- Add warning annotation for workflow fallback to dev tag
- Log actual error in test cleanup catch block
- Add missing datasets_restored field to RegenerateIamResponse
- Add TEST_SANDBOX_DATASET_ID env var to target specific sandbox dataset
- Add TEST_CREATE_SANDBOX env var to enable actual sandbox uploads
- Add test for sandbox upload with xx prefix datasets
- Default behavior remains dry-run only (safe for CI)
@neuromechanist
neuromechanist merged commit 4d3894b into dev Jan 17, 2026
@neuromechanist
neuromechanist deleted the feature/e2e-sandbox-tests branch January 17, 2026 17:57
@neuromechanist neuromechanist linked an issue Jan 17, 2026 that may be closed by this pull request
11 tasks

This branch was previously deployed

1 inactive deployment
npm — 9658980c Deployed Jan 17, 2026 by neuromechanist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: sandbox environment for testing dataset uploads

1 participant