Skip to content

Commit 8288a1f

Browse files
author
kalibera
committed
Test for .netrc support (PR#18892).
git-svn-id: https://svn.r-project.org/R/trunk@88416 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent e6218e8 commit 8288a1f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/download.file.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ tests <- function() {
8787
}, error = function(e) FALSE)
8888
stopifnot(any(grepl("authenticated.*true", h)))
8989

90+
if (getOption("download.file.method") == "libcurl") {
91+
cat("- Basic auth using .netrc (libcurl only)\n")
92+
fnetrc <- tempfile(tmpdir = getwd())
93+
writeLines(c("machine developer.R-project.org",
94+
"login Aladdin",
95+
"password OpenSesame"),
96+
fnetrc)
97+
with_options(list(netrc = fnetrc), {
98+
ret <- tryCatch({
99+
h <- suppressWarnings(get_headers(
100+
"basic-auth/Aladdin/OpenSesame"))
101+
TRUE
102+
}, error = function(e) FALSE)
103+
stopifnot(ret && any(grepl("authenticated.*true", h)))
104+
})
105+
unlink(fnetrc)
106+
}
107+
90108
if (getOption("download.file.method") == "libcurl") {
91109
cat("- Multiple urls (libcurl only)\n")
92110
urls <- get_path(c("anything", "headers"))

0 commit comments

Comments
 (0)