This depends on my patch 0116.

Something not mentioned in the commit message is that this also fixes the 'filter only' options.
From c676e7a85fc679307a4639b8328a2230984eebe3 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Mon, 13 Dec 2010 12:48:09 -0500
Subject: [PATCH] aci unit tests

also added module definitions to the other tests, as ACI usese it for
specifying the setup and teardown functions.

Fixed certificate test html
all_tests now runs aci and certificate tests
---
 install/static/aci.js                              |   30 ++++++-
 .../static/test/{all_tests.html => aci_tests.html} |   17 ++--
 install/static/test/aci_tests.js                   |   84 ++++++++++++++++++++
 install/static/test/all_tests.html                 |    2 +
 install/static/test/certificate_tests.html         |    2 +
 install/static/test/certificate_tests.js           |    2 +
 install/static/test/details_tests.js               |    2 +
 install/static/test/entity_tests.js                |    2 +
 install/static/test/index.html                     |    1 +
 install/static/test/ipa_tests.js                   |    2 +
 install/static/test/navigation_tests.js            |    2 +-
 11 files changed, 132 insertions(+), 14 deletions(-)
 copy install/static/test/{all_tests.html => aci_tests.html} (65%)
 mode change 100644 => 100755
 create mode 100644 install/static/test/aci_tests.js

diff --git a/install/static/aci.js b/install/static/aci.js
index 52515b6b671f1d0108a1f6d89998860ca0de66e5..b033dbff041958f8c41947e78aff4c5b0991b856 100644
--- a/install/static/aci.js
+++ b/install/static/aci.js
@@ -21,7 +21,9 @@
 /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
 
 
-function ipa_target_section(spec) {
+function ipa_target_section() {
+    var    spec =  {'name':'target',
+                    'label': 'Target'}
 
     var that = ipa_details_section(spec);
 
@@ -104,6 +106,20 @@ function ipa_target_section(spec) {
     }
 
 
+
+    function display_none_target(dl){
+        $("<dt/>").
+            append($("<label/>",{
+                text:  "None (Filter only)",
+            })).
+            append($('<input/>',{
+                type:"radio",
+                name:"type",
+                checked:"true",
+                id:"aci_none"
+            })).appendTo(dl);
+    }
+
     function display_type_target(dl){
         $("<dt/>").
             append($("<label/>",{
@@ -268,10 +284,14 @@ function ipa_target_section(spec) {
         dl =  $('<dl class="entryattrs"/>').appendTo(container);
 
         display_filter(dl);
+        display_none_target(dl);
         display_query_target(dl);
         display_group_target(dl);
         display_type_target(dl);
 
+        $('#aci_none', dl).click(function (){
+            disable_inputs();
+        });
 
         $('#aci_by_type', dl).click(function (){
             disable_inputs();
@@ -338,9 +358,13 @@ function ipa_target_section(spec) {
             var targetgroup=segments[0].split(/=/)[1];
             that.group_filter.val( targetgroup);
             $('#aci_by_group').click();
+        }else{
+            $('#aci_none').click();
         }
 
         if (result.filter){
+            $('#aci_use_filter').click();
+            $('#aci_filter').attr('disabled', '');
             $('#aci_filter').val(result.filter);
         }
 
@@ -514,9 +538,7 @@ function ipa_permission_details_facet() {
             name:'identity',label:'Identity'  }));
         section.create_field({ name: 'cn', 'read_only': true });
         section.create_field({ name: 'description'});
-        that.target_section = ipa_target_section(
-            {'name':'target',
-             'label': 'Target'});
+        that.target_section = ipa_target_section();
 
         that.add_section(that.target_section);
         that.details_facet_init();
diff --git a/install/static/test/all_tests.html b/install/static/test/aci_tests.html
old mode 100644
new mode 100755
similarity index 65%
copy from install/static/test/all_tests.html
copy to install/static/test/aci_tests.html
index 64412b01b044fc852efd37a368d14092a43a3f45..7cdbeffa3c8d92c245b3e28987fa5c23433da7a0
--- a/install/static/test/all_tests.html
+++ b/install/static/test/aci_tests.html
@@ -1,9 +1,12 @@
 <!DOCTYPE html>
 <html>
 <head>
-    <title>Complete Test Suite</title>
+    <title>Access Control Interface Test Suite</title>
     <link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
     <script type="text/javascript" src="qunit.js"></script>
+
+
+
     <script type="text/javascript" src="../jquery.js"></script>
     <script type="text/javascript" src="../jquery.ba-bbq.js"></script>
     <script type="text/javascript" src="../jquery-ui.js"></script>
@@ -15,16 +18,12 @@
     <script type="text/javascript" src="../entity.js"></script>
     <script type="text/javascript" src="../associate.js"></script>
     <script type="text/javascript" src="../navigation.js"></script>
-    <script type="text/javascript" src="../certificate.js"></script>
-    <script type="text/javascript" src="ipa_tests.js"></script>
-    <script type="text/javascript" src="details_tests.js"></script>
-    <script type="text/javascript" src="entity_tests.js"></script>
-    <script type="text/javascript" src="association_tests.js"></script>
-    <script type="text/javascript" src="navigation_tests.js"></script>
-    <script type="text/javascript" src="certificate_tests.js"></script>
+    <script type="text/javascript" src="../aci.js"></script>
+    
+    <script type="text/javascript" src="aci_tests.js"></script>
 </head>
 <body>
-    <h1 id="qunit-header">Complete Test Suite</h1>
+    <h1 id="qunit-header">Certificate Test Suite</h1>
     <h2 id="qunit-banner"></h2>
     <div id="qunit-testrunner-toolbar"></div>
     <h2 id="qunit-userAgent"></h2>
diff --git a/install/static/test/aci_tests.js b/install/static/test/aci_tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..6ccc34de60306493a5e3be2cd631985efb773043
--- /dev/null
+++ b/install/static/test/aci_tests.js
@@ -0,0 +1,84 @@
+/*  Authors:
+ *    Endi Sukma Dewata <edew...@redhat.com>
+ *
+ * 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; version 2 only
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+var target_section;
+var aci_container;
+
+module('aci',{
+       setup: function() {
+           IPA.ajax_options.async = false;
+           IPA.init(
+               "data",
+               true,
+               function(data, text_status, xhr) {
+                   ok(true, "ipa_init() succeeded.");
+               },
+               function(xhr, text_status, error_thrown) {
+                   ok(false, "ipa_init() failed: "+error_thrown);
+               }
+           );
+           aci_container = $('<div id="aci"/>').appendTo(document.body);
+           target_section = ipa_target_section();
+           target_section.create(aci_container);
+       },
+       teardown: function() {
+           aci_container.remove();
+       }}
+);
+
+
+test("Testing aci grouptarget.", function() {
+    var sample_data_filter_only = {"targetgroup":"ipausers"};
+    target_section.load(sample_data_filter_only);
+    ok($('#aci_by_group')[0].checked, 'aci_by_group control selected');
+    ok ($('#aci_target_group_select option').length > 2,'group select populated');
+
+});
+
+
+
+test("Testing aci object type.", function() {
+    var sample_data_filter_only = {"type":"hostgroup"};
+    target_section.load(sample_data_filter_only);
+    ok($('.aci-attribute', aci_container).length > 4);
+    ok($('#aci_by_type')[0].checked, 'aci_by_type control selected');
+
+});
+
+
+test("Testing aci filter only.", function() {
+
+    var sample_data_filter_only = {"filter":"somevalue"};
+
+    target_section.load(sample_data_filter_only);
+
+    ok( $('#aci_use_filter').attr('checked'),'use filter is checked');
+    ok( !$('#aci_filter').attr('disabled'),'filter field  is enabled');
+
+   var filter_only_radio = $('#aci_none');
+
+    ok(filter_only_radio.length,'find "filter_only_radio" control');
+    ok(filter_only_radio[0].checked,'filter_only_radio control is checked');
+
+});
+
+
+
diff --git a/install/static/test/all_tests.html b/install/static/test/all_tests.html
index 64412b01b044fc852efd37a368d14092a43a3f45..6a29daffab67c7b1768a9129145ed54c1e221b2b 100644
--- a/install/static/test/all_tests.html
+++ b/install/static/test/all_tests.html
@@ -16,12 +16,14 @@
     <script type="text/javascript" src="../associate.js"></script>
     <script type="text/javascript" src="../navigation.js"></script>
     <script type="text/javascript" src="../certificate.js"></script>
+    <script type="text/javascript" src="../aci.js"></script>
     <script type="text/javascript" src="ipa_tests.js"></script>
     <script type="text/javascript" src="details_tests.js"></script>
     <script type="text/javascript" src="entity_tests.js"></script>
     <script type="text/javascript" src="association_tests.js"></script>
     <script type="text/javascript" src="navigation_tests.js"></script>
     <script type="text/javascript" src="certificate_tests.js"></script>
+    <script type="text/javascript" src="aci_tests.js"></script>
 </head>
 <body>
     <h1 id="qunit-header">Complete Test Suite</h1>
diff --git a/install/static/test/certificate_tests.html b/install/static/test/certificate_tests.html
index 90f09b21aaf06588f6599c44c1a2262fa2f40cd2..5b411ff136a2b3b43837492b5047ee58bda49d9c 100755
--- a/install/static/test/certificate_tests.html
+++ b/install/static/test/certificate_tests.html
@@ -5,6 +5,8 @@
     <link rel="stylesheet" href="qunit.css" type="text/css" media="screen">
     <script type="text/javascript" src="qunit.js"></script>
     <script type="text/javascript" src="../jquery.js"></script>
+    <script type="text/javascript" src="../jquery.ba-bbq.js"></script>
+    <script type="text/javascript" src="../jquery-ui.js"></script>
     <script type="text/javascript" src="../ipa.js"></script>
     <script type="text/javascript" src="../details.js"></script>
     <script type="text/javascript" src="../search.js"></script>
diff --git a/install/static/test/certificate_tests.js b/install/static/test/certificate_tests.js
index 6ada6e401b00a8476151c5e2612db11d31d14d53..0467594fd0543da343757350fad5b723cecd87ec 100755
--- a/install/static/test/certificate_tests.js
+++ b/install/static/test/certificate_tests.js
@@ -18,6 +18,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+module('certificate');
+
 test("Testing certificate_parse_dn().", function() {
 
     same(
diff --git a/install/static/test/details_tests.js b/install/static/test/details_tests.js
index 3dee5357f7e48a77bd1ed065a48fece33ff7ea11..dbc9ed72168e90d200085fb228a60b8e2a80a756 100644
--- a/install/static/test/details_tests.js
+++ b/install/static/test/details_tests.js
@@ -19,6 +19,8 @@
  */
 
 
+module('details');
+
 test("Testing ipa_details_section.create().", function() {
 
     IPA.ajax_options.async = false;
diff --git a/install/static/test/entity_tests.js b/install/static/test/entity_tests.js
index 45834ac3cd8fb49ab9b6fec9bdcbe394500dd7a5..e05b61a5f602e28e10dd5a1cbc0eaf53e5ae3169 100644
--- a/install/static/test/entity_tests.js
+++ b/install/static/test/entity_tests.js
@@ -18,6 +18,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+module('entity');
+
 test('Testing ipa_entity_set_search_definition().', function() {
 
     var uid_callback = function() {
diff --git a/install/static/test/index.html b/install/static/test/index.html
index 5467a683f5f7490825721b65c8720dff39ac71f7..78b41e9b569da03f4191f084cfd08f14271ba8d1 100644
--- a/install/static/test/index.html
+++ b/install/static/test/index.html
@@ -30,6 +30,7 @@
         <li><a href="association_tests.html">Association Test Suite</a>
         <li><a href="navigation_tests.html">Navigation Test Suite</a>
         <li><a href="certificate_tests.html">Certificate Test Suite</a>
+        <li><a href="aci_tests.html">Access Control Interface Test Suite</a>
 
         </ul>
     </div>
diff --git a/install/static/test/ipa_tests.js b/install/static/test/ipa_tests.js
index 7124aa764ac7a985e913811e9eabec6d0a3c7598..f8f26b012796bc654faf5d9b8a794d3f3c9971c2 100644
--- a/install/static/test/ipa_tests.js
+++ b/install/static/test/ipa_tests.js
@@ -18,6 +18,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+module('ipa');
+
 test("Testing ipa_init().", function() {
 
     expect(1);
diff --git a/install/static/test/navigation_tests.js b/install/static/test/navigation_tests.js
index 0d6f322d1d37a767fddac2e9c3da25bd85c8d424..fc9fc75c9886ad356234dccc2430d9124f9f4704 100644
--- a/install/static/test/navigation_tests.js
+++ b/install/static/test/navigation_tests.js
@@ -19,7 +19,7 @@
  */
 
 
-
+module('navigation');
 
 test("Testing nav_create().", function() {
 
-- 
1.7.2.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to