From 10bfcbb36c18889f04aec901c0a86908b434b89c Mon Sep 17 00:00:00 2001 From: jennybc Date: Wed, 27 May 2015 16:18:35 -0700 Subject: [PATCH] make damn sure authorization NOT in place for tests of data consumption with public visibility --- tests/testthat/test-yy-axe-oauth-token.R | 26 ++++++++++++++++++++++++ tests/testthat/test-zz-clean-up.R | 8 ++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/testthat/test-yy-axe-oauth-token.R diff --git a/tests/testthat/test-yy-axe-oauth-token.R b/tests/testthat/test-yy-axe-oauth-token.R new file mode 100644 index 0000000..f1d2a8d --- /dev/null +++ b/tests/testthat/test-yy-axe-oauth-token.R @@ -0,0 +1,26 @@ +context("revoke authentication") + +## remove the google token, to make 100% sure the remaining tests run w/o auth + +## this filename is deliberate w/r/t alphabetical order, so don't change it +## lightly! it's no coincidence that "axe" starts with "A" +gs_auth_revoke(rm_httr_oauth = TRUE, verbose = FALSE) + +test_that("Token does NOT exist, no .httr-oauth file in wd", { + + expect_false(token_exists()) + expect_false(file.exists(".httr-oauth")) + +}) + +test_that("We can NOT register a pvt sheet owned by rpackagetest", { + + if(interactive()) { + mess <- paste("Skipping the attempt to access private third party", + "sheet w/o authorization, because session is interactive", + "and would launch browser-based authentication.") + skip(mess) + } + expect_error(gs_ws_feed(cars_pvt_ws_feed, lookup = FALSE, verbose = FALSE)) + +}) diff --git a/tests/testthat/test-zz-clean-up.R b/tests/testthat/test-zz-clean-up.R index dfe346b..044d7ed 100644 --- a/tests/testthat/test-zz-clean-up.R +++ b/tests/testthat/test-zz-clean-up.R @@ -1 +1,9 @@ +## re-authenticate! +gs_auth(token = "googlesheets_token.rds") + +## "RAIN DANCE" +## RELIABLY FORCES AUTO-REFRESH OF STALE OAUTH TOKEN +## I DON'T KNOW WHY THIS HELPS BUT IT DOES! +gs_ls() + gs_grepdel(TEST, verbose = FALSE)