USAID-OHA-SI / grabr

OHA/SI APIs package
https://usaid-oha-si.github.io/grabr/
Other
1 stars 2 forks source link

add unit test to get_outable() for DATIM creds #11

Closed jessmhoehner closed 1 year ago

jessmhoehner commented 1 year ago

Currently if a user doesn't have DATIM creds stored, this is the error message that the function throws.

"Error: lexical error: invalid char in json text. <webMessage xmlns="http://dhis2 (right here) ------^"

if datim_user and datim_pwd are blank. It would be nice to add a unit tests that checks if these necessary values are blank ("") and if so, provide an actionable error message to the user. I volunteer to take this on if developers think it would be a good addition.

achafetz commented 1 year ago

Sounds like there is a bug somewhere since this isn't performing as expected.

get_outable() calls on two sub-functions to pull the country UIDs and org unit levels.

https://github.com/USAID-OHA-SI/grabr/blob/9841e1b437b05a246c1e022458af6fd2948b8c4d/R/get_outable.R#L26-L30

Both of those function handle credentials via lazy_secrets().

https://github.com/USAID-OHA-SI/grabr/blob/9841e1b437b05a246c1e022458af6fd2948b8c4d/R/get_outable.R#L75-L78

If no user and/or password are provided or available (ie stored from glamr), the user should be prompted to enter both/either via GUI pop-up:

https://github.com/USAID-OHA-SI/grabr/blob/9841e1b437b05a246c1e022458af6fd2948b8c4d/R/utilities.R#L47-L55

So we need to look into what is happening at this step 🤔

achafetz commented 1 year ago

@jessmhoehner I tested this out and got a pop up for credentials with nothing stored or provided (code below). You might want to check (1) your password if its outdated and (2) you have access to final.datim.org

library(gagglr)
library(grabr)
library(keyring)

#ensure I have the latest version of grabr
oha_sitrep()

#current DATIM user name
datim_accnt <- "" #add DATIM user ID

#remove stored DATIM credentials
key_delete("datim", datim_accnt)

#confirm credential are removed
# expect: TRUE
!"datim" %in% key_list()$service

#run fcn that requires DATIM credentials
# no credentials provided here and none stored
# expect: 2 sets of popups requiring user and password be entered into GUI
get_outable()

#add credential back
set_datim(datim_accnt)
achafetz commented 1 year ago

unrelated to the specifics of this issue, but #13 resolved the dual pop up windows uncovered https://github.com/USAID-OHA-SI/grabr/issues/11#issuecomment-1405159540