File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ def self.allowed_origins = ENV.fetch('AUTO_SOURCE_ALLOWED_ORIGINS', '')
2424 # @return [RSS::Rss]
2525 def self . build_auto_source_from_encoded_url ( encoded_url )
2626 url = Addressable ::URI . parse Base64 . urlsafe_decode64 ( encoded_url )
27- request = SsrfFilter . get ( url )
27+ request = SsrfFilter . get ( url , headers : LocalConfig . global . fetch ( :headers , { } ) )
2828 headers = request . to_hash . transform_values ( &:first )
2929
3030 auto_source = Html2rss ::AutoSource . new ( url , body : request . body , headers :)
Original file line number Diff line number Diff line change 157157 end
158158 end
159159
160- let ( :encoded_url ) { Base64 . urlsafe_encode64 ( 'https://github.com/html2rss/html2rss-web/commits/master' ) }
160+ before do
161+ allow ( SsrfFilter ) . to receive ( :get ) . with ( any_args ) . and_call_original
162+ end
163+
164+ let ( :url ) { 'https://github.com/html2rss/html2rss-web/commits/master' }
165+ let ( :encoded_url ) { Base64 . urlsafe_encode64 ( url ) }
161166
162167 it 'returns an RSS::Rss object' do
163168 expect ( feed ) . to be_a ( RSS ::Rss )
164169 end
170+
171+ it 'sets headers in the http request' do
172+ feed
173+ expect ( SsrfFilter ) . to have_received ( :get ) . with ( Addressable ::URI . parse ( url ) ,
174+ headers : {
175+ 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' # rubocop:disable Layout/LineLength
176+ } )
177+ end
165178 end
166179end
You can’t perform that action at this time.
0 commit comments