- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.6k
 
[rb] Fix Network issue by removing nil values on network requests #16442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            24 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      8c317d8
              
                [build] allow tests tagged exclusive-if-local to run on rbe
              
              
                titusfortner bb29c66
              
                merge trunk
              
              
                aguspe 5b6a0ce
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe c9cb77c
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe ac9a80e
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe aef922a
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe 8dc6cfc
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe 16dc0d3
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe 85fdc1c
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe 72bf4ec
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe 81f2331
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe d03e95b
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe 0cc0626
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe efa60a2
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe 7de5a08
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe 629be32
              
                Merge branch 'trunk' of github.com:aguspe/selenium into trunk
              
              
                aguspe 92be65e
              
                Remove nil values for network requests
              
              
                aguspe 72445fc
              
                Update intercept request and response and improve headers and cookies
              
              
                aguspe 247863b
              
                Merge branch 'trunk' into rb_fix_network_issue
              
              
                diemol ea1f4f0
              
                request cookie and header setters now take hashes
              
              
                titusfortner 0f186b9
              
                put the unit tests back
              
              
                titusfortner 396d55a
              
                All tests fixed
              
              
                aguspe 0b6d365
              
                Merge remote-tracking branch 'origin/rb_fix_network_issue' into rb_fi…
              
              
                aguspe 91d1666
              
                Merge branch 'trunk' into rb_fix_network_issue
              
              
                aguspe File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            104 changes: 104 additions & 0 deletions
          
          104 
        
  rb/spec/unit/selenium/webdriver/bidi/intercepted_request_spec.rb
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # frozen_string_literal: true | ||
| 
     | 
||
| # Licensed to the Software Freedom Conservancy (SFC) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The SFC licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| 
     | 
||
| require File.expand_path('../spec_helper', __dir__) | ||
| require File.expand_path('../../../../../lib/selenium/webdriver/bidi/network/cookies', __dir__) | ||
| require File.expand_path('../../../../../lib/selenium/webdriver/bidi/network/headers', __dir__) | ||
| require File.expand_path('../../../../../lib/selenium/webdriver/bidi/network/intercepted_request', __dir__) | ||
| 
     | 
||
| module Selenium | ||
| module WebDriver | ||
| class BiDi | ||
| describe InterceptedRequest do | ||
| let(:mock_network) { instance_double(Network) } | ||
| let(:mock_request) { {'request' => 'req-123'} } | ||
| let(:request_id) { 'req-123' } | ||
| let(:intercepted_request) { described_class.new(mock_network, mock_request) } | ||
| let(:mock_headers) { [{name: 'Auth', value: 'token'}] } | ||
| let(:mock_cookies) { [{name: 'session', value: {type: 'string', value: '123'}}] } | ||
| 
     | 
||
| describe '#continue' do | ||
| before do | ||
| allow(mock_network).to receive(:continue_request) | ||
| end | ||
| 
     | 
||
| it 'sends only the mandatory ID when no optional fields are set' do | ||
| expected_payload = {id: request_id, body: nil, cookies: nil, headers: nil, method: nil, url: nil} | ||
| intercepted_request.continue | ||
| 
     | 
||
| expect(mock_network).to have_received(:continue_request).with(expected_payload) | ||
| end | ||
| 
     | 
||
| it 'sends headers payload when headers are explicitly set' do | ||
| intercepted_request.headers = mock_headers | ||
| 
     | 
||
| expected_payload = { | ||
| id: request_id, | ||
| body: nil, | ||
| cookies: nil, | ||
| headers: Headers.new(mock_headers).as_json, | ||
| method: nil, | ||
| url: nil | ||
| } | ||
| 
     | 
||
| intercepted_request.continue | ||
| 
     | 
||
| expect(mock_network).to have_received(:continue_request).with(expected_payload) | ||
| end | ||
| 
     | 
||
| it 'sends cookies payload when cookies are explicitly set' do | ||
| intercepted_request.cookies = mock_cookies | ||
| 
     | 
||
| expected_payload = { | ||
| id: request_id, | ||
| body: nil, | ||
| cookies: Cookies.new(mock_cookies).as_json, | ||
| headers: nil, | ||
| method: nil, | ||
| url: nil | ||
| } | ||
| 
     | 
||
| intercepted_request.continue | ||
| 
     | 
||
| expect(mock_network).to have_received(:continue_request).with(expected_payload) | ||
| end | ||
| 
     | 
||
| it 'sends full custom payload when all fields are set' do | ||
| intercepted_request.headers = mock_headers | ||
| intercepted_request.cookies = mock_cookies | ||
| intercepted_request.method = 'POST' | ||
| 
     | 
||
| expected_payload = { | ||
| id: request_id, | ||
| body: nil, | ||
| cookies: Cookies.new(mock_cookies).as_json, | ||
| headers: Headers.new(mock_headers).as_json, | ||
| method: 'POST', | ||
| url: nil | ||
| } | ||
| 
     | 
||
| intercepted_request.continue | ||
| 
     | 
||
| expect(mock_network).to have_received(:continue_request).with(expected_payload) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.