Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,26 @@ end
"~", "* *", "*~*", "***", "∀", "~, ***",
".com", "*com", ".*com", ".example.com", "*example.com",
]
for pattern in patterns
ENV["JULIA_NO_VERIFY_HOSTS"] = pattern
for url in TEST_URLS, transport in TRANSPORTS
verify = without_warnings() do
verify_host(url, transport)
end
@test verify
for url in TEST_URLS, transport in TRANSPORTS
for pattern in patterns
# NB: Setting ENV here in the inner loop so that we defeat
# the ENV_HOST_PATTERN_CACHE and get a warning every time.
ENV["JULIA_NO_VERIFY_HOSTS"] = pattern
@test @test_logs (:warn, r"bad host pattern in ENV") match_mode=:any verify_host(url, transport)
end
end
clear_vars!(ENV)
end

@testset "only ignore bad patterns in list" begin
patterns = ["ok.com,~", "^, ok.com ,, !"]
for pattern in patterns
ENV["JULIA_NO_VERIFY_HOSTS"] = pattern
for url in TEST_URLS
verify = without_warnings() do
verify_host(url)
end
@test verify
end
verify = without_warnings() do
verify_host("ok.com")
for url in TEST_URLS
for pattern in patterns
ENV["JULIA_NO_VERIFY_HOSTS"] = pattern
@test @test_logs (:warn, r"bad host pattern in ENV") match_mode=:any verify_host(url)
end
@test !verify
end
@test @test_logs min_level=Logging.Error !verify_host("ok.com")
end
clear_vars!(ENV)
end

Expand Down
8 changes: 0 additions & 8 deletions test/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,3 @@ function clear_vars!(ENV)
delete!(ENV, "JULIA_SSH_NO_VERIFY_HOSTS")
end

function without_warnings(body::Function)
log_level = Logging.min_enabled_level(current_logger())
disable_logging(Logging.Warn)
try body()
finally
disable_logging(log_level-1)
end
end