Skip to content

Commit

Permalink
/vsicurl: Add auth test with bearer token
Browse files Browse the repository at this point in the history
  • Loading branch information
drons committed Nov 10, 2023
1 parent 14e32b6 commit 175861a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions autotest/gcore/vsicurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,3 +1088,22 @@ def test_vsicurl_NETRC_FILE():
pytest.skip("got exception %s" % str(e))

assert "/i_do/not_exist" in err


###############################################################################
# Check auth with bearer token


def test_vsicurl_bearer():
if gdaltest.is_travis_branch("ubuntu_1804") or gdaltest.is_travis_branch(
"ubuntu_1804_32bit"
):
pytest.skip("Too old libcurl version, requires at least 7.61.0")
token = "myuniqtok"
with gdal.config_options({"GDAL_HTTP_AUTH": "BEARER", "GDAL_HTTP_BEARER": token}):
f = gdal.VSIFOpenL("/vsicurl/http://httpbin.org/bearer", "rb")
gdal.VSIFSeekL(f, 0, 2)
vsilen = gdal.VSIFTellL(f)
gdal.VSIFSeekL(f, 0, 0)
data = gdal.VSIFReadL(1, vsilen, f).decode("ascii")
assert token in data

0 comments on commit 175861a

Please sign in to comment.