OWASP / OWASP/SecurityShepherd
Modernize MongoDatabase off legacy com.mongodb.DB API + Testcontainers; rescue disabled MongoDatabaseIT tests
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.5k
- Forks
- 515
- Avg merge
- 3h 46m
- Merged PRs (30d)
- 1
Description
Summary
Two integration tests in src/it/java/dbProcs/MongoDatabaseIT.java are @Disabled and need rescuing:
getMongoDatabase_ShouldReturnTypeDBgetMongoDatabase_ReadDbName
They cover MongoDatabase.getMongoDatabase(mongoClient) — that it returns a DB and reads the configured db name (test_shepherdGames).
Why they're disabled
Timeline traced from git history:
- 2022-03-15 (
cf57dbfd) — written and passing against Fongo (insrc/test/.../MongoDatabaseTest.java). - 2026-03-28 (
f059bb58, "fix: CI pipeline... #801") — moved unit → integration (MongoDatabaseIT.java) and these two tests@Disabled. - 2026-05-30 (
c47c52f5, "feat: add connection pooling... #816") — reason string reworded.
Root cause: Fongo 2.1.1 is incompatible with mongo-java-driver:3.12.14 (NPE in createOperationExecutor). Fongo is unmaintained (last master commit ~2020) and is being dropped entirely in #861.
Why this is its own issue (not part of #861)
#861 is purely the javax.* → jakarta.* namespace migration. Rescuing these tests requires:
- Bumping
mongo-java-driver3.12.14 → 5.x, and - Rewriting
MongoDatabase.getMongoDatabaseoff the legacycom.mongodb.DBAPI (removed in driver 4.x) onto the modernMongoDatabasetype.
That's a production-code change + a major driver upgrade with no relation to the Jakarta namespace. Folding it into #861 would bloat the migration PR and hurt reviewability.
Proposed approach (best practice)
Use Testcontainers MongoDBContainer — the current ecosystem-recommended way to test Mongo in Java (Spring Boot 3 dropped Flapdoodle in favour of Testcontainers; Fongo is effectively deprecated). Requires Docker available in CI.
Work items
- Bump
org.mongodbdriver 3.12.14 → 5.x. - Modernize
MongoDatabase.getMongoDatabaseand callers off the removedcom.mongodb.DBAPI. - Add
org.testcontainers:mongodb(test scope); ensure CI has Docker. - Re-enable the two tests, restoring the original 2022 assertions:
getMongoDatabase_ShouldReturnTypeDB→ returns a Mongo database instance.getMongoDatabase_ReadDbName→ db name equalstest_shepherdGames.
- Remove the
@Disabledannotations and their reason strings.
Refs
- #861 (drops the dead Fongo dep; updates the
@Disabledreason to point here) - #801 (where the tests were disabled), #816
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/it/java/dbProcs/MongoDatabaseIT.java and the MongoDatabase.getMongoDatabase method and callers. Review the driver dependency and Testcontainers MongoDB setup first, then re-enable getMongoDatabase_ShouldReturnTypeDB and getMongoDatabase_ReadDbName; done means the modern database type is used and both assertions pass with test_shepherdGames.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mongodb
- Domain
- backend, databases, testing
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100