| 1 |
|
| 2 |
test_that("credentials are stripped from URLs", { |
| 3 |
|
| 4 |
# user:password style |
| 5 |
expect_equal( |
| 6 |
renv_url_sanitize("https://user:[email protected]/repo"), |
| 7 |
"https://example.com/repo" |
| 8 |
) |
| 9 |
|
| 10 |
# token-only style |
| 11 |
expect_equal( |
| 12 |
renv_url_sanitize("https://[email protected]/repo"), |
| 13 |
"https://example.com/repo" |
| 14 |
) |
| 15 |
|
| 16 |
# no credentials -- unchanged |
| 17 |
expect_equal( |
| 18 |
renv_url_sanitize("https://example.com/repo"), |
| 19 |
"https://example.com/repo" |
| 20 |
) |
| 21 |
|
| 22 |
# plain repository name -- unchanged |
| 23 |
expect_equal( |
| 24 |
renv_url_sanitize("CRAN"), |
| 25 |
"CRAN" |
| 26 |
) |
| 27 |
|
| 28 |
}) |
| 29 |
|
| 30 |
test_that("a variety of URLs can be parsed", { |
| 31 |
|
| 32 |
url <- "https://packagemanager.posit.co/cran/latest" |
| 33 |
parts <- renv_url_parse(url) |
| 34 |
|
| 35 |
expect_equal(renv_url_parse(url), list( |
| 36 |
url = url, |
| 37 |
protocol = "https://", |
| 38 |
domain = "packagemanager.posit.co", |
| 39 |
path = "/cran/latest", |
| 40 |
parameters = named(list()), |
| 41 |
fragment = "" |
| 42 |
)) |
| 43 |
|
| 44 |
url <- "https://example.com/path/to/page?name=ferret&color=purple" |
| 45 |
parts <- renv_url_parse(url) |
| 46 |
|
| 47 |
expect_equal(renv_url_parse(url), list( |
| 48 |
url = url, |
| 49 |
protocol = "https://", |
| 50 |
domain = "example.com", |
| 51 |
path = "/path/to/page", |
| 52 |
parameters = list( |
| 53 |
name = "ferret", |
| 54 |
color = "purple" |
| 55 |
), |
| 56 |
fragment = "" |
| 57 |
)) |
| 58 |
|
| 59 |
}) |