diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2011-11-16 21:07:20 -0600 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-12-06 22:07:52 +0000 |
commit | a8ea42bda841c8773d68886614faf9efd38e33bd (patch) | |
tree | 92ddaae7ead82784eefb8dde81bc81e91945bfa0 | |
parent | 6f0c16e4289dd1a68bfd673da52a511087d84b9a (diff) | |
download | freeipa-a8ea42bda841c8773d68886614faf9efd38e33bd.tar.gz freeipa-a8ea42bda841c8773d68886614faf9efd38e33bd.tar.xz freeipa-a8ea42bda841c8773d68886614faf9efd38e33bd.zip |
Fixed entity metadata resolution.
The current code assumes that an entity will always have a corresponding
LDAPObject on the server, so it looks for the metadata in a fixed location.
This assumption doesn't work for HBAC Test since it is a Command, not an
LDAPObject, so the metadata has to be obtained from a different location.
A new method get_default_metadata() has been added to allow each entity
to find the metadata from the correct location.
Ticket #388
-rw-r--r-- | install/ui/aci.js | 25 | ||||
-rw-r--r-- | install/ui/automount.js | 15 | ||||
-rw-r--r-- | install/ui/dns.js | 34 | ||||
-rw-r--r-- | install/ui/entitle.js | 5 | ||||
-rw-r--r-- | install/ui/entity.js | 33 | ||||
-rw-r--r-- | install/ui/group.js | 5 | ||||
-rw-r--r-- | install/ui/hbac.js | 15 | ||||
-rw-r--r-- | install/ui/host.js | 5 | ||||
-rw-r--r-- | install/ui/hostgroup.js | 5 | ||||
-rw-r--r-- | install/ui/ipa.js | 8 | ||||
-rw-r--r-- | install/ui/netgroup.js | 5 | ||||
-rw-r--r-- | install/ui/policy.js | 10 | ||||
-rw-r--r-- | install/ui/serverconfig.js | 5 | ||||
-rw-r--r-- | install/ui/service.js | 5 | ||||
-rw-r--r-- | install/ui/sudo.js | 15 | ||||
-rw-r--r-- | install/ui/test/details_tests.js | 19 | ||||
-rw-r--r-- | install/ui/test/entity_tests.js | 10 | ||||
-rw-r--r-- | install/ui/test/navigation_tests.js | 22 | ||||
-rw-r--r-- | install/ui/user.js | 13 |
19 files changed, 148 insertions, 106 deletions
diff --git a/install/ui/aci.js b/install/ui/aci.js index 7f82714c1..8e9e5433b 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -29,9 +29,10 @@ IPA.aci.permission_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.facet_groups([ 'privilege' , 'settings' ]). + that.builder.facet_groups([ 'privilege' , 'settings' ]). search_facet({ columns: [ 'cn' ] }). @@ -203,9 +204,10 @@ IPA.aci.privilege_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.facet_groups([ 'role', 'settings', 'permission' ]). + that.builder.facet_groups([ 'role', 'settings', 'permission' ]). search_facet({ columns: [ 'cn', @@ -259,9 +261,10 @@ IPA.aci.role_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.facet_groups([ 'member', 'settings', 'privilege' ]). + that.builder.facet_groups([ 'member', 'settings', 'privilege' ]). search_facet({ columns: [ 'cn', @@ -308,9 +311,10 @@ IPA.aci.selfservice_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ pagination: false, columns: [ 'aciname' ] }). @@ -349,9 +353,10 @@ IPA.aci.delegation_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ pagination: false, columns: [ 'aciname' ] }). diff --git a/install/ui/automount.js b/install/ui/automount.js index 11034ea25..8db08e384 100644 --- a/install/ui/automount.js +++ b/install/ui/automount.js @@ -29,9 +29,10 @@ IPA.automount.location_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.facet_groups([ 'automountmap', 'settings' ]). + that.builder.facet_groups([ 'automountmap', 'settings' ]). search_facet({ title: IPA.metadata.objects.automountlocation.label, columns:['cn'] @@ -64,9 +65,10 @@ IPA.automount.map_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.containing_entity('automountlocation'). + that.builder.containing_entity('automountlocation'). facet_groups([ 'automountkey', 'settings' ]). nested_search_facet({ facet_group: 'automountkey', @@ -153,9 +155,10 @@ IPA.automount.key_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.containing_entity('automountmap'). + that.builder.containing_entity('automountmap'). details_facet({ sections: [ { diff --git a/install/ui/dns.js b/install/ui/dns.js index e9505dc85..5f8a0d12a 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -29,16 +29,17 @@ IPA.dns.zone_entity = function(spec) { var that = IPA.entity(spec); - if (!IPA.dns_enabled) { - var except = { - expected: true - }; - throw except; - } + that.init = function() { + + if (!IPA.dns_enabled) { + throw { + expected: true + }; + } - that.init = function(params) { + that.entity_init(); - params.builder.facet_groups([ 'dnsrecord', 'settings' ]). + that.builder.facet_groups([ 'dnsrecord', 'settings' ]). search_facet({ title: IPA.metadata.objects.dnszone.label, columns: [ 'idnsname' ] @@ -483,16 +484,17 @@ IPA.dns.record_entity = function(spec) { var that = IPA.entity(spec); - if (!IPA.dns_enabled) { - var except = { - expected: true - }; - throw except; - } + that.init = function() { + + if (!IPA.dns_enabled) { + throw { + expected: true + }; + } - that.init = function(params) { + that.entity_init(); - params.builder.containing_entity('dnszone'). + that.builder.containing_entity('dnszone'). details_facet({ post_update_hook:function(data){ var result = data.result.result; diff --git a/install/ui/entitle.js b/install/ui/entitle.js index 0a87e3eae..ea838e2cb 100644 --- a/install/ui/entitle.js +++ b/install/ui/entitle.js @@ -37,9 +37,10 @@ IPA.entitle.entity = function(spec) { that.status = IPA.entitle.unregistered; - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.facet_groups([ 'account', 'certificates' ]). + that.builder.facet_groups([ 'account', 'certificates' ]). details_facet({ factory: IPA.entitle.details_facet, label: IPA.messages.objects.entitle.account, diff --git a/install/ui/entity.js b/install/ui/entity.js index 4e5c72447..a701009a3 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -32,10 +32,12 @@ IPA.entity = function(spec) { spec = spec || {}; var that = {}; - that.metadata = spec.metadata; + that.name = spec.name; - that.label = spec.label || spec.metadata.label || spec.name; - that.title = spec.title || that.label; + that.label = spec.label; + + that.metadata = spec.metadata; + that.builder = spec.builder; that.dialogs = $.ordered_map(); that.dialog_specs = spec.dialogs || []; @@ -52,7 +54,21 @@ IPA.entity = function(spec) { that.redirect_facet = spec.redirect_facet; that.containing_entity = null; - that.init = function(params) { + that.init = function() { + if (!that.metadata) { + that.metadata = that.get_default_metadata(); + if (!that.metadata) { + throw { + expected: true, + message: "Entity " + that.name + " not supported by server." + }; + } + } + that.label = that.label || that.metadata.label || that.name; + }; + + that.get_default_metadata = function() { + return IPA.metadata.objects[that.name]; }; that.get_containing_entity = function() { @@ -210,6 +226,7 @@ IPA.entity = function(spec) { pkey.unshift(IPA.nav.get_state(current_entity.name+'-pkey')); return pkey; }; + /* most entites only require -pkey for their primary keys, but some are more specific. This call allows those entites a place to override the other parameters. */ @@ -305,14 +322,6 @@ IPA.entity_builder = function() { spec = { name: spec }; } - spec.metadata = spec.metadata || IPA.metadata.objects[spec.name]; - if (!spec.metadata) { - throw { - expected: true, - message: "Entity " + spec.name + "not supported by server." - }; - } - entity = factory(spec); that.facet_groups([ diff --git a/install/ui/group.js b/install/ui/group.js index 959a96c40..3604271df 100644 --- a/install/ui/group.js +++ b/install/ui/group.js @@ -30,9 +30,10 @@ IPA.group.entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'cn', 'gidnumber', diff --git a/install/ui/hbac.js b/install/ui/hbac.js index cf13e459e..a65ab3711 100644 --- a/install/ui/hbac.js +++ b/install/ui/hbac.js @@ -33,9 +33,10 @@ IPA.hbac.rule_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ search_all: true, columns: [ 'cn', @@ -60,9 +61,10 @@ IPA.hbac.service_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'cn', 'description' @@ -125,9 +127,10 @@ IPA.hbac.service_group_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'cn', 'description' diff --git a/install/ui/host.js b/install/ui/host.js index 357eb3f8f..94dd6465f 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -30,9 +30,10 @@ IPA.host.entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'fqdn', 'description', diff --git a/install/ui/hostgroup.js b/install/ui/hostgroup.js index 00f76f2c6..20e7179fb 100644 --- a/install/ui/hostgroup.js +++ b/install/ui/hostgroup.js @@ -28,9 +28,10 @@ IPA.hostgroup.entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'cn', 'description' diff --git a/install/ui/ipa.js b/install/ui/ipa.js index 2bf004295..d85cd9965 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -191,14 +191,12 @@ var IPA = function() { builder.entity({ factory: factory, - name: name + name: name, + builder: builder }); var entity = builder.build(); - - entity.init({ - builder: builder - }); + entity.init(); return entity; diff --git a/install/ui/netgroup.js b/install/ui/netgroup.js index 6546c53d5..d54fdfd52 100644 --- a/install/ui/netgroup.js +++ b/install/ui/netgroup.js @@ -28,9 +28,10 @@ IPA.netgroup.entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'cn', 'description' diff --git a/install/ui/policy.js b/install/ui/policy.js index fbabd0830..d48cacc49 100644 --- a/install/ui/policy.js +++ b/install/ui/policy.js @@ -29,9 +29,10 @@ IPA.pwpolicy.entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns:['cn','cospriority']}). details_facet({ sections:[ @@ -79,9 +80,10 @@ IPA.krbtpolicy.entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.details_facet({ + that.builder.details_facet({ title: IPA.metadata.objects.krbtpolicy.label, sections: [ { diff --git a/install/ui/serverconfig.js b/install/ui/serverconfig.js index b120c4242..e6da7953a 100644 --- a/install/ui/serverconfig.js +++ b/install/ui/serverconfig.js @@ -29,9 +29,10 @@ IPA.config.entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.details_facet({ + that.builder.details_facet({ title: IPA.metadata.objects.config.label, sections: [ { diff --git a/install/ui/service.js b/install/ui/service.js index 5f46822e8..e41da2f99 100644 --- a/install/ui/service.js +++ b/install/ui/service.js @@ -29,9 +29,10 @@ IPA.service.entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'krbprincipalname' ] }). details_facet({ diff --git a/install/ui/sudo.js b/install/ui/sudo.js index 9af6b75a4..1affd0a37 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -32,9 +32,10 @@ IPA.sudo.rule_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'cn', 'ipaenabledflag', @@ -58,9 +59,10 @@ IPA.sudo.command_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'sudocmd', 'description' @@ -123,9 +125,10 @@ IPA.sudo.command_group_entity = function(spec) { var that = IPA.entity(spec); - that.init = function(params) { + that.init = function() { + that.entity_init(); - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'cn', 'description' diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index 0a914920c..fee170ba0 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -40,12 +40,13 @@ module('details', { details_container = $('<div id="details"/>').appendTo(document.body); - var obj_name = 'user'; - IPA.entity_factories.user= - function(){ - return IPA.entity({name:obj_name, - metadata:IPA.metadata.objects.user}); - }; + IPA.register('user', function(spec) { + + return IPA.entity({ + name: 'user', + metadata: IPA.metadata.objects.user + }); + }); }, teardown: function() { details_container.remove(); @@ -175,10 +176,10 @@ test("Testing details lifecycle: create, load.", function(){ var that = IPA.entity(spec); - that.init = function(params) { - that.entity_init(params); + that.init = function() { + that.entity_init(); - params.builder.details_facet({ + that.builder.details_facet({ sections: [ { name: 'identity', diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js index aa53613a3..a81e0b892 100644 --- a/install/ui/test/entity_tests.js +++ b/install/ui/test/entity_tests.js @@ -35,12 +35,12 @@ module('entity',{ var that = IPA.entity(spec); - that.init = function(params) { - that.entity_init(params); + that.init = function() { + that.entity_init(); - params.builder.search_facet({ - columns: [ 'uid' ] - }); + that.builder.search_facet({ + columns: [ 'uid' ] + }); }; return that; diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js index f55e29675..2fb1e814a 100644 --- a/install/ui/test/navigation_tests.js +++ b/install/ui/test/navigation_tests.js @@ -41,10 +41,11 @@ test("Testing IPA.navigation.create().", function() { //Force reset of entities IPA.entities = $.ordered_map(); - IPA.entity_factories.user = function() { + IPA.register('user', function(spec) { + var that = IPA.entity({ name: 'user', - metadata:IPA.metadata.objects.user, + metadata: IPA.metadata.objects.user, facets: [ { type: 'search' @@ -57,18 +58,25 @@ test("Testing IPA.navigation.create().", function() { same(container.attr('name'), 'user', 'user container name'); same(container[0].nodeName, 'DIV', 'user container element'); }; + return that; - }; - IPA.entity_factories.group = function(){ - var that = IPA.entity({name: 'group', - metadata:IPA.metadata.objects.group}); + }); + + 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); diff --git a/install/ui/user.js b/install/ui/user.js index e06cd42f2..09b4b2a3c 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -29,14 +29,15 @@ IPA.user.entity = function(spec) { var that = IPA.entity(spec); - var link = true; - if (IPA.nav && IPA.nav.name == 'self-service') { - link = false; - } + that.init = function() { + that.entity_init(); - that.init = function(params) { + var link = true; + if (IPA.nav && IPA.nav.name == 'self-service') { + link = false; + } - params.builder.search_facet({ + that.builder.search_facet({ columns: [ 'uid', 'givenname', |