Repository: ambari Updated Branches: refs/heads/branch-feature-AMBARI-14714-ui 0b915f268 -> c72a3bff5
AMBARI-22569 - Implemented additional functionality on the Configure Download screen. (Jason Golieb via jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c72a3bff Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c72a3bff Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c72a3bff Branch: refs/heads/branch-feature-AMBARI-14714-ui Commit: c72a3bff5c56860f2fb2dc7e430c86ffd52945a3 Parents: 0b915f2 Author: Jonathan Hurley <[email protected]> Authored: Mon Dec 4 12:23:25 2017 -0500 Committer: Jonathan Hurley <[email protected]> Committed: Mon Dec 4 12:23:25 2017 -0500 ---------------------------------------------------------------------- .../ZEPPELIN/0.6.0.3.0/metainfo.xml | 103 +++++++++++++++ ambari-web/app/assets/test/tests.js | 2 + .../wizard/configureDownload_controller.js | 76 ++++------- ambari-web/app/messages.js | 14 +- ambari-web/app/routes/installer.js | 4 +- .../app/templates/wizard/configureDownload.hbs | 72 ++++++---- ambari-web/app/utils.js | 1 + ambari-web/app/utils/constants.js | 28 ++++ .../app/views/wizard/configureDownload_view.js | 79 +++++++---- .../wizard/configureDownload_test.js | 85 ++++++++++++ .../views/wizard/configureDownload_view_test.js | 132 +++++++++++++++++++ 11 files changed, 492 insertions(+), 104 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-server/src/main/resources/common-services/ZEPPELIN/0.6.0.3.0/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/ZEPPELIN/0.6.0.3.0/metainfo.xml b/ambari-server/src/main/resources/common-services/ZEPPELIN/0.6.0.3.0/metainfo.xml new file mode 100644 index 0000000..597b6db --- /dev/null +++ b/ambari-server/src/main/resources/common-services/ZEPPELIN/0.6.0.3.0/metainfo.xml @@ -0,0 +1,103 @@ +<?xml version="1.0"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<metainfo> + <schemaVersion>2.0</schemaVersion> + <services> + <service> + <name>ZEPPELIN</name> + <displayName>Zeppelin Notebook</displayName> + <comment>A web-based notebook that enables interactive data analytics. It enables you to + make beautiful data-driven, interactive and collaborative documents with SQL, Scala + and more. + </comment> + <version>0.6.0</version> + <components> + <component> + <name>ZEPPELIN_MASTER</name> + <displayName>Zeppelin Notebook</displayName> + <category>MASTER</category> + <cardinality>1</cardinality> + <versionAdvertised>true</versionAdvertised> + <commandScript> + <script>scripts/master.py</script> + <scriptType>PYTHON</scriptType> + <timeout>10000</timeout> + </commandScript> + <dependencies> + <dependency> + <name>SPARK/SPARK_CLIENT</name> + <scope>host</scope> + <auto-deploy> + <enabled>true</enabled> + </auto-deploy> + </dependency> + <dependency> + <name>YARN/YARN_CLIENT</name> + <scope>host</scope> + <auto-deploy> + <enabled>true</enabled> + </auto-deploy> + </dependency> + </dependencies> + <logs> + <log> + <logId>zeppelin</logId> + <primary>true</primary> + </log> + </logs> + </component> + </components> + + <osSpecifics> + <osSpecific> + <osFamily>any</osFamily> + <packages> + <package> + <name>zeppelin</name> + </package> + </packages> + </osSpecific> + </osSpecifics> + + <commandScript> + <script>scripts/service_check.py</script> + <scriptType>PYTHON</scriptType> + <timeout>300</timeout> + </commandScript> + + <requiredServices> + <service>HDFS</service> + </requiredServices> + + <configuration-dependencies> + <config-type>zeppelin-config</config-type> + <config-type>zeppelin-env</config-type> + <config-type>zeppelin-shiro-ini</config-type> + <config-type>zeppelin-log4j-properties</config-type> + </configuration-dependencies> + <restartRequiredAfterChange>true</restartRequiredAfterChange> + + <quickLinksConfigurations> + <quickLinksConfiguration> + <fileName>quicklinks.json</fileName> + <default>true</default> + </quickLinksConfiguration> + </quickLinksConfigurations> + </service> + </services> +</metainfo> http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index b60e17a..438a3ab 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -135,6 +135,7 @@ var files = [ 'test/controllers/login_controller_test', 'test/controllers/experimental_test', 'test/controllers/wizard_test', + 'test/controllers/wizard/configureDownload_test', 'test/controllers/wizard/selectMpacks_test', 'test/controllers/wizard/step0_test', 'test/controllers/wizard/step1_test', @@ -385,6 +386,7 @@ var files = [ 'test/views/wizard/step3/hostLogPopupBody_view_test', 'test/views/wizard/step3/hostWarningPopupBody_view_test', 'test/views/wizard/step3/hostWarningPopupFooter_view_test', + 'test/views/wizard/configureDownload_view_test', 'test/views/wizard/step0_view_test', 'test/views/wizard/step1_view_test', 'test/views/wizard/step2_view_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/app/controllers/wizard/configureDownload_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/configureDownload_controller.js b/ambari-web/app/controllers/wizard/configureDownload_controller.js index 0246ad0..08af960 100644 --- a/ambari-web/app/controllers/wizard/configureDownload_controller.js +++ b/ambari-web/app/controllers/wizard/configureDownload_controller.js @@ -22,63 +22,41 @@ App.WizardConfigureDownloadController = Em.Controller.extend({ name: 'wizardConfigureDownloadController', - optionsToSelect: { - 'usePublicRepo': { - index: 0, - isSelected: true - }, - 'useLocalRepo': { - index: 1, - isSelected: false, - 'uploadFile': { - index: 0, - name: 'uploadFile', - file: '', - hasError: false, - isSelected: true - }, - 'enterUrl': { - index: 1, - name: 'enterUrl', - url: '', - placeholder: Em.I18n.t('installer.step1.useLocalRepo.enterUrl.placeholder'), - hasError: false, - isSelected: false - } + loadStep: function () { + let downloadConfig = this.get('content.downloadConfig'); + if (!downloadConfig) { + this.set('content.downloadConfig', { + useRedHatSatellite: false, + useCustomRepo: false, + useProxy: false, + proxyUrl: null, + proxyAuth: null, + proxyTestPassed: false + }); } }, - loadStep: function () { - let downloadConfig = this.get('content.downloadConfig'); - //if (!this.get('content.downloadConfig')) { - //let downloadConfig = this.get('wizardController').getDBProperty('downloadConfig'); + usePublicRepo: function () { + this.set('content.downloadConfig.useCustomRepo', false); + this.set('content.downloadConfig.useRedHatSatellite', false); + }, - if (!downloadConfig) { - downloadConfig = { - useRedhatSatellite: false, - usePublicRepo: true - }; - } + useCustomRepo: function () { + this.set('content.downloadConfig.useCustomRepo', true); + }, - this.set('content.downloadConfig', downloadConfig); - //} + setProxyAuth: function (authType) { + this.set('content.downloadConfig.proxyAuth', authType); + this.proxySettingsChanged(); }, - /** - * Restore base urls for selected stack when user select to use public repository - */ - usePublicRepo: function () { - this.set('content.downloadConfig', { - useRedhatSatellite: false, - usePublicRepo: true - }); + proxySettingsChanged: function () { + this.set('content.downloadConfig.proxyTestPassed', false); }, - useLocalRepo: function () { - this.set('content.downloadConfig', { - useRedhatSatellite: false, - usePublicRepo: false - }); + proxyTest: function () { + //TODO: mpacks - implement test proxy connection + this.set('content.downloadConfig.proxyTestPassed', true); }, /** @@ -91,8 +69,6 @@ App.WizardConfigureDownloadController = Em.Controller.extend({ return; } - //this.get('wizardController').setDBProperty('downloadConfig', this.get('content.downloadConfig')); - App.router.send('next'); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index e014d4a..2efc023 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -636,16 +636,18 @@ Em.I18n.translations = { 'installer.configureDownload.body.title': 'How do you want to download your products?', 'installer.configureDownload.body.description': 'Using Public Repository requires an internet connection. Using local repository requires you have configured the software in a repository available on your network.', 'installer.configureDownload.publicRepo': 'Public Repository', - 'installer.configureDownload.localRepo': 'Local Repository', - 'installer.configureDownload.publicRepo.hoverDesc': 'Management Packs will be downloaded using the internet', - 'installer.configureDownload.localRepo.hoverDesc': 'Management Packs will be downloaded from the specified local repository', - + 'installer.configureDownload.customRepo': 'Local Repository', + 'installer.configureDownload.publicRepo.description': 'Management Packs will be downloaded using the internet', + 'installer.configureDownload.customRepo.description': 'Management Packs will be downloaded from the specified local repository', + 'installer.configureDownload.useProxy': 'Use Proxy', + 'installer.configureDownload.proxyUrl': 'Proxy URL', + 'installer.configureDownload.proxyUrl.placeholder': 'http://server:port', + 'installer.configureDownload.proxyAuth': 'Authentication', + 'installer.configureDownload.useRedHatSatellite': 'Use Red Hat Satellite/Spacewalk', 'installer.downloadProducts.header': 'Download Products', 'installer.downloadProducts.body.title': 'Downloading and validating Management Packs', 'installer.downloadProducts.body.description': 'Ambari is downloading the Management Packs and validating its contents', - - 'installer.step1.header':'Select Version', 'installer.step1.body':'Select the software version and method of delivery for your cluster.', 'installer.step1.repo.body':'Using a Public Repository requires Internet connectivity. Using a Local Repository requires you have configured the software in a repository available in your network.', http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/app/routes/installer.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js index 73c716b..80cf116 100644 --- a/ambari-web/app/routes/installer.js +++ b/ambari-web/app/routes/installer.js @@ -242,7 +242,9 @@ module.exports = Em.Route.extend(App.RouterRedirections, { var wizardStep3Controller = router.get('wizardStep3Controller'); controller.saveConfirmedHosts(wizardStep3Controller); if (!wizardStep3Controller.get('isSaved')) { - App.router.get('wizardSelectMpacksController').clearSelection(); + var wizardSelectMpacksController = App.router.get('wizardSelectMpacksController'); + wizardSelectMpacksController.set('wizardController', controller); + wizardSelectMpacksController.clearSelection(); controller.set('content.selectedServices', undefined); controller.set('content.selectedServiceNames', undefined); controller.set('content.selectedMpacks', undefined); http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/app/templates/wizard/configureDownload.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/wizard/configureDownload.hbs b/ambari-web/app/templates/wizard/configureDownload.hbs index b62a4d9..37842c2 100644 --- a/ambari-web/app/templates/wizard/configureDownload.hbs +++ b/ambari-web/app/templates/wizard/configureDownload.hbs @@ -21,35 +21,57 @@ <div class="panel panel-default"> <div class="panel-body"> {{#if App.router.nextBtnClickInProgress}} - {{view App.SpinnerView}} + {{view App.SpinnerView}} {{else}} - <form id="repoVersionInfoForm" class="form-horizontal" role="form" name="localVersionInfoForm" novalidate> - <div class="panel panel-default repos-panel"> - <div class="step-title"> - <p>{{t installer.configureDownload.body.title}}</p> + <div class="panel panel-default repos-panel"> + <div class="step-title"> + <p>{{t installer.configureDownload.body.title}}</p> + </div> + <p class="step-description">{{t installer.configureDownload.body.description}}</p> + <div class="panel-body version-contents-body"> + <div class="row radio-group"> + {{! Public Repo radio button }} + <div {{bindAttr class=":col-sm-4 :radio :big-radio :public-radio :wizard-plain-text controller.content.downloadConfig.usePublicRepo:repo-selected:repo-not-selected"}} {{action usePublicRepo target="controller"}}> + {{view App.RadioButtonView checkboxClassNames="repo-checkbox" selectionBinding="controller.content.downloadConfig.useCustomRepo" valueBinding="App.False"}} + <p>{{t installer.configureDownload.publicRepo.description}}</p> + <span class="glyphicon glyphicon-cloud-download icon"></span> + <div class="repo-group">{{t installer.configureDownload.publicRepo}}</div> </div> - <p class="step-description">{{t installer.configureDownload.body.description}}</p> - <div class="panel-body version-contents-body"> - <div class="row radio-group"> - {{! Public Repository radio }} - <div {{bindAttr class=":col-sm-4 :radio :big-radio :public-radio :wizard-plain-text controller.content.downloadConfig.usePublicRepo:repo-selected:repo-not-selected"}} {{action usePublicRepo target="controller"}}> - {{view view.usePublicRepoRadioButton classNames="repo-checkbox" labelIdentifier="use-public-repo"}} - <p>{{t installer.configureDownload.publicRepo.hoverDesc}}</p> - <i class="icon icon-cloud-download"></i> - <div class="repo-group">{{t installer.configureDownload.publicRepo}}</div> - </div> - {{!--Local repo radio--}} - {{!--Not allowing any action on Local Repository for the first iteration. Will use action useLocalRepo later when this option is allowed--}} - <div {{bindAttr class=":col-sm-4 :radio :big-radio :local-radio :wizard-plain-text controller.content.downloadConfig.usePublicRepo:repo-not-selected:repo-selected"}}> - {{view view.useLocalRepoRadioButton classNames="repo-checkbox" labelIdentifier="use-local-repo"}} - <p>{{t installer.configureDownload.localRepo.hoverDesc}}</p> - <i class="icon icon-tasks"></i> - <div class="repo-group">{{t installer.configureDownload.localRepo}}</div> - </div> - </div> + {{! Custom Repo radio button }} + <div {{bindAttr class=":col-sm-4 :radio :big-radio :local-radio :wizard-plain-text controller.content.downloadConfig.usePublicRepo:repo-not-selected:repo-selected"}} {{action useCustomRepo target="controller"}}> + {{view App.RadioButtonView checkboxClassNames="repo-checkbox" selectionBinding="controller.content.downloadConfig.useCustomRepo" valueBinding="App.True"}} + <p>{{t installer.configureDownload.customRepo.description}}</p> + <span class="glyphicon glyphicon-tasks icon"></span> + <div class="repo-group">{{t installer.configureDownload.customRepo}}</div> </div> </div> - </form> + {{! Red Hat Satellite checkbox }} + {{#if controller.content.downloadConfig.useCustomRepo}} + {{view App.CheckboxView id="useRedHat" checkedBinding="controller.content.downloadConfig.useRedHatSatellite" labelTranslate="installer.configureDownload.useRedHatSatellite" changeBinding="view.useRedHatSatelliteChanged"}} + {{/if}} + {{! Use Proxy checkbox }} + {{#unless controller.content.downloadConfig.useRedHatSatellite}} + {{view App.CheckboxView id="useProxy" checkedBinding="controller.content.downloadConfig.useProxy" labelTranslate="installer.configureDownload.useProxy" changeBinding="view.useProxyChanged"}} + {{#if controller.content.downloadConfig.useProxy}} + <form id="proxySettings"> + <div class="form-group"> + <label for="proxyUrl" class="control-label required">{{t installer.configureDownload.proxyUrl}}</label> + {{view Em.TextField id="proxyUrl" class="form-control" placeholderBinding="view.proxyUrlPlaceholder" valueBinding="controller.content.downloadConfig.proxyUrl" changeBinding="view.proxyUrlChanged"}} + </div> + <div class="form-group"> + <label for="proxyAuth" class="required">{{t installer.configureDownload.proxyAuth}}</label> + <select id="proxyAuth" class="form-control" {{action proxyAuthChanged on="change" target="view"}}> + {{#each option in view.proxyAuthOptions}} + <option {{bindAttr value="option.value" selected="option.selected"}}>{{option.label}}</option> + {{/each}} + </select> + </div> + <button type="button" id="proxyTest" class="btn btn-default" {{bindAttr disabled="controller.content.downloadConfig.proxyTestPassed"}} {{action proxyTest target="controller"}}>Test Connection</button> + </form> + {{/if}} + {{/unless}} + </div> + </div> {{/if}} </div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/app/utils.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils.js b/ambari-web/app/utils.js index 509efc1..7b919ed 100644 --- a/ambari-web/app/utils.js +++ b/ambari-web/app/utils.js @@ -23,6 +23,7 @@ require('utils/errors/assertions'); require('utils/base64'); require('utils/db'); require('utils/helper'); +require('utils/constants'); require('utils/config'); require('utils/configs/theme/theme'); require('utils/configs/config_initializer'); http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/app/utils/constants.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/constants.js b/ambari-web/app/utils/constants.js new file mode 100644 index 0000000..fcaca90 --- /dev/null +++ b/ambari-web/app/utils/constants.js @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + Common values that can be used throughout the application. +*/ +var App = require('app'); + +//These can be used, for example, to bind the Boolean values of true and false to element attributes in templates, +//which will enable comparisons against Boolean values from code to be performed correctly against the atttributes. +//(Otherwise, you would end up setting attributes to the string values "true" and "false", which both evaluate to Boolean true.) +App.False = false; +App.True = true; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/app/views/wizard/configureDownload_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/configureDownload_view.js b/ambari-web/app/views/wizard/configureDownload_view.js index 8a02c71..71c6527 100644 --- a/ambari-web/app/views/wizard/configureDownload_view.js +++ b/ambari-web/app/views/wizard/configureDownload_view.js @@ -23,33 +23,68 @@ App.WizardConfigureDownloadView = Em.View.extend({ templateName: require('templates/wizard/configureDownload'), + proxyAuthOptions: [ + Em.Object.create({ value: 0, label: 'None', selected: true }), + Em.Object.create({ value: 1, label: 'Option 1', selected: false }), + Em.Object.create({ value: 2, label: 'Option 2', selected: false }) + ], + + proxyUrlPlaceholder: Em.I18n.t('installer.configureDownload.proxyUrl.placeholder'), + didInsertElement: function () { this.get('controller').loadStep(); + + const selectedProxyAuth = this.get('controller.content.downloadConfig.proxyAuth'); + this.setProxyAuth(selectedProxyAuth, true); + }, + + useRedHatSatelliteChanged: function () { + this.set('controller.content.downloadConfig.useProxy', false); + const self = this.useProxyChanged ? this : this.get('parentView'); //parentView is actually just this view, but this function gets called from a sub-view on the template so we have to reference this way + self.useProxyChanged(); + }, + + useProxyChanged: function () { + this.set('controller.content.downloadConfig.proxyUrl', null); + const self = this.setProxyAuth ? this : this.get('parentView'); //parentView is actually just this view, but this function gets called from a sub-view on the template so we have to reference this way + self.setProxyAuth(0); + this.get('controller').proxySettingsChanged(); + }, + + proxyUrlChanged: function () { + this.get('controller').proxySettingsChanged(); }, - /** - * Radio button for use Public repo - * - * @type {App.RadioButtonView} - */ - usePublicRepoRadioButton: App.RadioButtonView.extend({ - checked: Em.computed.alias('controller.content.downloadConfig.usePublicRepo'), - change: function () { - this.get('controller').usePublicRepo(); + setProxyAuth: function (value, doNotUpdateController) { + const optionToSelect = this.get('proxyAuthOptions').filter(option => option.get('value') == value); + + if (optionToSelect.length > 0) { + let proxyAuthOptions = this.get('proxyAuthOptions'); + proxyAuthOptions.forEach(option => { + if (option.get('value') == value) { + option.set('selected', true); + } else { + option.set('selected', false); + } + }); + + if (!doNotUpdateController) { + this.get('controller').setProxyAuth(value); + } } - }), - - /** - * Checkbox for use Public repo - * - * @type {App.RadioButtonView} - */ - useLocalRepoRadioButton: App.RadioButtonView.extend({ - checked: Em.computed.alias('controller.content.downloadConfig.useLocalRepo'), - disabled: true, - change: function () { - this.get('controller').useLocalRepo(); + }, + + proxyAuthChanged: function (event) { + const selected = event.target.value; + this.setProxyAuth(selected); + this.get('controller').proxySettingsChanged(); + }, + + isSubmitDisabled: function () { + if (this.get('controller.content.downloadConfig.useProxy') && !this.get('controller.content.downloadConfig.proxyTestPassed')) { + return true; } - }) + return false; + }.property('controller.content.downloadConfig.useProxy', 'controller.content.downloadConfig.proxyTestPassed') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/test/controllers/wizard/configureDownload_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/configureDownload_test.js b/ambari-web/test/controllers/wizard/configureDownload_test.js new file mode 100644 index 0000000..0bc1dfd --- /dev/null +++ b/ambari-web/test/controllers/wizard/configureDownload_test.js @@ -0,0 +1,85 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); +var controller = App.WizardConfigureDownloadController.create(); + +describe('App.WizardConfigureDownloadController', function () { + + beforeEach(function () { + controller.set('content', { + downloadConfig: { + useRedHatSatellite: false, + useCustomRepo: false, + useProxy: false, + proxyUrl: null, + proxyAuth: null, + proxyTestPassed: false + } + }); + }) + + describe('#usePublicRepo', function () { + it('Sets useCustomRepo and useRedHatSatellite to false', function () { + controller.set('content.downloadConfig.useCustomRepo', true); + controller.set('content.downloadConfig.useRedHatSatellite', true); + + controller.usePublicRepo(); + + expect(controller.get('content.downloadConfig.useCustomRepo')).to.be.false; + expect(controller.get('content.downloadConfig.useRedHatSatellite')).to.be.false; + }); + }); + + describe('#useCustomRepo', function () { + it('Sets useCustomRepo to true', function () { + controller.useCustomRepo(); + + expect(controller.get('content.downloadConfig.useCustomRepo')).to.be.true; + }); + }); + + describe('#setProxyAuth', function () { + it('Sets proxyAuth to the value passed and calls proxySettingsChanged', function () { + var value = 1; + sinon.stub(controller, 'proxySettingsChanged'); + + controller.setProxyAuth(value); + + expect(controller.get('content.downloadConfig.proxyAuth')).to.equal(value); + expect(controller.proxySettingsChanged.called).to.be.true; + + controller.proxySettingsChanged.restore(); + }); + }); + + describe('#proxySettingsChanged', function () { + it('Sets proxyTestPassed to false', function () { + controller.set('content.downloadConfig.proxyTestPassed', true); + + controller.proxySettingsChanged(); + + expect(controller.get('content.downloadConfig.proxyTestPassed')).to.be.false; + }); + }); + + describe('#proxyTest', function () { + it('Should test the proxy connection'); + }); + +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/c72a3bff/ambari-web/test/views/wizard/configureDownload_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/wizard/configureDownload_view_test.js b/ambari-web/test/views/wizard/configureDownload_view_test.js new file mode 100644 index 0000000..63c68e0 --- /dev/null +++ b/ambari-web/test/views/wizard/configureDownload_view_test.js @@ -0,0 +1,132 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); +var controller = App.WizardConfigureDownloadController.create(); +var view = App.WizardConfigureDownloadView.create({ controller: controller }); + +describe('App.WizardConfigureDownloadView', function () { + + beforeEach(function () { + controller.set('content', { + downloadConfig: { + useRedHatSatellite: false, + useCustomRepo: false, + useProxy: false, + proxyUrl: null, + proxyAuth: null, + proxyTestPassed: false + } + }); + }) + + describe('#useRedHatSatelliteChanged', function () { + it('Sets useProxy to false and calls useProxyChanged', function () { + controller.set('content.downloadConfig.useProxy', true); + sinon.stub(view, 'useProxyChanged'); + + view.useRedHatSatelliteChanged(); + + expect(controller.get('content.downloadConfig.useProxy')).to.be.false; + expect(view.useProxyChanged.called).to.be.true; + + view.useProxyChanged.restore(); + }); + }); + + describe('#useProxyChanged', function () { + it('Sets proxyUrl to null, calls setProxyAuth, and calls proxySettingsChanged on the controller', function () { + controller.set('content.downloadConfig.proxyUrl', 'not null'); + controller.set('content.downloadConfig.proxyAuth', 1); + sinon.stub(view, 'setProxyAuth'); + sinon.stub(controller, 'proxySettingsChanged'); + + view.useProxyChanged(); + + expect(controller.get('content.downloadConfig.proxyUrl')).to.equal(null); + expect(view.setProxyAuth.called).to.be.true; + expect(controller.proxySettingsChanged.called).to.be.true; + + view.setProxyAuth.restore(); + controller.proxySettingsChanged.restore(); + }); + }); + + describe('#proxyUrlChanged', function () { + it('Calls proxySettingsChanged on the controller', function () { + sinon.stub(controller, 'proxySettingsChanged'); + + view.proxyUrlChanged(); + + expect(controller.proxySettingsChanged.called).to.be.true; + + controller.proxySettingsChanged.restore(); + }); + }); + + describe('#setProxyAuth', function () { + it('Sets the selected proxy authentication option in both the view and the controller', function () { + var value = 1; + sinon.stub(controller, 'setProxyAuth'); + + view.setProxyAuth(value); + + var selected = view.get('proxyAuthOptions').filterProperty('selected'); + + expect(selected.length).to.equal(1); + expect(selected[0].get('value')).to.equal(value); + expect(controller.setProxyAuth.called).to.be.true; + + controller.setProxyAuth.restore(); + }); + + it('Sets the selected proxy authentication option in just the view', function () { + var value = 1; + sinon.stub(controller, 'setProxyAuth'); + + view.setProxyAuth(value, true); + + var selected = view.get('proxyAuthOptions').filterProperty('selected'); + + expect(selected.length).to.equal(1); + expect(selected[0].get('value')).to.equal(value); + expect(controller.setProxyAuth.called).to.be.false; + + controller.setProxyAuth.restore(); + }); + }); + + describe('#proxyAuthChanged', function () { + it('Calls setProxyAuth() with the correct value and calls proxySettingsChanged on the controller', function () { + var value = 1; + var event = { target: { value: value } }; + + sinon.stub(view, 'setProxyAuth'); + sinon.stub(controller, 'proxySettingsChanged'); + + view.proxyAuthChanged(event); + + expect(view.setProxyAuth.calledWith(value)).to.be.true; + expect(controller.proxySettingsChanged.called).to.be.true; + + view.setProxyAuth.restore(); + controller.proxySettingsChanged.restore(); + }); + }); + +}); \ No newline at end of file
