mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
committed by
Endi S. Dewata
parent
6f0c16e428
commit
a8ea42bda8
@@ -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' ]
|
||||
}).
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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() {
|
||||
|
||||
that.init = function(params) {
|
||||
if (!IPA.dns_enabled) {
|
||||
throw {
|
||||
expected: true
|
||||
};
|
||||
}
|
||||
|
||||
params.builder.facet_groups([ 'dnsrecord', 'settings' ]).
|
||||
that.entity_init();
|
||||
|
||||
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() {
|
||||
|
||||
that.init = function(params) {
|
||||
if (!IPA.dns_enabled) {
|
||||
throw {
|
||||
expected: true
|
||||
};
|
||||
}
|
||||
|
||||
params.builder.containing_entity('dnszone').
|
||||
that.entity_init();
|
||||
|
||||
that.builder.containing_entity('dnszone').
|
||||
details_facet({
|
||||
post_update_hook:function(data){
|
||||
var result = data.result.result;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user