diff options
author | Endi S. Dewata <edewata@redhat.com> | 2011-01-11 17:07:46 +0700 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2011-01-11 21:33:45 -0500 |
commit | 308b7b3a4965d4cef55929099939f2446104eaec (patch) | |
tree | 41aec023a9d7445fec1f7f5b12450a7d192700d7 /install | |
parent | 9d0dc89b03d4e3f50d54d1189a119016b2c805c3 (diff) | |
download | freeipa-308b7b3a4965d4cef55929099939f2446104eaec.tar.gz freeipa-308b7b3a4965d4cef55929099939f2446104eaec.tar.xz freeipa-308b7b3a4965d4cef55929099939f2446104eaec.zip |
Added group association table for SUDO command.
A section has been added to the SUDO command details page for managing
the association with SUDO command groups. New test data has been added
as well.
Diffstat (limited to 'install')
-rwxr-xr-x | install/static/sudocmd.js | 159 | ||||
-rwxr-xr-x | install/static/sudocmdgroup.js | 1 | ||||
-rw-r--r-- | install/static/test/data/sudocmd_memberof_add.json | 53 | ||||
-rw-r--r-- | install/static/test/data/sudocmd_memberof_remove.json | 50 | ||||
-rw-r--r-- | install/static/test/data/sudocmd_memberof_show.json | 61 | ||||
-rw-r--r-- | install/static/test/data/sudocmd_show.json | 4 |
6 files changed, 328 insertions, 0 deletions
diff --git a/install/static/sudocmd.js b/install/static/sudocmd.js index 864063f62..307f09900 100755 --- a/install/static/sudocmd.js +++ b/install/static/sudocmd.js @@ -107,8 +107,167 @@ function ipa_sudocmd_details_facet(spec) { section.create_field({'name': 'sudocmd'}); section.create_field({'name': 'description'}); + section = ipa_details_section({ + 'name': 'groups', + 'label': 'Groups' + }); + that.add_section(section); + + var field = ipa_sudocmd_member_sudocmdgroup_table_widget({ + 'name': 'memberof', + 'label': 'Groups', + 'other_entity': 'sudocmdgroup', + 'save_values': false + }); + section.add_field(field); + that.details_facet_init(); }; return that; +} + +function ipa_sudocmd_member_sudocmdgroup_table_widget(spec) { + + spec = spec || {}; + + var that = ipa_association_table_widget(spec); + + that.init = function() { + + var column = that.create_column({ + name: 'cn', + primary_key: true, + width: '150px' + }); + + column.setup = function(container, record) { + container.empty(); + + var value = record[column.name]; + value = value ? value.toString() : ''; + + $('<a/>', { + 'href': '#'+value, + 'html': value, + 'click': function (value) { + return function() { + var state = IPA.tab_state(that.other_entity); + state[that.other_entity + '-facet'] = 'details'; + state[that.other_entity + '-pkey'] = value; + $.bbq.pushState(state); + return false; + } + }(value) + }).appendTo(container); + }; + + that.create_column({ + name: 'description', + label: 'Description', + width: '150px' + }); + + that.create_adder_column({ + name: 'cn', + primary_key: true, + width: '100px' + }); + + that.create_adder_column({ + name: 'description', + width: '100px' + }); + + that.association_table_widget_init(); + }; + + that.get_records = function(on_success, on_error) { + + if (!that.values.length) return; + + var batch = ipa_batch_command({ + 'name': that.entity_name+'_'+that.name+'_show', + 'on_success': on_success, + 'on_error': on_error + }); + + for (var i=0; i<that.values.length; i++) { + var dn = that.values[i]; + var j = dn.indexOf('='); + var k = dn.indexOf(','); + var value = dn.substring(j+1, k); + + var command = ipa_command({ + 'method': that.other_entity+'_show', + 'args': [value], + 'options': { + 'all': true, + 'rights': true + } + }); + + batch.add_command(command); + } + + batch.execute(); + }; + + that.add = function(values, on_success, on_error) { + + if (!values.length) return; + + var batch = ipa_batch_command({ + 'name': that.entity_name+'_'+that.name+'_add', + 'on_success': on_success, + 'on_error': on_error + }); + + var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; + + for (var i=0; i<values.length; i++) { + var value = values[i]; + + var command = ipa_command({ + 'method': that.other_entity+'_add_member', + 'args': [value] + }); + + command.set_option('sudocmd', pkey); + + batch.add_command(command); + } + + batch.execute(); + }; + + that.remove = function(values, on_success, on_error) { + + if (!values.length) return; + + var batch = ipa_batch_command({ + 'name': that.entity_name+'_'+that.name+'_remove', + 'on_success': on_success, + 'on_error': on_error + }); + + var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; + + for (var i=0; i<values.length; i++) { + var value = values[i]; + + var command = ipa_command({ + 'method': that.other_entity+'_remove_member', + 'args': [value] + }); + + command.set_option('sudocmd', pkey); + + batch.add_command(command); + } + + batch.execute(); + }; + + return that; }
\ No newline at end of file diff --git a/install/static/sudocmdgroup.js b/install/static/sudocmdgroup.js index 1fb5e1899..a78d088b6 100755 --- a/install/static/sudocmdgroup.js +++ b/install/static/sudocmdgroup.js @@ -169,6 +169,7 @@ function ipa_sudocmdgroup_member_sudocmd_table_widget(spec) { }; that.create_column({ + name: 'description', label: 'Description', width: '150px' }); diff --git a/install/static/test/data/sudocmd_memberof_add.json b/install/static/test/data/sudocmd_memberof_add.json new file mode 100644 index 000000000..e263007d8 --- /dev/null +++ b/install/static/test/data/sudocmd_memberof_add.json @@ -0,0 +1,53 @@ +{ + "error": null, + "id": 0, + "result": { + "count": 2, + "results": [ + { + "completed": 1, + "error": null, + "failed": { + "member": { + "sudocmd": [], + "sudocmdgroup": [] + } + }, + "result": { + "cn": [ + "group1" + ], + "description": [ + "Group 1" + ], + "dn": "cn=group1,cn=sudocmdgroups,cn=accounts,dc=ipa", + "member_sudocmd": [ + "/usr/bin/less" + ] + } + }, + { + "completed": 1, + "error": null, + "failed": { + "member": { + "sudocmd": [], + "sudocmdgroup": [] + } + }, + "result": { + "cn": [ + "group2" + ], + "description": [ + "Group 2" + ], + "dn": "cn=group2,cn=sudocmdgroups,cn=accounts,dc=ipa", + "member_sudocmd": [ + "/usr/bin/more" + ] + } + } + ] + } +} diff --git a/install/static/test/data/sudocmd_memberof_remove.json b/install/static/test/data/sudocmd_memberof_remove.json new file mode 100644 index 000000000..347b5cded --- /dev/null +++ b/install/static/test/data/sudocmd_memberof_remove.json @@ -0,0 +1,50 @@ +{ + "error": null, + "id": 0, + "result": { + "count": 2, + "results": [ + { + "completed": 1, + "error": null, + "failed": { + "member": { + "sudocmd": [], + "sudocmdgroup": [] + } + }, + "result": { + "cn": [ + "group1" + ], + "description": [ + "Group 1" + ], + "dn": "cn=group1,cn=sudocmdgroups,cn=accounts,dc=ipa" + } + }, + { + "completed": 1, + "error": null, + "failed": { + "member": { + "sudocmd": [], + "sudocmdgroup": [] + } + }, + "result": { + "cn": [ + "group2" + ], + "description": [ + "Group 2" + ], + "dn": "cn=group2,cn=sudocmdgroups,cn=accounts,dc=ipa", + "memberindirect_sudocmd": [ + "/usr/bin/more" + ] + } + } + ] + } +} diff --git a/install/static/test/data/sudocmd_memberof_show.json b/install/static/test/data/sudocmd_memberof_show.json new file mode 100644 index 000000000..9b7f3af23 --- /dev/null +++ b/install/static/test/data/sudocmd_memberof_show.json @@ -0,0 +1,61 @@ +{ + "error": null, + "id": 0, + "result": { + "count": 2, + "results": [ + { + "error": null, + "result": { + "cn": [ + "group1" + ], + "description": [ + "Group 1" + ], + "dn": "cn=group1,cn=sudocmdgroups,cn=accounts,dc=ipa", + "ipauniqueid": [ + "fc775d2e-1d56-11e0-b7cd-00163e2fe6de" + ], + "member_sudocmd": [ + "/usr/bin/less" + ], + "objectclass": [ + "ipaobject", + "ipasudocmdgrp", + "groupOfNames", + "top" + ] + }, + "summary": null, + "value": "group1" + }, + { + "error": null, + "result": { + "cn": [ + "group2" + ], + "description": [ + "Group 2" + ], + "dn": "cn=group2,cn=sudocmdgroups,cn=accounts,dc=ipa", + "ipauniqueid": [ + "b90c1930-1d5b-11e0-ac89-00163e2fe6de" + ], + "member_sudocmd": [ + "/usr/bin/more" + ], + "objectclass": [ + "ipaobject", + "ipasudocmdgrp", + "groupOfNames", + "top" + ] + }, + "summary": null, + "value": "group2" + } + ] + } +} diff --git a/install/static/test/data/sudocmd_show.json b/install/static/test/data/sudocmd_show.json index f9eacc39b..a08401d7b 100644 --- a/install/static/test/data/sudocmd_show.json +++ b/install/static/test/data/sudocmd_show.json @@ -15,6 +15,10 @@ "ipauniqueid": [ "06708d0e-f454-11df-9273-00163e72f2d9" ], + "memberof": [ + "cn=group1,cn=sudocmdgroups,cn=accounts,dc=dev,dc=example,dc=com", + "cn=group2,cn=sudocmdgroups,cn=accounts,dc=dev,dc=example,dc=com" + ], "objectclass": [ "ipaobject", "ipasudocmd" |