syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdisabat...@apache.org
Subject syncope git commit: [SYNCOPE-752] Add console test for security questions
Date Thu, 03 Mar 2016 10:28:01 GMT
Repository: syncope
Updated Branches:
  refs/heads/master d53dce1df -> 936d5422b


[SYNCOPE-752] Add console test for security questions


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/936d5422
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/936d5422
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/936d5422

Branch: refs/heads/master
Commit: 936d5422bc6df7a4bb647c4ca91002163c9c50a2
Parents: d53dce1
Author: Marco Di Sabatino Di Diodoro <mdisabatino@apache.org>
Authored: Thu Mar 3 11:27:43 2016 +0100
Committer: Marco Di Sabatino Di Diodoro <mdisabatino@apache.org>
Committed: Thu Mar 3 11:27:43 2016 +0100

----------------------------------------------------------------------
 .../fit/console/AbstractConsoleITCase.java      |   9 +-
 .../fit/console/AbstractTypesITCase.java        |   2 +-
 .../fit/console/SecurityQuestionsITCase.java    | 122 +++++++++++++++++++
 3 files changed, 128 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/936d5422/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
index 33013a2..27ad920 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
@@ -35,10 +35,10 @@ import org.apache.wicket.util.visit.IVisit;
 import org.apache.wicket.util.visit.IVisitor;
 import org.junit.Before;
 
-public abstract class AbstractConsoleITCase extends AbstractITCase {
+public abstract class AbstractConsoleITCase<T> extends AbstractITCase {
 
     protected static final String KEY = "key";
-    
+
     protected static final String SCHEMA = "schema";
 
     protected WicketTester wicketTester;
@@ -78,7 +78,7 @@ public abstract class AbstractConsoleITCase extends AbstractITCase {
         formTester.submit("submit");
     }
 
-    protected Component findComponentByProp(final String property, final String searchPath,
final String key) {
+    protected Component findComponentByProp(final String property, final String searchPath,
final T key) {
         Component component = wicketTester.getComponentFromLastRenderedPage(searchPath);
 
         Component result = component.getPage().
@@ -89,7 +89,8 @@ public abstract class AbstractConsoleITCase extends AbstractITCase {
 
                         try {
                             if (PropertyResolver.getPropertyGetter(
-                                    property, object.getModelObject()).invoke(object.getModelObject()).equals(key))
{
+                                    property,
+                                    object.getModelObject()).invoke(object.getModelObject()).equals(key))
{
                                 visit.stop(object);
                             }
                         } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
ex) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/936d5422/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractTypesITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractTypesITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractTypesITCase.java
index 72f7251..241c54c 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractTypesITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractTypesITCase.java
@@ -24,7 +24,7 @@ import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.
 import org.apache.wicket.util.tester.FormTester;
 import org.junit.Before;
 
-public abstract class AbstractTypesITCase extends AbstractConsoleITCase {
+public abstract class AbstractTypesITCase extends AbstractConsoleITCase<String> {
 
     protected static final String PLAIN_DATATABLE_PATH = "body:content:tabbedPanel:panel:"
             + "accordionPanel:tabs:0:body:content:container:content:searchContainer:resultTable";

http://git-wip-us.apache.org/repos/asf/syncope/blob/936d5422/fit/core-reference/src/test/java/org/apache/syncope/fit/console/SecurityQuestionsITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/SecurityQuestionsITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/SecurityQuestionsITCase.java
new file mode 100644
index 0000000..c6abea2
--- /dev/null
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/SecurityQuestionsITCase.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.fit.console;
+
+import static org.apache.syncope.fit.console.AbstractConsoleITCase.KEY;
+import static org.junit.Assert.assertNull;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
+import org.apache.syncope.client.console.pages.SecurityQuestions;
+import org.apache.wicket.Component;
+import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
+import org.apache.wicket.util.tester.FormTester;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.JVM)
+public class SecurityQuestionsITCase extends AbstractConsoleITCase<Long> {
+
+    @Before
+    public void login() {
+        doLogin(ADMIN_UNAME, ADMIN_PWD);
+        wicketTester.clickLink("body:configurationLI:configurationUL:securityquestionsLI:securityquestions");
+        wicketTester.assertRenderedPage(SecurityQuestions.class);
+    }
+
+    @Test
+    public void read() {
+        wicketTester.assertLabel(
+                "body:content:securityQuestionPanel:container:content:searchContainer:resultTable:"
+                + "tablePanel:groupForm:checkgroup:dataTable:body:rows:1:cells:2:cell",
+                "What&#039;s your mother&#039;s maiden name?");
+
+        wicketTester.assertComponent(
+                "body:content:securityQuestionPanel:container:content:"
+                + "searchContainer:resultTable:tablePanel:"
+                + "groupForm:checkgroup:dataTable:body:rows:"
+                + "1:cells:3:cell:panelEdit:editLink", IndicatingAjaxLink.class);
+    }
+
+    @Test
+    public void create() {
+        wicketTester.clickLink("body:content:securityQuestionPanel:container:content:add");
+
+        wicketTester.assertComponent(
+                "body:content:securityQuestionPanel:modal", Modal.class);
+
+        final FormTester formTester = wicketTester.newFormTester("body:content:securityQuestionPanel"
+                + ":modal:form");
+        formTester.setValue("content:securityQuestionDetailsPanel:container:form:content:textField",
+                "What's your favorite team?");
+
+        wicketTester.clickLink("body:content:securityQuestionPanel:modal:dialog:footer:inputs:0:submit");
+
+        wicketTester.assertInfoMessages("Operation executed successfully");
+        wicketTester.cleanupFeedbackMessages();
+    }
+
+    @Test
+    public void update() {
+        Component result = findComponentByProp(KEY, "body:content:securityQuestionPanel:container:content:"
+                + "searchContainer:resultTable", 100L);
+
+        wicketTester.assertLabel(
+                result.getPageRelativePath() + ":cells:1:cell", "100");
+
+        wicketTester.clickLink(
+                result.getPageRelativePath() + ":cells:3:cell:panelEdit:editLink");
+
+        final FormTester formTester = wicketTester.newFormTester("body:content:securityQuestionPanel"
+                + ":modal:form");
+        formTester.setValue("content:securityQuestionDetailsPanel:container:form:content:textField",
+                "What's your favorite car?");
+
+        wicketTester.clickLink("body:content:securityQuestionPanel:modal:dialog:footer:inputs:0:submit");
+
+        wicketTester.assertInfoMessages("Operation executed successfully");
+        wicketTester.cleanupFeedbackMessages();
+    }
+
+    @Test
+    public void delete() {
+        Component result = findComponentByProp(KEY, "body:content:securityQuestionPanel:container:content:"
+                + "searchContainer:resultTable:", 100L);
+
+        wicketTester.assertLabel(
+                result.getPageRelativePath() + ":cells:1:cell", "100");
+
+        wicketTester.getRequest().addParameter("confirm", "true");
+        wicketTester.clickLink(
+                wicketTester.getComponentFromLastRenderedPage(
+                        result.getPageRelativePath() + ":cells:3:cell:panelDelete:deleteLink"));
+
+        wicketTester.executeAjaxEvent(wicketTester.getComponentFromLastRenderedPage(
+                result.getPageRelativePath() + ":cells:3:cell:panelDelete:deleteLink"), "onclick");
+
+        wicketTester.assertInfoMessages("Operation executed successfully");
+        wicketTester.cleanupFeedbackMessages();
+
+        assertNull(findComponentByProp(KEY,
+                "body:content:securityQuestionPanel:container:content:"
+                + "searchContainer:resultTable:"
+                + "tablePanel:groupForm:checkgroup:dataTable", 100L));
+    }
+}


Mime
View raw message