Skip to content

Commit

Permalink
Get host addr from env if not defined in config
Browse files Browse the repository at this point in the history
  • Loading branch information
ritvje authored and RadAdm committed Feb 27, 2024
1 parent 18fc161 commit 4271364
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions georest/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_read_config_credentials_in_env():

os.environ["GEOSERVER_USER"] = "user1"
os.environ["GEOSERVER_PASSWORD"] = "passwd1"
os.environ["GEOSERVER_HOST"] = "host1"
config = """
foo: bar
"""
Expand All @@ -55,6 +56,7 @@ def test_read_config_credentials_in_env():
assert res["foo"] == "bar"
assert res["user"] == "user1"
assert res["passwd"] == "passwd1"
assert res["host"] == "host1"


def test_read_config_default_credentials():
Expand All @@ -66,6 +68,7 @@ def test_read_config_default_credentials():

os.environ.pop("GEOSERVER_USER", None)
os.environ.pop("GEOSERVER_PASSWORD", None)
os.environ.pop("GEOSERVER_HOST", None)

config = """
foo: bar
Expand All @@ -78,6 +81,7 @@ def test_read_config_default_credentials():
assert res["foo"] == "bar"
assert res["user"] == "admin"
assert res["passwd"] == "geoserver"
assert res["host"] == "http://localhost:8080/geoserver/rest"


def test_write_wkt():
Expand Down
2 changes: 2 additions & 0 deletions georest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def read_config(fname):
config["user"] = os.environ.get("GEOSERVER_USER", "admin")
if "passwd" not in config:
config["passwd"] = os.environ.get("GEOSERVER_PASSWORD", "geoserver")
if "host" not in config:
config["host"] = os.environ.get("GEOSERVER_HOST", "http://localhost:8080/geoserver/rest")
return config


Expand Down

0 comments on commit 4271364

Please sign in to comment.