@velocitycareerlabs/tests-helpers 1.21.0-dev-build.14ffbd911 → 1.21.0-dev-build.103f31b32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/tests-helpers",
3
- "version": "1.21.0-dev-build.14ffbd911",
3
+ "version": "1.21.0-dev-build.103f31b32",
4
4
  "description": "Generic helpers for tests",
5
5
  "repository": "https://github.com/velocitycareerlabs/packages",
6
6
  "main": "index.js",
@@ -21,13 +21,13 @@
21
21
  "@fastify/swagger-ui": "~1.9.2",
22
22
  "@spencejs/spence-events": "^0.10.2",
23
23
  "@spencejs/spence-mongo-repos": "^0.10.2",
24
- "@velocitycareerlabs/common-functions": "1.21.0-dev-build.14ffbd911",
25
- "@velocitycareerlabs/common-schemas": "1.21.0-dev-build.14ffbd911",
26
- "@velocitycareerlabs/crypto": "1.21.0-dev-build.14ffbd911",
27
- "@velocitycareerlabs/fastify-plugins": "1.21.0-dev-build.14ffbd911",
28
- "@velocitycareerlabs/jwt": "1.21.0-dev-build.14ffbd911",
29
- "@velocitycareerlabs/logger": "1.21.0-dev-build.14ffbd911",
30
- "@velocitycareerlabs/rest-queries": "1.21.0-dev-build.14ffbd911",
24
+ "@velocitycareerlabs/common-functions": "1.21.0-dev-build.103f31b32",
25
+ "@velocitycareerlabs/common-schemas": "1.21.0-dev-build.103f31b32",
26
+ "@velocitycareerlabs/crypto": "1.21.0-dev-build.103f31b32",
27
+ "@velocitycareerlabs/fastify-plugins": "1.21.0-dev-build.103f31b32",
28
+ "@velocitycareerlabs/jwt": "1.21.0-dev-build.103f31b32",
29
+ "@velocitycareerlabs/logger": "1.21.0-dev-build.103f31b32",
30
+ "@velocitycareerlabs/rest-queries": "1.21.0-dev-build.103f31b32",
31
31
  "ajv-formats": "2.1.1",
32
32
  "dotenv": "^16.0.0",
33
33
  "env-var": "^7.0.0",
@@ -54,5 +54,5 @@
54
54
  "nanoid": "~3.3.1",
55
55
  "prettier": "~2.8.8"
56
56
  },
57
- "gitHead": "f82dded62b4abe9d0f268463f6fda393ac70e60f"
57
+ "gitHead": "6942a06ab4dcc2cb29d6ada263abdd3643a18377"
58
58
  }
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
-
16
+ const { includes } = require('lodash/fp');
17
17
  const env = require('env-var');
18
18
 
19
19
  const buildMongoConnection = (dbName) => {
@@ -26,10 +26,21 @@ const buildMongoConnection = (dbName) => {
26
26
  const mongoUsername = env.get('MONGO_USERNAME').default('').asString();
27
27
  const mongoPassword = env.get('MONGO_PASSWORD').default('').asString();
28
28
  const caFilename = env.get('CA_FILENAME').default('').asString();
29
+ const testMongoBaseUri = env
30
+ .get('TEST_MONGO_BASE_URI')
31
+ .default('')
32
+ .asString();
29
33
 
30
34
  // Uses tlsAllowInvalidHostnames to allow localhost SSH tunnleing to remote DB
31
- const connUri = `mongodb://${mongoUsername}:${mongoPassword}@localhost:27017/${dbName}`;
32
- const connOptions = `tls=true&tlsCAFile=${caFilename}&tlsAllowInvalidHostnames=true&retryWrites=false&directConnection=true`;
35
+ const connUri =
36
+ testMongoBaseUri !== ''
37
+ ? `${testMongoBaseUri}/${dbName}`
38
+ : `mongodb://${mongoUsername}:${mongoPassword}@localhost:27017/${dbName}`;
39
+ const directConnection = includes('mongodb+srv', testMongoBaseUri)
40
+ ? ''
41
+ : '&directConnection=true';
42
+ const tlsCaFileOption = caFilename !== '' ? `&tlsCAFile=${caFilename}` : '';
43
+ const connOptions = `tls=true${tlsCaFileOption}&tlsAllowInvalidHostnames=true&retryWrites=false${directConnection}`;
33
44
 
34
45
  return `${connUri}?${connOptions}`;
35
46
  };