Description:
login test
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r626:f38d39d4f555 - - 7 files changed: 35 inserted, 11 deleted
@@ -67,12 +67,12 | |||||
|
67 | gem 'ace-rails-ap' |
|
67 | gem 'ace-rails-ap' |
|
68 |
|
68 | ||
|
69 | gem 'haml' |
|
69 | gem 'haml' |
|
70 | gem 'haml-rails' |
|
70 | gem 'haml-rails' |
|
71 | gem 'mail' |
|
71 | gem 'mail' |
|
72 | gem 'rdiscount' |
|
72 | gem 'rdiscount' |
|
73 | - gem 'test-unit' |
|
73 | + #gem 'test-unit' |
|
74 | gem 'will_paginate', '~> 3.0.7' |
|
74 | gem 'will_paginate', '~> 3.0.7' |
|
75 | gem 'dynamic_form' |
|
75 | gem 'dynamic_form' |
|
76 | gem 'in_place_editing' |
|
76 | gem 'in_place_editing' |
|
77 | gem 'verification', :git => 'https://github.com/sikachu/verification.git' |
|
77 | gem 'verification', :git => 'https://github.com/sikachu/verification.git' |
|
78 |
|
78 |
@@ -114,13 +114,12 | |||||
|
114 | momentjs-rails (2.15.1) |
|
114 | momentjs-rails (2.15.1) |
|
115 | railties (>= 3.1) |
|
115 | railties (>= 3.1) |
|
116 | multi_json (1.12.1) |
|
116 | multi_json (1.12.1) |
|
117 | mysql2 (0.4.5) |
|
117 | mysql2 (0.4.5) |
|
118 | nokogiri (1.6.8.1) |
|
118 | nokogiri (1.6.8.1) |
|
119 | mini_portile2 (~> 2.1.0) |
|
119 | mini_portile2 (~> 2.1.0) |
|
120 | - power_assert (0.4.1) |
|
||
|
121 | rack (1.6.5) |
|
120 | rack (1.6.5) |
|
122 | rack-test (0.6.3) |
|
121 | rack-test (0.6.3) |
|
123 | rack (>= 1.0) |
|
122 | rack (>= 1.0) |
|
124 | rails (4.2.7.1) |
|
123 | rails (4.2.7.1) |
|
125 | actionmailer (= 4.2.7.1) |
|
124 | actionmailer (= 4.2.7.1) |
|
126 | actionpack (= 4.2.7.1) |
|
125 | actionpack (= 4.2.7.1) |
@@ -167,14 +166,12 | |||||
|
167 | rack (> 1, < 3) |
|
166 | rack (> 1, < 3) |
|
168 | sprockets-rails (3.2.0) |
|
167 | sprockets-rails (3.2.0) |
|
169 | actionpack (>= 4.0) |
|
168 | actionpack (>= 4.0) |
|
170 | activesupport (>= 4.0) |
|
169 | activesupport (>= 4.0) |
|
171 | sprockets (>= 3.0.0) |
|
170 | sprockets (>= 3.0.0) |
|
172 | sqlite3 (1.3.12) |
|
171 | sqlite3 (1.3.12) |
|
173 | - test-unit (3.2.3) |
|
||
|
174 | - power_assert |
|
||
|
175 | thor (0.19.4) |
|
172 | thor (0.19.4) |
|
176 | thread_safe (0.3.5) |
|
173 | thread_safe (0.3.5) |
|
177 | tilt (2.0.5) |
|
174 | tilt (2.0.5) |
|
178 | tzinfo (1.2.2) |
|
175 | tzinfo (1.2.2) |
|
179 | thread_safe (~> 0.1) |
|
176 | thread_safe (~> 0.1) |
|
180 | uglifier (3.0.4) |
|
177 | uglifier (3.0.4) |
@@ -209,13 +206,12 | |||||
|
209 | rails_bootstrap_sortable |
|
206 | rails_bootstrap_sortable |
|
210 | rdiscount |
|
207 | rdiscount |
|
211 | rouge |
|
208 | rouge |
|
212 | sass-rails |
|
209 | sass-rails |
|
213 | select2-rails |
|
210 | select2-rails |
|
214 | sqlite3 |
|
211 | sqlite3 |
|
215 | - test-unit |
|
||
|
216 | uglifier |
|
212 | uglifier |
|
217 | verification! |
|
213 | verification! |
|
218 | will_paginate (~> 3.0.7) |
|
214 | will_paginate (~> 3.0.7) |
|
219 |
|
215 | ||
|
220 | BUNDLED WITH |
|
216 | BUNDLED WITH |
|
221 | 1.13.6 |
|
217 | 1.13.6 |
@@ -8,12 +8,13 | |||||
|
8 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
8 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
9 | TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout' |
|
9 | TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout' |
|
10 | MULTICONTESTS_KEY = 'system.multicontests' |
|
10 | MULTICONTESTS_KEY = 'system.multicontests' |
|
11 | CONTEST_TIME_LIMIT_KEY = 'contest.time_limit' |
|
11 | CONTEST_TIME_LIMIT_KEY = 'contest.time_limit' |
|
12 | MULTIPLE_IP_LOGIN_KEY = 'right.multiple_ip_login' |
|
12 | MULTIPLE_IP_LOGIN_KEY = 'right.multiple_ip_login' |
|
13 | VIEW_TESTCASE = 'right.view_testcase' |
|
13 | VIEW_TESTCASE = 'right.view_testcase' |
|
|
14 | + SINGLE_USER_KEY = 'system.single_user' | ||
|
14 |
|
15 | ||
|
15 | cattr_accessor :config_cache |
|
16 | cattr_accessor :config_cache |
|
16 | cattr_accessor :task_grading_info_cache |
|
17 | cattr_accessor :task_grading_info_cache |
|
17 | cattr_accessor :contest_time_str |
|
18 | cattr_accessor :contest_time_str |
|
18 | cattr_accessor :contest_time |
|
19 | cattr_accessor :contest_time |
|
19 |
|
20 |
@@ -9,13 +9,13 | |||||
|
9 | - if flash[:notice] |
|
9 | - if flash[:notice] |
|
10 | %hr/ |
|
10 | %hr/ |
|
11 | %b= flash[:notice] |
|
11 | %b= flash[:notice] |
|
12 | %hr/ |
|
12 | %hr/ |
|
13 |
|
13 | ||
|
14 | %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"} |
|
14 | %div{ :style => "border: solid 1px gray; padding: 4px; background: #eeeeff;"} |
|
15 | - = form_tag :controller => 'login', :action => 'login' do |
|
15 | + = form_tag login_login_path do |
|
16 | %table |
|
16 | %table |
|
17 | %tr |
|
17 | %tr |
|
18 | %td{:align => "right"} |
|
18 | %td{:align => "right"} |
|
19 | ="#{t 'login_label'}:" |
|
19 | ="#{t 'login_label'}:" |
|
20 | %td= text_field_tag 'login' |
|
20 | %td= text_field_tag 'login' |
|
21 | %tr |
|
21 | %tr |
@@ -1,11 +1,14 | |||||
|
1 | CafeGrader::Application.routes.draw do |
|
1 | CafeGrader::Application.routes.draw do |
|
2 | get "sources/direct_edit" |
|
2 | get "sources/direct_edit" |
|
3 |
|
3 | ||
|
4 | root :to => 'main#login' |
|
4 | root :to => 'main#login' |
|
5 |
|
5 | ||
|
|
6 | + #logins | ||
|
|
7 | + get 'login/login', to: 'login#login' | ||
|
|
8 | + | ||
|
6 | resources :contests |
|
9 | resources :contests |
|
7 |
|
10 | ||
|
8 | resources :sites |
|
11 | resources :sites |
|
9 |
|
12 | ||
|
10 | resources :announcements do |
|
13 | resources :announcements do |
|
11 | member do |
|
14 | member do |
@@ -10,16 +10,16 | |||||
|
10 | login: john |
|
10 | login: john |
|
11 | full_name: john |
|
11 | full_name: john |
|
12 | hashed_password: <%= User.encrypt("hello",salt) %> |
|
12 | hashed_password: <%= User.encrypt("hello",salt) %> |
|
13 | salt: <%= salt %> |
|
13 | salt: <%= salt %> |
|
14 | activated: true |
|
14 | activated: true |
|
15 |
|
15 | ||
|
16 | - mary: |
|
16 | + admin: |
|
17 |
- login: |
|
17 | + login: admin |
|
18 |
- full_name: |
|
18 | + full_name: admin |
|
19 |
- hashed_password: <%= User.encrypt(" |
|
19 | + hashed_password: <%= User.encrypt("admin",salt) %> |
|
20 | salt: <%= salt %> |
|
20 | salt: <%= salt %> |
|
21 | roles: admin |
|
21 | roles: admin |
|
22 | activated: true |
|
22 | activated: true |
|
23 |
|
23 | ||
|
24 | james: |
|
24 | james: |
|
25 | login: james |
|
25 | login: james |
@@ -2,12 +2,36 | |||||
|
2 |
|
2 | ||
|
3 | class LoginTest < ActionDispatch::IntegrationTest |
|
3 | class LoginTest < ActionDispatch::IntegrationTest |
|
4 | # test "the truth" do |
|
4 | # test "the truth" do |
|
5 | # assert true |
|
5 | # assert true |
|
6 | # end |
|
6 | # end |
|
7 |
|
7 | ||
|
8 | - test "login with valid information" do |
|
8 | + test "login with invalid information" do |
|
|
9 | + get root_path | ||
|
|
10 | + assert_response :success | ||
|
|
11 | + post login_login_path, login: "root", password: "hahaha" | ||
|
|
12 | + assert_redirected_to root_path | ||
|
|
13 | + end | ||
|
|
14 | + | ||
|
|
15 | + test "normal user login" do | ||
|
9 | get root_path |
|
16 | get root_path |
|
10 | assert_response :success |
|
17 | assert_response :success |
|
|
18 | + post login_login_path, {login: "john", password: "hello" } | ||
|
|
19 | + assert_redirected_to main_list_path | ||
|
|
20 | + end | ||
|
11 |
|
21 | ||
|
|
22 | + test "normal user login in single_user mode" do | ||
|
|
23 | + GraderConfiguration[GraderConfiguration::SINGLE_USER_KEY] = 'true' | ||
|
|
24 | + get root_path | ||
|
|
25 | + assert_response :success | ||
|
|
26 | + post login_login_path, {login: "john", password: "hello" } | ||
|
|
27 | + assert_redirected_to root_path | ||
|
|
28 | + end | ||
|
|
29 | + | ||
|
|
30 | + test "root login in in single_user mode" do | ||
|
|
31 | + GraderConfiguration[GraderConfiguration::SINGLE_USER_KEY] = 'true' | ||
|
|
32 | + get root_path | ||
|
|
33 | + assert_response :success | ||
|
|
34 | + post login_login_path, {login: "admin", password: "admin" } | ||
|
|
35 | + assert_redirected_to main_list_path | ||
|
12 | end |
|
36 | end |
|
13 | end |
|
37 | end |
You need to be logged in to leave comments.
Login now