Imported Upstream version 4.6.2
This commit is contained in:
18
install/ui/test/README.md
Normal file
18
install/ui/test/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# WebUI Unit Tests
|
||||
|
||||
How to run tests:
|
||||
|
||||
1. Run "autoreconf" command in the root of the repository
|
||||
2. Run "./configure" in the root of the repository
|
||||
3. Go to install/ui/src/libs/ directory
|
||||
4. Run "$ make" - this step generates loader.js which is necessary for load
|
||||
current API version into WebUI. This version is necessary for checking
|
||||
response of each API call.
|
||||
5. Go to install/ui/test
|
||||
6. Run "$ firefox index.html"
|
||||
|
||||
Only Firefox browser is supported, because Google Chrome does not allow
|
||||
to fetch files using AJAX and file:// protocol.
|
||||
|
||||
For more information about WebUI unit tests please read following:
|
||||
https://www.freeipa.org/page/FreeIPAv2:UI_Unit_Tests
|
||||
25
install/ui/test/aci_tests.html
Executable file
25
install/ui/test/aci_tests.html
Executable file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Access Control Interface Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/aci_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">ACI Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
292
install/ui/test/aci_tests.js
Normal file
292
install/ui/test/aci_tests.js
Normal file
@@ -0,0 +1,292 @@
|
||||
/* Authors:
|
||||
* Adam Young <ayoung@redhat.com>
|
||||
* Petr Vobornik <pvoborni@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/>.
|
||||
*/
|
||||
|
||||
define([
|
||||
'freeipa/metadata',
|
||||
'freeipa/aci',
|
||||
'freeipa/details',
|
||||
'freeipa/facet',
|
||||
'freeipa/field',
|
||||
'freeipa/ipa',
|
||||
'freeipa/jquery',
|
||||
'freeipa/reg',
|
||||
'freeipa/widget'
|
||||
],
|
||||
function(md, aci, mod_details, mod_facet, fields, IPA, $, reg, widgets) {
|
||||
return function() {
|
||||
|
||||
var target_container;
|
||||
var target_widget;
|
||||
var target_facet;
|
||||
var entity = IPA.entity({ name: 'bogus', redirect_facet: 'details' });
|
||||
var group_entity = IPA.entity({ name: 'group' });
|
||||
|
||||
module('aci', {
|
||||
setup: function() {
|
||||
|
||||
fields.register();
|
||||
widgets.register();
|
||||
aci.register();
|
||||
mod_facet.register();
|
||||
mod_details.register();
|
||||
|
||||
IPA.ajax_options.async = false;
|
||||
IPA.init({
|
||||
url: 'data',
|
||||
on_error: function(xhr, text_status, error_thrown) {
|
||||
ok(false, "ipa_init() failed: "+error_thrown);
|
||||
}
|
||||
});
|
||||
|
||||
target_facet = IPA.details_facet({
|
||||
entity: entity,
|
||||
fields: [
|
||||
{
|
||||
$type: 'radio',
|
||||
name: 'target',
|
||||
widget: 'target.target',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
$type: 'multivalued',
|
||||
name: 'extratargetfilter',
|
||||
widget: 'target.extratargetfilter',
|
||||
acl_param: 'ipapermtargetfilter',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
$type: 'multivalued',
|
||||
name: 'memberof',
|
||||
widget: 'target.memberof',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'ipapermlocation',
|
||||
widget: 'target.ipapermlocation',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'ipapermtarget',
|
||||
widget: 'target.ipapermtarget',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
$type: 'select',
|
||||
name: 'type',
|
||||
widget: 'target.type',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'attrs',
|
||||
widget: 'target.attrs',
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
name: 'attrs_multi',
|
||||
param: 'attrs',
|
||||
$type: 'multivalued',
|
||||
widget: 'target.attrs_multi',
|
||||
enabled: false
|
||||
}
|
||||
],
|
||||
widgets: [
|
||||
{
|
||||
$type: 'permission_target',
|
||||
container_factory: IPA.details_section,
|
||||
group_entity: group_entity,
|
||||
name: 'target',
|
||||
label: 'Target',
|
||||
show_target: false
|
||||
}
|
||||
],
|
||||
policies: [
|
||||
{
|
||||
$factory: aci.permission_target_policy,
|
||||
widget_name: 'target'
|
||||
}
|
||||
]
|
||||
});
|
||||
entity.add_facet('details', target_facet);
|
||||
target_container = $('<div id="content"/>').appendTo(document.body);
|
||||
target_facet.container_node = target_container[0];
|
||||
target_facet.create();
|
||||
target_widget = target_facet.widgets.get_widget('target');
|
||||
},
|
||||
teardown: function() {
|
||||
target_container.remove();
|
||||
}}
|
||||
);
|
||||
|
||||
|
||||
test("aci.attributes_widget", function() {
|
||||
|
||||
var aciattrs = md.source.objects.user.aciattrs;
|
||||
|
||||
var container = $('<span/>', {
|
||||
name: 'attrs'
|
||||
});
|
||||
|
||||
var widget = aci.attributes_widget({
|
||||
name: 'attrs',
|
||||
object_type: 'user',
|
||||
entity:entity
|
||||
});
|
||||
|
||||
widget.create(container);
|
||||
|
||||
var list = $('ul', container);
|
||||
|
||||
ok(
|
||||
list,
|
||||
'Widget contains list');
|
||||
|
||||
widget.update([]);
|
||||
|
||||
list = $('ul', container); // reload the DOM node which contains options
|
||||
var li = $('li', list);
|
||||
|
||||
same(
|
||||
li.length, aciattrs.length,
|
||||
'Widget contains all user ACI attributes');
|
||||
|
||||
var record = {
|
||||
'attrs': [
|
||||
"unmatched",
|
||||
"cn",
|
||||
"description"
|
||||
]
|
||||
};
|
||||
|
||||
same(
|
||||
widget.save(), [],
|
||||
'Widget has no initialy checked values');
|
||||
|
||||
widget.update(record.attrs);
|
||||
|
||||
list = $('ul', container); // reload the DOM node which contains options
|
||||
li = $('li', list);
|
||||
|
||||
same(
|
||||
li.length, aciattrs.length+1,
|
||||
'Widget contains all user ACI attributes plus 1 unmatched attribute');
|
||||
|
||||
same(
|
||||
widget.save(), record.attrs.sort(),
|
||||
'All loaded values are saved and sorted');
|
||||
});
|
||||
|
||||
test("aci.rights_widget.", function() {
|
||||
|
||||
var container = $('<span/>', {
|
||||
name: 'permissions'
|
||||
});
|
||||
|
||||
var widget = aci.rights_widget({
|
||||
name: 'permissions',
|
||||
entity:entity
|
||||
});
|
||||
|
||||
widget.create(container);
|
||||
|
||||
var inputs = $('input', container);
|
||||
|
||||
same(
|
||||
inputs.length, widget.rights.length,
|
||||
'Widget displays all permissions');
|
||||
});
|
||||
|
||||
var get_visible_rows = function(section) {
|
||||
var keys = section.rows.keys;
|
||||
|
||||
var visible = [];
|
||||
|
||||
for (var i=0; i<keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var row = section.rows.get(key);
|
||||
var row_visible = row.css('display') !== 'none';
|
||||
if(row_visible) {
|
||||
visible.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
return visible;
|
||||
};
|
||||
|
||||
|
||||
test("Testing type target.", function() {
|
||||
var data = {
|
||||
id: null,
|
||||
error: null,
|
||||
result: { result: { type: 'hostgroup'} }
|
||||
};
|
||||
|
||||
target_facet.load(data);
|
||||
|
||||
same(target_widget.target, 'type', 'type selected');
|
||||
|
||||
var attrs_w = target_widget.widgets.get_widget('attrs');
|
||||
var options = attrs_w.options;
|
||||
ok(options.length > 0, "Attrs has some options");
|
||||
// check them all
|
||||
var values = [];
|
||||
for (var i=0,l=options.length; i<l; i++) {
|
||||
values.push(options[i].value);
|
||||
}
|
||||
attrs_w.update(values);
|
||||
attrs_w.emit('value-change', { source: attrs_w });
|
||||
|
||||
var record = {};
|
||||
target_facet.save(record);
|
||||
|
||||
same(record.type[0], data.result.result.type,
|
||||
"saved type matches sample data");
|
||||
|
||||
same(get_visible_rows(target_widget), ['type', 'extratargetfilter',
|
||||
'ipapermtarget', 'memberof', 'attrs'],
|
||||
'type and attrs rows visible');
|
||||
|
||||
same(record.attrs.length, options.length, "response contains all checked attrs");
|
||||
});
|
||||
|
||||
|
||||
test("Testing general target.", function() {
|
||||
|
||||
var data = {
|
||||
id: null,
|
||||
error: null,
|
||||
result: { result: { extratargetfilter: 'hostgroup'} }
|
||||
};
|
||||
|
||||
target_facet.load(data);
|
||||
|
||||
var record = {};
|
||||
target_facet.save(record);
|
||||
|
||||
same(target_widget.target, 'general', 'general selected');
|
||||
|
||||
same(get_visible_rows(target_widget), ['type', 'ipapermlocation',
|
||||
'extratargetfilter', 'ipapermtarget', 'memberof',
|
||||
'attrs_multi'], 'general target fields visible');
|
||||
|
||||
same(record.extratargetfilter[0], data.result.result.extratargetfilter, 'filter set correctly');
|
||||
});
|
||||
|
||||
};});
|
||||
54
install/ui/test/all_tests.html
Normal file
54
install/ui/test/all_tests.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Complete Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/bootstrap.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require([
|
||||
'test/ordered_map_tests',
|
||||
'test/ipa_tests',
|
||||
'test/details_tests',
|
||||
'test/entity_tests',
|
||||
'test/association_tests',
|
||||
'test/navigation_tests',
|
||||
'test/certificate_tests',
|
||||
'test/aci_tests',
|
||||
'test/widget_tests',
|
||||
'test/ip_tests',
|
||||
'test/utils_tests',
|
||||
'test/build_tests',
|
||||
'test/binding_tests',
|
||||
], function(om, ipa, details, entity, as, nav, cert, aci, wid, ip, ut, bt, bi){
|
||||
om();
|
||||
ipa();
|
||||
details();
|
||||
entity();
|
||||
as();
|
||||
nav();
|
||||
cert();
|
||||
aci();
|
||||
wid();
|
||||
ip();
|
||||
ut();
|
||||
bt();
|
||||
bi();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Complete Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
25
install/ui/test/association_tests.html
Normal file
25
install/ui/test/association_tests.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Association Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/association_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Association Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
149
install/ui/test/association_tests.js
Normal file
149
install/ui/test/association_tests.js
Normal file
@@ -0,0 +1,149 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
|
||||
|
||||
define([
|
||||
'freeipa/ipa',
|
||||
'freeipa/jquery',
|
||||
'freeipa/rpc',
|
||||
'freeipa/association',
|
||||
'freeipa/entity'
|
||||
], function(IPA, $, rpc)
|
||||
{ return function() {
|
||||
|
||||
module('association');
|
||||
|
||||
|
||||
test("Testing serial_associator().", function() {
|
||||
|
||||
expect(11);
|
||||
|
||||
var orig_ipa_batch_command = rpc.batch_command;
|
||||
|
||||
var user = IPA.entity({ name: 'user' });
|
||||
var group = IPA.entity({ name: 'group' });
|
||||
|
||||
var params = {
|
||||
method: 'add_member',
|
||||
pkey: 'test',
|
||||
entity: user,
|
||||
other_entity: group
|
||||
};
|
||||
|
||||
params.values = ['user1', 'user2', 'user3'];
|
||||
|
||||
rpc.batch_command = function(spec) {
|
||||
|
||||
var that = orig_ipa_batch_command(spec);
|
||||
|
||||
that.execute = function() {
|
||||
equals(that.commands.length, params.values.length,
|
||||
'Checking rpc.batch_command command count');
|
||||
|
||||
var i, command;
|
||||
|
||||
for(i=0; i < params.values.length; i++) {
|
||||
command = that.commands[i];
|
||||
|
||||
equals(
|
||||
command.entity, params.other_entity.name,
|
||||
'Checking rpc.command() parameter: entity');
|
||||
|
||||
equals(
|
||||
command.method, params.method,
|
||||
'Checking rpc.command() parameter: method');
|
||||
|
||||
equals(
|
||||
command.args[0], 'user'+(i+1),
|
||||
'Checking rpc.command() parameter: primary key');
|
||||
}
|
||||
|
||||
that.on_success({});
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
params.on_success = function() {
|
||||
ok(true, "on_success() is invoked.");
|
||||
};
|
||||
|
||||
var associator = IPA.serial_associator(params);
|
||||
associator.execute();
|
||||
|
||||
rpc.batch_command = orig_ipa_batch_command;
|
||||
});
|
||||
|
||||
test("Testing bulk_associator().", function() {
|
||||
|
||||
expect(4);
|
||||
|
||||
var orig_ipa_command = rpc.command;
|
||||
|
||||
var counter = 0;
|
||||
|
||||
var user = IPA.entity({ name: 'user' });
|
||||
var group = IPA.entity({ name: 'group' });
|
||||
|
||||
var params = {
|
||||
method: 'add_member',
|
||||
pkey: 'test',
|
||||
entity: user,
|
||||
other_entity: group
|
||||
};
|
||||
|
||||
params.values = ['user1', 'user2', 'user3'];
|
||||
|
||||
rpc.command = function(spec) {
|
||||
|
||||
var that = orig_ipa_command(spec);
|
||||
|
||||
that.execute = function() {
|
||||
counter++;
|
||||
|
||||
equals(
|
||||
that.method, params.method,
|
||||
'Checking rpc.command() parameter: method');
|
||||
|
||||
equals(
|
||||
that.args[0], params.pkey,
|
||||
'Checking rpc.command() parameter: primary key');
|
||||
|
||||
equals(
|
||||
that.options[params.other_entity.name], 'user1,user2,user3',
|
||||
'Checking rpc.command() parameter: options[\""+params.other_entity+"\"]');
|
||||
|
||||
that.on_success({});
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
params.on_success = function() {
|
||||
ok(true, "on_success() is invoked.");
|
||||
};
|
||||
|
||||
var associator = IPA.bulk_associator(params);
|
||||
associator.execute();
|
||||
|
||||
rpc.command = orig_ipa_command;
|
||||
});
|
||||
|
||||
};});
|
||||
53
install/ui/test/bin/update_ipa_init.sh
Executable file
53
install/ui/test/bin/update_ipa_init.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
FIXTURE_DIR=$1
|
||||
|
||||
INIT_FILE=$FIXTURE_DIR/ipa_init.json
|
||||
|
||||
usage(){
|
||||
echo "$0 {FIXTURE_DIR}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ ! -f $INIT_FILE ]
|
||||
then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
json="{
|
||||
\"method\": \"batch\",
|
||||
\"params\": [
|
||||
[
|
||||
{
|
||||
\"method\": \"i18n_messages\",
|
||||
\"params\": [[], {}]
|
||||
},
|
||||
{
|
||||
\"method\": \"user_find\",
|
||||
\"params\":[[], { \"whoami\": true, \"all\": true }]
|
||||
},
|
||||
{
|
||||
\"method\": \"env\",
|
||||
\"params\": [[], {}]
|
||||
},
|
||||
{
|
||||
\"method\": \"dns_is_enabled\",
|
||||
\"params\": [[], {}]
|
||||
}
|
||||
],
|
||||
{}
|
||||
]
|
||||
}"
|
||||
|
||||
curl -v\
|
||||
-H "Content-Type: application/json"\
|
||||
-H "Accept: applicaton/json"\
|
||||
-H "Referer: https://`hostname`/ipa/xml"\
|
||||
--negotiate\
|
||||
--delegation always\
|
||||
-u :\
|
||||
--cacert /etc/ipa/ca.crt\
|
||||
-d "$json"\
|
||||
-X POST\
|
||||
https://`hostname`/ipa/json | sed 's/[ \t]*$//' > $INIT_FILE
|
||||
25
install/ui/test/binding_tests.html
Normal file
25
install/ui/test/binding_tests.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>IPA Binding test suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/binding_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">IPA Binding test suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
125
install/ui/test/binding_tests.js
Normal file
125
install/ui/test/binding_tests.js
Normal file
@@ -0,0 +1,125 @@
|
||||
/* Authors:
|
||||
* Petr Vobornik <pvoborni@redhat.com>
|
||||
*
|
||||
* Copyright (C) 2013 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/>.
|
||||
*/
|
||||
|
||||
define([
|
||||
'freeipa/builder',
|
||||
'freeipa/FieldBinder',
|
||||
'freeipa/widget',
|
||||
'freeipa/field',
|
||||
'freeipa/entity'
|
||||
],
|
||||
function(builder, FieldBinder, mod_widget, mod_field) { return function() {
|
||||
|
||||
|
||||
module('build',{
|
||||
|
||||
setup: function() {
|
||||
},
|
||||
teardown: function() {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* This test tests two-way binding between one field and two widgets
|
||||
*
|
||||
* All three have to have the same value.
|
||||
*/
|
||||
test('Testing two way bindings', function() {
|
||||
|
||||
function test_same_value(value, dirty) {
|
||||
if (dirty) {
|
||||
ok(field.dirty, "Field is dirty")
|
||||
} else {
|
||||
ok(!field.dirty, "Field is not dirty")
|
||||
}
|
||||
same(widget1.get_value(), value, 'Testing Widget 1 value');
|
||||
same(widget2.get_value(), value, 'Testing Widget 2 value');
|
||||
same(field.get_value(), value, 'Testing Field value');
|
||||
}
|
||||
|
||||
mod_widget.register();
|
||||
mod_field.register();
|
||||
|
||||
var field = builder.build('field', 'f1');
|
||||
var widget1 = builder.build('widget', 'w1');
|
||||
var widget2 = builder.build('widget', 'w2');
|
||||
|
||||
// is it a bug that widgets needs to be created?
|
||||
var c1 = $("<div/>");
|
||||
var c2 = $("<div/>");
|
||||
widget1.create(c1);
|
||||
widget2.create(c2);
|
||||
|
||||
var b1 = new FieldBinder(field, widget1);
|
||||
b1.bind();
|
||||
|
||||
var b2 = new FieldBinder(field, widget2);
|
||||
b2.bind();
|
||||
|
||||
test_same_value([], false); // initial is empty
|
||||
|
||||
// set pristine value to field
|
||||
var value = ['val1'];
|
||||
field.set_value(value, true); // pristine = true
|
||||
test_same_value(value, false);
|
||||
|
||||
// set value from widget 1
|
||||
var value2 = ['val2'];
|
||||
widget1.set_value(value2);
|
||||
test_same_value(value2, true);
|
||||
|
||||
// set value from widget 2
|
||||
var value3 = ['val3'];
|
||||
widget1.set_value(value3);
|
||||
test_same_value(value3, true);
|
||||
|
||||
// reset the field, all should have original value
|
||||
field.reset();
|
||||
test_same_value(value, false);
|
||||
|
||||
// make the field dirty again and click on undo button
|
||||
widget1.set_value(value2);
|
||||
test_same_value(value2, true);
|
||||
widget1.get_undo().click();
|
||||
test_same_value(value, false);
|
||||
|
||||
// set new value to field
|
||||
field.set_value(value2);
|
||||
test_same_value(value2, true);
|
||||
|
||||
// unbind the fields, set different value to each
|
||||
b1.unbind();
|
||||
b2.unbind();
|
||||
field.reset();
|
||||
widget2.set_value(value3);
|
||||
same(widget1.get_value(), value2, 'Testing Widget 1 value');
|
||||
same(widget2.get_value(), value3, 'Testing Widget 2 value');
|
||||
same(field.get_value(), value, 'Testing Field value');
|
||||
|
||||
// bind again
|
||||
b1.bind();
|
||||
b2.bind();
|
||||
field.set_value(value2);
|
||||
test_same_value(value2, true);
|
||||
});
|
||||
|
||||
|
||||
};});
|
||||
25
install/ui/test/build_tests.html
Normal file
25
install/ui/test/build_tests.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>IPA utils test suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/build_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">IPA Build test suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
264
install/ui/test/build_tests.js
Normal file
264
install/ui/test/build_tests.js
Normal file
@@ -0,0 +1,264 @@
|
||||
/* Authors:
|
||||
* Petr Vobornik <pvoborni@redhat.com>
|
||||
*
|
||||
* Copyright (C) 2013 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/>.
|
||||
*/
|
||||
|
||||
define([
|
||||
'dojo/_base/declare',
|
||||
'freeipa/_base/Builder',
|
||||
'freeipa/_base/Construct_registry',
|
||||
'freeipa/_base/Spec_mod',
|
||||
'freeipa/ipa',
|
||||
'freeipa/spec_util'
|
||||
],
|
||||
function(declare, Builder, C_reg, Spec_mod, IPA, su) { return function() {
|
||||
|
||||
|
||||
module('build',{
|
||||
|
||||
setup: function() {
|
||||
},
|
||||
teardown: function() {
|
||||
}
|
||||
});
|
||||
|
||||
test('Testing builder', function() {
|
||||
|
||||
var simple_factory = function(spec) {
|
||||
|
||||
var that = IPA.object();
|
||||
su.set(that, spec, 'foo', 'bar');
|
||||
return that;
|
||||
};
|
||||
|
||||
var Simple_class = declare(null, {
|
||||
foo: 'bar',
|
||||
constructor: function(spec) {
|
||||
su.set(this, spec, 'foo');
|
||||
}
|
||||
});
|
||||
|
||||
var b1 = new Builder({factory: simple_factory});
|
||||
var b2 = new Builder({ctor: Simple_class});
|
||||
|
||||
var o1 = b1.build({});
|
||||
var o11 = b1.build({ foo: 'baz'});
|
||||
var o12 = b1.build(o11);
|
||||
|
||||
var o2 = b2.build({});
|
||||
var o21 = b2.build({ foo: 'baz'});
|
||||
var o22 = b2.build(o21);
|
||||
|
||||
var r1 = simple_factory({});
|
||||
var r11 = simple_factory({ foo: 'baz' });
|
||||
var r2 = new Simple_class({});
|
||||
var r21 = new Simple_class({ foo:'baz'});
|
||||
|
||||
deepEqual(o1, r1, 'Factory, default');
|
||||
deepEqual(o11, r11, 'Factory, spec use');
|
||||
|
||||
deepEqual(o2, r2, 'Constructor, default');
|
||||
deepEqual(o21, r21, 'Constructor, spec use');
|
||||
|
||||
strictEqual(o11, o12, 'Don\'t build built object - factory');
|
||||
strictEqual(o21, o22, 'Don\'t build built object - constructor');
|
||||
|
||||
});
|
||||
|
||||
test('Testing Spec_mod', function() {
|
||||
|
||||
var sm = new Spec_mod();
|
||||
|
||||
var spec = {
|
||||
foo: {
|
||||
arr1: [
|
||||
{ name: 'i1', a: 'b' },
|
||||
{ name: 'i2', a: 'b' },
|
||||
{ name: 'i3', a: 'c' },
|
||||
{ name: 'i4', a: 'c' },
|
||||
{ name: 'i5', a: 'a' }
|
||||
],
|
||||
arr2: ['item1']
|
||||
},
|
||||
baz: {
|
||||
bar: 'a'
|
||||
},
|
||||
bar: 'b'
|
||||
};
|
||||
|
||||
var diff = {
|
||||
$add: [
|
||||
['foo.arr1', { name: 'foo', a: 'c' }],
|
||||
['foo.arr2', 'item2'],
|
||||
['foo.arr2', { name: 'foo' }],
|
||||
['arr3', 'a'] //creates new array
|
||||
],
|
||||
$del: [
|
||||
[
|
||||
'foo.arr1',
|
||||
[
|
||||
{ name: 'i1' }, //match
|
||||
{ a: 'c'}, // 2 matches
|
||||
{ name: 'i2', a:'c' }, //no match
|
||||
{ name: 'i5', a:'a' } // match
|
||||
]
|
||||
],
|
||||
[ 'foo.arr2', ['item1'] ] //match
|
||||
],
|
||||
$set: [
|
||||
[ 'arr4', ['b'] ], // new array in spec
|
||||
[ 'baz.bar', 'c'], //overwrite 'a'
|
||||
[ 'baz.baz.baz', 'a'], // new property
|
||||
[ 'bar', { foo: 'baz' }] // replace string by object
|
||||
]
|
||||
};
|
||||
|
||||
var ref = {
|
||||
foo: {
|
||||
arr1: [
|
||||
{ name: 'i2', a: 'b' },
|
||||
{ name: 'foo', a: 'c'}
|
||||
],
|
||||
arr2: [
|
||||
'item2', { name: 'foo' }
|
||||
]
|
||||
},
|
||||
arr3: [ 'a' ],
|
||||
baz: {
|
||||
bar: 'c',
|
||||
baz: { baz: 'a' }
|
||||
},
|
||||
bar: { foo: 'baz' },
|
||||
arr4: ['b']
|
||||
};
|
||||
|
||||
sm.mod(spec, diff);
|
||||
|
||||
deepEqual(spec, ref, 'Complex Modification');
|
||||
|
||||
spec = {
|
||||
a: [ 'a1', 'a2', 'a3' ]
|
||||
};
|
||||
var rules = [[ 'a', 'new', 1]];
|
||||
sm.add(spec, rules);
|
||||
|
||||
deepEqual(spec, { a: ['a1', 'new', 'a2', 'a3'] }, 'Add on position');
|
||||
});
|
||||
|
||||
test('Testing Construct registry', function() {
|
||||
|
||||
var undefined;
|
||||
|
||||
var cr = new C_reg();
|
||||
|
||||
// test simple ctor registration
|
||||
var ctor = declare([], {});
|
||||
cr.register('ctor', ctor);
|
||||
|
||||
var ctor_cs = cr.get('ctor');
|
||||
equals(ctor_cs.type, 'ctor', 'Ctor: Match type');
|
||||
equals(ctor_cs.ctor, ctor, 'Ctor: Match ctor');
|
||||
equals(ctor_cs.factory, undefined, 'Ctor: Match factory');
|
||||
equals(ctor_cs.pre_ops.length, 0, 'Ctor: No pre_ops');
|
||||
equals(ctor_cs.post_ops.length, 0, 'Ctor: No post_ops');
|
||||
|
||||
// test simple factory registration
|
||||
var fac = function(){};
|
||||
cr.register('fac', fac);
|
||||
|
||||
var fac_cs = cr.get('fac');
|
||||
equals(fac_cs.type, 'fac', 'Factory: Match type');
|
||||
equals(fac_cs.ctor, undefined, 'Factory: Match ctor');
|
||||
equals(fac_cs.factory, fac, 'Factory: Match factory');
|
||||
equals(fac_cs.pre_ops.length, 0, 'Factory: No pre_ops');
|
||||
equals(fac_cs.post_ops.length, 0, 'Factory: No post_ops');
|
||||
|
||||
|
||||
// test complex registration
|
||||
|
||||
var spec = { name: 'spec' };
|
||||
|
||||
var cs = {
|
||||
type: 'complex',
|
||||
ctor: ctor,
|
||||
factory: fac, // for next test
|
||||
spec: spec
|
||||
};
|
||||
cr.register(cs);
|
||||
var complex_cs = cr.get('complex');
|
||||
equals(complex_cs.type, 'complex', 'Complex: Match type');
|
||||
equals(complex_cs.ctor, ctor, 'Complex: Match ctor');
|
||||
equals(complex_cs.factory, fac, 'Complex: Match factory');
|
||||
equals(complex_cs.pre_ops.length, 0, 'Complex: No pre_ops');
|
||||
equals(complex_cs.post_ops.length, 0, 'Complex: No post_ops');
|
||||
deepEqual(complex_cs.spec, spec, 'Complex: Match spec');
|
||||
|
||||
// copy: new cs based on existing
|
||||
cr.copy('complex', 'copy', {}); // pure copy
|
||||
var copy_cs = cr.get('copy');
|
||||
equals(copy_cs.type, 'copy', 'Copy: Match type');
|
||||
equals(copy_cs.ctor, ctor, 'Copy: Match ctor');
|
||||
equals(copy_cs.factory, fac, 'Copy: Match factory');
|
||||
equals(copy_cs.pre_ops.length, 0, 'Copy: No pre_ops');
|
||||
equals(copy_cs.post_ops.length, 0, 'Copy: No post_ops');
|
||||
deepEqual(copy_cs.spec, spec, 'Copy: Match spec');
|
||||
|
||||
// add post op and pre op to complex
|
||||
var op1 = function() {};
|
||||
var op2 = function() {};
|
||||
var op3 = function() {};
|
||||
var op4 = function() {};
|
||||
|
||||
cr.register_pre_op('complex', op1);
|
||||
cr.register_pre_op('complex', op2, true /* first*/);
|
||||
deepEqual(complex_cs.pre_ops, [op2, op1], 'Adding pre_ops');
|
||||
|
||||
cr.register_post_op('complex', op3);
|
||||
cr.register_post_op('complex', op4, true);
|
||||
deepEqual(complex_cs.post_ops, [op4, op3], 'Adding post_ops');
|
||||
|
||||
|
||||
// copy: altered
|
||||
var ctor2 = declare([], {});
|
||||
var fac2 = function() {};
|
||||
var op5 = function() {};
|
||||
var op6 = function() {};
|
||||
cr.copy('complex', 'copy2', {
|
||||
ctor: ctor2,
|
||||
factory: fac2,
|
||||
spec: {
|
||||
foo: 'bar'
|
||||
},
|
||||
pre_ops: [op5],
|
||||
post_ops: [op6]
|
||||
});
|
||||
var a_copy_cs = cr.get('copy2');
|
||||
|
||||
equals(a_copy_cs.type, 'copy2', 'Altered copy: Match type');
|
||||
equals(a_copy_cs.ctor, ctor2, 'Altered copy: Match ctor');
|
||||
equals(a_copy_cs.factory, fac2, 'Altered copy: Match factory');
|
||||
deepEqual(a_copy_cs.spec, {
|
||||
name: 'spec',
|
||||
foo: 'bar'
|
||||
}, 'Altered copy: Match spec');
|
||||
deepEqual(a_copy_cs.pre_ops, [op2, op1, op5], 'Altered copy: Match pre_ops');
|
||||
deepEqual(a_copy_cs.post_ops, [op4, op3, op6], 'Altered copy: Match post_ops');
|
||||
});
|
||||
|
||||
|
||||
};});
|
||||
25
install/ui/test/certificate_tests.html
Executable file
25
install/ui/test/certificate_tests.html
Executable file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Certificate Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/certificate_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Certificate Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
77
install/ui/test/certificate_tests.js
Executable file
77
install/ui/test/certificate_tests.js
Executable file
@@ -0,0 +1,77 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
|
||||
define(['freeipa/ipa', 'freeipa/jquery', 'freeipa/certificate'], function(IPA, $) {
|
||||
return function() {
|
||||
|
||||
module('certificate');
|
||||
|
||||
test("Testing certificate_parse_dn().", function() {
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn(), {},
|
||||
"Checking IPA.cert.parse_dn()");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn(''), {},
|
||||
"Checking IPA.cert.parse_dn('')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('c=US'), {'c': 'US'},
|
||||
"Checking IPA.cert.parse_dn('c=US')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('st=TX,c=US'), {'st': 'TX','c': 'US'},
|
||||
"Checking IPA.cert.parse_dn('st=TX,c=US')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('c=US,st=TX'), {'st': 'TX','c': 'US'},
|
||||
"Checking IPA.cert.parse_dn('c=US,st=TX')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn(' st = New Mexico , c = US '), {'st': 'New Mexico','c': 'US'},
|
||||
"Checking IPA.cert.parse_dn(' st = New Mexico , c = US ')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('ST=TX,C=US'), {'st': 'TX','c': 'US'},
|
||||
"Checking IPA.cert.parse_dn('ST=TX,C=US')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('cn=dev.example.com,ou=Engineering,o=Example,l=Austin,ST=TX,C=US'),
|
||||
{ 'cn': 'dev.example.com',
|
||||
'ou': 'Engineering',
|
||||
'o': 'Example',
|
||||
'l': 'Austin',
|
||||
'st': 'TX',
|
||||
'c': 'US'
|
||||
},
|
||||
"Checking IPA.cert.parse_dn('cn=dev.example.com,ou=Engineering,o=Example,l=Austin,ST=TX,C=US')");
|
||||
|
||||
same(
|
||||
IPA.cert.parse_dn('cn=John Smith,ou=Developers,ou=Users,dc=example,dc=com'),
|
||||
{
|
||||
'cn': 'John Smith',
|
||||
'ou': ['Developers','Users'],
|
||||
'dc': ['example', 'com']
|
||||
},
|
||||
"Checking IPA.cert.parse_dn('cn=John Smith,ou=Developers,ou=Users,dc=example,dc=com')");
|
||||
});
|
||||
|
||||
};});
|
||||
43
install/ui/test/config.js
Normal file
43
install/ui/test/config.js
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Authors:
|
||||
* Petr Vobornik <pvoborni@redhat.com>
|
||||
*
|
||||
* Copyright (C) 2012 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/>.
|
||||
*/
|
||||
|
||||
var dojoConfig= {
|
||||
baseUrl: "../js",
|
||||
has: {
|
||||
'dojo-firebug': false,
|
||||
'dojo-debug-messages': true
|
||||
},
|
||||
parseOnLoad: false,
|
||||
async: true,
|
||||
packages: [
|
||||
{
|
||||
name:'dojo',
|
||||
location:'dojo'
|
||||
},
|
||||
{
|
||||
name: 'freeipa',
|
||||
location: 'freeipa'
|
||||
},
|
||||
{
|
||||
name: 'test',
|
||||
location: '../test'
|
||||
}
|
||||
]
|
||||
};
|
||||
22
install/ui/test/data/group_show.json
Normal file
22
install/ui/test/data/group_show.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"result" : {
|
||||
"result" : {
|
||||
"dn" : "cn=ipausers,cn=groups,cn=accounts,dc=dom,dc=example,dc=com",
|
||||
"cn" : [
|
||||
"ipausers"
|
||||
],
|
||||
"description" : [
|
||||
"Default group for all users"
|
||||
],
|
||||
"member_user" : [
|
||||
"kfrog"
|
||||
]
|
||||
},
|
||||
"summary" : null,
|
||||
"value" : "ipausers"
|
||||
},
|
||||
"id" : null,
|
||||
"principal" : "admin@DOM.EXAMPLE.COM",
|
||||
"error" : null,
|
||||
"version" : "4.5.90.dev201706131442+gitd665224"
|
||||
}
|
||||
1072
install/ui/test/data/ipa_init.json
Normal file
1072
install/ui/test/data/ipa_init.json
Normal file
File diff suppressed because it is too large
Load Diff
125196
install/ui/test/data/ipa_init_commands.json
Normal file
125196
install/ui/test/data/ipa_init_commands.json
Normal file
File diff suppressed because it is too large
Load Diff
27343
install/ui/test/data/ipa_init_objects.json
Normal file
27343
install/ui/test/data/ipa_init_objects.json
Normal file
File diff suppressed because it is too large
Load Diff
25
install/ui/test/data/user_find.json
Normal file
25
install/ui/test/data/user_find.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"principal" : "admin@DOM.EXAMPLE.COM",
|
||||
"version" : "4.5.90.dev201706131442+gitd665224",
|
||||
"id" : null,
|
||||
"result" : {
|
||||
"count" : 2,
|
||||
"summary" : "2 users matched",
|
||||
"result" : [
|
||||
{
|
||||
"uid" : [
|
||||
"admin"
|
||||
],
|
||||
"dn" : "uid=admin,cn=users,cn=accounts,dc=dom,dc=example,dc=com"
|
||||
},
|
||||
{
|
||||
"dn" : "uid=kfrog,cn=users,cn=accounts,dc=dom,dc=example,dc=com",
|
||||
"uid" : [
|
||||
"kfrog"
|
||||
]
|
||||
}
|
||||
],
|
||||
"truncated" : false
|
||||
},
|
||||
"error" : null
|
||||
}
|
||||
170
install/ui/test/data/user_mod.json
Normal file
170
install/ui/test/data/user_mod.json
Normal file
@@ -0,0 +1,170 @@
|
||||
{
|
||||
"version" : "4.5.90.dev201706131442+gitd665224",
|
||||
"id" : null,
|
||||
"result" : {
|
||||
"summary" : "Modified user \"kfrog\"",
|
||||
"result" : {
|
||||
"uid" : [
|
||||
"kfrog"
|
||||
],
|
||||
"initials" : [
|
||||
"kf"
|
||||
],
|
||||
"has_keytab" : false,
|
||||
"gidnumber" : [
|
||||
"771200109"
|
||||
],
|
||||
"givenname" : [
|
||||
"k"
|
||||
],
|
||||
"sn" : [
|
||||
"frog"
|
||||
],
|
||||
"uidnumber" : [
|
||||
"771200109"
|
||||
],
|
||||
"has_password" : false,
|
||||
"mail" : [
|
||||
"kfrog@dom.example.com"
|
||||
],
|
||||
"nsaccountlock" : false,
|
||||
"displayname" : [
|
||||
"k frog"
|
||||
],
|
||||
"homedirectory" : [
|
||||
"/home/kfrog"
|
||||
],
|
||||
"loginshell" : [
|
||||
"/bin/sh"
|
||||
],
|
||||
"ipauniqueid" : [
|
||||
"01cdce66-5a8b-11e7-93c8-001a4a231594"
|
||||
],
|
||||
"krbprincipalname" : [
|
||||
"kfrog@DOM.EXAMPLE.COM"
|
||||
],
|
||||
"memberof_group" : [
|
||||
"ipausers"
|
||||
],
|
||||
"attributelevelrights" : {
|
||||
"x121address" : "rscwo",
|
||||
"photo" : "rscwo",
|
||||
"internationalisdnnumber" : "rscwo",
|
||||
"street" : "rscwo",
|
||||
"krblastpwdchange" : "rsc",
|
||||
"krbticketpolicyreference" : "rscwo",
|
||||
"pager" : "rscwo",
|
||||
"ou" : "rscwo",
|
||||
"aci" : "rscwo",
|
||||
"krbprincipalaliases" : "rscwo",
|
||||
"cn" : "rscwo",
|
||||
"krblastfailedauth" : "rsc",
|
||||
"objectclass" : "rscwo",
|
||||
"st" : "rscwo",
|
||||
"postalcode" : "rscwo",
|
||||
"krbpasswordexpiration" : "rscwo",
|
||||
"jpegphoto" : "rscwo",
|
||||
"x500uniqueidentifier" : "rscwo",
|
||||
"roomnumber" : "rscwo",
|
||||
"seealso" : "rscwo",
|
||||
"ipasshpubkey" : "rscwo",
|
||||
"krballowedtodelegateto" : "rscwo",
|
||||
"registeredaddress" : "rscwo",
|
||||
"initials" : "rscwo",
|
||||
"uid" : "rscwo",
|
||||
"usersmimecertificate" : "rscwo",
|
||||
"facsimiletelephonenumber" : "rscwo",
|
||||
"krbprincipaltype" : "rscwo",
|
||||
"krbprincipalauthind" : "rscwo",
|
||||
"preferredlanguage" : "rscwo",
|
||||
"krbmaxrenewableage" : "rscwo",
|
||||
"labeleduri" : "rscwo",
|
||||
"secretary" : "rscwo",
|
||||
"krbupenabled" : "rscwo",
|
||||
"carlicense" : "rscwo",
|
||||
"krbprincipalkey" : "swo",
|
||||
"userpassword" : "swo",
|
||||
"businesscategory" : "rscwo",
|
||||
"mail" : "rscwo",
|
||||
"nsaccountlock" : "rscwo",
|
||||
"krbloginfailedcount" : "rscwo",
|
||||
"manager" : "rscwo",
|
||||
"homepostaladdress" : "rscwo",
|
||||
"givenname" : "rscwo",
|
||||
"l" : "rscwo",
|
||||
"preferreddeliverymethod" : "rscwo",
|
||||
"mepmanagedentry" : "rscwo",
|
||||
"krbticketflags" : "rscwo",
|
||||
"inetuserhttpurl" : "rscwo",
|
||||
"krbprincipalname" : "rscwo",
|
||||
"destinationindicator" : "rscwo",
|
||||
"ipauniqueid" : "rsc",
|
||||
"memberof" : "rsc",
|
||||
"employeetype" : "rscwo",
|
||||
"postofficebox" : "rscwo",
|
||||
"employeenumber" : "rscwo",
|
||||
"teletexterminalidentifier" : "rscwo",
|
||||
"mobile" : "rscwo",
|
||||
"krbpwdpolicyreference" : "rscwo",
|
||||
"homephone" : "rscwo",
|
||||
"krbpwdhistory" : "",
|
||||
"uidnumber" : "rscwo",
|
||||
"userpkcs12" : "rscwo",
|
||||
"krbextradata" : "rsc",
|
||||
"telephonenumber" : "rscwo",
|
||||
"gidnumber" : "rscwo",
|
||||
"krblastadminunlock" : "rscwo",
|
||||
"inetuserstatus" : "rscwo",
|
||||
"o" : "rscwo",
|
||||
"krbcanonicalname" : "rscwo",
|
||||
"description" : "rscwo",
|
||||
"gecos" : "rscwo",
|
||||
"physicaldeliveryofficename" : "rscwo",
|
||||
"postaladdress" : "rscwo",
|
||||
"telexnumber" : "rscwo",
|
||||
"audio" : "rscwo",
|
||||
"loginshell" : "rscwo",
|
||||
"homedirectory" : "rscwo",
|
||||
"krbmaxticketlife" : "rscwo",
|
||||
"departmentnumber" : "rscwo",
|
||||
"displayname" : "rscwo",
|
||||
"title" : "rscwo",
|
||||
"krbprincipalexpiration" : "rscwo",
|
||||
"usercertificate" : "rscwo",
|
||||
"krblastsuccessfulauth" : "rsc",
|
||||
"sn" : "rscwo"
|
||||
},
|
||||
"gecos" : [
|
||||
"k frogx"
|
||||
],
|
||||
"dn" : "uid=kfrog,cn=users,cn=accounts,dc=dom,dc=example,dc=com",
|
||||
"objectclass" : [
|
||||
"top",
|
||||
"person",
|
||||
"organizationalperson",
|
||||
"inetorgperson",
|
||||
"inetuser",
|
||||
"posixaccount",
|
||||
"krbprincipalaux",
|
||||
"krbticketpolicyaux",
|
||||
"ipaobject",
|
||||
"ipasshuser",
|
||||
"ipaSshGroupOfPubKeys",
|
||||
"mepOriginEntry"
|
||||
],
|
||||
"cn" : [
|
||||
"k frog"
|
||||
],
|
||||
"krbcanonicalname" : [
|
||||
"kfrog@DOM.EXAMPLE.COM"
|
||||
],
|
||||
"mepmanagedentry" : [
|
||||
"cn=kfrog,cn=groups,cn=accounts,dc=dom,dc=example,dc=com"
|
||||
],
|
||||
"preserved" : false
|
||||
},
|
||||
"value" : "kfrog"
|
||||
},
|
||||
"principal" : "admin@DOM.EXAMPLE.COM",
|
||||
"error" : null
|
||||
}
|
||||
170
install/ui/test/data/user_show.json
Normal file
170
install/ui/test/data/user_show.json
Normal file
@@ -0,0 +1,170 @@
|
||||
{
|
||||
"error" : null,
|
||||
"principal" : "admin@DOM.EXAMPLE.COM",
|
||||
"id" : null,
|
||||
"version" : "4.5.90.dev201706131442+gitd665224",
|
||||
"result" : {
|
||||
"value" : "kfrog",
|
||||
"summary" : null,
|
||||
"result" : {
|
||||
"uidnumber" : [
|
||||
"771200109"
|
||||
],
|
||||
"homedirectory" : [
|
||||
"/home/kfrog"
|
||||
],
|
||||
"mail" : [
|
||||
"kfrog@dom.example.com"
|
||||
],
|
||||
"gidnumber" : [
|
||||
"771200109"
|
||||
],
|
||||
"krbcanonicalname" : [
|
||||
"kfrog@DOM.EXAMPLE.COM"
|
||||
],
|
||||
"has_keytab" : false,
|
||||
"mepmanagedentry" : [
|
||||
"cn=kfrog,cn=groups,cn=accounts,dc=dom,dc=example,dc=com"
|
||||
],
|
||||
"dn" : "uid=kfrog,cn=users,cn=accounts,dc=dom,dc=example,dc=com",
|
||||
"initials" : [
|
||||
"kf"
|
||||
],
|
||||
"cn" : [
|
||||
"k frog"
|
||||
],
|
||||
"objectclass" : [
|
||||
"top",
|
||||
"person",
|
||||
"organizationalperson",
|
||||
"inetorgperson",
|
||||
"inetuser",
|
||||
"posixaccount",
|
||||
"krbprincipalaux",
|
||||
"krbticketpolicyaux",
|
||||
"ipaobject",
|
||||
"ipasshuser",
|
||||
"ipaSshGroupOfPubKeys",
|
||||
"mepOriginEntry"
|
||||
],
|
||||
"loginshell" : [
|
||||
"/bin/sh"
|
||||
],
|
||||
"gecos" : [
|
||||
"k frog"
|
||||
],
|
||||
"ipauniqueid" : [
|
||||
"01cdce66-5a8b-11e7-93c8-001a4a231594"
|
||||
],
|
||||
"displayname" : [
|
||||
"k frog"
|
||||
],
|
||||
"has_password" : false,
|
||||
"krbprincipalname" : [
|
||||
"kfrog@DOM.EXAMPLE.COM"
|
||||
],
|
||||
"uid" : [
|
||||
"kfrog"
|
||||
],
|
||||
"givenname" : [
|
||||
"k"
|
||||
],
|
||||
"nsaccountlock" : false,
|
||||
"sn" : [
|
||||
"frog"
|
||||
],
|
||||
"memberof_group" : [
|
||||
"ipausers"
|
||||
],
|
||||
"attributelevelrights" : {
|
||||
"st" : "rscwo",
|
||||
"loginshell" : "rscwo",
|
||||
"l" : "rscwo",
|
||||
"krblastpwdchange" : "rsc",
|
||||
"destinationindicator" : "rscwo",
|
||||
"gecos" : "rscwo",
|
||||
"telephonenumber" : "rscwo",
|
||||
"displayname" : "rscwo",
|
||||
"secretary" : "rscwo",
|
||||
"telexnumber" : "rscwo",
|
||||
"userpkcs12" : "rscwo",
|
||||
"aci" : "rscwo",
|
||||
"krbloginfailedcount" : "rscwo",
|
||||
"preferreddeliverymethod" : "rscwo",
|
||||
"street" : "rscwo",
|
||||
"krbcanonicalname" : "rscwo",
|
||||
"inetuserhttpurl" : "rscwo",
|
||||
"krbpasswordexpiration" : "rscwo",
|
||||
"manager" : "rscwo",
|
||||
"krbmaxticketlife" : "rscwo",
|
||||
"initials" : "rscwo",
|
||||
"internationalisdnnumber" : "rscwo",
|
||||
"postalcode" : "rscwo",
|
||||
"krbprincipaltype" : "rscwo",
|
||||
"postaladdress" : "rscwo",
|
||||
"photo" : "rscwo",
|
||||
"krbprincipalkey" : "swo",
|
||||
"krbpwdpolicyreference" : "rscwo",
|
||||
"teletexterminalidentifier" : "rscwo",
|
||||
"usercertificate" : "rscwo",
|
||||
"physicaldeliveryofficename" : "rscwo",
|
||||
"postofficebox" : "rscwo",
|
||||
"mail" : "rscwo",
|
||||
"title" : "rscwo",
|
||||
"homepostaladdress" : "rscwo",
|
||||
"ipasshpubkey" : "rscwo",
|
||||
"o" : "rscwo",
|
||||
"krbticketpolicyreference" : "rscwo",
|
||||
"krblastsuccessfulauth" : "rsc",
|
||||
"x121address" : "rscwo",
|
||||
"ipauniqueid" : "rsc",
|
||||
"krbprincipalexpiration" : "rscwo",
|
||||
"registeredaddress" : "rscwo",
|
||||
"preferredlanguage" : "rscwo",
|
||||
"ou" : "rscwo",
|
||||
"labeleduri" : "rscwo",
|
||||
"mobile" : "rscwo",
|
||||
"audio" : "rscwo",
|
||||
"jpegphoto" : "rscwo",
|
||||
"inetuserstatus" : "rscwo",
|
||||
"sn" : "rscwo",
|
||||
"roomnumber" : "rscwo",
|
||||
"krbpwdhistory" : "",
|
||||
"gidnumber" : "rscwo",
|
||||
"usersmimecertificate" : "rscwo",
|
||||
"x500uniqueidentifier" : "rscwo",
|
||||
"krbprincipalauthind" : "rscwo",
|
||||
"employeenumber" : "rscwo",
|
||||
"seealso" : "rscwo",
|
||||
"krbticketflags" : "rscwo",
|
||||
"krbmaxrenewableage" : "rscwo",
|
||||
"krblastfailedauth" : "rsc",
|
||||
"businesscategory" : "rscwo",
|
||||
"userpassword" : "swo",
|
||||
"homephone" : "rscwo",
|
||||
"memberof" : "rsc",
|
||||
"krbextradata" : "rsc",
|
||||
"uid" : "rscwo",
|
||||
"krbprincipalname" : "rscwo",
|
||||
"krblastadminunlock" : "rscwo",
|
||||
"nsaccountlock" : "rscwo",
|
||||
"givenname" : "rscwo",
|
||||
"krbupenabled" : "rscwo",
|
||||
"employeetype" : "rscwo",
|
||||
"krballowedtodelegateto" : "rscwo",
|
||||
"homedirectory" : "rscwo",
|
||||
"uidnumber" : "rscwo",
|
||||
"departmentnumber" : "rscwo",
|
||||
"pager" : "rscwo",
|
||||
"carlicense" : "rscwo",
|
||||
"mepmanagedentry" : "rscwo",
|
||||
"objectclass" : "rscwo",
|
||||
"cn" : "rscwo",
|
||||
"description" : "rscwo",
|
||||
"facsimiletelephonenumber" : "rscwo",
|
||||
"krbprincipalaliases" : "rscwo"
|
||||
},
|
||||
"preserved" : false
|
||||
}
|
||||
}
|
||||
}
|
||||
77
install/ui/test/data/user_show/1.json
Normal file
77
install/ui/test/data/user_show/1.json
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"result" : {
|
||||
"result" : {
|
||||
"loginshell" : [
|
||||
"/bin/bash"
|
||||
],
|
||||
"has_keytab" : true,
|
||||
"krbprincipalname" : [
|
||||
"admin@DOM.EXAMPLE.COM"
|
||||
],
|
||||
"dn" : "uid=admin,cn=users,cn=accounts,dc=dom,dc=example,dc=com",
|
||||
"uidnumber" : [
|
||||
"771200000"
|
||||
],
|
||||
"cn" : [
|
||||
"Administrator"
|
||||
],
|
||||
"sn" : [
|
||||
"Administrator"
|
||||
],
|
||||
"krblastpwdchange" : [
|
||||
{
|
||||
"__datetime__" : "20170613145754Z"
|
||||
}
|
||||
],
|
||||
"gecos" : [
|
||||
"Administrator"
|
||||
],
|
||||
"ipauniqueid" : [
|
||||
"0805fdfa-5048-11e7-b863-001a4a231594"
|
||||
],
|
||||
"memberof_group" : [
|
||||
"trust admins",
|
||||
"admins"
|
||||
],
|
||||
"nsaccountlock" : false,
|
||||
"krbextradata" : [
|
||||
{
|
||||
"__base64__" : "AAJy/T9Zcm9vdC9hZG1pbkBET00tMDg0LkFCQy5JRE0uTEFCLkVORy5CUlEuUkVESEFULkNPTQA="
|
||||
}
|
||||
],
|
||||
"objectclass" : [
|
||||
"top",
|
||||
"person",
|
||||
"posixaccount",
|
||||
"krbprincipalaux",
|
||||
"krbticketpolicyaux",
|
||||
"inetuser",
|
||||
"ipaobject",
|
||||
"ipasshuser",
|
||||
"ipaSshGroupOfPubKeys"
|
||||
],
|
||||
"krbpasswordexpiration" : [
|
||||
{
|
||||
"__datetime__" : "20170911145754Z"
|
||||
}
|
||||
],
|
||||
"homedirectory" : [
|
||||
"/home/admin"
|
||||
],
|
||||
"gidnumber" : [
|
||||
"771200000"
|
||||
],
|
||||
"uid" : [
|
||||
"admin"
|
||||
],
|
||||
"has_password" : true,
|
||||
"preserved" : false
|
||||
},
|
||||
"summary" : null,
|
||||
"value" : "admin"
|
||||
},
|
||||
"principal" : "admin@DOM.EXAMPLE.COM",
|
||||
"version" : "4.5.90.dev201706131442+gitd665224",
|
||||
"error" : null,
|
||||
"id" : null
|
||||
}
|
||||
26
install/ui/test/details_tests.html
Normal file
26
install/ui/test/details_tests.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Details Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/bootstrap.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/details_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Details Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
349
install/ui/test/details_tests.js
Normal file
349
install/ui/test/details_tests.js
Normal file
@@ -0,0 +1,349 @@
|
||||
/* Authors:
|
||||
* Adam Young <ayoung@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/>.
|
||||
*/
|
||||
|
||||
define([
|
||||
'freeipa/metadata',
|
||||
'freeipa/ipa',
|
||||
'freeipa/jquery',
|
||||
'freeipa/details',
|
||||
'freeipa/facet',
|
||||
'freeipa/field',
|
||||
'freeipa/reg',
|
||||
'freeipa/rpc',
|
||||
'freeipa/entity',
|
||||
'freeipa/widget'],
|
||||
function(md, IPA, $, mod_details, mod_facet, mod_field, reg, rpc) {
|
||||
return function() {
|
||||
|
||||
var details_container;
|
||||
|
||||
|
||||
module('details', {
|
||||
setup: function() {
|
||||
IPA.ajax_options.async = false;
|
||||
|
||||
mod_facet.register();
|
||||
mod_details.register();
|
||||
mod_field.register();
|
||||
|
||||
IPA.init({
|
||||
url: 'data',
|
||||
on_error: function(xhr, text_status, error_thrown) {
|
||||
ok(false, "ipa_init() failed: "+error_thrown);
|
||||
}
|
||||
});
|
||||
|
||||
details_container = $('<div id="details"/>').appendTo(document.body);
|
||||
|
||||
IPA.register('user', function(spec) {
|
||||
|
||||
return IPA.entity({
|
||||
name: 'user',
|
||||
metadata: md.source.objects.user
|
||||
});
|
||||
});
|
||||
},
|
||||
teardown: function() {
|
||||
details_container.remove();
|
||||
reg.facet.remove('details');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test("Testing IPA.details_section.create().", function() {
|
||||
|
||||
var facet = IPA.details_facet({
|
||||
entity: IPA.get_entity('user'),
|
||||
sections: [
|
||||
{
|
||||
name:'IDIDID',
|
||||
label:'NAMENAMENAME',
|
||||
fields: [
|
||||
'cn', 'uid', 'mail'
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var section = facet.widgets.get_widget('IDIDID');
|
||||
|
||||
ok(section !== null, 'Verifying section existence.');
|
||||
|
||||
var fields = section.widgets.get_widgets();
|
||||
var container = $("<div/>");
|
||||
section.create(container);
|
||||
|
||||
var section_el = $('.details-section-content', container);
|
||||
|
||||
same(
|
||||
section_el.length, 1,
|
||||
'Verifying section element');
|
||||
|
||||
var controls = $('.form-group', section_el);
|
||||
same(
|
||||
controls.length, fields.length,
|
||||
'Verifying number of controls');
|
||||
|
||||
for (var i=0; i<fields.length; i++) {
|
||||
var field = fields[i];
|
||||
|
||||
var field_label = $('.control-label label[name='+field.name+']', container);
|
||||
same(
|
||||
field_label.text(), field.label,
|
||||
'Verifying label for field '+field.name);
|
||||
|
||||
var field_container = $('.controls div[name='+field.name+']', container);
|
||||
|
||||
ok(
|
||||
field_container.length,
|
||||
'Verifying container for field '+field.name);
|
||||
|
||||
ok(
|
||||
field_container.hasClass('widget'),
|
||||
'Verifying field '+field.name+' was created');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
test("Testing details lifecycle: create, load.", function(){
|
||||
|
||||
var data = {};
|
||||
data.result = {};
|
||||
data.result.result = {};
|
||||
|
||||
rpc.command({
|
||||
entity: 'user',
|
||||
method: 'show',
|
||||
args: ['kfrog'],
|
||||
on_success: function(data, text_status, xhr) {
|
||||
ok(true, "rpc.command() succeeded.");
|
||||
},
|
||||
on_error: function(xhr, text_status, error_thrown) {
|
||||
ok(false, "rpc.command() failed: "+error_thrown);
|
||||
}
|
||||
}).execute();
|
||||
|
||||
var save_called = false;
|
||||
var load_called = false;
|
||||
|
||||
var load_success_called = false;
|
||||
var load_failure_called = false;
|
||||
var update_success_called = false;
|
||||
var update_failure_called = false;
|
||||
|
||||
function test_field(spec) {
|
||||
var that = IPA.field(spec);
|
||||
|
||||
that.load = function(record) {
|
||||
load_called = true;
|
||||
that.field_load(record);
|
||||
};
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
function test_widget(spec) {
|
||||
var that = IPA.input_widget(spec);
|
||||
|
||||
that.widget_save = that.save;
|
||||
|
||||
that.save = function() {
|
||||
save_called = true;
|
||||
return that.widget_save();
|
||||
};
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
reg.field.register('test', test_field);
|
||||
reg.widget.register('test', test_widget);
|
||||
|
||||
IPA.register('user', function(spec) {
|
||||
|
||||
var that = IPA.entity(spec);
|
||||
|
||||
that.init = function() {
|
||||
that.entity_init();
|
||||
|
||||
that.builder.details_facet({
|
||||
sections: [
|
||||
{
|
||||
name: 'identity',
|
||||
label: IPA.messages.details.identity,
|
||||
fields: [ 'title', 'givenname', 'sn', 'cn', 'displayname', 'initials' ]
|
||||
},
|
||||
{
|
||||
name: 'contact',
|
||||
label: 'contact',
|
||||
fields: [
|
||||
{
|
||||
$type: 'test',
|
||||
name:'test'
|
||||
},
|
||||
{
|
||||
$type: 'multivalued',
|
||||
name:'mail'
|
||||
},
|
||||
{
|
||||
$type: 'multivalued',
|
||||
name:'telephonenumber'
|
||||
},
|
||||
{
|
||||
$type: 'multivalued',
|
||||
name:'pager'
|
||||
},
|
||||
{
|
||||
$type: 'multivalued',
|
||||
name:'mobile'
|
||||
},
|
||||
{
|
||||
$type: 'multivalued',
|
||||
name:'facsimiletelephonenumber'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
return that;
|
||||
});
|
||||
|
||||
var entity = IPA.get_entity('user');
|
||||
var container = $('<div/>', {}).appendTo(details_container);
|
||||
var facet = entity.get_facet('details');
|
||||
facet.container_node = container[0];
|
||||
facet.create();
|
||||
|
||||
facet.load(data);
|
||||
|
||||
var contact = $('.details-section[name=contact]', facet.dom_node);
|
||||
|
||||
ok(
|
||||
contact.length,
|
||||
'Verifying section for contact is created');
|
||||
|
||||
var identity = $('.details-section[name=identity]', facet.dom_node);
|
||||
|
||||
ok(
|
||||
identity.length,
|
||||
'Verifying section for identity is created');
|
||||
|
||||
var rows = $('.form-group', identity);
|
||||
|
||||
same(
|
||||
rows.length, 6,
|
||||
'Verifying rows for identity');
|
||||
|
||||
ok (load_called, 'load manager called');
|
||||
|
||||
var field = facet.fields.get_field('test');
|
||||
field.set_value("foo");
|
||||
var widget = facet.widgets.get_widget('contact.test');
|
||||
// simulate user change
|
||||
widget.emit('value-change', { source: widget, value: "foo" });
|
||||
|
||||
facet.update(
|
||||
function(){update_success_called = true;},
|
||||
function(){update_failure_called = true;});
|
||||
|
||||
ok (update_success_called,'update success called');
|
||||
ok (!update_failure_called,'update failure not called');
|
||||
ok (save_called, 'save called');
|
||||
|
||||
});
|
||||
|
||||
|
||||
test("Testing IPA.details_section_create again()",function() {
|
||||
|
||||
var facet = IPA.details_facet({
|
||||
entity: IPA.get_entity('user'),
|
||||
disable_breadcrumb: true,
|
||||
disable_facet_tabs: true,
|
||||
sections: [
|
||||
{
|
||||
name:'IDIDID',
|
||||
label:'NAMENAMENAME',
|
||||
fields: [
|
||||
{
|
||||
name: 'cn',
|
||||
label: 'Entity Name'
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: 'Description'
|
||||
},
|
||||
{
|
||||
name: 'number',
|
||||
label: 'Entity ID'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var section = facet.widgets.get_widget('IDIDID');
|
||||
ok(section !== null, 'Verifying section existence.');
|
||||
var fields = section.widgets.get_widgets();
|
||||
|
||||
var container = $("<div title='entity'/>");
|
||||
var details = $("<div/>");
|
||||
container.append(details);
|
||||
|
||||
var data = {};
|
||||
data.result = {};
|
||||
data.result.result = {};
|
||||
|
||||
section.create(container);
|
||||
facet.load(data);
|
||||
|
||||
var section_el = $('.details-section-content', container);
|
||||
|
||||
same(
|
||||
section_el.length, 1,
|
||||
'Verifying section element');
|
||||
|
||||
var controls = $('.form-group', section_el);
|
||||
same(
|
||||
controls.length, fields.length,
|
||||
'Verifying number of controls');
|
||||
|
||||
for (var i=0; i<fields.length; i++) {
|
||||
var field = fields[i];
|
||||
|
||||
var field_label = $('.control-label label[name='+field.name+']', container);
|
||||
same(
|
||||
field_label.text(), field.label,
|
||||
'Verifying label for field '+field.name);
|
||||
|
||||
var field_container = $('.controls div[name='+field.name+']', container);
|
||||
|
||||
ok(
|
||||
field_container.length,
|
||||
'Verifying container for field '+field.name);
|
||||
|
||||
ok(
|
||||
field_container.hasClass('widget'),
|
||||
'Verifying field '+field.name+' was created');
|
||||
}
|
||||
});
|
||||
|
||||
};});
|
||||
25
install/ui/test/entity_tests.html
Normal file
25
install/ui/test/entity_tests.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Entity Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/entity_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Entity Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
102
install/ui/test/entity_tests.js
Normal file
102
install/ui/test/entity_tests.js
Normal file
@@ -0,0 +1,102 @@
|
||||
/* Authors:
|
||||
* Endi Sukma Dewata <edewata@redhat.com>
|
||||
* Adam Young <ayoung@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/>.
|
||||
*/
|
||||
|
||||
define([
|
||||
'freeipa/ipa',
|
||||
'freeipa/jquery',
|
||||
'freeipa/facet',
|
||||
'freeipa/search',
|
||||
'freeipa/reg',
|
||||
'freeipa/entity',
|
||||
'freeipa/details'],
|
||||
function(IPA, $, mod_facet, mod_search, reg, mod_ent, mod_details) {
|
||||
return function() {
|
||||
|
||||
var container;
|
||||
|
||||
module('entity',{
|
||||
setup: function() {
|
||||
|
||||
IPA.ajax_options.async = false;
|
||||
|
||||
mod_search.register();
|
||||
mod_details.register();
|
||||
|
||||
IPA.init({
|
||||
url: 'data',
|
||||
on_success: function(data, text_status, xhr) {
|
||||
|
||||
IPA.register('user', function(spec) {
|
||||
|
||||
var that = IPA.entity(spec);
|
||||
|
||||
that.init = function() {
|
||||
that.entity_init();
|
||||
|
||||
that.builder.search_facet({
|
||||
columns: [ 'uid' ]
|
||||
});
|
||||
};
|
||||
|
||||
return that;
|
||||
});
|
||||
},
|
||||
on_error: function(xhr, text_status, error_thrown) {
|
||||
ok(false, "ipa_init() failed: "+error_thrown);
|
||||
}
|
||||
});
|
||||
|
||||
container = $('<div id="content"/>').appendTo(document.body);
|
||||
|
||||
},
|
||||
teardown: function() {
|
||||
container.remove();
|
||||
reg.facet.remove('search');
|
||||
}
|
||||
});
|
||||
|
||||
test('Testing IPA.entity_set_search_definition().', function() {
|
||||
|
||||
var uid_callback = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
var entity = IPA.get_entity('user');
|
||||
var facet = entity.get_facet('search');
|
||||
facet.container_node = container[0];
|
||||
facet.create();
|
||||
|
||||
var column = facet.get_columns()[0];
|
||||
ok(
|
||||
column,
|
||||
'column is not null');
|
||||
|
||||
equals(
|
||||
column.name, 'uid',
|
||||
'column.name');
|
||||
|
||||
equals(
|
||||
column.label, 'User login',
|
||||
'column.label');
|
||||
|
||||
});
|
||||
|
||||
};});
|
||||
48
install/ui/test/index.html
Normal file
48
install/ui/test/index.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>IPA Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<style type="text/css">
|
||||
#content {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
font-size: smaller;
|
||||
|
||||
border-bottom: 1px solid #fff;
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">IPA Test Suite</h1>
|
||||
|
||||
<h2 id="qunit-banner" class="qunit-pass"></h2>
|
||||
|
||||
<div id="content">
|
||||
<a href="all_tests.html">Complete Test Suite</a>
|
||||
<ul>
|
||||
<li><a href="ordered_map_tests.html">Ordered Map Test Suite</a>
|
||||
<li><a href="ipa_tests.html">Core Test Suite</a>
|
||||
<li><a href="entity_tests.html">Entity Test Suite</a>
|
||||
<li><a href="details_tests.html">Details Test Suite</a>
|
||||
<li><a href="association_tests.html">Association Test Suite</a>
|
||||
<li><a href="navigation_tests.html">Navigation Test Suite</a>
|
||||
<li><a href="certificate_tests.html">Certificate Test Suite</a>
|
||||
<li><a href="aci_tests.html">Access Control Interface Test Suite</a>
|
||||
<li><a href="widget_tests.html">Widget Test Suite</a>
|
||||
<li><a href="ip_tests.html">IP Addresses Test Suite</a>
|
||||
<li><a href="utils_tests.html">Utils Test Suite</a>
|
||||
<li><a href="build_tests.html">Build Test Suite</a>
|
||||
<li><a href="binding_tests.html">Binding Test Suite</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="qunit-testresult">
|
||||
<br>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
25
install/ui/test/ip_tests.html
Normal file
25
install/ui/test/ip_tests.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>IP addresses test suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/ip_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">IP addresses test suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
308
install/ui/test/ip_tests.js
Normal file
308
install/ui/test/ip_tests.js
Normal file
@@ -0,0 +1,308 @@
|
||||
/* Authors:
|
||||
* Petr Vobornik <pvoborni@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/>.
|
||||
*/
|
||||
|
||||
define(['freeipa/ipa', 'freeipa/net'], function(IPA, NET) {
|
||||
return function() {
|
||||
|
||||
module('ip-addresses',{
|
||||
setup: function() {
|
||||
},
|
||||
teardown: function() {
|
||||
}
|
||||
});
|
||||
|
||||
var get_reverse = function(str) {
|
||||
var address = NET.ip_address(str);
|
||||
return address.get_reverse();
|
||||
};
|
||||
|
||||
test('Testing correct IPv4 addresses', function() {
|
||||
|
||||
var address = NET.ip_address('255.0.173.1');
|
||||
ok(address.valid, 'Dotted decimal - 255.0.173.1');
|
||||
same(address.parts, ['255', '0', '173', '1'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('0377.0.0255.01');
|
||||
ok(address.valid, 'Dotted octal - 0377.0.0255.01');
|
||||
same(address.parts, ['255', '0', '173', '1'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('0xFF.0x0.0xAD.0x1');
|
||||
ok(address.valid, 'Dotted hexadecimal - 0xFF.0x.0xAD.0x1');
|
||||
same(address.parts, ['255', '0', '173', '1'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('4294967295');
|
||||
ok(address.valid, 'Max decimal - 4294967295');
|
||||
same(address.parts, ['255', '255', '255', '255'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('037777777777');
|
||||
ok(address.valid, 'Max octal - 037777777777');
|
||||
same(address.parts, ['255', '255', '255', '255'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('0xFFFFFFFF');
|
||||
ok(address.valid, 'Max hexadecimal - 0xFFFFFFFF');
|
||||
same(address.parts, ['255', '255', '255', '255'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('255.0.0xAD.01');
|
||||
ok(address.valid, 'Dotted mixed - 255.0.0xAD.01');
|
||||
same(address.parts, ['255', '0', '173', '1'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('0');
|
||||
ok(address.valid, 'Zero decimal - 0');
|
||||
same(address.parts, ['0', '0', '0', '0'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('00');
|
||||
ok(address.valid, 'Zero octal - 00');
|
||||
same(address.parts, ['0', '0', '0', '0'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('0X0');
|
||||
ok(address.valid, 'Zero hexa - 0X0');
|
||||
same(address.parts, ['0', '0', '0', '0'], 'Checking parts');
|
||||
});
|
||||
|
||||
test('Testing incorrect IPv4 addresses', function() {
|
||||
|
||||
var address = NET.ip_address('256.0.0.1');
|
||||
ok(!address.valid, 'Out of range - 256.0.0.1');
|
||||
|
||||
address = NET.ip_address('0x100.0.0.1');
|
||||
ok(!address.valid, 'Out of range - 0x100.0.0.1');
|
||||
|
||||
address = NET.ip_address('0400.0.0.1');
|
||||
ok(!address.valid, 'Out of range - 0400.0.0.1');
|
||||
|
||||
|
||||
address = NET.ip_address('0x100000000');
|
||||
ok(!address.valid, 'Out of range - 0x100000000');
|
||||
|
||||
address = NET.ip_address('040000000000');
|
||||
ok(!address.valid, 'Out of range - 040000000000');
|
||||
|
||||
address = NET.ip_address('4294967296');
|
||||
ok(!address.valid, 'Out of range - 4294967296');
|
||||
|
||||
address = NET.ip_address('250.0.173');
|
||||
ok(!address.valid, '3 parts - 250.0.173');
|
||||
|
||||
address = NET.ip_address('250.0.173.21.21');
|
||||
ok(!address.valid, '5 parts - 250.0.173.21.21');
|
||||
|
||||
address = NET.ip_address('250.001.173.21');
|
||||
ok(!address.valid, 'Trailing zeros - 250.001.173.21');
|
||||
|
||||
address = NET.ip_address('250.001.173.FF');
|
||||
ok(!address.valid, 'Bad hexapart - 250.01.173.FF');
|
||||
|
||||
address = NET.ip_address('abcd');
|
||||
ok(!address.valid, 'Word - abcd');
|
||||
|
||||
address = NET.ip_address('192.168 .0.21');
|
||||
ok(!address.valid, 'With space - 192.168 .0.21');
|
||||
|
||||
address = NET.ip_address(' 192.168.0.21');
|
||||
ok(!address.valid, 'With space - " 192.168.0.21"');
|
||||
});
|
||||
|
||||
test('Testing correct IPv6 addresses', function() {
|
||||
|
||||
var address = NET.ip_address('2001:0db8:85a3:0000:0000:8a2e:0370:7334');
|
||||
ok(address.valid, 'Address - 2001:0db8:85a3:0000:0000:8a2e:0370:7334');
|
||||
same(address.parts, ['2001', '0db8', '85a3', '0000','0000','8a2e','0370','7334'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('2001:db8:85a3:0:0:8a2e:370:7334');
|
||||
ok(address.valid, 'Without trailing zeros - 2001:db8:85a3:0:0:8a2e:370:7334');
|
||||
same(address.parts, ['2001', '0db8', '85a3', '0000','0000','8a2e','0370','7334'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('2001:db8::1:0:0:1');
|
||||
ok(address.valid, 'With :: - 2001:db8::1:0:0:1');
|
||||
same(address.parts, ['2001', '0db8', '0000', '0000','0001','0000','0000','0001'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('::1');
|
||||
ok(address.valid, 'Address - ::1');
|
||||
same(address.parts, ['0000', '0000', '0000', '0000','0000','0000','0000','0001'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('::');
|
||||
ok(address.valid, 'Address - ::');
|
||||
same(address.parts, ['0000', '0000', '0000', '0000','0000','0000','0000','0000'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('1::');
|
||||
ok(address.valid, 'Address - 1::');
|
||||
same(address.parts, ['0001', '0000', '0000', '0000','0000','0000','0000','0000'], 'Checking parts');
|
||||
|
||||
address = NET.ip_address('::ffff:192.0.2.128');
|
||||
ok(address.valid, 'With IPv4 part - ::ffff:192.0.2.128');
|
||||
same(address.parts, ['0000', '0000', '0000', '0000','0000','ffff','c000','0280'], 'Checking parts');
|
||||
|
||||
});
|
||||
|
||||
test('Testing incorrect IPv6 addresses', function() {
|
||||
|
||||
var address = NET.ip_address('02001:0db8:85a3:0000:0000:8a2e:0370:7334');
|
||||
ok(!address.valid, 'Too long part- 02001:0db8:85a3:0000:0000:8a2e:0370:7334');
|
||||
|
||||
address = NET.ip_address('2001:db8:85a3:0:0:8a2e:370');
|
||||
ok(!address.valid, 'Missing part - 2001:db8:85a3:0:0:8a2e:370');
|
||||
|
||||
address = NET.ip_address(':');
|
||||
ok(!address.valid, 'Address - :');
|
||||
|
||||
address = NET.ip_address('::1::');
|
||||
ok(!address.valid, 'Address - ::1::');
|
||||
|
||||
address = NET.ip_address(':::');
|
||||
ok(!address.valid, 'Address - :::');
|
||||
|
||||
address = NET.ip_address('1::1::1');
|
||||
ok(!address.valid, 'Address - 1::1::1');
|
||||
|
||||
address = NET.ip_address('::ffff:192.0.0x2.128');
|
||||
ok(!address.valid, 'With IPv4 hex part - ::ffff:192.0.0x2.128');
|
||||
|
||||
address = NET.ip_address('::ffff:192.0.02.128');
|
||||
ok(!address.valid, 'With IPv4 oct part - ::ffff:192.0.02.128');
|
||||
|
||||
address = NET.ip_address('aa:rt::');
|
||||
ok(!address.valid, 'Invalid chars - aa:rt::');
|
||||
});
|
||||
|
||||
|
||||
test('Testing reverse addresses', function() {
|
||||
|
||||
var reverse_valid = '4.3.3.7.0.7.3.0.e.2.a.8.0.0.0.0.0.0.0.0.3.a.5.8.8.b.d.0.1.0.0.2.ip6.arpa';
|
||||
|
||||
var reverse = get_reverse('2001:0db8:85a3:0000:0000:8a2e:0370:7334');
|
||||
same(reverse, reverse_valid, '2001:0db8:85a3:0000:0000:8a2e:0370:7334');
|
||||
|
||||
reverse = get_reverse('2001:db8:85a3::8a2e:370:7334');
|
||||
same(reverse, reverse_valid, '2001:db8:85a3::8a2e:370:7334');
|
||||
|
||||
reverse_valid = '1.0.168.192.in-addr.arpa';
|
||||
reverse = get_reverse('192.168.0.1');
|
||||
same(reverse, reverse_valid, '192.168.0.1');
|
||||
|
||||
reverse_valid = '0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa';
|
||||
reverse = get_reverse('::');
|
||||
same(reverse, reverse_valid, '::');
|
||||
|
||||
reverse_valid = '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa';
|
||||
reverse = get_reverse('::1');
|
||||
same(reverse, reverse_valid, '::1');
|
||||
|
||||
reverse_valid = '0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.ip6.arpa';
|
||||
reverse = get_reverse('1::');
|
||||
same(reverse, reverse_valid, '1::');
|
||||
|
||||
reverse_valid = '5.1.0.0.8.a.0.c.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa';
|
||||
reverse = get_reverse('::192.168.0.21');
|
||||
same(reverse, reverse_valid, '::192.168.0.21');
|
||||
|
||||
reverse_valid = '255.254.253.252.in-addr.arpa';
|
||||
reverse = get_reverse('0xFCFDFEFF');
|
||||
same(reverse, reverse_valid, '0xFCFDFEFF');
|
||||
|
||||
reverse = get_reverse('4244504319');
|
||||
same(reverse, reverse_valid, '4244504319');
|
||||
|
||||
reverse = get_reverse('037477377377');
|
||||
same(reverse, reverse_valid, '037477377377');
|
||||
|
||||
reverse_valid = '0.0.0.0.in-addr.arpa';
|
||||
reverse = get_reverse('0');
|
||||
same(reverse, reverse_valid, '0');
|
||||
|
||||
reverse = get_reverse('00');
|
||||
same(reverse, reverse_valid, '00');
|
||||
|
||||
reverse = get_reverse('0x0');
|
||||
same(reverse, reverse_valid, '0x0');
|
||||
});
|
||||
|
||||
test('Usage - constructor direct input', function() {
|
||||
|
||||
var address = NET.ip_address('0xC0A80001');
|
||||
ok(address.valid, 'Valid');
|
||||
same(address.type, 'v4-int', 'Checking type');
|
||||
same(address.parts, ['192', '168', '0', '1'], 'Checking parts');
|
||||
var reverse_valid = '1.0.168.192.in-addr.arpa';
|
||||
same(address.get_reverse(), reverse_valid, 'Checking reverse address');
|
||||
});
|
||||
|
||||
test('Usage - constructor spec object', function() {
|
||||
|
||||
var address = NET.ip_address({ address: '0xC0A80001' });
|
||||
ok(address.valid, 'Valid');
|
||||
same(address.type, 'v4-int', 'Checking type');
|
||||
same(address.parts, ['192', '168', '0', '1'], 'Checking parts');
|
||||
var reverse_valid = '1.0.168.192.in-addr.arpa';
|
||||
same(address.get_reverse(), reverse_valid, 'Checking reverse address');
|
||||
});
|
||||
|
||||
test('Usage - constructor spec object - by parts', function() {
|
||||
|
||||
var address = NET.ip_address({
|
||||
parts: ['0xC0', '168', '00', '1'],
|
||||
type: 'v4-quads'
|
||||
});
|
||||
ok(address.valid, 'Valid');
|
||||
same(address.type, 'v4-quads', 'Checking type');
|
||||
same(address.parts, ['192', '168', '0', '1'], 'Checking parts');
|
||||
var reverse_valid = '1.0.168.192.in-addr.arpa';
|
||||
same(address.get_reverse(), reverse_valid, 'Checking reverse address');
|
||||
});
|
||||
|
||||
test('Usage - constructor spec object - by parts - IPv6', function() {
|
||||
|
||||
var address = NET.ip_address({
|
||||
parts: ['2001','db8','85a3','0','0','8a2e','370','7334'],
|
||||
type: 'v6'
|
||||
});
|
||||
ok(address.valid, 'Valid');
|
||||
same(address.type, 'v6', 'Checking type');
|
||||
same(address.parts, ['2001','0db8','85a3','0000','0000','8a2e','0370','7334'], 'Checking parts');
|
||||
var reverse_valid = '4.3.3.7.0.7.3.0.e.2.a.8.0.0.0.0.0.0.0.0.3.a.5.8.8.b.d.0.1.0.0.2.ip6.arpa';
|
||||
same(address.get_reverse(), reverse_valid, 'Checking reverse address');
|
||||
});
|
||||
|
||||
|
||||
test('Usage - set address.input', function() {
|
||||
|
||||
var address = NET.ip_address();
|
||||
|
||||
ok(!address.valid, 'No input - invalid');
|
||||
address.input = '192.168.0.1';
|
||||
address.parse();
|
||||
ok(address.valid, 'Valid');
|
||||
same(address.type, 'v4-quads', 'Checking type');
|
||||
same(address.parts, ['192', '168', '0', '1'], 'Checking parts');
|
||||
var reverse_valid = '1.0.168.192.in-addr.arpa';
|
||||
same(address.get_reverse(), reverse_valid, 'Checking reverse address');
|
||||
});
|
||||
|
||||
test('Usage - set address.parts, no type', function() {
|
||||
|
||||
var address = NET.ip_address();
|
||||
|
||||
ok(!address.valid, 'No input - invalid');
|
||||
address.parts = ['192', '168', '0', '1'];
|
||||
address.parse();
|
||||
ok(!address.valid, 'Still invalid');
|
||||
same(address.type, null, 'Checking type');
|
||||
});
|
||||
|
||||
};});
|
||||
26
install/ui/test/ipa_tests.html
Normal file
26
install/ui/test/ipa_tests.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Core Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/bootstrap.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/ipa_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Core Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
327
install/ui/test/ipa_tests.js
Normal file
327
install/ui/test/ipa_tests.js
Normal file
@@ -0,0 +1,327 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
|
||||
define([
|
||||
'freeipa/ipa',
|
||||
'freeipa/jquery',
|
||||
'freeipa/rpc',
|
||||
'freeipa/dialog',
|
||||
'freeipa/widget',
|
||||
'freeipa/details',
|
||||
'freeipa/entity'],
|
||||
function(IPA, $, rpc) {
|
||||
return function() {
|
||||
|
||||
module('ipa');
|
||||
|
||||
test("Testing ipa_init().", function() {
|
||||
|
||||
expect(1);
|
||||
|
||||
IPA.ajax_options.async = false;
|
||||
|
||||
IPA.init({
|
||||
url: 'data',
|
||||
on_success: function(data, text_status, xhr) {
|
||||
ok(true, "ipa_init() succeeded.");
|
||||
},
|
||||
on_error: function(xhr, text_status, error_thrown) {
|
||||
ok(false, "ipa_init() failed: "+error_thrown);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test("Testing IPA.get_entity_param().", function() {
|
||||
|
||||
var metadata = IPA.get_entity_param("user", "uid");
|
||||
ok(
|
||||
metadata,
|
||||
"IPA.get_entity_param(\"user\", \"uid\") not null");
|
||||
|
||||
equals(
|
||||
metadata["label"], "User login",
|
||||
"IPA.get_entity_param(\"user\", \"uid\")[\"label\"]");
|
||||
|
||||
equals(
|
||||
IPA.get_entity_param("user", "wrong_attribute"), null,
|
||||
"IPA.get_entity_param(\"user\", \"wrong_attribute\")");
|
||||
|
||||
equals(
|
||||
IPA.get_entity_param("user", null), null,
|
||||
"IPA.get_entity_param(\"user\", null)");
|
||||
|
||||
equals(
|
||||
IPA.get_entity_param("wrong_entity", "uid"), null,
|
||||
"IPA.get_entity_param(\"wrong_entity\", \"uid\")");
|
||||
|
||||
equals(
|
||||
IPA.get_entity_param(null, "uid"), null,
|
||||
"IPA.get_entity_param(null, \"uid\")");
|
||||
});
|
||||
|
||||
test("Testing IPA.get_member_attribute().", function() {
|
||||
|
||||
equals(
|
||||
IPA.get_member_attribute("user", "group"), "memberofindirect",
|
||||
"IPA.get_member_attribute(\"user\", \"group\")");
|
||||
|
||||
equals(
|
||||
IPA.get_member_attribute("user", "host"), null,
|
||||
"IPA.get_member_attribute(\"user\", \"host\")");
|
||||
|
||||
equals(
|
||||
IPA.get_member_attribute("user", null), null,
|
||||
"IPA.get_member_attribute(\"user\", null)");
|
||||
|
||||
equals(
|
||||
IPA.get_member_attribute(null, "group"), null,
|
||||
"IPA.get_member_attribute(null, \"group\")");
|
||||
});
|
||||
|
||||
test("Testing successful rpc.command().", function() {
|
||||
|
||||
var method = 'method';
|
||||
var args = ['arg1', 'arg2', 'arg3'];
|
||||
var options = {
|
||||
opt1: 'val1',
|
||||
opt2: 'val2',
|
||||
opt3: 'val3'
|
||||
};
|
||||
var object = 'object';
|
||||
|
||||
var success_handler_counter = 0;
|
||||
var error_handler_counter = 0;
|
||||
|
||||
function success_handler(data, status, xhr) {
|
||||
success_handler_counter++;
|
||||
}
|
||||
|
||||
function error_handler(xhr, text_status, error_thrown) {
|
||||
error_handler_counter++;
|
||||
}
|
||||
|
||||
var orig = $.ajax;
|
||||
|
||||
// Result needs to be there as it is place where message from API call is
|
||||
// stored
|
||||
var xhr = {"result": {}};
|
||||
var text_status = null;
|
||||
var error_thrown = {name:'ERROR', message:'An error has occurred'};
|
||||
|
||||
var ajax_counter = 0;
|
||||
|
||||
$.ajax = function(request) {
|
||||
ajax_counter++;
|
||||
|
||||
equals(
|
||||
request.url, "data/"+object+"_"+method+".json",
|
||||
"Checking request.url");
|
||||
|
||||
var data = JSON.parse(request.data);
|
||||
|
||||
equals(
|
||||
data.method, object+'_'+method,
|
||||
"Checking method");
|
||||
|
||||
// By default all rpc calls contain version of API
|
||||
$.extend(options, {'version': window.ipa_loader.api_version});
|
||||
|
||||
same(
|
||||
data.params, [args, options],
|
||||
"Checking parameters");
|
||||
|
||||
request.success(xhr, text_status, error_thrown);
|
||||
};
|
||||
|
||||
rpc.command({
|
||||
entity: object,
|
||||
method: method,
|
||||
args: args,
|
||||
options: options,
|
||||
on_success: success_handler,
|
||||
on_error: error_handler
|
||||
}).execute();
|
||||
|
||||
equals(
|
||||
ajax_counter, 1,
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
var dialog = $('[data-name=error_dialog]');
|
||||
|
||||
ok(
|
||||
dialog.length === 0,
|
||||
"The dialog box is not created.");
|
||||
|
||||
ok(
|
||||
success_handler_counter === 1 && error_handler_counter === 0,
|
||||
"Only the success handler is called.");
|
||||
|
||||
$.ajax = orig;
|
||||
});
|
||||
|
||||
test("Testing unsuccessful rpc.command().", function() {
|
||||
|
||||
var method = 'method';
|
||||
var args = ['arg1', 'arg2', 'arg3'];
|
||||
var options = {
|
||||
opt1: 'val1',
|
||||
opt2: 'val2',
|
||||
opt3: 'val3'
|
||||
};
|
||||
var object = 'object';
|
||||
|
||||
var success_handler_counter = 0;
|
||||
var error_handler_counter = 0;
|
||||
var dialog_selector = '[data-name=error_dialog]';
|
||||
|
||||
function success_handler(data, status, xhr) {
|
||||
success_handler_counter++;
|
||||
}
|
||||
|
||||
function error_handler(xhr, text_status, error_thrown) {
|
||||
error_handler_counter++;
|
||||
}
|
||||
|
||||
var orig = $.ajax;
|
||||
|
||||
var xhr = {};
|
||||
var text_status = null;
|
||||
var error_thrown = {name:'ERROR', message:'An error has occurred'};
|
||||
|
||||
var ajax_counter = 0;
|
||||
|
||||
$.ajax = function(request) {
|
||||
ajax_counter++;
|
||||
|
||||
equals(request.url, "data/"+object+"_"+method+".json",
|
||||
"Checking request.url");
|
||||
|
||||
var data = JSON.parse(request.data);
|
||||
|
||||
equals(data.method, object+'_'+method, "Checking method");
|
||||
|
||||
// By default all rpc calls contain version of API
|
||||
$.extend(options, { 'version': window.ipa_loader.api_version});
|
||||
|
||||
same(data.params, [args, options], "Checking parameters");
|
||||
|
||||
// remove api version from options object
|
||||
delete options.version;
|
||||
|
||||
request.error(xhr, text_status, error_thrown);
|
||||
};
|
||||
|
||||
rpc.command({
|
||||
entity: object,
|
||||
method: method,
|
||||
args: args,
|
||||
options: options,
|
||||
on_success: success_handler,
|
||||
on_error: error_handler
|
||||
}).execute();
|
||||
|
||||
function click_button(name) {
|
||||
var dialog = $(dialog_selector);
|
||||
var btn = $('button[name='+name+']', dialog).first();
|
||||
btn.trigger('click');
|
||||
}
|
||||
|
||||
var dialog = $(dialog_selector);
|
||||
|
||||
equals(
|
||||
ajax_counter, 1,
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
ok(
|
||||
dialog.length === 1,
|
||||
"The dialog box is created and open.");
|
||||
|
||||
ok(
|
||||
success_handler_counter === 0 && error_handler_counter === 0,
|
||||
"Initially none of the handlers are called.");
|
||||
|
||||
click_button('retry');
|
||||
|
||||
equals(
|
||||
ajax_counter, 2,
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
ok(
|
||||
success_handler_counter === 0 && error_handler_counter === 0,
|
||||
"After 1st retry, none of the handlers are called.");
|
||||
|
||||
click_button('retry');
|
||||
|
||||
equals(ajax_counter, 3,
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
ok(success_handler_counter === 0 && error_handler_counter === 0,
|
||||
"After 2nd retry, none of the handlers are called.");
|
||||
|
||||
click_button('cancel');
|
||||
|
||||
equals(ajax_counter, 3,
|
||||
"Checking ajax invocation counter");
|
||||
|
||||
ok(success_handler_counter === 0 && error_handler_counter === 1,
|
||||
"Only the error handler is called.");
|
||||
|
||||
// cleanup - qunit doesn't really play well with asynchronous opening and
|
||||
// closing of dialogs
|
||||
// opening and closing may be rewritten as asynchronous test
|
||||
$('.modal').remove();
|
||||
$('.modal-backdrop').remove();
|
||||
|
||||
$.ajax = orig;
|
||||
});
|
||||
|
||||
test("Testing observer.", function() {
|
||||
expect(6);
|
||||
var obj = {};
|
||||
var param1_value = 'p1';
|
||||
var param2_value = 'p2';
|
||||
|
||||
obj.event = IPA.observer();
|
||||
|
||||
obj.event.attach(function(param1, param2) {
|
||||
ok(true, "Proper function 1 callback");
|
||||
});
|
||||
|
||||
var first = true;
|
||||
|
||||
var func = function(param1, param2) {
|
||||
if(first) {
|
||||
ok(true, "Proper function 2 callback");
|
||||
equals(param1, param1_value, "Testing Parameter 1");
|
||||
equals(param2, param2_value, "Testing Parameter 2");
|
||||
equals(this, obj, "Testing Context");
|
||||
first = false;
|
||||
} else {
|
||||
ok(false, "Fail function 2 callback");
|
||||
}
|
||||
};
|
||||
|
||||
obj.event.attach(func);
|
||||
obj.event.notify([param1_value, param2_value], obj);
|
||||
obj.event.detach(func);
|
||||
obj.event.notify([param1_value, param2_value], obj);
|
||||
});
|
||||
|
||||
};});
|
||||
152
install/ui/test/jsl.conf
Normal file
152
install/ui/test/jsl.conf
Normal file
@@ -0,0 +1,152 @@
|
||||
#
|
||||
# Configuration File for JavaScript Lint 0.3.0
|
||||
# Developed by Matthias Miller (http://www.JavaScriptLint.com)
|
||||
#
|
||||
# This configuration file can be used to lint a collection of scripts, or to enable
|
||||
# or disable warnings for scripts that are linted via the command line.
|
||||
#
|
||||
|
||||
### Warnings
|
||||
# Enable or disable warnings based on requirements.
|
||||
# Use "+WarningName" to display or "-WarningName" to suppress.
|
||||
#
|
||||
+no_return_value # function {0} does not always return a value
|
||||
+duplicate_formal # duplicate formal argument {0}
|
||||
+equal_as_assign # test for equality (==) mistyped as assignment (=)?{0}
|
||||
+var_hides_arg # variable {0} hides argument
|
||||
+redeclared_var # redeclaration of {0} {1}
|
||||
+anon_no_return_value # anonymous function does not always return a value
|
||||
+missing_semicolon # missing semicolon
|
||||
+meaningless_block # meaningless block; curly braces have no impact
|
||||
+comma_separated_stmts # multiple statements separated by commas (use semicolons?)
|
||||
+unreachable_code # unreachable code
|
||||
+missing_break # missing break statement
|
||||
+missing_break_for_last_case # missing break statement for last case in switch
|
||||
+comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
|
||||
+inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
|
||||
+useless_void # use of the void type may be unnecessary (void is always undefined)
|
||||
+multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
|
||||
+use_of_label # use of label
|
||||
-block_without_braces # block statement without curly braces
|
||||
+leading_decimal_point # leading decimal point may indicate a number or an object member
|
||||
+trailing_decimal_point # trailing decimal point may indicate a number or an object member
|
||||
+octal_number # leading zeros make an octal number
|
||||
+nested_comment # nested comment
|
||||
+misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
|
||||
+ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement
|
||||
+empty_statement # empty statement or extra semicolon
|
||||
-missing_option_explicit # the "option explicit" control comment is missing
|
||||
+partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag
|
||||
+dup_option_explicit # duplicate "option explicit" control comment
|
||||
+useless_assign # useless assignment
|
||||
+ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
|
||||
+ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
|
||||
+missing_default_case # missing default case in switch statement
|
||||
+duplicate_case_in_switch # duplicate case in switch statements
|
||||
+default_not_at_end # the default case is not at the end of the switch statement
|
||||
+legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
|
||||
+jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
|
||||
+useless_comparison # useless comparison; comparing identical expressions
|
||||
+with_statement # with statement hides undeclared variables; use temporary variable instead
|
||||
+trailing_comma_in_array # extra comma is not recommended in array initializers
|
||||
+assign_to_function_call # assignment to a function call
|
||||
+parseint_missing_radix # parseInt missing radix parameter
|
||||
|
||||
|
||||
### Output format
|
||||
# Customize the format of the error message.
|
||||
# __FILE__ indicates current file path
|
||||
# __FILENAME__ indicates current file name
|
||||
# __LINE__ indicates current line
|
||||
# __ERROR__ indicates error message
|
||||
#
|
||||
# Visual Studio syntax (default):
|
||||
+output-format __FILE__(__LINE__): __ERROR__
|
||||
# Alternative syntax:
|
||||
#+output-format __FILE__:__LINE__: __ERROR__
|
||||
|
||||
|
||||
### Context
|
||||
# Show the in-line position of the error.
|
||||
# Use "+context" to display or "-context" to suppress.
|
||||
#
|
||||
+context
|
||||
|
||||
|
||||
### Semicolons
|
||||
# By default, assignments of an anonymous function to a variable or
|
||||
# property (such as a function prototype) must be followed by a semicolon.
|
||||
#
|
||||
+lambda_assign_requires_semicolon
|
||||
|
||||
|
||||
### Control Comments
|
||||
# Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for
|
||||
# the /*@keyword@*/ control comments and JScript conditional comments. (The latter is
|
||||
# enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason,
|
||||
# although legacy control comments are enabled by default for backward compatibility.
|
||||
#
|
||||
+legacy_control_comments
|
||||
|
||||
|
||||
### JScript Function Extensions
|
||||
# JScript allows member functions to be defined like this:
|
||||
# function MyObj() { /*constructor*/ }
|
||||
# function MyObj.prototype.go() { /*member function*/ }
|
||||
#
|
||||
# It also allows events to be attached like this:
|
||||
# function window::onload() { /*init page*/ }
|
||||
#
|
||||
# This is a Microsoft-only JavaScript extension. Enable this setting to allow them.
|
||||
#
|
||||
-jscript_function_extensions
|
||||
|
||||
|
||||
### Defining identifiers
|
||||
# By default, "option explicit" is enabled on a per-file basis.
|
||||
# To enable this for all files, use "+always_use_option_explicit"
|
||||
#-always_use_option_explicit
|
||||
+always_use_option_explicit
|
||||
|
||||
# Define certain identifiers of which the lint is not aware.
|
||||
# (Use this in conjunction with the "undeclared identifier" warning.)
|
||||
#
|
||||
# Common uses for webpages might be:
|
||||
+define window
|
||||
+define document
|
||||
+define alert
|
||||
+define $
|
||||
+define JSON
|
||||
+define jQuery
|
||||
|
||||
+define module
|
||||
+define ok
|
||||
+define same
|
||||
+define test
|
||||
+define strictEqual
|
||||
+define deepEqual
|
||||
+define equals
|
||||
+define expect
|
||||
+define IPA
|
||||
+define NET
|
||||
+define define
|
||||
|
||||
|
||||
### Files
|
||||
# Specify which files to lint
|
||||
# Use "+recurse" to enable recursion (disabled by default).
|
||||
# To add a set of files, use "+process FileName", "+process Folder\Path\*.js",
|
||||
# or "+process Folder\Path\*.htm".
|
||||
#
|
||||
+process aci_tests.js
|
||||
+process certificate_tests.js
|
||||
+process entity_tests.js
|
||||
+process navigation_tests.js
|
||||
+process association_tests.js
|
||||
+process details_tests.js
|
||||
+process ipa_tests.js
|
||||
+process ordered_map_tests.js
|
||||
+process widget_tests.js
|
||||
+process ip_tests.js
|
||||
+process utils_tests.js
|
||||
+process build_tests.js
|
||||
25
install/ui/test/navigation_tests.html
Normal file
25
install/ui/test/navigation_tests.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Navigation Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/navigation_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Navigation Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
225
install/ui/test/navigation_tests.js
Normal file
225
install/ui/test/navigation_tests.js
Normal file
@@ -0,0 +1,225 @@
|
||||
/* Authors:
|
||||
* Adam Young <ayoung@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/>.
|
||||
*/
|
||||
|
||||
define(['freeipa/ipa', 'freeipa/jquery', 'freeipa/navigation', 'freeipa/entity'],
|
||||
function(IPA, $) {
|
||||
return function() {
|
||||
|
||||
module('navigation', {
|
||||
|
||||
// setup: function() {
|
||||
// IPA.ajax_options.async = false;
|
||||
// IPA.init({
|
||||
// url: 'data',
|
||||
// on_error: function(xhr, text_status, error_thrown) {
|
||||
// ok(false, 'ipa_init() failed: '+error_thrown);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
});
|
||||
|
||||
test("Testing IPA.navigation.create().", function() {
|
||||
|
||||
// var entity;
|
||||
// var user_mock_called = false;
|
||||
// var group_mock_called = false;
|
||||
// //Force reset of entities
|
||||
// IPA.entities = $.ordered_map();
|
||||
//
|
||||
// IPA.register('user', function(spec) {
|
||||
//
|
||||
// var that = IPA.entity({
|
||||
// name: 'user',
|
||||
// metadata: IPA.metadata.objects.user,
|
||||
// facets: [
|
||||
// {
|
||||
// type: 'search'
|
||||
// }
|
||||
// ]
|
||||
// });
|
||||
//
|
||||
// that.display = function(container){
|
||||
// user_mock_called = true;
|
||||
// same(container.attr('name'), 'user', 'user container name');
|
||||
// same(container[0].nodeName, 'DIV', 'user container element');
|
||||
// };
|
||||
//
|
||||
// return that;
|
||||
// });
|
||||
//
|
||||
// IPA.register('group', function(spec) {
|
||||
//
|
||||
// var that = IPA.entity({
|
||||
// name: 'group',
|
||||
// metadata: IPA.metadata.objects.group
|
||||
// });
|
||||
//
|
||||
// that.display = function(container){
|
||||
// group_mock_called = true;
|
||||
// same(container.attr('name'), 'group','user container name');
|
||||
// same(container[0].nodeName, 'DIV', 'user container element');
|
||||
// };
|
||||
//
|
||||
// return that;
|
||||
// });
|
||||
//
|
||||
// var navigation_container = $('<div id="navigation"/>').appendTo(document.body);
|
||||
// var entity_container = $('<div id="content"/>').appendTo(document.body);
|
||||
//
|
||||
// var navigation = IPA.navigation({
|
||||
// container: navigation_container,
|
||||
// content: entity_container,
|
||||
// tabs: [
|
||||
// { name:'identity', label:'IDENTITY', children: [
|
||||
// {name:'user', entity:'user'},
|
||||
// {name:'group', entity:'group'}
|
||||
// ]}
|
||||
// ]
|
||||
// });
|
||||
//
|
||||
// navigation.create();
|
||||
// navigation.update();
|
||||
//
|
||||
// ok(user_mock_called, "mock user setup was called");
|
||||
// ok(!group_mock_called, "mock group setup was not called because the tab is inactive");
|
||||
//
|
||||
// var tabs_container = navigation_container.children('div');
|
||||
//
|
||||
// var level1_tabs = tabs_container.children('div');
|
||||
// same(level1_tabs.length, 1, "One level 1 tab");
|
||||
//
|
||||
// var identity_tab = level1_tabs.first();
|
||||
// same(identity_tab.attr('name'), 'identity', "Identity Tab");
|
||||
//
|
||||
// var level2_tabs = identity_tab.children('div');
|
||||
// same(level2_tabs.length, 2, "Two level 2 tabs");
|
||||
//
|
||||
// var user_tab = level2_tabs.first();
|
||||
// same(user_tab.attr('name'), 'user', "User Tab");
|
||||
//
|
||||
// var group_tab = user_tab.next();
|
||||
// same(group_tab.attr('name'), 'group', "Group Tab");
|
||||
//
|
||||
// entity_container.remove();
|
||||
// navigation_container.remove();
|
||||
});
|
||||
|
||||
test("Testing IPA.navigation.update() with valid index.", function() {
|
||||
|
||||
// var navigation_container = $('<div id="navigation"/>').appendTo(document.body);
|
||||
// var entity_container = $('<div id="content"/>').appendTo(document.body);
|
||||
//
|
||||
// var navigation = IPA.navigation({
|
||||
// container: navigation_container,
|
||||
// content: entity_container,
|
||||
// tabs: [
|
||||
// { name:'identity', label:'IDENTITY', children: [
|
||||
// {name:'one', label:'One'},
|
||||
// {name:'two', label:'Two'}
|
||||
// ]}
|
||||
// ]
|
||||
// });
|
||||
//
|
||||
// var state = {};
|
||||
//
|
||||
// navigation.push_state = function(params) {
|
||||
// $.extend(state, params);
|
||||
// };
|
||||
//
|
||||
// navigation.get_state = function(key) {
|
||||
// return key ? state[key] : {};
|
||||
// };
|
||||
//
|
||||
// navigation.remove_state = function(key) {
|
||||
// delete state[key];
|
||||
// };
|
||||
//
|
||||
// navigation.create();
|
||||
// navigation.push_state({'identity': 'two'});
|
||||
// navigation.update();
|
||||
//
|
||||
// var tabs_container = navigation_container.children('div');
|
||||
//
|
||||
// same(
|
||||
// tabs_container.tabs('option', 'selected'), 0,
|
||||
// "Active tab at level 1");
|
||||
//
|
||||
// same(
|
||||
// $('.tabs[name=identity]', tabs_container).tabs('option', 'selected'), 1,
|
||||
// "Active tab at level 2");
|
||||
//
|
||||
// navigation.remove_state("identity");
|
||||
//
|
||||
// entity_container.remove();
|
||||
// navigation_container.remove();
|
||||
// });
|
||||
//
|
||||
// test("Testing IPA.navigation.update() with out-of-range index.", function() {
|
||||
//
|
||||
// var navigation_container = $('<div id="navigation"/>').appendTo(document.body);
|
||||
// var entity_container = $('<div id="content"/>').appendTo(document.body);
|
||||
//
|
||||
// var navigation = IPA.navigation({
|
||||
// container: navigation_container,
|
||||
// content: entity_container,
|
||||
// tabs: [
|
||||
// { name:'identity', label:'IDENTITY', children: [
|
||||
// {name:'one', label:'One', setup: function (){}},
|
||||
// {name:'two', label:'Two', setup: function (){}}
|
||||
// ]}
|
||||
// ]
|
||||
// });
|
||||
//
|
||||
// var state = {};
|
||||
//
|
||||
// navigation.push_state = function(params) {
|
||||
// $.extend(state, params);
|
||||
// };
|
||||
//
|
||||
// navigation.get_state = function(key) {
|
||||
// return key ? state[key] : {};
|
||||
// };
|
||||
//
|
||||
// navigation.remove_state = function(key) {
|
||||
// delete state[key];
|
||||
// };
|
||||
//
|
||||
// navigation.create();
|
||||
// navigation.push_state({'identity': 'three'});
|
||||
// navigation.update();
|
||||
//
|
||||
// var tabs_container = navigation_container.children('div');
|
||||
//
|
||||
// same(
|
||||
// tabs_container.tabs('option', 'selected'), 0,
|
||||
// "Active tab at level 1");
|
||||
//
|
||||
// same(
|
||||
// $('.tabs[name=identity]', tabs_container).tabs('option', 'selected'), 0,
|
||||
// "Active tab at level 2");
|
||||
//
|
||||
// navigation.remove_state("identity");
|
||||
//
|
||||
// entity_container.remove();
|
||||
// navigation_container.remove();
|
||||
});
|
||||
|
||||
};});
|
||||
25
install/ui/test/ordered_map_tests.html
Executable file
25
install/ui/test/ordered_map_tests.html
Executable file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Ordered Map Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/ordered_map_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Ordered Map Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
159
install/ui/test/ordered_map_tests.js
Executable file
159
install/ui/test/ordered_map_tests.js
Executable file
@@ -0,0 +1,159 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
|
||||
define(['freeipa/jquery'], function($) {
|
||||
return function() {
|
||||
|
||||
module('ordered_map');
|
||||
|
||||
test("Testing $.ordered_map constructor.", function() {
|
||||
|
||||
var test = $.ordered_map();
|
||||
|
||||
strictEqual(test.length, 0, "Checking length.");
|
||||
deepEqual(test.keys, [], "Checking keys.");
|
||||
deepEqual(test.values, [], "Checking values.");
|
||||
});
|
||||
|
||||
test("Testing $.ordered_map.put().", function() {
|
||||
|
||||
var test = $.ordered_map();
|
||||
|
||||
var key1 = 'key1';
|
||||
var value1 = 'value1';
|
||||
|
||||
var key2 = 'key2';
|
||||
var value2 = 'value2';
|
||||
|
||||
var key3 = 'key3';
|
||||
var value3 = 'value3';
|
||||
|
||||
var key4 = 'key4';
|
||||
var value4 = 'value4';
|
||||
|
||||
var key5 = 'key5';
|
||||
var value5 = 'value5';
|
||||
|
||||
var key6 = 'key6';
|
||||
var value6 = 'value6';
|
||||
|
||||
var key7 = 'key7';
|
||||
var value7 = 'value7';
|
||||
|
||||
var key8 = 'key8';
|
||||
var value8 = 'value8';
|
||||
|
||||
var map = {};
|
||||
map[key1] = value1;
|
||||
map[key2] = value2;
|
||||
map[key3] = value3;
|
||||
map[key4] = value4;
|
||||
map[key5] = value5;
|
||||
map[key6] = value6;
|
||||
map[key7] = value7;
|
||||
map[key8] = value8;
|
||||
|
||||
test.put(key1, value1);
|
||||
test.put(key2, value2);
|
||||
|
||||
test.put(key3, value3, 1); //put before key2
|
||||
test.put(key4, value4, 0); //put at beginning
|
||||
test.put(key5, value5, -2); //put at beginning
|
||||
test.put(key6, value6, 5); //put at end
|
||||
test.put(key7, value7, 100); //put at end
|
||||
test.put(key8, value8, 'foobar'); //put at end
|
||||
|
||||
strictEqual(test.length, 8, 'Checking length.');
|
||||
deepEqual(test.keys, [key5, key4, key1, key3, key2, key6, key7, key8], 'Checking keys.');
|
||||
deepEqual(test.values, [value5, value4, value1, value3, value2, value6, value7, value8], 'Checking values.');
|
||||
});
|
||||
|
||||
test("Testing $.ordered_map.get().", function() {
|
||||
|
||||
var test = $.ordered_map();
|
||||
|
||||
var key1 = 'key1';
|
||||
var value1 = 'value1';
|
||||
|
||||
var key2 = 'key2';
|
||||
var value2 = 'value2';
|
||||
|
||||
var map = {};
|
||||
map[key1] = value1;
|
||||
map[key2] = value2;
|
||||
|
||||
test.put(key1, value1);
|
||||
test.put(key2, value2);
|
||||
|
||||
var result1 = test.get(key1);
|
||||
var result2 = test.get(key2);
|
||||
|
||||
strictEqual(test.length, 2, 'Checking length.');
|
||||
deepEqual(test.keys, [key1, key2], 'Checking keys.');
|
||||
deepEqual(test.values, [value1, value2], 'Checking values.');
|
||||
strictEqual(result1, value1, 'Checking result 1.');
|
||||
strictEqual(result2, value2, 'Checking result 2.');
|
||||
});
|
||||
|
||||
test("Testing $.ordered_map.remove().", function() {
|
||||
|
||||
var test = $.ordered_map();
|
||||
|
||||
var key1 = 'key1';
|
||||
var value1 = 'value1';
|
||||
|
||||
var key2 = 'key2';
|
||||
var value2 = 'value2';
|
||||
|
||||
var map = {};
|
||||
map[key2] = value2;
|
||||
|
||||
test.put(key1, value1);
|
||||
test.put(key2, value2);
|
||||
|
||||
var result1 = test.remove(key1);
|
||||
|
||||
strictEqual(test.length, 1, 'Checking length.');
|
||||
deepEqual(test.keys, [key2], 'Checking keys.');
|
||||
deepEqual(test.values, [value2], 'Checking values.');
|
||||
strictEqual(result1, value1, 'Checking result.');
|
||||
});
|
||||
|
||||
test("Testing $.ordered_map.empty().", function() {
|
||||
|
||||
var test = $.ordered_map();
|
||||
|
||||
var key1 = 'key1';
|
||||
var value1 = 'value1';
|
||||
|
||||
var key2 = 'key2';
|
||||
var value2 = 'value2';
|
||||
|
||||
test.put(key1, value1);
|
||||
test.put(key2, value2);
|
||||
|
||||
test.empty();
|
||||
|
||||
strictEqual(test.length, 0, 'Checking length.');
|
||||
deepEqual(test.keys, [], 'Checking keys.');
|
||||
deepEqual(test.values, [], 'Checking values.');
|
||||
});
|
||||
|
||||
};});
|
||||
155
install/ui/test/qunit.css
Normal file
155
install/ui/test/qunit.css
Normal file
@@ -0,0 +1,155 @@
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px;
|
||||
background-color: #0d3349;
|
||||
|
||||
border-radius: 15px 15px 0 0;
|
||||
-moz-border-radius: 15px 15px 0 0;
|
||||
-webkit-border-top-right-radius: 15px;
|
||||
-webkit-border-top-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0em 0 0.5em 2em;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
background-color: #2b81af;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom: 1px solid #fff;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests ol {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
|
||||
box-shadow: inset 0px 2px 13px #999;
|
||||
-moz-box-shadow: inset 0px 2px 13px #999;
|
||||
-webkit-box-shadow: inset 0px 2px 13px #999;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: black; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
margin: 0.5em;
|
||||
padding: 0.4em 0.5em 0.4em 0.5em;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #5E740B;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #EE5757;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: green; }
|
||||
|
||||
#qunit-banner.qunit-fail,
|
||||
#qunit-testrunner-toolbar { background-color: #EE5757; }
|
||||
|
||||
|
||||
/** Footer */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-radius: 0 0 15px 15px;
|
||||
-moz-border-radius: 0 0 15px 15px;
|
||||
-webkit-border-bottom-right-radius: 15px;
|
||||
-webkit-border-bottom-left-radius: 15px;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
}
|
||||
1261
install/ui/test/qunit.js
Normal file
1261
install/ui/test/qunit.js
Normal file
File diff suppressed because it is too large
Load Diff
25
install/ui/test/utils_tests.html
Normal file
25
install/ui/test/utils_tests.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>IPA utils test suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/utils_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">IPA utils test suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
246
install/ui/test/utils_tests.js
Normal file
246
install/ui/test/utils_tests.js
Normal file
@@ -0,0 +1,246 @@
|
||||
/* Authors:
|
||||
* Petr Vobornik <pvoborni@redhat.com>
|
||||
*
|
||||
* Copyright (C) 2012 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/>.
|
||||
*/
|
||||
|
||||
define([
|
||||
'freeipa/ipa',
|
||||
'freeipa/jquery',
|
||||
'freeipa/datetime',
|
||||
'freeipa/util',
|
||||
'freeipa/field',
|
||||
'freeipa/widget'],
|
||||
function(IPA, $, datetime, util) { return function() {
|
||||
|
||||
var old;
|
||||
|
||||
module('utils',{
|
||||
|
||||
setup: function() {
|
||||
old = IPA.messages;
|
||||
IPA.messages = {
|
||||
widget: {
|
||||
validation: {
|
||||
integer: "",
|
||||
decimal: "",
|
||||
min_value: "",
|
||||
max_value: "",
|
||||
pattern_errmsg: ""
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
teardown: function() {
|
||||
IPA.messages = old;
|
||||
}
|
||||
});
|
||||
|
||||
test('Testing metadata validator', function() {
|
||||
|
||||
// using strings as values because it is an output of inputs
|
||||
|
||||
var validator = IPA.build({
|
||||
$factory: IPA.metadata_validator
|
||||
});
|
||||
|
||||
var metadata = {
|
||||
type: 'int',
|
||||
maxvalue: 300,
|
||||
minvalue: 30
|
||||
};
|
||||
|
||||
var context = { metadata: metadata };
|
||||
|
||||
var value;
|
||||
|
||||
value = "50";
|
||||
ok(validator.validate(value, context).valid, 'Checking lower maximun, alphabetically higher');
|
||||
|
||||
value = "200";
|
||||
ok(validator.validate(value, context).valid, 'Checking higher minimum, alphabetically lower');
|
||||
|
||||
value = "29";
|
||||
ok(!validator.validate(value, context).valid, 'Checking below minimum');
|
||||
|
||||
value = "301";
|
||||
ok(!validator.validate(value, context).valid, 'Checking above maximum');
|
||||
|
||||
context.metadata.minvalue = 0;
|
||||
value = "-1";
|
||||
ok(!validator.validate(value, context).valid, 'Checking zero minimum - below');
|
||||
value = "0";
|
||||
ok(validator.validate(value, context).valid, 'Checking zero minimum - above');
|
||||
value = "1";
|
||||
ok(validator.validate(value, context).valid, 'Checking zero minimum - same');
|
||||
|
||||
context.metadata = {
|
||||
type: 'int',
|
||||
maxvalue: "",
|
||||
minvalue: ""
|
||||
};
|
||||
|
||||
ok(validator.validate(value, context).valid, 'Checking empty strings as boundaries');
|
||||
|
||||
context.metadata = {
|
||||
type: 'int',
|
||||
maxvalue: null,
|
||||
minvalue: null
|
||||
};
|
||||
ok(validator.validate(value, context).valid, 'Checking null as boundaries');
|
||||
|
||||
context.metadata = {
|
||||
type: 'int',
|
||||
maxvalue: undefined,
|
||||
minvalue: undefined
|
||||
};
|
||||
ok(validator.validate(value, context).valid, 'Checking undefined as boundaries');
|
||||
|
||||
context.metadata = {
|
||||
type: 'Decimal',
|
||||
maxvalue: "10.333",
|
||||
minvalue: "-10.333"
|
||||
};
|
||||
|
||||
value = "10.333";
|
||||
ok(validator.validate(value, context).valid, 'Decimal: checking maximum');
|
||||
value = "10.3331";
|
||||
ok(!validator.validate(value, context).valid, 'Decimal: checking maximum - invalid');
|
||||
|
||||
value = "-10.333";
|
||||
ok(validator.validate(value, context).valid, 'Decimal: checking minimum');
|
||||
value = "-10.3331";
|
||||
ok(!validator.validate(value, context).valid, 'Decimal: checking minimum - invalid');
|
||||
});
|
||||
|
||||
test('Testing IPA.defined', function() {
|
||||
|
||||
// positive
|
||||
same(IPA.defined({}), true, 'Object');
|
||||
same(IPA.defined(0), true, 'Zero number');
|
||||
same(IPA.defined(1), true, 'Some number');
|
||||
same(IPA.defined(false), true, 'false');
|
||||
same(IPA.defined(true), true, 'true');
|
||||
same(IPA.defined(function(){}), true, 'function');
|
||||
same(IPA.defined(''), true, 'Empty string - not checking');
|
||||
|
||||
// negative
|
||||
same(IPA.defined('', true), false, 'Empty string - checking');
|
||||
same(IPA.defined(undefined), false, 'undefined');
|
||||
same(IPA.defined(null), false, 'null');
|
||||
});
|
||||
|
||||
test('Testing util.equals', function() {
|
||||
|
||||
ok(util.equals([], []), 'Empty Arrays');
|
||||
ok(util.equals([1, "a", false, true], [1, "a", false, true]), 'Arrays');
|
||||
ok(util.equals(true, true), 'Boolean: true');
|
||||
ok(util.equals(false, false), 'Boolean: false');
|
||||
ok(!util.equals(true, false), 'Negative: boolean');
|
||||
ok(!util.equals(false, true), 'Negative: boolean');
|
||||
ok(util.equals("abc", "abc"), 'Positive: strings');
|
||||
ok(!util.equals("abc", "aBC"), 'Negative: string casing');
|
||||
ok(util.equals(1, 1), 'Positive: number');
|
||||
ok(util.equals(1.0, 1), 'Positive: number');
|
||||
ok(util.equals(2.2, 2.2), 'Positive: number');
|
||||
|
||||
ok(!util.equals([], [""]), 'Negative: empty array');
|
||||
});
|
||||
|
||||
test('Testing datetime', function() {
|
||||
|
||||
var valid = [
|
||||
// [format, str, data, utc, output]
|
||||
[ '${YYYY}${MM}${DD}${HH}${mm}${ss}Z', '20140114175402Z', [ 2014, 1, 14, 17, 54, 2], true ],
|
||||
[ '${YYYY}-${MM}-${DD}T${HH}:${mm}:${ss}Z', '2014-01-14T17:54:02Z', [ 2014, 1, 14, 17, 54, 2], true ],
|
||||
[ '${YYYY}-${MM}-${DD} ${HH}:${mm}:${ss}Z', '2014-01-14 17:54:02Z', [ 2014, 1, 14, 17, 54, 2], true ],
|
||||
[ '${YYYY}-${MM}-${DD}T${HH}:${mm}Z', '2014-01-14T17:54Z', [ 2014, 1, 14, 17, 54, 0], true ],
|
||||
[ '${YYYY}-${MM}-${DD} ${HH}:${mm}Z', '2014-01-14 17:54Z', [ 2014, 1, 14, 17, 54, 0], true ],
|
||||
[ '${YYYY}-${MM}-${DD}', '2014-01-14', [ 2014, 1, 14, 0, 0, 0], true ],
|
||||
|
||||
// allow overflows?
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear
|
||||
[ '${YYYY}-${MM}-${DD}', '2014-01-32', [ 2014, 2, 1, 0, 0, 0], true, '2014-02-01' ],
|
||||
[ '${YYYY}-${MM}-${DD}', '2014-02-30', [ 2014, 3, 2, 0, 0, 0], true, '2014-03-02' ],
|
||||
[ '${YYYY}-${MM}-${DD}', '2014-15-10', [ 2015, 3, 10, 0, 0, 0], true, '2015-03-10' ],
|
||||
|
||||
// local time
|
||||
[ '${YYYY}-${MM}-${DD}T${HH}:${mm}:${ss}', '2014-01-14T17:54:13', [ 2014, 1, 14, 17, 54, 13], false ],
|
||||
[ '${YYYY}-${MM}-${DD} ${HH}:${mm}:${ss}', '2014-01-14 17:54:13', [ 2014, 1, 14, 17, 54, 13], false ],
|
||||
[ '${YYYY}-${MM}-${DD}T${HH}:${mm}', '2014-01-14T17:54', [ 2014, 1, 14, 17, 54, 0], false ],
|
||||
[ '${YYYY}-${MM}-${DD} ${HH}:${mm}', '2014-01-14 17:54', [ 2014, 1, 14, 17, 54, 0], false ]
|
||||
];
|
||||
var invalid = [
|
||||
// [str, utc]
|
||||
['2014-01-14T12:01:00', true],
|
||||
['2014-01-14T12:01', true],
|
||||
['2014-01-14T12', true],
|
||||
['2014-01-14T12Z', true],
|
||||
['2014-01-14TZ', true],
|
||||
|
||||
|
||||
['2014-01-14 17:54:00', true],
|
||||
['2014-01-14 17:54', true],
|
||||
['2014-01-14 17', true],
|
||||
['2014-01-14 17Z', true],
|
||||
['2014-01-14Z', true],
|
||||
|
||||
['2014-01-14X17:54:00Z', true],
|
||||
['20140114175400', false]
|
||||
];
|
||||
var i, l;
|
||||
|
||||
function test_valid(format, str, data, utc, output) {
|
||||
datetime.allow_local = !utc;
|
||||
var d = data;
|
||||
|
||||
var expected = new Date();
|
||||
if (utc) {
|
||||
expected.setUTCFullYear(d[0], d[1]-1, d[2]);
|
||||
expected.setUTCHours(d[3], d[4], d[5], 0); // set ms to 0
|
||||
} else {
|
||||
expected.setFullYear(d[0], d[1]-1, d[2]);
|
||||
expected.setHours(d[3], d[4], d[5], 0); // set ms to 0
|
||||
}
|
||||
|
||||
var parsed = datetime.parse(str);
|
||||
|
||||
ok(parsed, "Parse successful: "+str);
|
||||
if (!parsed) return; // don't die for other tests
|
||||
strictEqual(parsed.getTime(), expected.getTime(), "Valid date: "+str);
|
||||
|
||||
var formatted = datetime.format(parsed, format, !utc);
|
||||
expected = output || str;
|
||||
strictEqual(formatted, expected, "Format: "+format);
|
||||
}
|
||||
|
||||
function test_invalid(str, utc) {
|
||||
datetime.allow_local = !utc;
|
||||
var parsed = datetime.parse(str);
|
||||
strictEqual(parsed, null, "Parse invalid date: "+str);
|
||||
}
|
||||
|
||||
for (i=0, l=valid.length; i < l; i++) {
|
||||
test_valid(valid[i][0], valid[i][1], valid[i][2], valid[i][3], valid[i][4]);
|
||||
}
|
||||
|
||||
for (i=0, l=invalid.length; i < l; i++) {
|
||||
test_invalid(invalid[i][0], invalid[i][1]);
|
||||
}
|
||||
});
|
||||
|
||||
};});
|
||||
25
install/ui/test/widget_tests.html
Executable file
25
install/ui/test/widget_tests.html
Executable file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Widget Test Suite</title>
|
||||
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="qunit.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/loader.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.js"></script>
|
||||
<script type="text/javascript" src="../js/libs/jquery.ordered-map.js"></script>
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
<script type="text/javascript" src="../js/dojo/dojo.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(['test/widget_tests'], function(tests){ tests() });
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Widget Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
368
install/ui/test/widget_tests.js
Normal file
368
install/ui/test/widget_tests.js
Normal file
@@ -0,0 +1,368 @@
|
||||
/* Authors:
|
||||
* Adam Young <ayoung@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/>.
|
||||
*/
|
||||
|
||||
define([
|
||||
'dojo/on',
|
||||
'freeipa/ipa',
|
||||
'freeipa/jquery',
|
||||
'freeipa/group',
|
||||
'freeipa/field',
|
||||
'freeipa/widget',
|
||||
'freeipa/entity'
|
||||
], function(on, IPA, $, group) { return function() {
|
||||
|
||||
var widget_container;
|
||||
var widget;
|
||||
var factory;
|
||||
var spec;
|
||||
|
||||
|
||||
module('widget',{
|
||||
setup: function() {
|
||||
IPA.ajax_options.async = false;
|
||||
IPA.init({
|
||||
url: 'data',
|
||||
on_error: function(xhr, text_status, error_thrown) {
|
||||
ok(false, "ipa_init() failed: "+error_thrown);
|
||||
}
|
||||
});
|
||||
widget_container = $('<div id="widget"/>').appendTo(document.body);
|
||||
|
||||
widget = null;
|
||||
factory = null;
|
||||
spec = null;
|
||||
|
||||
group.register();
|
||||
|
||||
},
|
||||
teardown: function() {
|
||||
widget_container.remove();
|
||||
}}
|
||||
);
|
||||
|
||||
|
||||
function base_widget_test(value){
|
||||
spec.entity = {
|
||||
name:'user'
|
||||
};
|
||||
|
||||
widget = factory(spec);
|
||||
|
||||
var field_name = widget.name;
|
||||
ok(widget, "Created Widget");
|
||||
|
||||
//init reads param info for an entity. We'll use the user entity
|
||||
widget.name = field_name;
|
||||
|
||||
// ok(widget.label,'widget with entity and name has label');
|
||||
// ok(widget.tooltip,'widget with entity and name has tooltip');
|
||||
|
||||
|
||||
ok(!widget.container,'widget has no container before create');
|
||||
widget.create(widget_container);
|
||||
ok(widget.container,'widget has container after create');
|
||||
|
||||
}
|
||||
|
||||
|
||||
function widget_string_test() {
|
||||
var value = 'test_title';
|
||||
var mock_record = {'title': value};
|
||||
|
||||
widget.update(mock_record.title);
|
||||
|
||||
ok(widget.save() instanceof Array,'save returns array');
|
||||
|
||||
|
||||
mock_record = {'title':[value]};
|
||||
widget.update(mock_record.title);
|
||||
|
||||
ok(widget.save() instanceof Array,'save returns array');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function text_tests(widget,input){
|
||||
|
||||
var value_changed = false;
|
||||
var undo_clicked = false;
|
||||
|
||||
widget.value_changed.attach(function() {
|
||||
value_changed = true;
|
||||
});
|
||||
|
||||
widget.undo_clicked.attach(function() {
|
||||
undo_clicked = true;
|
||||
});
|
||||
|
||||
input.val('changed');
|
||||
input.keyup();
|
||||
same(widget.save(),['changed'], "Setting Value");
|
||||
same(value_changed, true, "Click triggers value_changed");
|
||||
|
||||
var undo = widget.get_undo();
|
||||
undo.click();
|
||||
same(undo_clicked, true, "Click on 'undo' triggers undo_clicked");
|
||||
}
|
||||
|
||||
function multivalued_text_tests(widget) {
|
||||
|
||||
var values = ['val1', 'val2', 'val3'];
|
||||
var changed = false;
|
||||
function on_change (event) {
|
||||
changed = true;
|
||||
}
|
||||
on(widget, 'value-change', on_change);
|
||||
|
||||
widget.update(values);
|
||||
|
||||
same(widget.save(), values, "All values loaded");
|
||||
|
||||
values = ['val1', 'val2', 'val3', 'val4'];
|
||||
widget.add_row(['val4']);
|
||||
same(widget.save(), values, "Value added");
|
||||
ok(changed, "Value changed");
|
||||
changed = false;
|
||||
|
||||
values = ['val1', 'val3', 'val4'];
|
||||
widget.remove_row(widget.rows[1]);
|
||||
|
||||
same(widget.save(), values, "Value removed");
|
||||
ok(changed, "Value changed");
|
||||
changed = false;
|
||||
}
|
||||
|
||||
test("IPA.table_widget" ,function(){
|
||||
factory = IPA.table_widget;
|
||||
spec = {
|
||||
undo:true,
|
||||
name:'users',
|
||||
entity: {
|
||||
name:'user'
|
||||
}
|
||||
};
|
||||
widget = factory(spec);
|
||||
widget.add_column(IPA.column({
|
||||
entity: spec.entity,
|
||||
name:'uid',
|
||||
label:'User ID',
|
||||
primary_key:'uid',
|
||||
width:'20em'
|
||||
}));
|
||||
widget.add_column(IPA.column({
|
||||
entity: spec.entity,
|
||||
name:'title',
|
||||
lable:'Title',
|
||||
primary_key:'uid',
|
||||
width:'20em'
|
||||
}));
|
||||
|
||||
ok(!widget.container,'widget has no container before create');
|
||||
widget.create(widget_container);
|
||||
ok(widget.container,'widget has container after create');
|
||||
|
||||
|
||||
var mock_results = {
|
||||
users:[{ uid: 'kfrog', title:'reporter' },
|
||||
{ uid: 'grover',title:'waiter' }]
|
||||
};
|
||||
|
||||
widget.load(mock_results);
|
||||
|
||||
same ($('tr' ,widget_container).length, 4, 'four rows after load');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
test("Testing base widget.", function() {
|
||||
var update_called = false;
|
||||
spec = {
|
||||
name:'title'
|
||||
};
|
||||
|
||||
factory = IPA.input_widget;
|
||||
base_widget_test('test_value');
|
||||
widget_string_test();
|
||||
});
|
||||
|
||||
|
||||
|
||||
test("IPA.textarea_widget" ,function(){
|
||||
spec = {undo:true,name:'title'};
|
||||
factory = IPA.textarea_widget;
|
||||
base_widget_test('test_value');
|
||||
widget_string_test();
|
||||
text_tests(widget, $('textarea',widget_container));
|
||||
|
||||
});
|
||||
|
||||
|
||||
test("Testing text widget.", function() {
|
||||
factory = IPA.text_widget;
|
||||
spec = {undo:true,name:'title'};
|
||||
base_widget_test('test_value');
|
||||
widget_string_test();
|
||||
text_tests(widget, $('input[type=text]',widget_container));
|
||||
|
||||
});
|
||||
|
||||
test("Testing multi-valued text widget.", function() {
|
||||
factory = IPA.multivalued_widget;
|
||||
spec = {undo:true,name:'title'};
|
||||
base_widget_test('test_value');
|
||||
widget_string_test();
|
||||
multivalued_text_tests(widget);
|
||||
});
|
||||
|
||||
test("Testing checkbox widget.", function() {
|
||||
factory = IPA.checkbox_widget;
|
||||
spec = {name:'title'};
|
||||
base_widget_test('test_value');
|
||||
|
||||
//Changing mock record from 'TRUE' to true. Value normalization is field's
|
||||
//job. Checkbox should work with booleans values.
|
||||
var mock_record = { 'title': [true] };
|
||||
|
||||
widget.update(mock_record.title);
|
||||
same(widget.save(),[true], "Checkbox is set");
|
||||
|
||||
mock_record = {'title':null};
|
||||
|
||||
widget.update(mock_record.title);
|
||||
same(widget.save(), [false], "Checkbox is not set");
|
||||
|
||||
var input = $('input[type=checkbox]',widget_container);
|
||||
|
||||
same(input.length,1,'One control in the container');
|
||||
|
||||
var value_changed = false;
|
||||
widget.value_changed.attach(function() {
|
||||
value_changed = true;
|
||||
});
|
||||
|
||||
input.click();
|
||||
|
||||
same(widget.save(),[true], "Click sets checkbox");
|
||||
same(value_changed, true, "Click triggers value_changed");
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
test("IPA.checkboxes_widget" ,function(){
|
||||
factory = IPA.checkboxes_widget;
|
||||
spec = {undo:true, name:'title' };
|
||||
base_widget_test('test_value');
|
||||
|
||||
});
|
||||
test("IPA.select_widget" ,function(){
|
||||
|
||||
factory = IPA.select_widget;
|
||||
spec = {undo:true,name:'title'};
|
||||
base_widget_test('test_value');
|
||||
|
||||
});
|
||||
|
||||
|
||||
test("IPA.entity_select_widget" ,function() {
|
||||
var user = IPA.entity({ name: 'user' });
|
||||
factory = IPA.entity_select_widget;
|
||||
spec = {
|
||||
name: 'uid',
|
||||
other_entity: user,
|
||||
other_field: 'uid'
|
||||
};
|
||||
|
||||
base_widget_test('test_value');
|
||||
var mock_record = { uid: ['kfrog']};
|
||||
widget.update(mock_record.uid);
|
||||
ok($('option', widget.list).length > 1,"options come from AJAX");
|
||||
|
||||
var value = widget.save();
|
||||
same(value, ['kfrog'],'select set from values');
|
||||
});
|
||||
|
||||
|
||||
test("IPA.entity_link_widget" ,function(){
|
||||
factory = IPA.link_widget;
|
||||
spec = {
|
||||
name: 'gidnumber',
|
||||
other_entity:'group',
|
||||
other_pkeys: function() {
|
||||
return ['kfrog'];
|
||||
}
|
||||
};
|
||||
base_widget_test(widget,'user','test_value');
|
||||
|
||||
var mock_entity = {
|
||||
get_primary_key: function(){
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
widget.entity = mock_entity;
|
||||
|
||||
var nonlink = widget_container.find('label');
|
||||
var link = widget_container.find('a');
|
||||
|
||||
ok(nonlink.length === 1, "Only one <label> element exists");
|
||||
ok(link.length === 1, "Only one <a> element exists");
|
||||
|
||||
var mock_record = { gidnumber: ['123456']};
|
||||
widget.update(mock_record.gidnumber);
|
||||
|
||||
link = widget_container.find('a:contains("123456")');
|
||||
|
||||
same(link.length, 1,'link is populated');
|
||||
same(link.css('display'), 'inline','link is displayed');
|
||||
same(widget.nonlink.css('display'), 'none','text is not displayed');
|
||||
|
||||
});
|
||||
|
||||
|
||||
test("IPA.radio_widget" ,function(){
|
||||
var options = [{label:"Engineer",value:"engineer"},
|
||||
{label:"Manager", value:"manager"},
|
||||
{label:"Director",value:"director"},
|
||||
{label:"Vice President",value:"VP"}];
|
||||
factory = IPA.radio_widget;
|
||||
spec = {undo:true, name: 'title',options:options};
|
||||
base_widget_test('test_value');
|
||||
var mock_record = {'title':["director"]};
|
||||
widget.update(mock_record.title);
|
||||
var values = widget.save();
|
||||
same(values[0],'director','Options set correctly');
|
||||
|
||||
mock_record = { title: ["VP"]};
|
||||
widget.update(mock_record.title);
|
||||
values = widget.save();
|
||||
same(values[0],'VP','Options set correctly');
|
||||
|
||||
var i =0;
|
||||
$('label', widget_container).each( function(){
|
||||
same( $(this).text(),options[i].label, 'labels match');
|
||||
i += 1;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
};});
|
||||
Reference in New Issue
Block a user