/usr/share/doc/r-cran-crul/tests/testthat/test-auth.R is in r-cran-crul 0.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | context("authenticate")
test_that("auth construction works", {
basic <- auth(user = "foo", pwd = "bar", auth = "basic")
digest <- auth(user = "foo", pwd = "bar", auth = "digest")
ntlm <- auth(user = "foo", pwd = "bar", auth = "ntlm")
any <- auth(user = "foo", pwd = "bar", auth = "any")
expect_is(basic, "auth")
expect_is(digest, "auth")
expect_is(ntlm, "auth")
expect_is(any, "auth")
expect_named(basic, c('userpwd', 'httpauth'))
expect_named(digest, c('userpwd', 'httpauth'))
expect_named(ntlm, c('userpwd', 'httpauth'))
expect_named(any, c('userpwd', 'httpauth'))
expect_equal(attr(basic, "type"), "basic")
expect_equal(attr(digest, "type"), "digest")
expect_equal(attr(ntlm, "type"), "ntlm")
expect_equal(attr(any, "type"), "any")
})
test_that("auth works with HttpClient", {
aa <- HttpClient$new(
url = "https://httpbin.org/basic-auth/user/passwd",
auth = auth(user = "foo", pwd = "bar")
)
expect_is(aa, "HttpClient")
expect_is(aa$auth, "auth")
expect_equal(aa$auth$userpwd, "foo:bar")
expect_equal(aa$auth$httpauth, 1)
})
test_that("auth works with HttpRequest", {
aa <- HttpRequest$new(
url = "https://httpbin.org/basic-auth/user/passwd",
auth = auth(user = "foo", pwd = "bar")
)
expect_is(aa, "HttpRequest")
expect_is(aa$auth, "auth")
expect_equal(aa$auth$userpwd, "foo:bar")
expect_equal(aa$auth$httpauth, 1)
})
test_that("auth fails well", {
expect_error(auth(), "argument \"user\" is missing")
expect_error(auth(user = "asdf"), "argument \"pwd\" is missing")
expect_error(auth(5, 5), "user must be of class character")
expect_error(auth("adsf", 5), "pwd must be of class character")
expect_error(
auth("asdf", "asdf", 5), "inherits\\(x, \"character\"\\) is not TRUE")
})
|