|
141 | 141 | expect(hosts[0][:port]).to be(9200) |
142 | 142 | end |
143 | 143 |
|
| 144 | + context 'when IPv6 format is used' do |
| 145 | + |
| 146 | + around do |example| |
| 147 | + original_setting = Faraday.ignore_env_proxy |
| 148 | + Faraday.ignore_env_proxy = true |
| 149 | + example.run |
| 150 | + Faraday.ignore_env_proxy = original_setting |
| 151 | + end |
| 152 | + |
| 153 | + let(:host) do |
| 154 | + 'https://[2090:db8:85a3:9811::1f]:8080' |
| 155 | + end |
| 156 | + |
| 157 | + it 'extracts the host' do |
| 158 | + expect(hosts[0][:host]).to eq('[2090:db8:85a3:9811::1f]') |
| 159 | + expect(hosts[0][:scheme]).to eq('https') |
| 160 | + expect(hosts[0][:port]).to be(8080) |
| 161 | + end |
| 162 | + |
| 163 | + it 'creates the correct full url' do |
| 164 | + expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://[2090:db8:85a3:9811::1f]:8080') |
| 165 | + end |
| 166 | + end |
| 167 | + |
144 | 168 | context 'when a path is specified' do |
145 | 169 |
|
146 | 170 | let(:host) do |
|
222 | 246 | expect(hosts[0][:port]).to be(9200) |
223 | 247 | end |
224 | 248 |
|
| 249 | + context 'when IPv6 format is used' do |
| 250 | + |
| 251 | + around do |example| |
| 252 | + original_setting = Faraday.ignore_env_proxy |
| 253 | + Faraday.ignore_env_proxy = true |
| 254 | + example.run |
| 255 | + Faraday.ignore_env_proxy = original_setting |
| 256 | + end |
| 257 | + |
| 258 | + let(:host) do |
| 259 | + { host: '[2090:db8:85a3:9811::1f]', scheme: 'https', port: '443' } |
| 260 | + end |
| 261 | + |
| 262 | + it 'extracts the host' do |
| 263 | + expect(hosts[0][:host]).to eq('[2090:db8:85a3:9811::1f]') |
| 264 | + expect(hosts[0][:scheme]).to eq('https') |
| 265 | + expect(hosts[0][:port]).to be(443) |
| 266 | + end |
| 267 | + |
| 268 | + it 'creates the correct full url' do |
| 269 | + expect(client.transport.__full_url(client.transport.hosts[0])).to eq('https://[2090:db8:85a3:9811::1f]:443') |
| 270 | + end |
| 271 | + end |
| 272 | + |
| 273 | + context 'when the host is localhost as a IPv6 address' do |
| 274 | + |
| 275 | + around do |example| |
| 276 | + original_setting = Faraday.ignore_env_proxy |
| 277 | + Faraday.ignore_env_proxy = true |
| 278 | + example.run |
| 279 | + Faraday.ignore_env_proxy = original_setting |
| 280 | + end |
| 281 | + |
| 282 | + let(:host) do |
| 283 | + { host: '[::1]' } |
| 284 | + end |
| 285 | + |
| 286 | + it 'extracts the host' do |
| 287 | + expect(hosts[0][:host]).to eq('[::1]') |
| 288 | + expect(hosts[0][:port]).to be(9200) |
| 289 | + end |
| 290 | + |
| 291 | + it 'creates the correct full url' do |
| 292 | + expect(client.transport.__full_url(client.transport.hosts[0])).to eq('http://[::1]:9200') |
| 293 | + end |
| 294 | + end |
| 295 | + |
225 | 296 | context 'when the port is specified as a String' do |
226 | 297 |
|
227 | 298 | let(:host) do |
|
0 commit comments