|
275 | 275 | end |
276 | 276 | end |
277 | 277 |
|
| 278 | + describe "#credential_store_spec" do |
| 279 | + it "is off when the setting is unset" do |
| 280 | + expect(settings.send(:credential_store_spec)).to be_nil |
| 281 | + end |
| 282 | + |
| 283 | + it "reads the same false spellings as every other Bundler boolean" do |
| 284 | + ["", "false", "FALSE", "f", "no", "n", "0"].each do |off| |
| 285 | + settings.set_local "credential_store", off |
| 286 | + |
| 287 | + expect(settings.send(:credential_store_spec)).to be_nil, "#{off.inspect} should turn the store off" |
| 288 | + end |
| 289 | + end |
| 290 | + |
| 291 | + it "reads the boolean true spellings as this platform's native store" do |
| 292 | + %w[true TRUE t yes y on 1].each do |on| |
| 293 | + settings.set_local "credential_store", on |
| 294 | + |
| 295 | + expect(settings.send(:credential_store_spec)).to be(true), "#{on.inspect} should select the native store" |
| 296 | + end |
| 297 | + end |
| 298 | + |
| 299 | + it "reads anything else as a backend name, `off` included" do |
| 300 | + %w[1password off 1Password].each do |name| |
| 301 | + settings.set_local "credential_store", name |
| 302 | + |
| 303 | + expect(settings.send(:credential_store_spec)).to eq(name) |
| 304 | + end |
| 305 | + end |
| 306 | + |
| 307 | + it "lets a host override the global setting" do |
| 308 | + settings.set_local "credential_store", "1password" |
| 309 | + settings.set_local "credential_store.gemserver.example.org", "false" |
| 310 | + |
| 311 | + expect(settings.send(:credential_store_spec, "gemserver.example.org")).to be_nil |
| 312 | + expect(settings.send(:credential_store_spec, "other.example.org")).to eq("1password") |
| 313 | + end |
| 314 | + |
| 315 | + it "survives an undecodable environment variable" do |
| 316 | + # #to_bool refuses these bytes too, not just String#downcase. |
| 317 | + without_env_side_effects do |
| 318 | + ENV["BUNDLE_CREDENTIAL_STORE"] = "\xff".dup.force_encoding("UTF-8") |
| 319 | + |
| 320 | + expect(settings.send(:credential_store_spec)).to eq(ENV["BUNDLE_CREDENTIAL_STORE"]) |
| 321 | + end |
| 322 | + end |
| 323 | + end |
| 324 | + |
278 | 325 | describe "#credentials_for" do |
279 | 326 | let(:uri) { Gem::URI("https://gemserver.example.org/") } |
280 | 327 | let(:credentials) { "username:password" } |
|
0 commit comments