freeipa/install/ui/test/association_tests.js
Endi S. Dewata eb8f091c9b Fixed association facets.
The association config has been removed because it incorrectly assumes there is only one association between two entities. Now each association is defined separately using association facets.

The service.py has been modified to specify the correct relationships. The API.txt has been updated.

https://fedorahosted.org/freeipa/ticket/960
2011-02-15 17:45:46 -05:00

118 lines
2.8 KiB
JavaScript

/* Authors:
* Endi Sukma Dewata <edewata@redhat.com>
*
* Copyright (C) 2010 Red Hat
* see file 'COPYING' for use and warranty information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
module('associate');
test("Testing serial_associator().", function() {
expect(7);
var orig_ipa_cmd = IPA.cmd;
var counter = 0;
var params = {
method: "add_member",
pkey: "test",
entity_name: "user",
other_entity: "group"
};
params.values = ['user1', 'user2', 'user3'];
IPA.cmd = function(name, args, options, win_callback, fail_callback, objname) {
counter++;
equals(
name, params.other_entity+'_'+params.method,
"Checking IPA.cmd() parameter: method"
);
equals(
args[0], "user"+counter,
"Checking IPA.cmd() parameter: primary key"
);
var response = {};
win_callback(response);
return 0;
};
params.on_success = function() {
ok(true, "on_success() is invoked.");
};
var associator = IPA.serial_associator(params);
associator.execute();
IPA.cmd = orig_ipa_cmd;
});
test("Testing bulk_associator().", function() {
expect(4);
var orig_ipa_cmd = IPA.cmd;
var counter = 0;
var params = {
method: "add_member",
pkey: "test",
entity_name: "user",
other_entity: "group"
};
params.values = ['user1', 'user2', 'user3'];
IPA.cmd = function(name, args, options, win_callback, fail_callback, objname) {
counter++;
equals(
name, params.entity_name+'_'+params.method,
"Checking IPA.cmd() parameter: method"
);
equals(
args[0], params.pkey,
"Checking IPA.cmd() parameter: primary key"
);
equals(
options[params.other_entity], "user1,user2,user3",
"Checking IPA.cmd() parameter: options[\""+params.other_entity+"\"]"
);
var response = {};
win_callback(response);
return 0;
};
params.on_success = function() {
ok(true, "on_success() is invoked.");
};
var associator = IPA.bulk_associator(params);
associator.execute();
IPA.cmd = orig_ipa_cmd;
});