@@ -0,0 +1,25 | |||||
|
1 | # redMine - project management software | |||
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |||
|
3 | # | |||
|
4 | # This program is free software; you can redistribute it and/or | |||
|
5 | # modify it under the terms of the GNU General Public License | |||
|
6 | # as published by the Free Software Foundation; either version 2 | |||
|
7 | # of the License, or (at your option) any later version. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
14 | # You should have received a copy of the GNU General Public License | |||
|
15 | # along with this program; if not, write to the Free Software | |||
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
|
17 | ||||
|
18 | class LdapAuthSourcesController < AuthSourcesController | |||
|
19 | ||||
|
20 | protected | |||
|
21 | ||||
|
22 | def auth_source_class | |||
|
23 | AuthSourceLdap | |||
|
24 | end | |||
|
25 | end |
@@ -0,0 +1,13 | |||||
|
1 | <%= error_messages_for 'auth_source' %> | |||
|
2 | ||||
|
3 | <div class="box"> | |||
|
4 | <!--[form:auth_source]--> | |||
|
5 | <p><label for="auth_source_name"><%=l(:field_name)%> <span class="required">*</span></label> | |||
|
6 | <%= text_field 'auth_source', 'name' %></p> | |||
|
7 | ||||
|
8 | <p><label for="auth_source_onthefly_register"><%=l(:field_onthefly)%></label> | |||
|
9 | <%= check_box 'auth_source', 'onthefly_register' %></p> | |||
|
10 | </div> | |||
|
11 | ||||
|
12 | <!--[eoform:auth_source]--> | |||
|
13 |
@@ -0,0 +1,83 | |||||
|
1 | require 'test_helper' | |||
|
2 | ||||
|
3 | class AuthSourcesControllerTest < ActionController::TestCase | |||
|
4 | fixtures :all | |||
|
5 | ||||
|
6 | def setup | |||
|
7 | @request.session[:user_id] = 1 | |||
|
8 | end | |||
|
9 | ||||
|
10 | context "get :index" do | |||
|
11 | setup do | |||
|
12 | get :index | |||
|
13 | end | |||
|
14 | ||||
|
15 | should_assign_to :auth_sources | |||
|
16 | should_assign_to :auth_source_pages | |||
|
17 | should_respond_with :success | |||
|
18 | should_render_template :index | |||
|
19 | end | |||
|
20 | ||||
|
21 | context "get :new" do | |||
|
22 | setup do | |||
|
23 | get :new | |||
|
24 | end | |||
|
25 | ||||
|
26 | should_assign_to :auth_source | |||
|
27 | should_respond_with :success | |||
|
28 | should_render_template :new | |||
|
29 | ||||
|
30 | should "initilize a new AuthSource" do | |||
|
31 | assert_equal AuthSource, assigns(:auth_source).class | |||
|
32 | assert assigns(:auth_source).new_record? | |||
|
33 | end | |||
|
34 | end | |||
|
35 | ||||
|
36 | context "post :create" do | |||
|
37 | setup do | |||
|
38 | post :create, :auth_source => {:name => 'Test'} | |||
|
39 | end | |||
|
40 | ||||
|
41 | should_respond_with :redirect | |||
|
42 | should_redirect_to("index") {{:action => 'index'}} | |||
|
43 | should_set_the_flash_to /success/i | |||
|
44 | end | |||
|
45 | ||||
|
46 | context "get :edit" do | |||
|
47 | setup do | |||
|
48 | @auth_source = AuthSource.generate!(:name => 'TestEdit') | |||
|
49 | get :edit, :id => @auth_source.id | |||
|
50 | end | |||
|
51 | ||||
|
52 | should_assign_to(:auth_source) {@auth_source} | |||
|
53 | should_respond_with :success | |||
|
54 | should_render_template :edit | |||
|
55 | end | |||
|
56 | ||||
|
57 | context "post :update" do | |||
|
58 | setup do | |||
|
59 | @auth_source = AuthSource.generate!(:name => 'TestEdit') | |||
|
60 | post :update, :id => @auth_source.id, :auth_source => {:name => 'TestUpdate'} | |||
|
61 | end | |||
|
62 | ||||
|
63 | should_respond_with :redirect | |||
|
64 | should_redirect_to("index") {{:action => 'index'}} | |||
|
65 | should_set_the_flash_to /update/i | |||
|
66 | end | |||
|
67 | ||||
|
68 | context "post :destroy" do | |||
|
69 | context "without users" do | |||
|
70 | setup do | |||
|
71 | @auth_source = AuthSource.generate!(:name => 'TestEdit') | |||
|
72 | post :destroy, :id => @auth_source.id | |||
|
73 | end | |||
|
74 | ||||
|
75 | should_respond_with :redirect | |||
|
76 | should_redirect_to("index") {{:action => 'index'}} | |||
|
77 | should_set_the_flash_to /deletion/i | |||
|
78 | ||||
|
79 | end | |||
|
80 | ||||
|
81 | should "be tested with users" | |||
|
82 | end | |||
|
83 | end |
@@ -0,0 +1,24 | |||||
|
1 | require 'test_helper' | |||
|
2 | ||||
|
3 | class LdapAuthSourcesControllerTest < ActionController::TestCase | |||
|
4 | fixtures :all | |||
|
5 | ||||
|
6 | def setup | |||
|
7 | @request.session[:user_id] = 1 | |||
|
8 | end | |||
|
9 | ||||
|
10 | context "get :new" do | |||
|
11 | setup do | |||
|
12 | get :new | |||
|
13 | end | |||
|
14 | ||||
|
15 | should_assign_to :auth_source | |||
|
16 | should_respond_with :success | |||
|
17 | should_render_template :new | |||
|
18 | ||||
|
19 | should "initilize a new AuthSource" do | |||
|
20 | assert_equal AuthSourceLdap, assigns(:auth_source).class | |||
|
21 | assert assigns(:auth_source).new_record? | |||
|
22 | end | |||
|
23 | end | |||
|
24 | end |
@@ -22,29 +22,31 class AuthSourcesController < ApplicationController | |||||
22 |
|
22 | |||
23 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
23 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) | |
24 | verify :method => :post, :only => [ :destroy, :create, :update ], |
|
24 | verify :method => :post, :only => [ :destroy, :create, :update ], | |
25 |
:redirect_to => { : |
|
25 | :redirect_to => { :template => :index } | |
26 |
|
26 | |||
27 | def index |
|
27 | def index | |
28 |
@auth_source_pages, @auth_sources = paginate |
|
28 | @auth_source_pages, @auth_sources = paginate auth_source_class.name.tableize, :per_page => 10 | |
29 | render :action => "index", :layout => false if request.xhr? |
|
29 | render "auth_sources/index" | |
30 | end |
|
30 | end | |
31 |
|
31 | |||
32 | def new |
|
32 | def new | |
33 |
@auth_source = |
|
33 | @auth_source = auth_source_class.new | |
|
34 | render 'auth_sources/new' | |||
34 | end |
|
35 | end | |
35 |
|
36 | |||
36 | def create |
|
37 | def create | |
37 |
@auth_source = |
|
38 | @auth_source = auth_source_class.new(params[:auth_source]) | |
38 | if @auth_source.save |
|
39 | if @auth_source.save | |
39 | flash[:notice] = l(:notice_successful_create) |
|
40 | flash[:notice] = l(:notice_successful_create) | |
40 | redirect_to :action => 'index' |
|
41 | redirect_to :action => 'index' | |
41 | else |
|
42 | else | |
42 |
render |
|
43 | render 'auth_sources/new' | |
43 | end |
|
44 | end | |
44 | end |
|
45 | end | |
45 |
|
46 | |||
46 | def edit |
|
47 | def edit | |
47 | @auth_source = AuthSource.find(params[:id]) |
|
48 | @auth_source = AuthSource.find(params[:id]) | |
|
49 | render 'auth_sources/edit' | |||
48 | end |
|
50 | end | |
49 |
|
51 | |||
50 | def update |
|
52 | def update | |
@@ -53,7 +55,7 class AuthSourcesController < ApplicationController | |||||
53 | flash[:notice] = l(:notice_successful_update) |
|
55 | flash[:notice] = l(:notice_successful_update) | |
54 | redirect_to :action => 'index' |
|
56 | redirect_to :action => 'index' | |
55 | else |
|
57 | else | |
56 |
render |
|
58 | render 'auth_sources/edit' | |
57 | end |
|
59 | end | |
58 | end |
|
60 | end | |
59 |
|
61 | |||
@@ -76,4 +78,10 class AuthSourcesController < ApplicationController | |||||
76 | end |
|
78 | end | |
77 | redirect_to :action => 'index' |
|
79 | redirect_to :action => 'index' | |
78 | end |
|
80 | end | |
|
81 | ||||
|
82 | protected | |||
|
83 | ||||
|
84 | def auth_source_class | |||
|
85 | AuthSource | |||
|
86 | end | |||
79 | end |
|
87 | end |
@@ -3,6 +3,7 | |||||
3 | <li><%= link_to l(:label_project_plural), {:controller => 'admin', :action => 'projects'}, :class => 'projects' %></li> |
|
3 | <li><%= link_to l(:label_project_plural), {:controller => 'admin', :action => 'projects'}, :class => 'projects' %></li> | |
4 | <li><%= link_to l(:label_user_plural), {:controller => 'users'}, :class => 'users' %></li> |
|
4 | <li><%= link_to l(:label_user_plural), {:controller => 'users'}, :class => 'users' %></li> | |
5 | <li><%= link_to l(:label_group_plural), {:controller => 'groups'}, :class => 'groups' %></li> |
|
5 | <li><%= link_to l(:label_group_plural), {:controller => 'groups'}, :class => 'groups' %></li> | |
|
6 | <li><%= link_to l(:label_ldap_authentication), :controller => 'ldap_auth_sources', :action => 'index' %></li> | |||
6 | <li><%= link_to l(:label_role_and_permissions), {:controller => 'roles'}, :class => 'roles' %></li> |
|
7 | <li><%= link_to l(:label_role_and_permissions), {:controller => 'roles'}, :class => 'roles' %></li> | |
7 | <li><%= link_to l(:label_tracker_plural), {:controller => 'trackers'}, :class => 'trackers' %></li> |
|
8 | <li><%= link_to l(:label_tracker_plural), {:controller => 'trackers'}, :class => 'trackers' %></li> | |
8 | <li><%= link_to l(:label_issue_status_plural), {:controller => 'issue_statuses'}, :class => 'issue_statuses' %></li> |
|
9 | <li><%= link_to l(:label_issue_status_plural), {:controller => 'issue_statuses'}, :class => 'issue_statuses' %></li> |
1 | NO CONTENT: file renamed from app/views/auth_sources/_form.rhtml to app/views/ldap_auth_sources/_form.rhtml |
|
NO CONTENT: file renamed from app/views/auth_sources/_form.rhtml to app/views/ldap_auth_sources/_form.rhtml |
@@ -20,7 +20,7 | |||||
20 | </div> |
|
20 | </div> | |
21 |
|
21 | |||
22 | <div style="float:right;"> |
|
22 | <div style="float:right;"> | |
23 | <%= link_to l(:label_ldap_authentication), :controller => 'auth_sources', :action => 'index' %> |
|
23 | <%= link_to l(:label_ldap_authentication), :controller => 'ldap_auth_sources', :action => 'index' %> | |
24 | </div> |
|
24 | </div> | |
25 |
|
25 | |||
26 | <%= submit_tag l(:button_save) %> |
|
26 | <%= submit_tag l(:button_save) %> |
General Comments 0
You need to be logged in to leave comments.
Login now