reconTests.js revision 01a229e011c0d84be34e967cf517d35a476c541a
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2014 ForgeRock AS. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
/*global require, define, QUnit, $ */
define([
"sinon",
"../mocks/reconPolicyMappings"
return {
executeAll: function (server) {
// These three constants come from MappingBaseView and are the arguments passed into the SituationPolicyView render function.
// Should those arguments change than these need to be updated.
var sync = [{"target":"managed/user","properties":[{"target":"displayName","source":"cn"},{"target":"description","source":"description"},{"target":"givenName","source":"givenName"},{"target":"mail","source":"mail"},{"target":"telephoneNumber","source":"telephoneNumber"},{"target":"sn","source":"sn"},{"target":"userName","source":"uid"}],"source":"system/ldap/account","policies":[{"action":"UPDATE","situation":"CONFIRMED"},{"action":"UPDATE","situation":"FOUND"},{"action":"CREATE","situation":"ABSENT"},{"action":"EXCEPTION","situation":"AMBIGUOUS"},{"action":"CREATE","situation":"MISSING"},{"action":"DELETE","situation":"SOURCE_MISSING"},{"action":"IGNORE","situation":"UNQUALIFIED"},{"action":"IGNORE","situation":"UNASSIGNED"}],"name":"systemLdapAccounts_managedUser"},{"target":"system/ldap/account","links":"systemLdapAccounts_managedUser","properties":[{"target":"givenName","source":"givenName"},{"target":"sn","source":"sn"},{"target":"cn","source":"","transform":{"type":"text/javascript","source":"source.displayName || (source.givenName + ' ' + source.sn);"}},{"target":"uid","source":"userName"},{"target":"description","source":"description","condition":{"type":"text/javascript","source":"!!object.description"}},{"target":"mail","source":"mail"},{"target":"userPassword","transform":{"type":"text/javascript","source":"openidm.decrypt(source);"},"source":"password","condition":{"type":"text/javascript","source":"object.password != null"}},{"target":"telephoneNumber","source":"telephoneNumber","condition":{"type":"text/javascript","source":"!!object.telephoneNumber"}}],"source":"managed/user","onCreate":{"type":"text/javascript","source":"target.dn = 'uid=' + source.userName + ',ou=People,dc=example,dc=com';"},"policies":[{"action":"UPDATE","situation":"CONFIRMED"},{"action":"LINK","situation":"FOUND"},{"action":"CREATE","situation":"ABSENT"},{"action":"IGNORE","situation":"AMBIGUOUS"},{"action":"IGNORE","situation":"MISSING"},{"action":"DELETE","situation":"SOURCE_MISSING"},{"action":"IGNORE","situation":"UNQUALIFIED"},{"action":"IGNORE","situation":"UNASSIGNED"}],"name":"managedUser_systemLdapAccounts"}],
mapping = {"target":"managed/user","properties":[{"target":"displayName","source":"cn"},{"target":"description","source":"description"},{"target":"givenName","source":"givenName"},{"target":"mail","source":"mail"},{"target":"telephoneNumber","source":"telephoneNumber"},{"target":"sn","source":"sn"},{"target":"userName","source":"uid"}],"source":"system/ldap/account","policies":[{"action":"UPDATE","situation":"CONFIRMED"},{"action":"UPDATE","situation":"FOUND"},{"action":"CREATE","situation":"ABSENT"},{"action":"EXCEPTION","situation":"AMBIGUOUS"},{"action":"CREATE","situation":"MISSING"},{"action":"DELETE","situation":"SOURCE_MISSING"},{"action":"IGNORE","situation":"UNQUALIFIED"},{"action":"IGNORE","situation":"UNASSIGNED"}],"name":"systemLdapAccounts_managedUser"},
mappingName = "systemLdapAccounts_managedUser";
module("Admin Mapping tab, Recon sub-tab tests");
QUnit.equal(SituationPolicyView.$el.children().length, 0, "There are no children in the container before render.");
QUnit.ok(SituationPolicyView.$el.children().length > 0, "After rendering there are now child elements");
// -1 because of the source row used to create the others is still on the page but hidden
"All situations are present");
"All actions are present");
"Patterns rendered are the same as the stored patterns");
_.each(SituationPolicyView.model.allPatterns["Default Actions"].policies, function(situation, index) {
if (situation.note !== SituationPolicyView.$el.find(".situationRow .info:eq("+index+")").attr("data-title")) {
messages = false;
}
if (SituationPolicyView.model.lookup.situations[situation.situation] !== SituationPolicyView.$el.find(".situationRow label:eq("+index+")").text()) {
order = false;
}
});
QUnit.equal(SituationPolicyView.$el.find(".situationRow .failure-display").length, 7, "There are 7 situations with error classes");
QUnit.equal(SituationPolicyView.$el.find(".situationRow .warning-display").length, 3, "There are 2 situations with warning classes");
QUnit.equal(SituationPolicyView.$el.find(".situationRow .success-display").length, 3, "There are 3 situations with success classes");
var readOnly = true, defaultActions = true;
if ($(row).find(".action").val() !== "ASYNC" && index < SituationPolicyView.model.allPatterns["Read-only"].policies.length) {
readOnly = false
}
});
if ($(row).find(".action :selected").text().indexOf("★") < 0 && index < SituationPolicyView.model.allPatterns["Read-only"].policies.length) {
defaultActions = false
}
});
QUnit.ok(defaultActions, "When the pattern changes to Default-Actions all actions are set to the starred value");
mappingUpdated = false,
deferredRead = $.Deferred(),
deferredWrite = $.Deferred(),
return deferredRead.promise();
}),
mappingUpdated = true;
}
});
}
});
return deferredWrite.promise();
});
deferredRead.done(function() {
});
$("#policyPattern").remove();
});
});
}
};
});