mechanize.cr/spec/http_auth_store_spec.cr

25 lines
736 B
Crystal
Raw Normal View History

2021-12-29 09:23:42 +01:00
require "./spec_helper"
describe "Mechanize AuthStore test" do
it "add_auth" do
auth_store = Mechanize::HTTP::AuthStore.new
url = URI.parse("http://example.com/")
user = "kanezoh"
password = "password"
2022-01-01 05:27:20 +01:00
realm = ""
2021-12-29 09:23:42 +01:00
auth_store.add_auth(url, user, password)
2022-01-01 05:27:20 +01:00
auth_store.auth_accounts[url].size.should eq 1
auth_store.auth_accounts[url][realm].should eq(["kanezoh", "password", nil])
end
it "credentials_for" do
auth_store = Mechanize::HTTP::AuthStore.new
url = URI.parse("http://example.com/")
user = "kanezoh"
password = "password"
realm = ""
auth_store.add_auth(url, user, password)
auth_store.credentials_for(url, realm).should eq ["kanezoh", "password", nil]
2021-12-29 09:23:42 +01:00
end
end