step2_controller_test.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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', 'array');
  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. }
  50. return App.ServiceConfigProperty.create({name: name, value: value, isRequiredByAgent: true, filename: 'some-site.xml'});
  51. };
  52. var tests = [
  53. {
  54. stepConfigs: [
  55. ['realm', ' SPACES ', 'host'],
  56. ['admin_server_host', ' space_left', 'host'],
  57. ['kdc_host', ' space_left_and_right ', 'host'],
  58. ['ldap_url', 'space_right ', 'host']
  59. ],
  60. e: {
  61. realm: 'SPACES',
  62. admin_server_host: 'space_left',
  63. kdc_host: 'space_left_and_right',
  64. ldap_url: 'space_right'
  65. }
  66. }
  67. ];
  68. tests.forEach(function(test) {
  69. describe('Should trim values for properties ' + Em.keys(test.e).join(','), function() {
  70. var result;
  71. beforeEach(function () {
  72. sinon.stub(App.StackService, 'find').returns([Em.Object.create({serviceName: 'KERBEROS'})]);
  73. controller.set('stepConfigs', [
  74. App.ServiceConfig.create({
  75. configs: test.stepConfigs.map(function(item) { return _createProperty(item[0], item[1], item[2]); })
  76. })
  77. ]);
  78. result = controller.createKerberosSiteObj('some-site', 'random-tag');
  79. });
  80. afterEach(function () {
  81. App.StackService.find.restore();
  82. });
  83. Em.keys(test.e).forEach(function(propertyName) {
  84. it(propertyName, function () {
  85. expect(result.properties[propertyName]).to.be.eql(test.e[propertyName]);
  86. });
  87. });
  88. });
  89. });
  90. });
  91. });