specific.js revision 26a6ec53bb06b3fb881e2a0cf5855c300513cad6
0N/A/**
243N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0N/A *
0N/A * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
0N/A *
0N/A * The contents of this file are subject to the terms
0N/A * of the Common Development and Distribution License
0N/A * (the License). You may not use this file except in
0N/A * compliance with the License.
0N/A *
0N/A * You can obtain a copy of the License at
0N/A * http://forgerock.org/license/CDDLv1.0.html
0N/A * See the License for the specific language governing
0N/A * permission and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL
0N/A * Header Notice in each file and include the License file
0N/A * at http://forgerock.org/license/CDDLv1.0.html
0N/A * If applicable, add the following below the CDDL Header,
0N/A * with the fields enclosed by brackets [] replaced by
0N/A * your own identifying information:
0N/A * "Portions Copyrighted [year] [name of copyright owner]"
0N/A */
0N/A
0N/A/*global require, define, QUnit, $ */
0N/A
0N/Adefine([
0N/A "sinon",
0N/A "org/forgerock/commons/ui/common/util/Constants",
0N/A "org/forgerock/commons/ui/common/main/Router",
0N/A "org/forgerock/commons/ui/common/main/EventManager",
243N/A "org/forgerock/openidm/ui/admin/MandatoryPasswordChangeDialog",
0N/A "org/forgerock/openidm/ui/admin/managed/AddEditManagedView",
0N/A "org/forgerock/openidm/ui/admin/ResourcesView",
0N/A "./mocks/adminInit",
0N/A "./mocks/encryptedPW",
0N/A "./mocks/cleartextPW",
0N/A "./mocks/addEditManaged"
0N/A], function (sinon, constants, router, eventManager, mandatoryPasswordChangeDialog, addEditManagedView, resourcesView, adminInit, encryptedPW, cleartextPW, addEditManaged) {
0N/A
0N/A return {
0N/A executeAll: function (server) {
0N/A
0N/A adminInit(server);
0N/A
0N/A var testPromises = [];
0N/A
0N/A module('Admin UI Functions');
0N/A
0N/A QUnit.asyncTest("Initial Login Process", function () {
0N/A
0N/A var dialogRenderStub = sinon.stub(mandatoryPasswordChangeDialog, "render", function (args, callback) {
0N/A
0N/A mandatoryPasswordChangeDialog.render.restore();
0N/A mandatoryPasswordChangeDialog.render(args, function () {
0N/A
0N/A QUnit.ok(true, "Mandatory password change dialog displayed when cleartext password used");
0N/A
0N/A QUnit.equal(mandatoryPasswordChangeDialog.$el.find(".validationRules.group-field-errors>.field-rule").length, 5, "Five validation rules for password displayed");
0N/A
0N/A if (callback) {
0N/A callback();
0N/A }
0N/A
0N/A QUnit.start();
0N/A });
0N/A });
0N/A
0N/A cleartextPW(server);
0N/A
0N/A eventManager.sendEvent(constants.EVENT_LOGIN_REQUEST, { userName: "openidm-admin", password: "openidm-admin" });
0N/A });
0N/A
0N/A
0N/A QUnit.asyncTest("Subsequent Login Process", function () {
0N/A var resourceRenderStub = sinon.stub(resourcesView, "render", function (args, callback) {
0N/A
0N/A resourcesView.render.restore();
1338N/A resourcesView.render(args, function () {
0N/A var viewManager = require("org/forgerock/commons/ui/common/main/ViewManager");
0N/A
0N/A QUnit.ok(viewManager.currentView === "org/forgerock/openidm/ui/admin/ResourcesView" && viewManager.currentDialog === "null", "Resource page shown after successful login with encrypted password");
0N/A
0N/A if (callback) {
0N/A callback();
0N/A }
0N/A
0N/A QUnit.start();
0N/A });
0N/A });
0N/A
0N/A encryptedPW(server);
0N/A
0N/A eventManager.sendEvent(constants.EVENT_LOGIN_REQUEST, { userName: "openidm-admin", password: "Passw0rd" });
0N/A });
0N/A
0N/A QUnit.asyncTest("Resource View", function () {
0N/A
0N/A addEditManaged(server);
0N/A
0N/A resourcesView.render([], function () {
0N/A var viewManager = require("org/forgerock/commons/ui/common/main/ViewManager");
0N/A
0N/A QUnit.equal(resourcesView.$el.find("#resourceConnectorContainer .resource-body").length, 2, "Connectors and add Connector successfully added");
0N/A
0N/A QUnit.equal(resourcesView.$el.find("#resourceManagedContainer .resource-body").length, 5, "Managed Objects and add Managed Object successfully added");
0N/A
0N/A QUnit.start();
0N/A });
0N/A });
0N/A
0N/A QUnit.asyncTest("Managed Objects Add/Edit", function () {
0N/A
0N/A addEditManaged(server);
0N/A
0N/A addEditManagedView.render([], function () {
0N/A
0N/A QUnit.start();
0N/A
0N/A addEditManagedView.$el.find("#addManagedProperties").trigger("click");
0N/A
0N/A QUnit.equal(addEditManagedView.$el.find(".add-remove-block:visible").length, 1, "Add Object Type property successfull");
0N/A
0N/A addEditManagedView.$el.find(".add-remove-block:visible .remove-btn").trigger("click");
0N/A $(".ui-dialog .ui-dialog-buttonset .ui-button:last").trigger("click");
0N/A
0N/A QUnit.equal(addEditManagedView.$el.find(".add-remove-block:visible").length, 0, "Delete Object Type property successfull");
0N/A
0N/A addEditManagedView.$el.find("#addManagedScript").trigger("click");
0N/A
0N/A QUnit.equal(addEditManagedView.$el.find(".managed-event-hook").length, 1, "Script hook added");
0N/A
0N/A QUnit.stop();
0N/A
0N/A setTimeout(function() {
0N/A addEditManagedView.$el.find(".event-hook-empty").trigger("click");
0N/A
0N/A QUnit.equal($("#scriptManagerDialogForm").length, 1, "Script editor successfully opened");
0N/A
0N/A $("#scriptFilePath").val("test");
0N/A $("#scriptFilePath").trigger("blur");
0N/A
0N/A QUnit.ok($("#scriptDialogOkay").is(":disabled") === false, "Script Dialog submit button enabled");
0N/A
0N/A $("#scriptDialogOkay").trigger("click");
0N/A
0N/A QUnit.equal(addEditManagedView.$el.find(".event-hook-status").length, 2, "Script Successfully Added");
0N/A
0N/A addEditManagedView.$el.find(".event-hook-status").trigger("click");
0N/A
0N/A addEditManagedView.$el.find(".add-remove-block:visible .remove-btn").trigger("click");
0N/A $(".ui-dialog .ui-dialog-buttonset .ui-button:last").trigger("click");
0N/A
0N/A QUnit.equal(addEditManagedView.$el.find(".add-remove-block:visible").length, 0, "Delete script successfull");
0N/A
0N/A addEditManagedView.$el.find("#managedObjectName").val("testname");
0N/A addEditManagedView.$el.find("#managedObjectName").trigger("blur");
0N/A
0N/A QUnit.ok(addEditManagedView.$el.find("#addEditManaged").is(":disabled") === false, "Submit button enabled");
0N/A
0N/A addEditManagedView.$el.find("#addEditManaged").trigger("click");
0N/A
0N/A QUnit.start();
0N/A }, 100);
0N/A
0N/A });
0N/A
0N/A });
0N/A }
0N/A
0N/A };
0N/A
0N/A});