step2_controller_test.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var setups = require('test/init_model_test');
  20. function getController() {
  21. return App.KerberosWizardStep2Controller.create({});
  22. }
  23. describe('App.KerberosWizardStep2Controller', function() {
  24. App.TestAliases.testAsComputedAlias(getController(), 'isBackBtnDisabled', 'testConnectionInProgress', 'boolean');
  25. App.TestAliases.testAsComputedAlias(getController(), 'hostNames', 'App.allHostNames');
  26. App.TestAliases.testAsComputedAlias(getController(), 'isConfigsLoaded', 'wizardController.stackConfigsLoaded', 'boolean');
  27. describe('#createKerberosSiteObj', function() {
  28. var controller;
  29. beforeEach(function() {
  30. setups.setupStackVersion(this, 'HDP-2.3');
  31. controller = getController();
  32. sinon.stub(controller, 'tweakKdcTypeValue', Em.K);
  33. sinon.stub(controller, 'tweakManualKdcProperties', Em.K);
  34. });
  35. after(function() {
  36. setups.restoreStackVersion(this);
  37. controller.tweakKdcTypeValue.restore();
  38. controller.tweakManualKdcProperties.restore();
  39. });
  40. var _createProperty = function(name, value, displayType) {
  41. var preDefProp = App.config.get('preDefinedSiteProperties').findProperty('name', name);
  42. if (preDefProp) {
  43. return App.ServiceConfigProperty.create(
  44. $.extend(true, {}, preDefProp, {
  45. value: value, filename: 'some-site.xml',
  46. 'displayType': displayType,
  47. isRequiredByAgent: preDefProp.isRequiredByAgent == undefined ? true : preDefProp.isRequiredByAgent
  48. }));
  49. } else {
  50. return App.ServiceConfigProperty.create({name: name, value: value, isRequiredByAgent: true, filename: 'some-site.xml'});
  51. }
  52. };
  53. var tests = [
  54. {
  55. stepConfigs: [
  56. ['realm', ' SPACES ', 'host'],
  57. ['admin_server_host', ' space_left', 'host'],
  58. ['kdc_host', ' space_left_and_right ', 'host'],
  59. ['ldap_url', 'space_right ', 'host']
  60. ],
  61. e: {
  62. realm: 'SPACES',
  63. admin_server_host: 'space_left',
  64. kdc_host: 'space_left_and_right',
  65. ldap_url: 'space_right'
  66. }
  67. }
  68. ];
  69. tests.forEach(function(test) {
  70. describe('Should trim values for properties ' + Em.keys(test.e).join(','), function() {
  71. var result;
  72. beforeEach(function () {
  73. sinon.stub(App.StackService, 'find').returns([Em.Object.create({serviceName: 'KERBEROS'})]);
  74. controller.set('stepConfigs', [
  75. App.ServiceConfig.create({
  76. configs: test.stepConfigs.map(function(item) { return _createProperty(item[0], item[1], item[2]); })
  77. })
  78. ]);
  79. result = controller.createKerberosSiteObj('some-site', 'random-tag');
  80. });
  81. afterEach(function () {
  82. App.StackService.find.restore();
  83. });
  84. Em.keys(test.e).forEach(function(propertyName) {
  85. it(propertyName, function () {
  86. expect(result.properties[propertyName]).to.be.eql(test.e[propertyName]);
  87. });
  88. });
  89. });
  90. });
  91. });
  92. });