Permalink
Browse files

Added simple testcase for regular recaptcha and recaptcha over https

  • Loading branch information...
1 parent f8cd6f5 commit 759339942a4f96592b68dd331f1347426fd40ee6 @raphaelbauer committed Jan 15, 2012
@@ -0,0 +1,38 @@
+package controllers;
+
+import play.*;
+import play.mvc.*;
+
+import java.util.*;
+
+import ugot.recaptcha.Recaptcha;
+
+import models.*;
+
+
+/**
+ *
+ * @author Olivier Refalo
+ */
+public class ApplicationHttps extends Controller {
+
+ public static void index() {
+ render();
+ }
+
+ public static void good() {
+ render();
+ }
+ public static void save(@Recaptcha String recaptcha) {
+
+ if(validation.hasErrors()) {
+ validation.keep();
+ index();
+ }
+ else {
+ // validation is fine, let the use know
+ good();
+ }
+
+ }
+}
@@ -0,0 +1,4 @@
+#{extends 'main.html' /}
+#{set title:'Test reCaptcha' /}
+
+Visual validation passed.
@@ -0,0 +1,19 @@
+#{extends 'main.html' /}
+#{set title:'Test reCaptcha' /}
+ #{form @save()} My sample captcha!
+ <p>
+ #{ugot.recaptcha theme:"red", tabindex:1, https:true/}
+ </p>
+
+ #{ifError 'recaptcha'}
+ <ul>
+ <li style="color:red">
+ #{error 'recaptcha'/}
+ </li>
+ </ul>
+ #{/ifError}
+ <p>
+ <input type="submit" value="Register"/>
+ </p>
+
+ #{/form}
@@ -5,6 +5,12 @@
# Home page
GET / Application.index
+GET /recaptcha Application.index
+GET /recaptcha/good Application.good
+
+GET /recaptcha_https ApplicationHttps.index
+GET /recaptcha_https/good ApplicationHttps.index
+
# Map static resources from the /app/public folder to the /public path
GET /public/ staticDir:public
@@ -0,0 +1,24 @@
+package controllers;
+
+
+
+import org.junit.Test;
+
+import play.Play;
+import play.mvc.Http.Response;
+import play.test.FunctionalTest;
+
+public class ApplicationHttpsTest extends FunctionalTest {
+
+
+ @Test
+ public void testBasicStuff() {
+
+ Response response = GET("/recaptcha_https");
+ assertStatus(200, response);
+ //make sure recaptcha is rendered into page with HTTPS
+ assertTrue(response.out.toString().contains("https://www.google.com/recaptcha/api/challenge"));
+
+ }
+
+}
@@ -0,0 +1,24 @@
+package controllers;
+
+
+
+import org.junit.Test;
+
+import play.Play;
+import play.mvc.Http.Response;
+import play.test.FunctionalTest;
+
+public class ApplicationTest extends FunctionalTest {
+
+
+ @Test
+ public void testBasicStuff() {
+
+ Response response = GET("/recaptcha");
+ assertStatus(200, response);
+ //make sure recaptcha is rendered into page
+ assertTrue(response.out.toString().contains("http://www.google.com/recaptcha/api/challenge"));
+
+ }
+
+}

0 comments on commit 7593399

Please sign in to comment.