<commit_before>import Mixin from '@ember/object/mixin';
import { inject as service } from '@ember/service';
import { computed, get, set, setProperties } from '@ember/object';
import { alias } from '@ember/object/computed';
import C from 'ui/utils/constants';

export default Mixin.create({
  settings:         service(),
  saml:             service(),
  errors:           null,
  redirectUrl:      null,
  saving:           false,
  saved:            false,
  testing:          false,
  disableAuth:      true,
  urlError:         null,
  urlWarning:       false,
  urlInvalid:       false,
  protocol:         'https://',
  authConfig:       alias('model.authConfig'),
  providerNamePath: null,
  providerName:     null,

  actions: {
    authTest(cb) {
      this.send('clearError');

      const model = get(this, 'authConfig');
      const am    = get(model, 'accessMode') || 'unrestricted';

      setProperties(model, { accessMode: am });

      const errors = model.validationErrors();

      if ( errors.get('length') ) {
        setProperties(this, {
          errors,
          testing: false
        });

        set(model, 'enabled', false);
        cb(false);
      } else {
        set(this, 'testing', true);

        setProperties(model, {
          'enabled':             false, // It should already be, but just in case..
          'allowedPrincipalIds': [],
        });

        model.save().then(() => {
          model.doAction('testAndEnable', { finalRedirectUrl: `${ window.location.origin }/verify-auth?config=${ get(this, 'providerName') }` }).then( ( resp ) => {
            get(this, 'saml').test(resp, (popupResults) => {
              if (popupResults.type === 'error') {
                this.set('errors', [popupResults.message]);
                cb(false);
              } else {
                this.send('waitAndRefresh');
              }
            });
          }).catch((err) => {<commit_msg>If Editing Saml will no longer reset the allowedPrincipalIds on save<commit_after>import Mixin from '@ember/object/mixin';
import { inject as service } from '@ember/service';
import { computed, get, set, setProperties } from '@ember/object';
import { alias } from '@ember/object/computed';
import C from 'ui/utils/constants';

export default Mixin.create({
  settings:         service(),
  saml:             service(),
  errors:           null,
  redirectUrl:      null,
  saving:           false,
  saved:            false,
  testing:          false,
  disableAuth:      true,
  urlError:         null,
  urlWarning:       false,
  urlInvalid:       false,
  protocol:         'https://',
  authConfig:       alias('model.authConfig'),
  providerNamePath: null,
  providerName:     null,

  actions: {
    authTest(cb) {
      this.send('clearError');

      const model = get(this, 'authConfig');
      const am    = get(model, 'accessMode') || 'unrestricted';

      setProperties(model, { accessMode: am });

      const errors = model.validationErrors();

      if ( errors.get('length') ) {
        setProperties(this, {
          errors,
          testing: false
        });

        set(model, 'enabled', false);
        cb(false);
      } else {
        set(this, 'testing', true);

        let allowedPrincipals = [];

        if (get(this, 'editing')) {
          allowedPrincipals = get(model, 'allowedPrincipalIds');
        }

        setProperties(model, {
          'enabled':             false, // It should already be, but just in case..
          'allowedPrincipalIds': allowedPrincipals,
        });

        model.save().then(() => {
          model.doAction('testAndEnable', { finalRedirectUrl: `${ window.location.origin }/verify-auth?config=${ get(this, 'providerName') }` }).then( ( resp ) => {
            get(this, 'saml').test(resp, (popupResults) => {
              if (popupResults.type === 'error') {
                this.set('errors', [popupResults.message]);
                cb(false);
              } else {
                this.send('waitAndRefresh');
              }
            });
          }).catch((err) => {
{'fraction_non_alphanumeric': 0.14373313711062055, 'fraction_numerical': 0.0, 'mean_word_length': 2.0118168389955686, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1203268', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1117, 'n_words': 265}