Skip to content

Commit 06f90ad

Browse files
fix auth tests #60
1 parent 0111a9b commit 06f90ad

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

tests/testthat/test-auth.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ test_that('`bs_auth()` forces refresh when save_auth = NULL', {
4141
expect_true(fs::file_exists(bs_auth_file()))
4242

4343
# manually overwrite timestamp to expire it
44-
auth <- readRDS(bs_auth_file())
44+
key <- openssl::sha256(charToRaw(get_bluesky_pass()))
45+
auth <- httr2::secret_read_rds(bs_auth_file(), key = key)
4546
auth$bskyr_created_time <- Sys.time() - as.difftime(15, units = 'mins')
46-
saveRDS(auth, bs_auth_file())
47+
httr2::secret_write_rds(auth, path = bs_auth_file(), key = key)
4748

4849
# now refresh it
4950
new_auth <- bs_auth(
@@ -60,11 +61,11 @@ test_that('`bs_auth()` bypasses cache with save_auth = FALSE', {
6061
skip_if_not(bs_has_pass())
6162
skip_if_not(bs_has_user())
6263

63-
time <- NULL
64-
time <- try({readRDS(bs_auth_file())$bskyr_created_time})
65-
if (is.null(time)) {
64+
if (!fs::file_exists(bs_auth_file())) {
6665
skip('No cached auth found, skipping test')
6766
}
67+
key <- openssl::sha256(charToRaw(get_bluesky_pass()))
68+
time <- httr2::secret_read_rds(bs_auth_file(), key = key)$bskyr_created_time
6869

6970
vcr::local_cassette('repo_auth_direct', match_requests_on = c('uri', 'method'))
7071
auth <- bs_auth(

0 commit comments

Comments
 (0)