diff --git a/index.js b/index.js index 09bb3fb..9355eb2 100644 --- a/index.js +++ b/index.js @@ -154,6 +154,17 @@ class ScmRouter extends Scm { return this.chooseScm(config).then(scm => scm.addWebhook(config)); } + /** + * Returns whether auto deploy key generation is enabled on or not + * @method _autoDeployKeyGenerationEnabled + * @param {Object} config Configuration + * @param {String} config.scmContext Name of scm context + * @return {Promise} Resolves when operation completed without failure + */ + _autoDeployKeyGenerationEnabled(config) { + return this.chooseScm(config).then(scm => scm.autoDeployKeyGenerationEnabled(config)); + } + /** * Parse the url for a repo for the specific source control * @method _addDeployKey diff --git a/test/index.test.js b/test/index.test.js index 8cb4e53..dc63389 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -38,6 +38,7 @@ describe('index test', () => { 'dummyRejectFunction', 'addWebhook', 'addDeployKey', + 'autoDeployKeyGenerationEnabled', 'parseUrl', 'parseHook', 'getCheckoutCommand', @@ -581,6 +582,25 @@ describe('index test', () => { }); }); + describe('_autoDeployKeyGenerationEnabled', () => { + const config = { scmContext: 'example.context' }; + + it('call origin autoDeployKeyGenerationEnabled', () => { + const scmGithub = scm.scms['github.context']; + const exampleScm = scm.scms['example.context']; + const scmGitlab = scm.scms['gitlab.context']; + + return scm._autoDeployKeyGenerationEnabled(config) + .then((result) => { + assert.strictEqual(result, 'example'); + assert.notCalled(scmGithub.autoDeployKeyGenerationEnabled); + assert.notCalled(scmGitlab.autoDeployKeyGenerationEnabled); + assert.calledOnce(exampleScm.autoDeployKeyGenerationEnabled); + assert.calledWith(exampleScm.autoDeployKeyGenerationEnabled, config); + }); + }); + }); + describe('_parseUrl', () => { const config = { scmContext: 'example.context' };