Commits

Stefan Saasen committed 71057cc

Add simple integration tests.

Comments (0)

Files changed (4)

src/test/java/it/AbstractIntegrationTestCase.java

 import com.atlassian.confluence.plugin.functest.AbstractConfluencePluginWebTestCase;
 import com.atlassian.confluence.plugin.functest.JWebUnitConfluenceWebTester;
 import com.atlassian.confluence.plugin.functest.TesterConfiguration;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
 import junit.framework.Assert;
 
 import java.io.IOException;
 
         return tester;
     }
+
+    void assertPageRequiresXsrfToken(String url) {
+        try {
+            getTester().setIgnoreFailingStatusCodes(true);
+            gotoPage(url);
+            assertTextPresent("a required security token was not present in the request.");
+        }
+        finally {
+            getTester().setIgnoreFailingStatusCodes(false);
+        }
+    }
 }

src/test/java/it/IntegrationTestAdminTokenConfigurationAction.java

+package it;
+
+/**
+ * Minimal integration test that ensures that the plugin is working and actions are wired correctly.
+ */
+public class IntegrationTestAdminTokenConfigurationAction extends AbstractIntegrationTestCase {
+
+    public void testConfigurationViewPage() {
+        gotoPage("/admin/hipchat.action");
+        assertTextPresent("HipChat API Auth Token Configuration");
+    }
+
+    public void testSaveConfigurationRequiresXsrfToken() {
+        assertPageRequiresXsrfToken("/admin/doconfigure-hipchat.action");
+    }
+}

src/test/java/it/IntegrationTestSpaceAdminAction.java

+package it;
+
+public class IntegrationTestSpaceAdminAction extends AbstractIntegrationTestCase {
+    public void testSpaceConfigurationViewPage() {
+        gotoPage("/spaces/hipchat.action?key=ds");
+        assertTextPresent("HipChat Configuration");
+    }
+
+    public void testSaveSpaceConfigurationRequiresXsrfToken() {
+        assertPageRequiresXsrfToken("/spaces/doconfigure-hipchat.action");
+    }
+
+}
+

src/test/java/it/IntegrationTestTokenConfigurationAction.java

-package it;
-
-public class IntegrationTestTokenConfigurationAction extends AbstractIntegrationTestCase
-{
-	public void testSomething()
-	{
-        gotoPage("");
-        assertTextPresent("Welcome");
-	}
-}