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
@@ -61,18 +61,18 | |||
|
61 | 61 | |
|
62 | 62 | #bootstrap sortable |
|
63 | 63 | gem 'momentjs-rails' |
|
64 | 64 | gem 'rails_bootstrap_sortable' |
|
65 | 65 | |
|
66 | 66 | #ace editor |
|
67 | 67 | gem 'ace-rails-ap' |
|
68 | 68 | |
|
69 | 69 | gem 'haml' |
|
70 | 70 | gem 'haml-rails' |
|
71 | 71 | gem 'mail' |
|
72 | 72 | gem 'rdiscount' |
|
73 | - gem 'test-unit' | |
|
73 | + #gem 'test-unit' | |
|
74 | 74 | gem 'will_paginate', '~> 3.0.7' |
|
75 | 75 | gem 'dynamic_form' |
|
76 | 76 | gem 'in_place_editing' |
|
77 | 77 | gem 'verification', :git => 'https://github.com/sikachu/verification.git' |
|
78 | 78 |
@@ -108,25 +108,24 | |||
|
108 | 108 | mime-types (>= 1.16, < 4) |
|
109 | 109 | mime-types (3.1) |
|
110 | 110 | mime-types-data (~> 3.2015) |
|
111 | 111 | mime-types-data (3.2016.0521) |
|
112 | 112 | mini_portile2 (2.1.0) |
|
113 | 113 | minitest (5.10.1) |
|
114 | 114 | momentjs-rails (2.15.1) |
|
115 | 115 | railties (>= 3.1) |
|
116 | 116 | multi_json (1.12.1) |
|
117 | 117 | mysql2 (0.4.5) |
|
118 | 118 | nokogiri (1.6.8.1) |
|
119 | 119 | mini_portile2 (~> 2.1.0) |
|
120 | - power_assert (0.4.1) | |
|
121 | 120 | rack (1.6.5) |
|
122 | 121 | rack-test (0.6.3) |
|
123 | 122 | rack (>= 1.0) |
|
124 | 123 | rails (4.2.7.1) |
|
125 | 124 | actionmailer (= 4.2.7.1) |
|
126 | 125 | actionpack (= 4.2.7.1) |
|
127 | 126 | actionview (= 4.2.7.1) |
|
128 | 127 | activejob (= 4.2.7.1) |
|
129 | 128 | activemodel (= 4.2.7.1) |
|
130 | 129 | activerecord (= 4.2.7.1) |
|
131 | 130 | activesupport (= 4.2.7.1) |
|
132 | 131 | bundler (>= 1.3.0, < 2.0) |
@@ -161,26 +160,24 | |||
|
161 | 160 | tilt (>= 1.1, < 3) |
|
162 | 161 | select2-rails (4.0.3) |
|
163 | 162 | thor (~> 0.14) |
|
164 | 163 | sexp_processor (4.7.0) |
|
165 | 164 | sprockets (3.7.1) |
|
166 | 165 | concurrent-ruby (~> 1.0) |
|
167 | 166 | rack (> 1, < 3) |
|
168 | 167 | sprockets-rails (3.2.0) |
|
169 | 168 | actionpack (>= 4.0) |
|
170 | 169 | activesupport (>= 4.0) |
|
171 | 170 | sprockets (>= 3.0.0) |
|
172 | 171 | sqlite3 (1.3.12) |
|
173 | - test-unit (3.2.3) | |
|
174 | - power_assert | |
|
175 | 172 | thor (0.19.4) |
|
176 | 173 | thread_safe (0.3.5) |
|
177 | 174 | tilt (2.0.5) |
|
178 | 175 | tzinfo (1.2.2) |
|
179 | 176 | thread_safe (~> 0.1) |
|
180 | 177 | uglifier (3.0.4) |
|
181 | 178 | execjs (>= 0.3.0, < 3) |
|
182 | 179 | will_paginate (3.0.12) |
|
183 | 180 | |
|
184 | 181 | PLATFORMS |
|
185 | 182 | ruby |
|
186 | 183 | |
@@ -203,19 +200,18 | |||
|
203 | 200 | jquery-timepicker-addon-rails |
|
204 | 201 | jquery-ui-rails |
|
205 | 202 | |
|
206 | 203 | momentjs-rails |
|
207 | 204 | mysql2 |
|
208 | 205 | rails (~> 4.2.0) |
|
209 | 206 | rails_bootstrap_sortable |
|
210 | 207 | rdiscount |
|
211 | 208 | rouge |
|
212 | 209 | sass-rails |
|
213 | 210 | select2-rails |
|
214 | 211 | sqlite3 |
|
215 | - test-unit | |
|
216 | 212 | uglifier |
|
217 | 213 | verification! |
|
218 | 214 | will_paginate (~> 3.0.7) |
|
219 | 215 | |
|
220 | 216 | BUNDLED WITH |
|
221 | 217 | 1.13.6 |
@@ -2,24 +2,25 | |||
|
2 | 2 | |
|
3 | 3 | # |
|
4 | 4 | # This class also contains various login of the system. |
|
5 | 5 | # |
|
6 | 6 | class GraderConfiguration < ActiveRecord::Base |
|
7 | 7 | |
|
8 | 8 | SYSTEM_MODE_CONF_KEY = 'system.mode' |
|
9 | 9 | TEST_REQUEST_EARLY_TIMEOUT_KEY = 'contest.test_request.early_timeout' |
|
10 | 10 | MULTICONTESTS_KEY = 'system.multicontests' |
|
11 | 11 | CONTEST_TIME_LIMIT_KEY = 'contest.time_limit' |
|
12 | 12 | MULTIPLE_IP_LOGIN_KEY = 'right.multiple_ip_login' |
|
13 | 13 | VIEW_TESTCASE = 'right.view_testcase' |
|
14 | + SINGLE_USER_KEY = 'system.single_user' | |
|
14 | 15 | |
|
15 | 16 | cattr_accessor :config_cache |
|
16 | 17 | cattr_accessor :task_grading_info_cache |
|
17 | 18 | cattr_accessor :contest_time_str |
|
18 | 19 | cattr_accessor :contest_time |
|
19 | 20 | |
|
20 | 21 | GraderConfiguration.config_cache = nil |
|
21 | 22 | GraderConfiguration.task_grading_info_cache = nil |
|
22 | 23 | |
|
23 | 24 | def self.config_cached? |
|
24 | 25 | (defined? CONFIGURATION_CACHE_ENABLED) and (CONFIGURATION_CACHE_ENABLED) |
|
25 | 26 | end |
@@ -3,25 +3,25 | |||
|
3 | 3 | |
|
4 | 4 | - if !@hidelogin |
|
5 | 5 | =t 'login.message' |
|
6 | 6 | %br/ |
|
7 | 7 | %br/ |
|
8 | 8 | |
|
9 | 9 | - if flash[:notice] |
|
10 | 10 | %hr/ |
|
11 | 11 | %b= flash[:notice] |
|
12 | 12 | %hr/ |
|
13 | 13 | |
|
14 | 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 | 16 | %table |
|
17 | 17 | %tr |
|
18 | 18 | %td{:align => "right"} |
|
19 | 19 | ="#{t 'login_label'}:" |
|
20 | 20 | %td= text_field_tag 'login' |
|
21 | 21 | %tr |
|
22 | 22 | %td{:align => "right"} |
|
23 | 23 | ="#{t 'password_label'}:" |
|
24 | 24 | %td= password_field_tag |
|
25 | 25 | - unless GraderConfiguration['right.bypass_agreement'] |
|
26 | 26 | %tr |
|
27 | 27 | %td{:align => "right"}= check_box_tag 'accept_agree' |
@@ -1,17 +1,20 | |||
|
1 | 1 | CafeGrader::Application.routes.draw do |
|
2 | 2 | get "sources/direct_edit" |
|
3 | 3 | |
|
4 | 4 | root :to => 'main#login' |
|
5 | 5 | |
|
6 | + #logins | |
|
7 | + get 'login/login', to: 'login#login' | |
|
8 | + | |
|
6 | 9 | resources :contests |
|
7 | 10 | |
|
8 | 11 | resources :sites |
|
9 | 12 | |
|
10 | 13 | resources :announcements do |
|
11 | 14 | member do |
|
12 | 15 | get 'toggle','toggle_front' |
|
13 | 16 | end |
|
14 | 17 | end |
|
15 | 18 | |
|
16 | 19 | resources :problems do |
|
17 | 20 | member do |
@@ -4,28 +4,28 | |||
|
4 | 4 | User.public_class_method :encrypt |
|
5 | 5 | |
|
6 | 6 | salt = "abc" |
|
7 | 7 | %> |
|
8 | 8 | |
|
9 | 9 | john: |
|
10 | 10 | login: john |
|
11 | 11 | full_name: john |
|
12 | 12 | hashed_password: <%= User.encrypt("hello",salt) %> |
|
13 | 13 | salt: <%= salt %> |
|
14 | 14 | activated: true |
|
15 | 15 | |
|
16 | - mary: | |
|
17 |
- login: |
|
|
18 |
- full_name: |
|
|
19 |
- hashed_password: <%= User.encrypt(" |
|
|
16 | + admin: | |
|
17 | + login: admin | |
|
18 | + full_name: admin | |
|
19 | + hashed_password: <%= User.encrypt("admin",salt) %> | |
|
20 | 20 | salt: <%= salt %> |
|
21 | 21 | roles: admin |
|
22 | 22 | activated: true |
|
23 | 23 | |
|
24 | 24 | james: |
|
25 | 25 | login: james |
|
26 | 26 | full_name: James |
|
27 | 27 | hashed_password: <%= User.encrypt("morning",salt) %> |
|
28 | 28 | salt: <%= salt %> |
|
29 | 29 | contests: contest_a |
|
30 | 30 | activated: true |
|
31 | 31 |
@@ -1,13 +1,37 | |||
|
1 | 1 | require 'test_helper' |
|
2 | 2 | |
|
3 | 3 | class LoginTest < ActionDispatch::IntegrationTest |
|
4 | 4 | # test "the truth" do |
|
5 | 5 | # assert true |
|
6 | 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 | 16 | get root_path |
|
10 | 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 | 36 | end |
|
13 | 37 | end |
You need to be logged in to leave comments.
Login now