diff --git a/inst/httptest2/redact.R b/inst/httptest2/redact.R index 141b9fff..7da852e9 100644 --- a/inst/httptest2/redact.R +++ b/inst/httptest2/redact.R @@ -30,7 +30,7 @@ function(response) { # simplify = FALSE response <- httptest2::redact_headers( response, - headers = c("x-request-id", "date", "Authorization", "x-amz-id-2", "x-amz-request-id") + headers = c("x-request-id", "date", "x-amz-id-2", "x-amz-request-id") ) return(response) diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/changeset/357503/close-PUT.html b/tests/testthat/mock_edit_objects/osm.org/api/0.6/changeset/357503/close-PUT.html new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/changeset/create-dd36bf-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/changeset/create-dd36bf-PUT.txt index d75cbe39..c076ad98 100644 --- a/tests/testthat/mock_edit_objects/osm.org/api/0.6/changeset/create-dd36bf-PUT.txt +++ b/tests/testthat/mock_edit_objects/osm.org/api/0.6/changeset/create-dd36bf-PUT.txt @@ -1 +1 @@ -300706 \ No newline at end of file +357503 \ No newline at end of file diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4345520038-96fb64-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4348975121-2ecc9b-PUT.txt similarity index 100% rename from tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4345520038-96fb64-PUT.txt rename to tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4348975121-2ecc9b-PUT.txt diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4345520038-9a5177-DELETE.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4348975121-f559f5-DELETE.txt similarity index 100% rename from tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4345520038-9a5177-DELETE.txt rename to tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4348975121-f559f5-DELETE.txt diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4345520039-c95e18-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4348975122-0e5354-PUT.txt similarity index 100% rename from tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4345520039-c95e18-PUT.txt rename to tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4348975122-0e5354-PUT.txt diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4345520039-b79ae3-DELETE.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4348975122-275587-DELETE.txt similarity index 100% rename from tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4345520039-b79ae3-DELETE.txt rename to tests/testthat/mock_edit_objects/osm.org/api/0.6/node/4348975122-275587-DELETE.txt diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-34fb8f-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-34fb8f-PUT.txt new file mode 100644 index 00000000..e2dbbba7 --- /dev/null +++ b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-34fb8f-PUT.txt @@ -0,0 +1 @@ +4348975122 \ No newline at end of file diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-4496a6-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-4496a6-PUT.txt new file mode 100644 index 00000000..2d748b5f --- /dev/null +++ b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-4496a6-PUT.txt @@ -0,0 +1 @@ +4348975121 \ No newline at end of file diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-76764b-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-76764b-PUT.txt deleted file mode 100644 index 64196d4d..00000000 --- a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-76764b-PUT.txt +++ /dev/null @@ -1 +0,0 @@ -4345520039 \ No newline at end of file diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-909f8d-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-909f8d-PUT.txt deleted file mode 100644 index 9a9aa7fa..00000000 --- a/tests/testthat/mock_edit_objects/osm.org/api/0.6/node/create-909f8d-PUT.txt +++ /dev/null @@ -1 +0,0 @@ -4345520038 \ No newline at end of file diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/4305173297-407dbd-DELETE.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/4305223441-3c20c3-DELETE.txt similarity index 100% rename from tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/4305173297-407dbd-DELETE.txt rename to tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/4305223441-3c20c3-DELETE.txt diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/4305173297-ccc981-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/4305223441-ac1cb3-PUT.txt similarity index 100% rename from tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/4305173297-ccc981-PUT.txt rename to tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/4305223441-ac1cb3-PUT.txt diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/create-23ebff-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/create-23ebff-PUT.txt deleted file mode 100644 index f37262e3..00000000 --- a/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/create-23ebff-PUT.txt +++ /dev/null @@ -1 +0,0 @@ -4305173297 \ No newline at end of file diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/create-9eea05-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/create-9eea05-PUT.txt new file mode 100644 index 00000000..df373380 --- /dev/null +++ b/tests/testthat/mock_edit_objects/osm.org/api/0.6/relation/create-9eea05-PUT.txt @@ -0,0 +1 @@ +4305223441 \ No newline at end of file diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/4306375851-7b848f-DELETE.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/4306500960-216b81-DELETE.txt similarity index 100% rename from tests/testthat/mock_edit_objects/osm.org/api/0.6/way/4306375851-7b848f-DELETE.txt rename to tests/testthat/mock_edit_objects/osm.org/api/0.6/way/4306500960-216b81-DELETE.txt diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/4306375851-14e340-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/4306500960-e9fc2a-PUT.txt similarity index 100% rename from tests/testthat/mock_edit_objects/osm.org/api/0.6/way/4306375851-14e340-PUT.txt rename to tests/testthat/mock_edit_objects/osm.org/api/0.6/way/4306500960-e9fc2a-PUT.txt diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/create-05ff2e-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/create-05ff2e-PUT.txt new file mode 100644 index 00000000..61cf27ae --- /dev/null +++ b/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/create-05ff2e-PUT.txt @@ -0,0 +1 @@ +4306500960 \ No newline at end of file diff --git a/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/create-2bd3a3-PUT.txt b/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/create-2bd3a3-PUT.txt deleted file mode 100644 index 54fd2abb..00000000 --- a/tests/testthat/mock_edit_objects/osm.org/api/0.6/way/create-2bd3a3-PUT.txt +++ /dev/null @@ -1 +0,0 @@ -4306375851 \ No newline at end of file diff --git a/tests/testthat/mock_get_data_gpx/osm.org/api/0.6/gpx/3458743/data.R b/tests/testthat/mock_get_data_gpx/osm.org/api/0.6/gpx/3458743/data.R index b9f4fccc..b4854721 100644 --- a/tests/testthat/mock_get_data_gpx/osm.org/api/0.6/gpx/3458743/data.R +++ b/tests/testthat/mock_get_data_gpx/osm.org/api/0.6/gpx/3458743/data.R @@ -1,8 +1,8 @@ -structure(list(method = "GET", url = "https://openstreetmap-gps-traces.s3.dualstack.eu-west-1.amazonaws.com/0j780j5aldkjjd07uk4jbg3lco3t?response-content-disposition=attachment%3B%20filename%3D%223458743.gpx%22%3B%20filename%2A%3DUTF-8%27%273458743.gpx&response-content-type=application%2Fgpx%2Bxml&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIASQUXHPE7AMJQRFOS%2F20240425%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20240425T084725Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=f3492c3e7af80ec0d26ee2910ec883457cbb0aafc7eb5531874c2299a4a9821f", - status_code = 200L, headers = structure(list(`x-amz-id-2` = "REDACTED", - `x-amz-request-id` = "REDACTED", Date = "REDACTED", `x-amz-replication-status` = "COMPLETED", - `Last-Modified` = "Wed, 02 Mar 2022 22:41:40 GMT", ETag = "\"05a29542ae0f0181b1187b68a2b98535\"", - `Cache-Control` = "public, max-age=31536000, immutable", +structure(list(method = "GET", url = "https://openstreetmap-gps-traces.s3.dualstack.eu-west-1.amazonaws.com/0j780j5aldkjjd07uk4jbg3lco3t?response-content-disposition=attachment%3B%20filename%3D%223458743.gpx%22%3B%20filename%2A%3DUTF-8%27%273458743.gpx&response-content-type=application%2Fgpx%2Bxml&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIASQUXHPE7AMJQRFOS%2F20240426%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20240426T102812Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=aa140fc459ac049d9a22cd0940415e03f005a272de358ebf6e013e68b3fb1ea4", + status_code = 200L, headers = structure(list(`x-amz-id-2` = "8K25LubAjNTPqBq0P6UnjGK9h9WzTp68joIhBescwAHL0vvcBzbnYDF1uQEw2g4WsJLuw44gbsQ=", + `x-amz-request-id` = "AZ9FE54K9F9B77BN", Date = "REDACTED", + `x-amz-replication-status` = "COMPLETED", `Last-Modified` = "Wed, 02 Mar 2022 22:41:40 GMT", + ETag = "\"05a29542ae0f0181b1187b68a2b98535\"", `Cache-Control` = "public, max-age=31536000, immutable", `Content-Disposition` = "attachment; filename=\"3458743.gpx\"; filename*=UTF-8''3458743.gpx", `x-amz-version-id` = "lS5bf7hjJ8dTACfw8_yLzrg7TnQ4rDKC", `Accept-Ranges` = "bytes", `Content-Type` = "application/gpx+xml", @@ -6259,26 +6259,4 @@ structure(list(method = "GET", url = "https://openstreetmap-gps-traces.s3.dualst 0x72, 0x6b, 0x70, 0x74, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x74, 0x72, 0x6b, 0x73, 0x65, 0x67, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x2f, 0x74, 0x72, 0x6b, 0x3e, 0x0a, 0x3c, - 0x2f, 0x67, 0x70, 0x78, 0x3e)), request = structure(list( - url = "https://api.openstreetmap.org/api/0.6/gpx/3458743/data", - method = "GET", headers = structure(list(Authorization = "Bearer kcV3MYRNTBJOt-1Tqd5Yfv-jaAUEbDcbmynR0TdZ5ek"), redact = "Authorization"), - body = NULL, fields = list(), options = list(useragent = "osmapiR (https://github.com/jmaspons/osmapiR)"), - policies = list(retry_max_tries = 10L, error_body = function (resp) - { - out <- switch(httr2::resp_content_type(resp), `text/plain` = httr2::resp_body_string(resp), - `text/html` = parse_html_error(resp), httr2::resp_headers(resp)$status) - return(out) - }, auth_oauth = list(cache = list(get = function () - env_get(the$token_cache, key, default = NULL), set = function (token) - env_poke(the$token_cache, key, token), clear = function () - env_unbind(the$token_cache, key)), flow = "oauth_flow_auth_code", - flow_params = list(client = structure(list(name = "osmapiR", - id = "cxMGJjSNnEGiKHAdp0pGq54XtQPTSyuTOu-nVJ4P6FE", - secret = structure("L9o3QNmMC-rn8Hl6qcJrCpkty2QUCJPAWoiB2lIwawoZup_gfImaV9iUfGSZIeZSLP_s89qiFrbAH_Y", class = "httr2_obfuscated"), - key = NULL, token_url = "https://www.openstreetmap.org/oauth2/token", - auth = "oauth_client_req_auth_header", auth_params = list()), class = "httr2_oauth_client"), - auth_url = "https://www.openstreetmap.org/oauth2/authorize", - scope = "read_prefs write_prefs write_api read_gpx write_gpx write_notes", - pkce = TRUE, auth_params = list(), token_params = list(), - redirect_uri = "http://127.0.0.1:14149")))), class = "httr2_request"), - cache = new.env(parent = emptyenv())), class = "httr2_response") + 0x2f, 0x67, 0x70, 0x78, 0x3e)), cache = new.env(parent = emptyenv())), class = "httr2_response") diff --git a/tests/testthat/mock_get_data_gpx/osm.org/api/0.6/gpx/3458743/data.gpx.R b/tests/testthat/mock_get_data_gpx/osm.org/api/0.6/gpx/3458743/data.gpx.R index 2b5971a8..a646103a 100644 --- a/tests/testthat/mock_get_data_gpx/osm.org/api/0.6/gpx/3458743/data.gpx.R +++ b/tests/testthat/mock_get_data_gpx/osm.org/api/0.6/gpx/3458743/data.gpx.R @@ -5,7 +5,7 @@ structure(list(method = "GET", url = "osm.org/api/0.6/gpx/3458743/data.gpx", `content-language` = "en", `x-request-id` = "REDACTED", `content-disposition` = "attachment; filename=\"3458743.gpx\"; filename*=UTF-8''3458743.gpx", `x-download-options` = "noopen", `content-transfer-encoding` = "binary", - `x-runtime` = "0.252595", `x-frame-options` = "sameorigin", + `x-runtime` = "0.250427", `x-frame-options` = "sameorigin", `x-content-type-options` = "nosniff", `content-security-policy` = "default-src 'self'; child-src 'self'; connect-src 'self' matomo.openstreetmap.org; font-src 'none'; form-action 'self'; frame-ancestors 'self'; frame-src 'self'; img-src 'self' data: www.gravatar.com *.wp.com tile.openstreetmap.org *.tile.openstreetmap.org *.tile.thunderforest.com tile.tracestrack.com *.openstreetmap.fr matomo.openstreetmap.org https://openstreetmap-user-avatars.s3.dualstack.eu-west-1.amazonaws.com https://openstreetmap-gps-images.s3.dualstack.eu-west-1.amazonaws.com; manifest-src 'self'; media-src 'none'; object-src 'self'; script-src 'self' matomo.openstreetmap.org; style-src 'self'; worker-src 'none'", date = "REDACTED", `x-powered-by` = "Phusion Passenger(R) 6.0.20", `strict-transport-security` = "max-age=31536000; includeSubDomains; preload", @@ -6263,26 +6263,4 @@ structure(list(method = "GET", url = "osm.org/api/0.6/gpx/3458743/data.gpx", 0x72, 0x6b, 0x70, 0x74, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x74, 0x72, 0x6b, 0x73, 0x65, 0x67, 0x3e, 0x0a, 0x20, 0x20, 0x3c, 0x2f, 0x74, 0x72, 0x6b, 0x3e, 0x0a, 0x3c, - 0x2f, 0x67, 0x70, 0x78, 0x3e)), request = structure(list( - url = "https://api.openstreetmap.org/api/0.6/gpx/3458743/data.gpx", - method = "GET", headers = structure(list(Authorization = "Bearer kcV3MYRNTBJOt-1Tqd5Yfv-jaAUEbDcbmynR0TdZ5ek"), redact = "Authorization"), - body = NULL, fields = list(), options = list(useragent = "osmapiR (https://github.com/jmaspons/osmapiR)"), - policies = list(retry_max_tries = 10L, error_body = function (resp) - { - out <- switch(httr2::resp_content_type(resp), `text/plain` = httr2::resp_body_string(resp), - `text/html` = parse_html_error(resp), httr2::resp_headers(resp)$status) - return(out) - }, auth_oauth = list(cache = list(get = function () - env_get(the$token_cache, key, default = NULL), set = function (token) - env_poke(the$token_cache, key, token), clear = function () - env_unbind(the$token_cache, key)), flow = "oauth_flow_auth_code", - flow_params = list(client = structure(list(name = "osmapiR", - id = "cxMGJjSNnEGiKHAdp0pGq54XtQPTSyuTOu-nVJ4P6FE", - secret = structure("L9o3QNmMC-rn8Hl6qcJrCpkty2QUCJPAWoiB2lIwawoZup_gfImaV9iUfGSZIeZSLP_s89qiFrbAH_Y", class = "httr2_obfuscated"), - key = NULL, token_url = "https://www.openstreetmap.org/oauth2/token", - auth = "oauth_client_req_auth_header", auth_params = list()), class = "httr2_oauth_client"), - auth_url = "https://www.openstreetmap.org/oauth2/authorize", - scope = "read_prefs write_prefs write_api read_gpx write_gpx write_notes", - pkce = TRUE, auth_params = list(), token_params = list(), - redirect_uri = "http://127.0.0.1:44392")))), class = "httr2_request"), - cache = new.env(parent = emptyenv())), class = "httr2_response") + 0x2f, 0x67, 0x70, 0x78, 0x3e)), cache = new.env(parent = emptyenv())), class = "httr2_response") diff --git a/tests/testthat/mock_redact_object/osm.org/api/0.6/changeset/357506/close-PUT.html b/tests/testthat/mock_redact_object/osm.org/api/0.6/changeset/357506/close-PUT.html new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/mock_redact_object/osm.org/api/0.6/changeset/create-e3cf44-PUT.txt b/tests/testthat/mock_redact_object/osm.org/api/0.6/changeset/create-e3cf44-PUT.txt new file mode 100644 index 00000000..fbc0e4b9 --- /dev/null +++ b/tests/testthat/mock_redact_object/osm.org/api/0.6/changeset/create-e3cf44-PUT.txt @@ -0,0 +1 @@ +357506 \ No newline at end of file diff --git a/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125-25f672-DELETE.txt b/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125-25f672-DELETE.txt new file mode 100644 index 00000000..d8263ee9 --- /dev/null +++ b/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125-25f672-DELETE.txt @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125.xml b/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125.xml new file mode 100644 index 00000000..b41440d3 --- /dev/null +++ b/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125/1/redact-POST.html b/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125/1/redact-POST.html new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125/1/redact-ee4788-POST.html b/tests/testthat/mock_redact_object/osm.org/api/0.6/node/4348975125/1/redact-ee4788-POST.html new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/mock_redact_object/osm.org/api/0.6/node/create-d45974-PUT.txt b/tests/testthat/mock_redact_object/osm.org/api/0.6/node/create-d45974-PUT.txt new file mode 100644 index 00000000..47f71286 --- /dev/null +++ b/tests/testthat/mock_redact_object/osm.org/api/0.6/node/create-d45974-PUT.txt @@ -0,0 +1 @@ +4348975125 \ No newline at end of file diff --git a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-e183c9-PUT.R b/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-e183c9-PUT.R deleted file mode 100644 index f4278188..00000000 --- a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-e183c9-PUT.R +++ /dev/null @@ -1,37 +0,0 @@ -structure(list(method = "PUT", url = "osm.org/api/0.6/user/preferences", - status_code = 200L, headers = structure(list(`cache-control` = "no-cache", - vary = "Origin,Accept-Encoding", `referrer-policy` = "strict-origin-when-cross-origin", - `x-permitted-cross-domain-policies` = "none", `x-xss-protection` = "1; mode=block", - `x-request-id` = "01234567-89ab-cdef-0123-456789abcdef", - `x-download-options` = "noopen", `x-runtime` = "0.013955", - `x-frame-options` = "sameorigin", `x-content-type-options` = "nosniff", - `content-security-policy` = "default-src 'self'; child-src 'self'; connect-src 'self'; font-src 'none'; form-action 'self'; frame-ancestors 'self'; frame-src 'self'; img-src 'self' data: www.gravatar.com *.wp.com tile.openstreetmap.org *.tile.openstreetmap.org *.tile.thunderforest.com tile.tracestrack.com *.openstreetmap.fr; manifest-src 'self'; media-src 'none'; object-src 'self'; script-src 'self'; style-src 'self'; worker-src 'none'", - date = "DoW, 24 Jun 2024 00:00:00 GMT", `x-powered-by` = "Phusion Passenger(R) 6.0.20", - `strict-transport-security` = "max-age=31536000; includeSubDomains; preload", - status = "200 OK", `content-encoding` = "br", `x-robots-tag` = "noindex, nofollow", - `content-length` = "1", `content-type` = "text/plain; charset=utf-8", - server = "Apache/2.4.54 (Ubuntu)"), class = "httr2_headers"), - body = raw(0), request = structure(list(url = "https://master.apis.dev.openstreetmap.org/api/0.6/user/preferences", - method = "PUT", headers = structure(list(Authorization = "Bearer *******************************************"), redact = "Authorization"), - body = list(data = structure("/tmp/RtmpBqEmqg/file1c3a30b5450a.xml", class = "httr2_path"), - type = "raw-file", content_type = "", params = list()), - fields = list(), options = list(useragent = "osmapiR (https://github.com/jmaspons/osmapiR)"), - policies = list(retry_max_tries = 10L, error_body = function (resp) - { - out <- switch(httr2::resp_content_type(resp), `text/plain` = httr2::resp_body_string(resp), - `text/html` = parse_html_error(resp), httr2::resp_headers(resp)$status) - return(out) - }, auth_oauth = list(cache = list(get = function () - env_get(the$token_cache, key, default = NULL), set = function (token) - env_poke(the$token_cache, key, token), clear = function () - env_unbind(the$token_cache, key)), flow = "oauth_flow_auth_code", - flow_params = list(client = structure(list(name = "osmapiR", - id = "*******************************************", - secret = structure("*******************************************************************************", class = "httr2_obfuscated"), - key = NULL, token_url = "https://master.apis.dev.openstreetmap.org/oauth2/token", - auth = "oauth_client_req_auth_header", auth_params = list()), class = "httr2_oauth_client"), - auth_url = "https://master.apis.dev.openstreetmap.org/oauth2/authorize", - scope = "read_prefs write_prefs write_api read_gpx write_gpx write_notes", - pkce = TRUE, auth_params = list(), token_params = list(), - redirect_uri = "http://127.0.0.1:26553")))), class = "httr2_request"), - cache = new.env(parent = emptyenv())), class = "httr2_response") diff --git a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-e183c9-PUT.txt b/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-e183c9-PUT.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-eb5ee0-PUT.R b/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-eb5ee0-PUT.R deleted file mode 100644 index 20696bfa..00000000 --- a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-eb5ee0-PUT.R +++ /dev/null @@ -1,37 +0,0 @@ -structure(list(method = "PUT", url = "osm.org/api/0.6/user/preferences", - status_code = 200L, headers = structure(list(`cache-control` = "no-cache", - vary = "Origin,Accept-Encoding", `referrer-policy` = "strict-origin-when-cross-origin", - `x-permitted-cross-domain-policies` = "none", `x-xss-protection` = "1; mode=block", - `x-request-id` = "01234567-89ab-cdef-0123-456789abcdef", - `x-download-options` = "noopen", `x-runtime` = "0.015826", - `x-frame-options` = "sameorigin", `x-content-type-options` = "nosniff", - `content-security-policy` = "default-src 'self'; child-src 'self'; connect-src 'self'; font-src 'none'; form-action 'self'; frame-ancestors 'self'; frame-src 'self'; img-src 'self' data: www.gravatar.com *.wp.com tile.openstreetmap.org *.tile.openstreetmap.org *.tile.thunderforest.com tile.tracestrack.com *.openstreetmap.fr; manifest-src 'self'; media-src 'none'; object-src 'self'; script-src 'self'; style-src 'self'; worker-src 'none'", - date = "DoW, 24 Jun 2024 00:00:00 GMT", `x-powered-by` = "Phusion Passenger(R) 6.0.20", - `strict-transport-security` = "max-age=31536000; includeSubDomains; preload", - status = "200 OK", `content-encoding` = "br", `x-robots-tag` = "noindex, nofollow", - `content-length` = "1", `content-type` = "text/plain; charset=utf-8", - server = "Apache/2.4.54 (Ubuntu)"), class = "httr2_headers"), - body = raw(0), request = structure(list(url = "https://master.apis.dev.openstreetmap.org/api/0.6/user/preferences", - method = "PUT", headers = structure(list(Authorization = "Bearer *******************************************"), redact = "Authorization"), - body = list(data = structure("/tmp/RtmpBqEmqg/file1c3af2e62ff.xml", class = "httr2_path"), - type = "raw-file", content_type = "", params = list()), - fields = list(), options = list(useragent = "osmapiR (https://github.com/jmaspons/osmapiR)"), - policies = list(retry_max_tries = 10L, error_body = function (resp) - { - out <- switch(httr2::resp_content_type(resp), `text/plain` = httr2::resp_body_string(resp), - `text/html` = parse_html_error(resp), httr2::resp_headers(resp)$status) - return(out) - }, auth_oauth = list(cache = list(get = function () - env_get(the$token_cache, key, default = NULL), set = function (token) - env_poke(the$token_cache, key, token), clear = function () - env_unbind(the$token_cache, key)), flow = "oauth_flow_auth_code", - flow_params = list(client = structure(list(name = "osmapiR", - id = "*******************************************", - secret = structure("*******************************************************************************", class = "httr2_obfuscated"), - key = NULL, token_url = "https://master.apis.dev.openstreetmap.org/oauth2/token", - auth = "oauth_client_req_auth_header", auth_params = list()), class = "httr2_oauth_client"), - auth_url = "https://master.apis.dev.openstreetmap.org/oauth2/authorize", - scope = "read_prefs write_prefs write_api read_gpx write_gpx write_notes", - pkce = TRUE, auth_params = list(), token_params = list(), - redirect_uri = "http://127.0.0.1:36485")))), class = "httr2_request"), - cache = new.env(parent = emptyenv())), class = "httr2_response") diff --git a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-eb5ee0-PUT.txt b/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences-eb5ee0-PUT.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-6abd41-PUT.R b/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-6abd41-PUT.R deleted file mode 100644 index 8c5d5815..00000000 --- a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-6abd41-PUT.R +++ /dev/null @@ -1,37 +0,0 @@ -structure(list(method = "PUT", url = "osm.org/api/0.6/user/preferences/test-pref", - status_code = 200L, headers = structure(list(`cache-control` = "no-cache", - vary = "Origin,Accept-Encoding", `referrer-policy` = "strict-origin-when-cross-origin", - `x-permitted-cross-domain-policies` = "none", `x-xss-protection` = "1; mode=block", - `x-request-id` = "01234567-89ab-cdef-0123-456789abcdef", - `x-download-options` = "noopen", `x-runtime` = "0.019066", - `x-frame-options` = "sameorigin", `x-content-type-options` = "nosniff", - `content-security-policy` = "default-src 'self'; child-src 'self'; connect-src 'self'; font-src 'none'; form-action 'self'; frame-ancestors 'self'; frame-src 'self'; img-src 'self' data: www.gravatar.com *.wp.com tile.openstreetmap.org *.tile.openstreetmap.org *.tile.thunderforest.com tile.tracestrack.com *.openstreetmap.fr; manifest-src 'self'; media-src 'none'; object-src 'self'; script-src 'self'; style-src 'self'; worker-src 'none'", - date = "DoW, 24 Jun 2024 00:00:00 GMT", `x-powered-by` = "Phusion Passenger(R) 6.0.20", - `strict-transport-security` = "max-age=31536000; includeSubDomains; preload", - status = "200 OK", `content-encoding` = "br", `x-robots-tag` = "noindex, nofollow", - `content-length` = "1", `content-type` = "text/plain; charset=utf-8", - server = "Apache/2.4.54 (Ubuntu)"), class = "httr2_headers"), - body = raw(0), request = structure(list(url = "https://master.apis.dev.openstreetmap.org/api/0.6/user/preferences/test-pref", - method = "PUT", headers = structure(list(Authorization = "Bearer *******************************************"), redact = "Authorization"), - body = list(data = "value", type = "raw", content_type = "", - params = list()), fields = list(), options = list( - useragent = "osmapiR (https://github.com/jmaspons/osmapiR)"), - policies = list(retry_max_tries = 10L, error_body = function (resp) - { - out <- switch(httr2::resp_content_type(resp), `text/plain` = httr2::resp_body_string(resp), - `text/html` = parse_html_error(resp), httr2::resp_headers(resp)$status) - return(out) - }, auth_oauth = list(cache = list(get = function () - env_get(the$token_cache, key, default = NULL), set = function (token) - env_poke(the$token_cache, key, token), clear = function () - env_unbind(the$token_cache, key)), flow = "oauth_flow_auth_code", - flow_params = list(client = structure(list(name = "osmapiR", - id = "*******************************************", - secret = structure("*******************************************************************************", class = "httr2_obfuscated"), - key = NULL, token_url = "https://master.apis.dev.openstreetmap.org/oauth2/token", - auth = "oauth_client_req_auth_header", auth_params = list()), class = "httr2_oauth_client"), - auth_url = "https://master.apis.dev.openstreetmap.org/oauth2/authorize", - scope = "read_prefs write_prefs write_api read_gpx write_gpx write_notes", - pkce = TRUE, auth_params = list(), token_params = list(), - redirect_uri = "http://127.0.0.1:26829")))), class = "httr2_request"), - cache = new.env(parent = emptyenv())), class = "httr2_response") diff --git a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-6abd41-PUT.txt b/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-6abd41-PUT.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-DELETE.R b/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-DELETE.R deleted file mode 100644 index 76004da8..00000000 --- a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-DELETE.R +++ /dev/null @@ -1,35 +0,0 @@ -structure(list(method = "DELETE", url = "osm.org/api/0.6/user/preferences/test-pref", - status_code = 200L, headers = structure(list(`cache-control` = "no-cache", - vary = "Origin,Accept-Encoding", `referrer-policy` = "strict-origin-when-cross-origin", - `x-permitted-cross-domain-policies` = "none", `x-xss-protection` = "1; mode=block", - `x-request-id` = "01234567-89ab-cdef-0123-456789abcdef", - `x-download-options` = "noopen", `x-runtime` = "0.013267", - `x-frame-options` = "sameorigin", `x-content-type-options` = "nosniff", - `content-security-policy` = "default-src 'self'; child-src 'self'; connect-src 'self'; font-src 'none'; form-action 'self'; frame-ancestors 'self'; frame-src 'self'; img-src 'self' data: www.gravatar.com *.wp.com tile.openstreetmap.org *.tile.openstreetmap.org *.tile.thunderforest.com tile.tracestrack.com *.openstreetmap.fr; manifest-src 'self'; media-src 'none'; object-src 'self'; script-src 'self'; style-src 'self'; worker-src 'none'", - date = "DoW, 24 Jun 2024 00:00:00 GMT", `x-powered-by` = "Phusion Passenger(R) 6.0.20", - `strict-transport-security` = "max-age=31536000; includeSubDomains; preload", - status = "200 OK", `content-encoding` = "br", `x-robots-tag` = "noindex, nofollow", - `content-length` = "1", `content-type` = "text/plain; charset=utf-8", - server = "Apache/2.4.54 (Ubuntu)"), class = "httr2_headers"), - body = raw(0), request = structure(list(url = "https://master.apis.dev.openstreetmap.org/api/0.6/user/preferences/test-pref", - method = "DELETE", headers = structure(list(Authorization = "Bearer *******************************************"), redact = "Authorization"), - body = NULL, fields = list(), options = list(useragent = "osmapiR (https://github.com/jmaspons/osmapiR)"), - policies = list(retry_max_tries = 10L, error_body = function (resp) - { - out <- switch(httr2::resp_content_type(resp), `text/plain` = httr2::resp_body_string(resp), - `text/html` = parse_html_error(resp), httr2::resp_headers(resp)$status) - return(out) - }, auth_oauth = list(cache = list(get = function () - env_get(the$token_cache, key, default = NULL), set = function (token) - env_poke(the$token_cache, key, token), clear = function () - env_unbind(the$token_cache, key)), flow = "oauth_flow_auth_code", - flow_params = list(client = structure(list(name = "osmapiR", - id = "*******************************************", - secret = structure("*******************************************************************************", class = "httr2_obfuscated"), - key = NULL, token_url = "https://master.apis.dev.openstreetmap.org/oauth2/token", - auth = "oauth_client_req_auth_header", auth_params = list()), class = "httr2_oauth_client"), - auth_url = "https://master.apis.dev.openstreetmap.org/oauth2/authorize", - scope = "read_prefs write_prefs write_api read_gpx write_gpx write_notes", - pkce = TRUE, auth_params = list(), token_params = list(), - redirect_uri = "http://127.0.0.1:47460")))), class = "httr2_request"), - cache = new.env(parent = emptyenv())), class = "httr2_response") diff --git a/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-DELETE.txt b/tests/testthat/mock_set_prefs_user/osm.org/api/0.6/user/preferences/test-pref-DELETE.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/test-elements.R b/tests/testthat/test-elements.R index 3cd35adf..ede0d56f 100644 --- a/tests/testthat/test-elements.R +++ b/tests/testthat/test-elements.R @@ -105,9 +105,7 @@ test_that("edit OSM object works", { delete_version[i] <- osm_delete_object(x[i, ], changeset_id = changeset_id) } - # osm_close_changeset(changeset_id) - # TODO: Error in `resp_body_raw()`: ! Can not retrieve empty body. Fixed in httptest2 > 0.1.0 - # https://github.com/nealrichardson/httptest2/pull/28 + osm_close_changeset(changeset_id) }) expect_match(create_id, "[0-9]+") @@ -304,47 +302,23 @@ test_that("osm_full_object works", { ## Redaction: `POST /api/0.6/[node|way|relation]/#id/#version/redact?redaction=#redaction_id` ---- test_that("osm_redaction_object works", { - # x <- data.frame(type = "node", lat = 0, lon = 0, name = "Test redaction.") - # obj <- osmapi_objects(x, tag_columns = "name") - - # with_mock_dir("mock_redaction_object", { - # changeset_id <- osm_create_changeset( - # comment = "Test object redaction", - # created_by = "osmapiR", # avoid changes in calls when updating version - # hashtags = "#testing;#osmapiR", - # verbose = TRUE - # ) - # - # node_id <- osm_create_object(x = obj, changeset_id = changeset_id) - # node_osm <- osm_read_object(osm_type = "node", osm_id = node_id) - # deleted_version <- osm_delete_object(x = node_osm, changeset_id = changeset_id) - # redaction <- osm_redaction_object(osm_type = node_osm$type, osm_id = node_osm$id, version = 1, redaction_id = 1) - # unredaction <- osm_redaction_object(osm_type = node_osm$type, osm_id = node_osm$id, version = 1) - # - # osm_close_changeset(changeset_id = changeset_id) - # }) - ## TODO: works as expected but httptest2 fails: - # - # Error in `resp_body_raw()`: - # ! Can't retrieve empty body. - # --- - # Backtrace: - # ▆ - # 1. ├─httptest2::with_mock_dir(...) - # 2. │ ├─httptest2:::with_mock_path(...) - # 3. │ │ └─base::eval.parent(expr) - # 4. │ │ └─base::eval(expr, p) - # 5. │ └─httptest2::capture_requests(expr, simplify = simplify) - # 6. │ └─base::eval.parent(expr) - # 7. │ └─base::eval(expr, p) - # 8. └─osmapiR::osm_redaction_object(...) - # 9. └─httr2::req_perform(req) at osmapiR/R/osmapi_elements.R:1002:3 - # 10. ├─base::.doTrace(...) at osmapiR/R/osmapi_elements.R:1002:3 - # 11. │ └─base::eval.parent(exprObj) - # 12. │ └─base::eval(expr, p) - # 13. │ └─base::eval(expr, p) - # 14. └─httptest2::save_response(...) - # 15. └─httr2::resp_body_string(response) - # 16. └─httr2::resp_body_raw(resp) - # Run rlang::last_trace(drop = FALSE) to see 2 hidden frames. + x <- data.frame(type = "node", lat = 0, lon = 0, name = "Test redaction.") + obj <- osmapi_objects(x, tag_columns = "name") + + with_mock_dir("mock_redact_object", { + changeset_id <- osm_create_changeset( + comment = "Test object redaction", + created_by = "osmapiR", # avoid changes in calls when updating version + hashtags = "#testing;#osmapiR", + verbose = TRUE + ) + + node_id <- osm_create_object(x = obj, changeset_id = changeset_id) + node_osm <- osm_get_objects(osm_type = "node", osm_id = node_id) + deleted_version <- osm_delete_object(x = node_osm, changeset_id = changeset_id) + redaction <- osm_redaction_object(osm_type = node_osm$type, osm_id = node_osm$id, version = 1, redaction_id = 1) + unredaction <- osm_redaction_object(osm_type = node_osm$type, osm_id = node_osm$id, version = 1) + + osm_close_changeset(changeset_id = changeset_id) + }) }) diff --git a/tests/testthat/test-user_data.R b/tests/testthat/test-user_data.R index f98a8665..66235f0a 100644 --- a/tests/testthat/test-user_data.R +++ b/tests/testthat/test-user_data.R @@ -107,55 +107,33 @@ test_that("osm_details_logged_user works", { ## Preferences of the logged-in user: `GET /api/0.6/user/preferences` ---- -# PUT /api/0.6/user/preferences -# -# The same structure in the body of the a PUT will upload preferences. All existing preferences are replaced by the newly uploaded set. -# -# GET /api/0.6/user/preferences/[your_key] (without the brackets) -# -# Returns a string with that preference's value. -# -# PUT /api/0.6/user/preferences/[your_key] (without the brackets) -# -# Will set a single preference's value to a string passed as the content of the request. -# -# PUT /api/0.6/user/preferences/[your_key] -# -# in this instance, the payload of the request should only contain the value of the preference, i.e. not XML formatted. -# -# The PUT call returns HTTP response code 406 (not acceptable) if the same key occurs more than once, and code 413 (request entity too large) if you try to upload more than 150 preferences at once. The sizes of the key and value are limited to 255 characters. -# -# A single preference entry can be deleted with -# -# DELETE /api/0.6/user/preferences/[your_key] - -test_that("osm_get_preferences_user works", { - path_xml <- tempfile(fileext = ".xml") +test_that("osm_set-get_preferences_user works", { with_mock_dir("mock_get_prefs_user", { + ### `GET /api/0.6/user/preferences` ---- preferences <- osm_get_preferences_user() preferences_xml <- osm_get_preferences_user(format = "xml") preferences_json <- osm_get_preferences_user(format = "json") + ### `GET /api/0.6/user/preferences/[your_key]` (without the brackets) ---- preference <- osm_get_preferences_user(key = "mapcomplete-language") # preference <- osm_get_preferences_user(key = "gps.trace.visibility") # TODO: error due to dots? }) - with_mock_dir("mock_set_prefs_user", - { - expect_null(osm_set_preferences_user(key = "test-pref", value = "value")) - expect_null(osm_set_preferences_user(key = "test-pref", value = NULL)) - - expect_null(osm_set_preferences_user(all_prefs = preferences)) - expect_null(osm_set_preferences_user(all_prefs = preferences_xml)) - expect_null(osm_set_preferences_user(all_prefs = preferences_json)) - - xml2::write_xml(preferences_xml, file = path_xml) - expect_null(osm_set_preferences_user(all_prefs = path_xml)) - }, - simplify = FALSE - ) + path_xml <- tempfile(fileext = ".xml") + with_mock_dir("mock_set_prefs_user", { + ### `PUT /api/0.6/user/preferences/[your_key]` ---- + expect_null(osm_set_preferences_user(key = "test-pref", value = "value")) + ### `DELETE /api/0.6/user/preferences/[your_key]` ---- + expect_null(osm_set_preferences_user(key = "test-pref", value = NULL)) + ### `PUT /api/0.6/user/preferences` ---- + expect_null(osm_set_preferences_user(all_prefs = preferences)) + expect_null(osm_set_preferences_user(all_prefs = preferences_xml)) + expect_null(osm_set_preferences_user(all_prefs = preferences_json)) + + xml2::write_xml(preferences_xml, file = path_xml) + expect_null(osm_set_preferences_user(all_prefs = path_xml)) + }) file.remove(path_xml) - expect_s3_class(preferences, "data.frame") expect_named(preferences, c("key", "value"))