Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.

Commit 639943b

Browse files
authored
feat!: remove datatype validation code COMPASS-4550 (#341)
1 parent 9f285d2 commit 639943b

File tree

6 files changed

+7
-65
lines changed

6 files changed

+7
-65
lines changed

lib/connection-collection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { each } = require('lodash');
55
const raf = require('raf');
66

77
/**
8-
* The name of a remote electon application that
8+
* The name of a remote electron application that
99
* uses `connection-model` as a dependency.
1010
*/
1111
let appName;

lib/data-types.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

lib/model.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const AmpersandModel = require('ampersand-model');
1616
const AmpersandCollection = require('ampersand-rest-collection');
1717
const { ReadPreference } = require('mongodb');
1818
const { parseConnectionString } = require('mongodb/lib/core');
19-
const dataTypes = require('./data-types');
2019
const localPortGenerator = require('./local-port-generator');
2120

2221
/**
@@ -81,7 +80,7 @@ assign(props, {
8180
ns: { type: 'string', default: undefined },
8281
isSrvRecord: { type: 'boolean', default: false },
8382
hostname: { type: 'string', default: 'localhost' },
84-
port: { type: 'port', default: 27017 },
83+
port: { type: 'number', default: 27017 },
8584
hosts: {
8685
type: 'array',
8786
default: () => [{ host: 'localhost', port: 27017 }]
@@ -371,11 +370,11 @@ assign(props, {
371370
/**
372371
* The SSH port of the remote host.
373372
*/
374-
sshTunnelPort: { type: 'port', default: 22 },
373+
sshTunnelPort: { type: 'number', default: 22 },
375374
/**
376375
* Bind the localhost endpoint of the SSH Tunnel to this port.
377376
*/
378-
sshTunnelBindToLocalPort: { type: 'port', default: undefined },
377+
sshTunnelBindToLocalPort: { type: 'number', default: undefined },
379378
/**
380379
* The optional SSH username for the remote host.
381380
*/
@@ -770,7 +769,6 @@ Connection = AmpersandModel.extend({
770769
props,
771770
derived,
772771
session,
773-
dataTypes,
774772
initialize(attrs) {
775773
if (attrs) {
776774
if (typeof attrs === 'string') {

test/build-uri.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,12 +954,12 @@ describe('Connection model builder', () => {
954954
expect(error.message).to.equal('The \'Password\' field is required when using \'Username/Password\' or \'SCRAM-SHA-256\' for authentication.');
955955
});
956956

957-
it('should generate the local port when using a ssh tunne and bind to local port does not exist', () => {
957+
it('should generate the local port when using a ssh tunnel and bind to local port does not exist', () => {
958958
const c = new Connection();
959959

960960
c.sshTunnel = 'USER_PASSWORD';
961961
c.sshTunnelHostname = '123.45.67.89';
962-
c.sshTunnelPort = '22';
962+
c.sshTunnelPort = 22;
963963
c.sshTunnelUsername = 'user';
964964
c.sshTunnelPassword = 'pass';
965965

test/connect.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('connection model connector', () => {
8989
it('should close ssh tunnel if the connection fails', (done) => {
9090
const model = new MockConnection({
9191
hostname: 'localhost',
92-
port: '27020',
92+
port: 27020,
9393
sshTunnel: 'USER_PASSWORD',
9494
sshTunnelHostname: 'my.ssh-server.com',
9595
sshTunnelPassword: 'password',

test/ssh-tunnel.test.js

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,6 @@ describe('sshTunnel', function () {
3535

3636
assert.equal(c.sshTunnelPort, 22);
3737
});
38-
39-
it('should cast an empty string to the default', () => {
40-
const c = new Connection({ sshTunnelPort: '' });
41-
42-
assert.equal(c.sshTunnelPort, 22);
43-
});
44-
45-
it('should cast an empty string to the default when updating', () => {
46-
const c = new Connection({});
47-
48-
c.set({ sshTunnelPort: '' });
49-
assert.equal(c.sshTunnelPort, 22);
50-
});
51-
52-
it('should not allow negative numbers', () => {
53-
assert.throws(
54-
() => {
55-
/* eslint no-new:0 */
56-
new Connection({ sshTunnelPort: -22 });
57-
},
58-
TypeError,
59-
/must be positive/
60-
);
61-
});
62-
63-
it('should not allow values above the max port number value', () => {
64-
assert.throws(
65-
() => {
66-
/* eslint no-new:0 */
67-
new Connection({ sshTunnelPort: 27017 * 10000 });
68-
},
69-
TypeError,
70-
/must be below/
71-
);
72-
});
7338
});
7439

7540
describe('NONE', () => {

0 commit comments

Comments
 (0)