Code coverage report for app/controllers/main/admin/kerberos/step5_controller.js

Statements: 100% (25 / 25)      Branches: 75% (3 / 4)      Functions: 100% (11 / 11)      Lines: 100% (25 / 25)      Ignored: none     

All files » app/controllers/main/admin/kerberos/ » step5_controller.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130    1                                   1 1 1   1                                                       1             1 1                                   2 2 2 2         1 3     1               1                 2 2           2 2   8       2 2   1 1        
'use strict';
 
;require.register("controllers/main/admin/kerberos/step5_controller", function (exports, require, module) {
  /**
   * 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 stringUtils = require('utils/string_utils');
  var fileUtils = require('utils/file_utils');
 
  App.KerberosWizardStep5Controller = App.KerberosProgressPageController.extend(App.AddSecurityConfigs, {
    name: 'kerberosWizardStep5Controller',
 
    /**
     * @type {Array}
     */
    csvData: [],
 
    /**
     * @type {Array}
     */
    kdcProperties: [{
      key: Em.I18n.t('admin.kerberos.wizard.step1.option.kdc'),
      properties: ['kdc_type', 'kdc_hosts', 'realm', 'executable_search_paths']
    }, {
      key: Em.I18n.t('admin.kerberos.wizard.step1.option.ad'),
      properties: ['kdc_type', 'kdc_hosts', 'realm', 'ldap_url', 'container_dn', 'executable_search_paths']
    }, {
      key: Em.I18n.t('admin.kerberos.wizard.step1.option.ipa'),
      properties: ['kdc_type', 'kdc_hosts', 'realm', 'executable_search_paths']
    }, {
      key: Em.I18n.t('admin.kerberos.wizard.step1.option.manual'),
      properties: ['kdc_type', 'realm', 'executable_search_paths']
    }],
 
    isCSVRequestInProgress: false,
 
    submit: function submit() {
      App.router.send('next');
    },
 
    /**
     * get CSV data from the server
     */
    getCSVData: function getCSVData(skipDownload) {
      this.set('isCSVRequestInProgress', true);
      return App.ajax.send({
        name: 'admin.kerberos.cluster.csv',
        sender: this,
        data: {
          'skipDownload': skipDownload
        },
        success: 'getCSVDataSuccessCallback',
        error: 'getCSVDataSuccessCallback'
      });
    },
 
    /**
     * get CSV data from server success callback
     * @param data {string}
     * @param opt {object}
     * @param params {object}
     */
    getCSVDataSuccessCallback: function getCSVDataSuccessCallback(data, opt, params) {
      this.set('csvData', this.prepareCSVData(data.split('\n')));
      this.set('isCSVRequestInProgress', false);
      Eif (!Em.get(params, 'skipDownload')) {
        fileUtils.downloadTextFile(stringUtils.arrayToCSV(this.get('csvData')), 'csv', 'kerberos.csv');
      }
    },
 
    prepareCSVData: function prepareCSVData(array) {
      for (var i = 0; i < array.length; i += 1) {
        array[i] = array[i].split(',');
      }
 
      return array;
    },
 
    /**
     * Send request to unkerberisze cluster
     * @returns {$.ajax}
     */
    unkerberizeCluster: function unkerberizeCluster() {
      return App.ajax.send({
        name: 'admin.unkerberize.cluster',
        sender: this,
        success: 'goToNextStep',
        error: 'goToNextStep'
      });
    },
 
    goToNextStep: function goToNextStep() {
      this.clearStage();
      App.router.transitionTo('step5');
    },
 
    isSubmitDisabled: Em.computed.notExistsIn('status', ['COMPLETED', 'FAILED']),
 
    confirmProperties: function () {
      var wizardController = App.router.get('kerberosWizardController');
      var kdc_type = wizardController.get('content.kerberosOption'),
          kdcTypeProperties = this.get('kdcProperties').filter(function (item) {
        return item.key === kdc_type;
      }),
          properties = kdcTypeProperties.length ? kdcTypeProperties[0].properties : [];
 
      return wizardController.get('content.serviceConfigProperties').filter(function (item) {
        return properties.contains(item.name);
      }).map(function (item) {
        item['label'] = Em.I18n.t('admin.kerberos.wizard.step5.' + item['name'] + '.label');
        return item;
      });
    }.property('App.router.kerberosWizardController.content.@each.serviceConfigProperties')
  });
});