mirror of
				https://github.com/sinatra/sinatra
				synced 2023-03-27 23:18:01 -04:00 
			
		
		
		
	Replace origin_whitelist with origin_permitted
This commit is contained in:
		
							parent
							
								
									380a833e2c
								
							
						
					
					
						commit
						166da3084d
					
				
					 2 changed files with 14 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -15,7 +15,7 @@ describe Rack::Protection::HttpOrigin do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  %w(GET HEAD).each do |method|
 | 
			
		||||
    it "accepts #{method} requests with non-whitelisted Origin" do
 | 
			
		||||
    it "accepts #{method} requests with non-permitted Origin" do
 | 
			
		||||
      expect(send(method.downcase, '/', {}, 'HTTP_ORIGIN' => 'http://malicious.com')).to be_ok
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -31,13 +31,13 @@ describe Rack::Protection::HttpOrigin do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  %w(POST PUT DELETE).each do |method|
 | 
			
		||||
    it "denies #{method} requests with non-whitelisted Origin" do
 | 
			
		||||
    it "denies #{method} requests with non-permitted Origin" do
 | 
			
		||||
      expect(send(method.downcase, '/', {}, 'HTTP_ORIGIN' => 'http://malicious.com')).not_to be_ok
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "accepts #{method} requests with whitelisted Origin" do
 | 
			
		||||
      mock_app do
 | 
			
		||||
        use Rack::Protection::HttpOrigin, :origin_whitelist => ['http://www.friend.com']
 | 
			
		||||
        use Rack::Protection::HttpOrigin, :origin_permitted => ['http://www.friend.com']
 | 
			
		||||
        run DummyApp
 | 
			
		||||
      end
 | 
			
		||||
      expect(send(method.downcase, '/', {}, 'HTTP_ORIGIN' => 'http://www.friend.com')).to be_ok
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue