Realm Domains page

Add support for Realm Domains to web UI.

https://fedorahosted.org/freeipa/ticket/3407
This commit is contained in:
Ana Krivokapic 2013-03-07 14:12:49 +01:00 committed by Petr Vobornik
parent 8d36951911
commit 6c85b88874
9 changed files with 190 additions and 7 deletions

View File

@ -41,6 +41,7 @@ define([
'./idrange',
'./netgroup',
'./policy',
'./realmdomains',
'./rule',
'./selinux',
'./serverconfig',

View File

@ -0,0 +1,103 @@
/* Authors:
* Ana Krivokapic <akrivoka@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(['./ipa', './jquery', './details', './entity'], function (IPA, $) {
IPA.realmdomains = {};
IPA.realmdomains.entity = function (spec) {
var that = IPA.entity(spec);
that.init = function () {
that.entity_init();
that.builder.details_facet({
factory: IPA.realmdomains_details_facet,
title: IPA.metadata.objects.realmdomains.label,
sections: [
{
name: 'identity',
label: IPA.messages.objects.realmdomains.identity,
fields: [
{
name: 'associateddomain',
type: 'multivalued'
}
]
}
],
needs_update: true
});
};
return that;
};
IPA.realmdomains_details_facet = function (spec) {
spec = spec || {};
var that = IPA.details_facet(spec);
that.update = function (on_success, on_error) {
var command = that.create_update_command();
command.on_success = function (data, text_status, xhr) {
that.update_on_success(data, text_status, xhr);
if (on_success) on_success.call(this, data, text_status, xhr);
};
command.on_error = function (xhr, text_status, error_thrown) {
that.update_on_error(xhr, text_status, error_thrown);
if (on_error) on_error.call(this, xhr, text_status, error_thrown);
};
var dialog = IPA.confirm_dialog({
title: IPA.messages.objects.realmdomains.check_dns,
message: IPA.messages.objects.realmdomains.check_dns_confirmation,
ok_label: IPA.messages.objects.realmdomains.check_dns,
on_ok: function () {
command.execute();
}
});
var cancel_button = dialog.get_button('cancel');
dialog.buttons.remove('cancel');
dialog.create_button({
name: 'force',
label: IPA.messages.objects.realmdomains.force_update,
visible: true,
click: function () {
command.set_option('force', true);
command.execute();
dialog.close();
}
});
dialog.add_button(cancel_button);
dialog.open();
};
return that;
};
IPA.register('realmdomains', IPA.realmdomains.entity);
return {};
});

View File

@ -43,7 +43,8 @@ IPA.admin_navigation = function(spec) {
{entity: 'dnsrecord', hidden:true}
]
},
{entity: 'cert', label: IPA.messages.tabs.cert }
{entity: 'cert', label: IPA.messages.tabs.cert },
{entity: 'realmdomains'}
]},
{name: 'policy', label: IPA.messages.tabs.policy, children: [
{name: 'hbac', label: IPA.messages.tabs.hbac, children: [
@ -127,4 +128,4 @@ IPA.self_serv_navigation = function(spec) {
};
return {};
});
});

View File

@ -398,6 +398,12 @@
"type_ad": "Active Directory domain",
"type_local": "Local domain"
},
"realmdomains": {
"identity": "Realm Domains",
"check_dns": "Check DNS",
"check_dns_confirmation": "Do you also want to perform DNS check?",
"force_update": "Force Update"
},
"role": {
"identity": "Role Settings"
},

View File

@ -6026,6 +6026,48 @@
],
"uuid_attribute": ""
},
"realmdomains": {
"aciattrs": [],
"attribute_members": {},
"bindable": false,
"container_dn": "",
"default_attributes": ["associateddomain"],
"hidden_attributes": [
"objectclass",
"aci"
],
"label": "Realm Domains",
"label_singular": "Realm Domains",
"methods": [
"mod",
"show"
],
"name": "realmdomains",
"object_class": [
"domainrelatedobject",
"top",
"nscontainter"
],
"object_class_config": null,
"object_name": "realmdomains",
"object_name_plural": "realmdomains",
"parent_object": "",
"rdn_attribute": "",
"relationships": {},
"takes_params": [
{
"class": "Str",
"doc": "Domain",
"flags": [],
"label": "Domain",
"name": "associateddomain",
"required": true,
"type": "unicode",
"multivalued": true
}
],
"uuid_attribute": ""
},
"role": {
"aciattrs": [
"businesscategory",

View File

@ -0,0 +1,24 @@
{
"error": null,
"id": 0,
"result": {
"result": {
"attributelevelrights": {
"aci": "rscwo",
"cn": "rscwo",
"associateddomain": "rscwo",
"objectclass": "rscwo"
},
"cn": ["Realm Domains"],
"dn": "cn=Realm Domains,cn=ipa,cn=etc,dc=example,dc=com",
"associateddomain": ["example.com"],
"objectclass": [
"nsContainer",
"top",
"domainRelatedObject"
]
},
"summary": null,
"value": ""
}
}

View File

@ -536,6 +536,12 @@ class i18n_messages(Command):
"type_ad": _("Active Directory domain"),
"type_local": _("Local domain"),
},
"realmdomains": {
"identity": _("Realm Domains"),
"check_dns": _("Check DNS"),
"check_dns_confirmation": _("Do you also want to perform DNS check?"),
"force_update": _("Force Update"),
},
"role": {
"identity": _("Role Settings"),
},

View File

@ -105,9 +105,10 @@ class realmdomains_mod(LDAPUpdate):
if get_domain_name() not in associateddomain:
raise errors.ValidationError(name='domain', error=_("cannot delete domain of IPA server"))
if not force:
for d in associateddomain:
if not has_soa_or_ns_record(d):
raise errors.ValidationError(name='domain', error=_("no SOA or NS records found for domain %s" % d))
bad_domains = [d for d in associateddomain if not has_soa_or_ns_record(d)]
if bad_domains:
bad_domains = ', '.join(bad_domains)
raise errors.ValidationError(name='domain', error=_("no SOA or NS records found for domains: %s" % bad_domains))
return dn
# If --add-domain or --del-domain options were provided, read

View File

@ -20,7 +20,6 @@
Test the `ipalib/plugins/realmdomains.py` module.
"""
import random, string
from ipalib import api, errors
from ipapython.dn import DN
from tests.test_xmlrpc import objectclasses
@ -131,7 +130,7 @@ class test_realmdomains(Declarative):
desc='Try to replace list of realm domains with a list with an invalid domain "%s"' % bad_domain,
command=('realmdomains_mod', [], {'associateddomain': [our_domain, bad_domain]}),
expected=errors.ValidationError(
name='domain', error='no SOA or NS records found for domain %s' % bad_domain),
name='domain', error='no SOA or NS records found for domains: %s' % bad_domain),
),
dict(
desc='Try to add an invalid domain "%s"' % bad_domain,