File: test-req-auth.R

package info (click to toggle)
r-cran-httr2 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,604 kB
  • sloc: sh: 21; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 522 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
test_that("can send username/password", {
  user <- "u"
  password <- "p"
  req1 <- request_test("/basic-auth/:user/:password")
  req2 <- req1 %>% req_auth_basic(user, password)
  expect_redacted(req2, "Authorization")

  expect_error(req_perform(req1), class = "httr2_http_401")
  expect_error(req_perform(req2), NA)
})

test_that("can send bearer token", {
  req <- req_auth_bearer_token(request_test(), "abc")
  expect_equal(
    req$headers,
    new_headers(list(Authorization = "Bearer abc"), "Authorization")
  )
})