reconTests.js revision 7ed4684789d023e1d4ede1b0d4468b9724587466
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * The contents of this file are subject to the terms
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * of the Common Development and Distribution License
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * (the License). You may not use this file except in
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * compliance with the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * You can obtain a copy of the License at
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * http://forgerock.org/license/CDDLv1.0.html
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * See the License for the specific language governing
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * permission and limitations under the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * When distributing Covered Code, include this CDDL
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * Header Notice in each file and include the License file
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * at http://forgerock.org/license/CDDLv1.0.html
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * If applicable, add the following below the CDDL Header,
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * with the fields enclosed by brackets [] replaced by
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * your own identifying information:
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy * "Portions Copyrighted [year] [name of copyright owner]"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy/*global require, define, QUnit, $ */
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy "org/forgerock/commons/ui/common/main/EventManager",
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy "org/forgerock/openidm/ui/admin/sync/SituationPolicyView",
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy "org/forgerock/openidm/ui/common/delegates/ConfigDelegate",
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy], function (sinon, eventManager, SituationPolicyView, ConfigDelegate, reconPolicyMappings) {
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy $("body").append("<div id='policyPattern'></div>");
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy // These three constants come from MappingBaseView and are the arguments passed into the SituationPolicyView render function.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy // Should those arguments change than these need to be updated.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy 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"}],
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy 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"},
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy mappingName = "systemLdapAccounts_managedUser";
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy module("Admin Mapping tab, Recon sub-tab tests");
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy QUnit.asyncTest("Situational Policy Renders", function () {
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy QUnit.equal(SituationPolicyView.$el.children().length, 0, "There are no children in the container before render.");
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy SituationPolicyView.render({sync: sync, mapping: mapping, mappingName: mappingName}, function() {
QUnit.ok(SituationPolicyView.$el.children().length > 0, "After rendering there are now child elements");
_.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");
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,
mappingUpdated = true;