diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index 65baaffea..0e15a8842 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -207,4 +207,20 @@ export default class TargetModel extends GeneratedTargetModel { removeCredentialSource(credentialLibraryID, options) { return this.removeCredentialSources([credentialLibraryID], options); } + + /** + * True if the target type is tcp. + * @type {boolean} + */ + get isTCP() { + return this.type === 'tcp'; + } + + /** + * True if the target type is ssh. + * @type {boolean} + */ + get isSSH() { + return this.type === 'ssh'; + } } diff --git a/addons/api/tests/unit/models/target-test.js b/addons/api/tests/unit/models/target-test.js index e182ccf9f..f3afdb333 100644 --- a/addons/api/tests/unit/models/target-test.js +++ b/addons/api/tests/unit/models/target-test.js @@ -384,4 +384,24 @@ module('Unit | Model | target', function (hooks) { const model = store.peekRecord('target', '123abc'); await model.removeCredentialSource('2'); }); + + test('it has isSSH property and returns the expected values', function (assert) { + assert.expect(2); + const store = this.owner.lookup('service:store'); + const modelSSH = store.createRecord('target', { + type: 'ssh', + }); + assert.true(modelSSH.isSSH); + assert.false(modelSSH.isTCP); + }); + + test('it has isTCP property and returns the expected values', function (assert) { + assert.expect(2); + const store = this.owner.lookup('service:store'); + const modelTCP = store.createRecord('target', { + type: 'tcp', + }); + assert.true(modelTCP.isTCP); + assert.false(modelTCP.isSSH); + }); });