toggle_isrequired_test.js 2.5 KB

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