tests/testthat/test-eruu_generate_keys.R

test_that("encryption works", {
  computed_key <- encrypt_redcap_key("SecurePassword!!", "123456789ABCDEFGHIJKLMNOPQRSTUVW")
  expect_false(is.null(computed_key))
  expect_true(is.raw(computed_key))
})

test_that("password hash works", {
  digested_password <- digest_passwd("SecurePassword!!")
  expect_equal(length(digested_password), 32)
})

test_that("Data recovered", {
  encrypted <- encrypt_redcap_key("SecurePassword!!", "123456789ABCDEFGHIJKLMNOPQRSTUVW")
  decrypted <- decrypt_redcap_key("SecurePassword!!", encrypted)
  expect_equal(decrypted, "123456789ABCDEFGHIJKLMNOPQRSTUVW")
})
pydupont/esr.redcap.user.ui documentation built on Dec. 25, 2019, 3:20 a.m.