diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am
index 8b613666c..835888d94 100644
--- a/install/ui/Makefile.am
+++ b/install/ui/Makefile.am
@@ -25,6 +25,7 @@ app_DATA = \
field.js \
group.js \
hbac.js \
+ hbactest.js \
host.js \
hostgroup.js \
index.html \
diff --git a/install/ui/facet.js b/install/ui/facet.js
index 71ad5c08b..65ac71ee0 100644
--- a/install/ui/facet.js
+++ b/install/ui/facet.js
@@ -110,6 +110,9 @@ IPA.facet = function(spec) {
that.header.load(data.result.result);
};
+ that.refresh = function() {
+ };
+
that.clear = function() {
};
@@ -320,7 +323,7 @@ IPA.facet_header = function(spec) {
}).appendTo(container);
var span = $('
', {
- text: that.facet.entity.metadata.label
+ text: that.facet.entity.label
}).appendTo(that.title_container);
if (!that.facet.disable_facet_tabs) {
@@ -341,9 +344,6 @@ IPA.facet_header = function(spec) {
that.load = function(data) {
if (!that.facet.disable_facet_tabs) {
var pkey = that.facet.pkey;
- if(!pkey || !data) {
- pkey = '';
- }
var facet_groups = that.facet.entity.facet_groups.values;
for (var i=0; i
+ *
+ * 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 .
+ */
+
+/* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js,hbac.js */
+
+IPA.hbac.test_entity = function(spec) {
+
+ var that = IPA.entity(spec);
+
+ that.get_default_metadata = function() {
+ return IPA.metadata.commands[that.name];
+ };
+
+ that.init = function() {
+ that.entity_init();
+
+ that.label = IPA.messages.objects.hbactest.label;
+
+ that.builder.facet_groups([ 'default' ]).
+ facet({
+ factory: IPA.hbac.test_facet,
+ name: 'user',
+ label: 'Who',
+ managed_entity_name: 'user',
+ disable_breadcrumb: true,
+ facet_group: 'default',
+ columns: [
+ 'uid',
+ 'givenname',
+ 'sn'
+ ]
+ }).
+ facet({
+ factory: IPA.hbac.test_facet,
+ name: 'targethost',
+ label: 'Accessing',
+ managed_entity_name: 'host',
+ disable_breadcrumb: true,
+ facet_group: 'default',
+ columns: [
+ 'fqdn',
+ 'description',
+ {
+ name: 'has_keytab',
+ label: IPA.messages.objects.host.enrolled
+ }
+ ]
+ }).
+ facet({
+ factory: IPA.hbac.test_facet,
+ name: 'service',
+ label: 'Via Service',
+ managed_entity_name: 'hbacsvc',
+ disable_breadcrumb: true,
+ facet_group: 'default',
+ columns: [
+ 'cn',
+ 'description'
+ ]
+ }).
+ facet({
+ factory: IPA.hbac.test_facet,
+ name: 'sourcehost',
+ label: 'From Host',
+ managed_entity_name: 'host',
+ disable_breadcrumb: true,
+ facet_group: 'default',
+ columns: [
+ 'fqdn',
+ 'description',
+ {
+ name: 'has_keytab',
+ label: IPA.messages.objects.host.enrolled
+ }
+ ]
+ }).
+ facet({
+ factory: IPA.hbac.test_rules_facet,
+ name: 'rules',
+ label: 'On Rules',
+ managed_entity_name: 'hbacrule',
+ disable_breadcrumb: true,
+ facet_group: 'default',
+ multivalued: true,
+ columns: [
+ 'cn',
+ 'ipaenabledflag',
+ 'description'
+ ]
+ }).
+ facet({
+ factory: IPA.hbac.test_run_facet,
+ name: 'run',
+ label: 'Run Test',
+ managed_entity_name: 'hbacrule',
+ disable_breadcrumb: true,
+ pagination: true,
+ facet_group: 'default',
+ columns: [
+ 'cn',
+ {
+ name: 'matched',
+ label: 'Matched'
+ },
+ 'ipaenabledflag',
+ 'description'
+ ]
+ });
+ };
+
+ return that;
+};
+
+IPA.hbac.test_facet = function(spec) {
+
+ spec = spec || {};
+
+ var that = IPA.table_facet(spec);
+ that.multivalued = spec.multivalued;
+
+ var init = function() {
+
+ that.managed_entity = IPA.get_entity(that.managed_entity_name);
+
+ var columns = that.columns.values;
+ for (var i=0; i', {
+ text: that.label
+ }).appendTo(container);
+
+ var filter_container = $('', {
+ 'class': 'search-filter'
+ }).appendTo(header);
+
+ that.filter = $('', {
+ type: 'text',
+ name: 'filter'
+ }).appendTo(filter_container);
+
+ that.filter.keypress(function(e) {
+ /* if the key pressed is the enter key */
+ if (e.which == 13) {
+ that.find();
+ }
+ });
+
+ that.find_button = IPA.action_button({
+ name: 'find',
+ icon: 'search-icon',
+ click: function() {
+ that.find();
+ return false;
+ }
+ }).appendTo(filter_container);
+
+ header.append(IPA.create_network_spinner());
+
+ var div = $('', {
+ style: 'position: relative; height: 200px'
+ }).appendTo(container);
+
+ that.table.create(div);
+
+ container.append('
');
+
+ that.create_buttons(container);
+ };
+
+ that.create_buttons = function(container) {
+
+ var buttons = $('', {
+ style: 'float: right'
+ }).appendTo(container);
+
+ that.back_button = IPA.button({
+ name: 'back',
+ label: 'Back',
+ click: function() {
+ if (!that.back_button.hasClass('action-button-disabled')) {
+ that.back();
+ }
+ return false;
+ }
+ }).appendTo(buttons);
+
+ that.next_button = IPA.button({
+ name: 'next',
+ label: 'Next',
+ click: function() {
+ if (!that.add_button.hasClass('action-button-disabled')) {
+ that.next();
+ }
+ return false;
+ }
+ }).appendTo(buttons);
+ };
+
+ that.get_pkeys = function(data) {
+ var result = data.result.result;
+ var pkey_name = that.managed_entity.metadata.primary_key;
+ var pkeys = [];
+ for (var i=0; i', {
+ }).appendTo(container);
+
+ $('', {
+ text: that.label,
+ style: 'display: inline-block'
+ }).appendTo(header);
+
+ header.append(' ');
+
+ that.enabled = $('', {
+ id: 'hbactest-rules-include-enabled',
+ type: 'checkbox',
+ name: 'enabled'
+ }).appendTo(header);
+
+ $('', {
+ 'for': 'hbactest-rules-include-enabled',
+ text: 'Include enabled'
+ }).appendTo(header);
+
+ that.disabled = $('', {
+ id: 'hbactest-rules-include-disabled',
+ type: 'checkbox',
+ name: 'disabled'
+ }).appendTo(header);
+
+ $('', {
+ 'for': 'hbactest-rules-include-disabled',
+ text: 'Include disabled'
+ }).appendTo(header);
+
+ var div = $('', {
+ style: 'position: relative; height: 200px'
+ }).appendTo(container);
+
+ that.table.create(div);
+
+ container.append('
');
+
+ that.create_buttons(container);
+ };
+
+
+ that.save = function(record) {
+ if (that.selected_values && that.selected_values.length) {
+ record[that.name] = that.selected_values;
+ }
+ if (that.enabled && that.enabled.is(':checked')) {
+ record['enabled'] = true;
+ }
+ if (that.disabled && that.disabled.is(':checked')) {
+ record['disabled'] = true;
+ }
+ };
+ init();
+
+ return that;
+};
+
+IPA.hbac.test_run_facet = function(spec) {
+
+ spec = spec || {};
+
+ var that = IPA.hbac.test_facet(spec);
+
+ var init = function() {
+ that.table.selectable = false;
+ };
+
+ that.create_content = function(container) {
+
+ var action_panel = $('', {
+ style: 'border: 1px solid #C9C3BA; padding: 10px'
+ }).appendTo(container);
+
+ var action_button = $('', {
+ style: 'width: 100px; display: inline-block'
+ }).appendTo(action_panel);
+
+ that.run_button = IPA.button({
+ name: 'run',
+ label: 'Run Test',
+ click: function() {
+ if (!that.run_button.hasClass('action-button-disabled')) {
+ that.run();
+ }
+ return false;
+ }
+ }).appendTo(action_button);
+
+ var action_result = $('', {
+ style: 'display: inline-block'
+ }).appendTo(action_panel);
+
+ that.test_result = $('').appendTo(action_result);
+
+ var header = $('', {
+ text: 'Rules'
+ }).appendTo(container);
+
+ var div = $('', {
+ style: 'position: relative; height: 200px'
+ }).appendTo(container);
+
+ that.table.create(div);
+
+ container.append('
');
+
+ var buttons = $('', {
+ style: 'float: right'
+ }).appendTo(container);
+
+ that.back_button = IPA.button({
+ name: 'back',
+ label: 'Back',
+ click: function() {
+ if (!that.back_button.hasClass('action-button-disabled')) {
+ that.back();
+ }
+ return false;
+ }
+ }).appendTo(buttons);
+
+ that.new_test_button = IPA.button({
+ name: 'new_test',
+ label: 'New Test',
+ click: function() {
+ if (!that.new_test_button.hasClass('action-button-disabled')) {
+ that.new_test();
+ }
+ return false;
+ }
+ }).appendTo(buttons);
+ };
+
+ that.refresh = function() {
+ };
+
+ that.run = function() {
+
+ var command = IPA.command({ method: 'hbactest' });
+
+ var options = {};
+
+ var facet = that.entity.get_facet('user');
+ facet.save(options);
+
+ facet = that.entity.get_facet('targethost');
+ facet.save(options);
+
+ facet = that.entity.get_facet('service');
+ facet.save(options);
+
+ facet = that.entity.get_facet('sourcehost');
+ facet.save(options);
+
+ facet = that.entity.get_facet('rules');
+ facet.save(options);
+
+ command.set_options(options);
+
+ command.on_success = function(data, text_status, xhr) {
+ var message = data.result.value ? 'Access granted' : 'Access Denied';
+ that.test_result.text(message);
+
+ that.load(data);
+ };
+
+ command.execute();
+ };
+
+ that.get_pkeys = function(data) {
+ var pkeys = [];
+ that.matched = {};
+
+ var matched = data.result.matched;
+ if (matched) {
+ for (var i=0; i
+
@@ -64,11 +65,13 @@
-
-