mirror of
				https://github.com/redmine/redmine.git
				synced 2025-11-03 20:06:24 +01:00 
			
		
		
		
	Fixed: API 401 response does not include WWW-Authenticate header (#5322).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3679 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
		@@ -128,8 +128,8 @@ class ApplicationController < ActionController::Base
 | 
				
			|||||||
      respond_to do |format|
 | 
					      respond_to do |format|
 | 
				
			||||||
        format.html { redirect_to :controller => "account", :action => "login", :back_url => url }
 | 
					        format.html { redirect_to :controller => "account", :action => "login", :back_url => url }
 | 
				
			||||||
        format.atom { redirect_to :controller => "account", :action => "login", :back_url => url }
 | 
					        format.atom { redirect_to :controller => "account", :action => "login", :back_url => url }
 | 
				
			||||||
        format.xml { head :unauthorized }
 | 
					        format.xml  { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
 | 
				
			||||||
        format.json { head :unauthorized }
 | 
					        format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="Redmine API"' }
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      return false
 | 
					      return false
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,6 +44,18 @@ class HttpBasicLoginTest < ActionController::IntegrationTest
 | 
				
			|||||||
          assert_equal User.anonymous, User.current
 | 
					          assert_equal User.anonymous, User.current
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      context "without credentials" do
 | 
				
			||||||
 | 
					        setup do
 | 
				
			||||||
 | 
					          get "/projects/onlinestore/news.xml"
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        should_respond_with :unauthorized
 | 
				
			||||||
 | 
					        should_respond_with_content_type :xml
 | 
				
			||||||
 | 
					        should "include_www_authenticate_header" do
 | 
				
			||||||
 | 
					          assert @controller.response.headers.has_key?('WWW-Authenticate')
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    context "in :json format" do
 | 
					    context "in :json format" do
 | 
				
			||||||
@@ -76,5 +88,16 @@ class HttpBasicLoginTest < ActionController::IntegrationTest
 | 
				
			|||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    context "without credentials" do
 | 
				
			||||||
 | 
					      setup do
 | 
				
			||||||
 | 
					        get "/projects/onlinestore/news.json"
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      should_respond_with :unauthorized
 | 
				
			||||||
 | 
					      should_respond_with_content_type :json
 | 
				
			||||||
 | 
					      should "include_www_authenticate_header" do
 | 
				
			||||||
 | 
					        assert @controller.response.headers.has_key?('WWW-Authenticate')
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user