Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added selenium test

  • Loading branch information...
commit bc99cfd3e4b19160d7df1dc1379d1cd6baaf3fb8 1 parent c0c719a
Christian Meier authored
27 demo/Gemfile
View
@@ -1,3 +1,4 @@
+# -*- mode: ruby -*-
source 'http://rubygems.org'
gem 'rails', '3.0.0'
@@ -32,3 +33,29 @@ gem "jdbc-sqlite3", :require => false if defined?(JRUBY_VERSION)
# end
gem 'enforce-ssl'
+
+if defined? MAVEN
+ properties({ "jruby.plugins.version" => '0.23.0-SNAPSHOT' })
+
+ #TODO allow :scope => :test, :classifier => "test", :exclusions => ['ant.ant']
+ #group :dev do
+ jar 'junit.junit', '3.8.2'
+ jar 'org.seleniumhq.selenium.client-drivers.selenium-java-client-driver', '1.0.1'
+ #end
+
+ plugin('org.mortbay.jetty.jetty-maven-plugin', '${jetty.version}') do |jetty|
+ jetty.with(:stopKey => 'foo', :stopPort => 9999)
+ jetty.in_phase('pre-integration-test').execute('run').with(:daemon => true)
+ jetty.in_phase('post-integration-test').execute('stop')
+ end
+
+ plugin('org.codehaus.mojo.selenium-maven-plugin', '1.1') do |selenium|
+ selenium.in_phase('pre-integration-test').execute("start-server").with({
+ :background => true, :firefoxProfileTemplate => "src/test/resources/selenium" })
+ end
+
+ plugin('surefire', '2.6') do |surefire|
+ surefire.with :skip => true
+ surefire.in_phase('integration-test').execute('test').with :skip => false
+ end
+end
57 demo/README.textile
View
@@ -0,0 +1,57 @@
+h1. Start the demo application
+
+h2. with maven3 (jetty)
+
+bc. mvn rails3:rake -Dargs="db:setup"
+mvn jetty:run -f Gemfile.pom
+
+p. note: there is no need to have jruby, rubygems, rails installed !!!
+
+h2. with ruby-maven gem (jetty)
+
+bc. jruby -S gem install ruby-maven --pre
+rmvn rake db:setup
+rmvn jetty-run
+
+p. note: you need to have jruby installed but no rails or bundler !!!
+
+h2. with jruby (webrick)
+
+bc. jruby -S bundle install
+jruby -S rake db:setup
+jruby script/rails server
+
+p. note: you to have jruby and bundler installed !!!
+
+h2. with ruby (webrick)
+
+bc. bundle install
+rake db:setup
+script/rails server
+
+p. note: you to have bundler installed !!!
+
+h1. Run the integration test (selenium)
+
+h2. with maven3 (jetty)
+
+bc. mvn rails3:rake -Dargs="db:setup"
+mvn integration-test -f Gemfile.pom
+
+p. note: there is no need to have jruby, rubygems, rails installed !!!
+
+h2. with ruby-maven gem (jetty)
+
+bc. jruby -S gem install ruby-maven --pre
+rmvn rake db:setup
+rmvn integration-test
+
+p. note: you need to have jruby installed but no rails or bundler !!!
+
+h1. Navigate through the application
+
+p. I use the jetty port 8080 for the sample urls. starting point is
+
+p. "http://localhost:8080/users":http://localhost:8080/users
+
+p. any further link enforces SSL will switch over to port 8443 and https.
13 demo/app/controllers/application_controller.rb
View
@@ -1,3 +1,16 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
+ before_filter do
+
+ # work around a bug somewhere in the
+ # tcp stack from rails, rack, jruby-rack, jetty
+ # when request HEAD and then following a GET on
+ # the same connection does not send the body of the
+ # GET. on a fresh connection both HEAD and HEAD work
+ # as expected
+ # only appeared on selenium tests
+ response.header["Connection"] = "close"
+
+ end
end
38 demo/src/test/java/enforce_ssl/DevelopmentTestCase.java
View
@@ -0,0 +1,38 @@
+package enforce_ssl;
+
+import junit.framework.TestCase;
+
+import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.SeleniumException;
+
+public class DevelopmentTestCase
+ extends TestCase
+{
+ protected DefaultSelenium createSeleniumClient(String url) throws Exception {
+ return new DefaultSelenium("localhost", 4444, "*firefox", url);
+ }
+
+ public void testRedirectToSsl() throws Exception {
+ DefaultSelenium selenium = createSeleniumClient("http://localhost:8080");
+ selenium.start();
+
+ selenium.open("/users");
+ selenium.click("link=New User");
+ selenium.waitForPageToLoad("10000");
+ assertEquals("https://localhost:8443/users/new", selenium.getLocation());
+
+ selenium.stop();
+ }
+
+ public void testStayOnSsl() throws Exception {
+ DefaultSelenium selenium = createSeleniumClient("https://localhost:8443");
+ selenium.start();
+
+ selenium.open("/users");
+ selenium.click("link=New User");
+ selenium.waitForPageToLoad("10000");
+ assertEquals("https://localhost:8443/users/new", selenium.getLocation());
+
+ selenium.stop();
+ }
+}
0  demo/src/test/resources/selenium/.parentlock
View
No changes.
BIN  demo/src/test/resources/selenium/cert8.db
View
Binary file not shown
3  demo/src/test/resources/selenium/cert_override.txt
View
@@ -0,0 +1,3 @@
+# PSM Certificate Override Settings file
+# This is a generated file! Do not edit.
+localhost:8443 OID.2.16.840.1.101.3.4.2.1 92:DE:D7:63:60:A6:4C:A8:97:B9:E6:26:46:94:BC:C9:31:73:69:00:95:3B:14:E4:B7:3C:C7:26:59:CD:F4:55 U AAAAAAAAAAAAAAAEAAAAcEzJ5aIwbjEQMA4GA1UEBhMHVW5rbm93bjEQMA4GA1UE CBMHVW5rbm93bjEQMA4GA1UEBxMHVW5rbm93bjEQMA4GA1UEChMHVW5rbm93bjEQ MA4GA1UECxMHVW5rbm93bjESMBAGA1UEAxMJbG9jYWxob3N0
Please sign in to comment.
Something went wrong with that request. Please try again.