|
36 | 36 | page.should have_content("You have successfully logged in")
|
37 | 37 | end
|
38 | 38 |
|
| 39 | + it "auto-forwards when you're already logged in" do |
| 40 | + visit "/login" |
| 41 | + |
| 42 | + fill_in 'username', :with => VALID_USERNAME |
| 43 | + fill_in 'password', :with => VALID_PASSWORD |
| 44 | + click_button 'login-submit' |
| 45 | + |
| 46 | + visit "/login?service="+CGI.escape(@target_service) |
| 47 | + |
| 48 | + page.current_url.should =~ /^#{Regexp.escape(@target_service)}\/?\?ticket=ST\-[1-9rA-Z]+/ |
| 49 | + end |
| 50 | + |
39 | 51 | it "fails to log in with invalid password" do
|
40 | 52 | visit "/login"
|
41 | 53 | fill_in 'username', :with => VALID_USERNAME
|
|
92 | 104 | #page.should have_xpath("<script>alert(32)</script>")
|
93 | 105 | end
|
94 | 106 |
|
| 107 | + describe 'service_uri validation' do |
| 108 | + let(:service) { 'http://imposter.com/' } |
| 109 | + |
| 110 | + it "doesn't redirect back to untrusted services" do |
| 111 | + visit "/login?service="+CGI.escape(service) |
| 112 | + |
| 113 | + page.should have_content("The target service is not allowed") |
| 114 | + |
| 115 | + fill_in 'username', :with => VALID_USERNAME |
| 116 | + fill_in 'password', :with => VALID_PASSWORD |
| 117 | + |
| 118 | + click_button 'login-submit' |
| 119 | + |
| 120 | + page.should have_content("The target service is not allowed") |
| 121 | + end |
| 122 | + |
| 123 | + it "doesn't redirect back when already logged in" do |
| 124 | + visit "/login" |
| 125 | + |
| 126 | + fill_in 'username', :with => VALID_USERNAME |
| 127 | + fill_in 'password', :with => VALID_PASSWORD |
| 128 | + |
| 129 | + click_button 'login-submit' |
| 130 | + |
| 131 | + visit "/login?service="+CGI.escape(service) |
| 132 | + |
| 133 | + page.should have_content("The target service is not allowed") |
| 134 | + end |
| 135 | + |
| 136 | + end |
| 137 | + |
| 138 | + |
95 | 139 | end # describe '/login'
|
96 | 140 |
|
97 | 141 |
|
|
0 commit comments