toggle_isrequired_test.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. describe('#_overrideConfigIsRequired', function () {
  20. var controller,
  21. instanceObject,
  22. configs,
  23. serviceConfig;
  24. beforeEach(function() {
  25. var mixinObject = Em.Controller.extend(App.ToggleIsRequiredMixin, {});
  26. instanceObject = mixinObject.create({});
  27. configs = Em.A([
  28. App.ServiceConfigProperty.create({ name: 'kdc_host', value: '', category: 'KDC', serviceName: 'KERBEROS', isRequired: true}),
  29. App.ServiceConfigProperty.create({ name: 'admin_server_host', value: '', category: 'KDC', serviceName: 'KERBEROS', isRequired: true}),
  30. App.ServiceConfigProperty.create({ name: 'admin_principal', value: '', category: 'KDC', serviceName: 'KERBEROS', isRequired: true}),
  31. App.ServiceConfigProperty.create({ name: 'admin_password', value: '', category: 'KDC', serviceName: 'KERBEROS', isRequired: true})
  32. ]);
  33. configs.forEach(function(config) {
  34. config.validate(); // make isRequired to trigger validation and to set every property's error flag to true
  35. });
  36. serviceConfig = App.ServiceConfig.create({
  37. 'serviceName': 'KERBEROS',
  38. 'configs': configs
  39. });
  40. });
  41. it('should make isRequired = false for kerberos properties', function () {
  42. instanceObject.overrideConfigIsRequired(serviceConfig);
  43. // toggle isRequired to false
  44. configs.forEach(function(p) {
  45. expect(p.isRequired).to.be.false;
  46. expect(p.error).to.be.false;
  47. });
  48. });
  49. it('should make isRequired = true for kerberos properties', function () {
  50. // toggle to false
  51. instanceObject.overrideConfigIsRequired(serviceConfig);
  52. // toggle to true
  53. instanceObject.overrideConfigIsRequired(serviceConfig);
  54. configs.forEach(function(p) {
  55. expect(p.isRequired).to.be.true;
  56. });
  57. });
  58. });