Skip to content

Commit

Permalink
testing bad token
Browse files Browse the repository at this point in the history
ref #372 & #375
  • Loading branch information
wibeasley committed Nov 26, 2021
1 parent 147e843 commit e18389a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 0 additions & 2 deletions R/redcap-arm-export.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ redcap_arm_export <- function(
arm_name = character(0)
)
} else {
# nocov start
error_message <- sprintf(
paste(
"The REDCapR arm export failed.",
Expand All @@ -142,7 +141,6 @@ redcap_arm_export <- function(
kernel$raw_text
)
stop(error_message)
# nocov end
}
} else {
# nocov start
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-arm-export.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,19 @@ test_that("Longitudinal Single Arm", {
expect_true(returned_object$success)
})

test_that("Bad Token", {
testthat::skip_on_cran()
credential <- retrieve_credential_testing(2629L)
bad_token <- "1234567890ABCDEF1234567890ABCDEF"

expected_error_message <- "The REDCapR arm export failed\\. The http status code was 403. The error message was: 'ERROR: You do not have permissions to use the API'"
expect_error(
redcap_arm_export(
redcap_uri = credential$redcap_uri,
token = bad_token
),
regexp = expected_error_message
)
})

rm(read_arms, empty_data_frame)
17 changes: 17 additions & 0 deletions tests/testthat/test-delete.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,20 @@ test_that("unspecified required arm", {
regexp = expected_outcome_message
)
})

test_that("Bad Token", {
testthat::skip_on_cran()
credential <- retrieve_credential_testing(153L)
bad_token <- "1234567890ABCDEF1234567890ABCDEF"
records_to_delete <- 101

expected_error_message <- "The REDCapR arm export failed\\. The http status code was 403. The error message was: 'ERROR: You do not have permissions to use the API'"
expect_error(
redcap_delete(
redcap_uri = credential$redcap_uri,
token = bad_token,
records_to_delete = records_to_delete
),
regexp = expected_error_message
)
})
1 change: 0 additions & 1 deletion tests/testthat/test-file-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ test_that("Full Directory Specific", {
expect_true(start_time <= info_actual$atime, label="The downloaded file's last access time should not precede this function's start time.")
})


test_that("download file conflict -Error", {
testthat::skip_on_cran()

Expand Down

0 comments on commit e18389a

Please sign in to comment.