Skip to content

Commit

Permalink
add dev config
Browse files Browse the repository at this point in the history
  • Loading branch information
mki-c2c committed Feb 6, 2025
1 parent 2410039 commit 6aabb31
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 2 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ The folder [backend](backend) contains the API written with FastAPI.

The configuration is based on a YAML file containing connection information about the source and destination servers. You can find an example of this file in [test_config.yaml](backend/tests/test_config.yaml)

The file has 2 categories:
For dev use of the platform, there is a sample config in the backend folder: [dev_config.yaml](backend/dev_config.yaml). This config is used by default in the docker compo.

The file has 3 categories:
- sources
- destinations
- db_logging

Sources contains 2 list of servers: `geonetwork_instances` and `geoserver_instances`. Each instance is described by its `url` (`api_url` for geonetwork), and their credentials.

Expand All @@ -43,6 +46,16 @@ The logics for credentials is by decreasing order of importance:
4. Then constant login/password keys are read
5. I still either "login" or "password" is not defined, the credentials are considered invalid and anonymous acces is used for the instance without authentication

The section db_logging contains all connection information to reach a writable postgres DB to use for writing and reading application logs:
- host (default: database)
- port (default: 5432)
- login (default: georchestra)
- password (default: georchestra)
- database (default: georchestra)
- schema (default: maelstro
- table: (default: logs)


Example (see [doc_sample_config.yaml](backend/tests/doc_sample_config.yaml)):

```
Expand Down
41 changes: 41 additions & 0 deletions backend/dev_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
sources:
geonetwork_instances:
# une seule instance geonetwork source supportée dans la v1
# ce nom sera utilisé dans une V2 (non financée) pour que l'utilisateur final choisisse l'instance GN source
- name: "GeonetworkDemo"
# api_url: https://mastergn.rennesmetropole.fr/geonetwork/srv/api
api_url: https://demo.georchestra.org/geonetwork/srv/api
login_env_var: DEMO_LOGIN
password_env_var: DEMO_LOGIN
- name: "GeonetworkRennes"
api_url: https://public.sig.rennesmetropole.fr/geonetwork/srv/api
login_env_var: XXX
password_env_var: XXX
geoserver_instances:
- url: "https://demo.georchestra.org/geoserver"
login_env_var: DEMO_LOGIN
password_env_var: DEMO_LOGIN


destinations:
# nom de l'instance geOrchestra destination, telle qu'il apparaitra dans la UI
"CompoLocale":
login_env_var: LOCAL_LOGIN
password_env_var: LOCAL_LOGIN
geonetwork:
api_url: http://proxy:8080/geonetwork/srv/api
geoserver:
url: http://proxy:8080/geoserver
"CompoLocaleMaelstro":
login: tmaelstro
password: tmaelstro
geonetwork:
api_url: http://proxy:8080/geonetwork/srv/api
geoserver:
url: http://proxy:8080/geoserver

db_logging:
host: database
port: 5432
login: georchestra
password: georchestra
40 changes: 40 additions & 0 deletions backend/tests/test_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,46 @@ def test_read_main():
assert response.json() == {'Hello': 'World'}


@pytest.mark.mo0
def test_debug_():
response = client.post("/debug", json={'query': {}}, headers={"accept": "application/json"})
assert response.status_code == 200
assert len(response.json()) == 13


@pytest.mark.mo2
def test_search_2():
response = client.post("/search/GeonetworkGAM", json={'query': {
"query_string": {
"query": "*"
}}}, headers={"accept": "application/json"})
assert response.status_code == 400
assert list(response.json()['detail']['content'].keys()) == ['info_0', 'Request:', 'Error:']




@pytest.mark.mo1
def test_search_():
response = client.post("/search/GeonetworkGAM", json={'query': {}}, headers={"accept": "application/json"})
assert response.status_code == 400
assert list(response.json()['detail']['content'].keys()) == ['info_0', 'Request:', 'Error:']


@pytest.mark.mo
def test_copy__():
response = client.put("/copy?src_name=GeonetworkGAM&dst_name=CompoLocale&metadataUuid=269f8f0c-7695-43f3-9239-f6e39eba59fd0&copy_meta=true&copy_layers=false&copy_styles=true", headers={"accept": "application/json"})
assert response.status_code == 200
assert len(response.json()) == 15


@pytest.mark.mox
def test_copy_():
response = client.put("/copy?src_name=GeonetworkGAM&dst_name=CompoLocale&metadataUuid=269f8f0c-7695-43f3-9239-f6e39eba59fd&copy_meta=true&copy_layers=true&copy_styles=false&dry_run=false", headers={"accept": "application/json"})
assert response.status_code == 200
assert len(response.json()) == 15


@pytest.mark.skip("Search on demo server currently down")
def test_search():
response = client.post("/search/GeonetworkDemo", json={})
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
- ./backend:/app
- georchestra_datadir:/etc/georchestra
environment:
MAELSTRO_CONFIG: /app/tests/test_config.yaml
MAELSTRO_CONFIG: /app/dev_config.yaml
LOCAL_LOGIN: testadmin
LOCAL_PASSWORD: testadmin
healthcheck:
Expand Down

0 comments on commit 6aabb31

Please sign in to comment.