Skip to content

Commit

Permalink
Tidy up comments and README
Browse files Browse the repository at this point in the history
  • Loading branch information
moonraker595 committed Nov 15, 2024
1 parent acce5e4 commit 359dbb6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ A list of endpoints can be found in the OpenAPI spec at `/docs`.
The API looks for the `investigations` tag in the decoded jwt metadata, it then uses this to apply a filter to the search results.

## Example Request
After starting the stack with `docker compose up`
```commandline
curl --request GET \
curl --request POST \
--url http://127.0.0.1:8000/search \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidXNlciI6InVzZXIxIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMiwiaW52ZXN0aWdhdGlvbnMiOlt7ImlkIjoiMTAxIn1dfQ.bHJcGR9CEzxnahv3PaSyNw9m2gScHg1NAnVXTZlTlBpnYMAdPpkeWEoOr2R55Sp3bA_t9tVYIM0ROgz3rmteyCbVhKCKG9vLbdFGvVtaGqPvEwLGM4ADw-cEZZU1WDLYGJwEW84tzvufMvlf9mLxNy3jrlfBA_bWFjZiDZz16Wb80v2kTlPZagoqJZvw4GUv4dxXlFFxp04ZqUQIxchpWUlvnNeGnsaUfoMmwbAqxOuyGSAAcYNRNhz_RNFWYybAR-pZp_lGYAiox1xUGG_7X2cJBe71JDsDvTXKTLx5xuFJd6-5Eb15JbbB1k3AV8UQOiozBd-AMBNI4LEJvtPIeRtruyp1PEwTE0nnmhQtZ6vl32zpkwYS5vLlx5WvPCQF0C8EizhAcLs224RM958EV0MKuOHKz-Jcx9oLeIzmhIDpr-B-Aox_qil-bKenJnQh6BStuZhFY7N13KxRr99dVrtQQ0LQpP6boavjywrHkDw62Mfbwl3UngzABpQC4MSj' \
--header 'Content-Type: application/json' \
Expand Down
11 changes: 8 additions & 3 deletions api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ class Settings(BaseSettings):

version: str = "1.0"

opensearch_host: str = "127.0.0.1"
# When running the api locally against a compose stack
#opensearch_host: str = "127.0.0.1"
#scigateway_auth: str = "http://127.0.0.1:8008/verify"

# When running the api, and everything else, from a compose stack
opensearch_host: str = "opensearch"
scigateway_auth: str = "http://scigateway_auth_container:8000/verify"

opensearch_port: int = 9200
opensearch_index: str = "my-index"

jwt_public_key: str = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj8UF0wr1OBqY52aKwEUNx/NOF6XorpADDj3fszm1Dw+LMmxfZ9IylkL7qbYfzh8bg/bhI4yphfyt/AfCWRScuFUbkaJO9urEV4Ru1UT16/nDl7efSG9e8Fvzg719y+XSSNT4PWamw7n8e+pMz/2baJcsQdnuSkH68qGj0mr/Yo62cZ5g0oKByd2LfJxNAjjcezXrFPLM+mKQuMcbqwM3cawlRnEKK1YUehewQAhvAsuUWsvVVLx70bggRsEjorqdoLPaYJa60fAL2Q7qLlIN9xD6vWfMQ2DZ8g+MttVGELnu+nStdgPznE9oiPqYr3VxR+NB7rBm2VbeY4MI6iT7h0XY7D6kofVDmU9vqPXVTHBMsSE8gIE3XinZRlHa//XNq0Qqf81a5KjpmKgwbK5IG3LIltBDf3AO1u4gJMhm7ltC4iDZUrbjC7SGBdwUC6/at9aZytbCRfMFBHNa/YkBzAf1ih5SpZ1n/D+AWzDlJLQ0l9Xr4cu9W1xhPeV9F+LM= scigateway-auth@7b8bc716bc39"
jwt_algo: str = "RS256"

scigateway_auth: str = "http://127.0.0.1:8008/verify"


# create a single instance on the class to import
settings = Settings()
9 changes: 4 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Once this has been run. it can be tested with:
# curl -X GET 'http://localhost:9200/my-index/_search' -H 'Content-Type: application/json' -d' { "query": {"match_all": { }}}'

services:

# targets: test or production
search-api:
container_name: search-api
build:
target: test
target: production
depends_on:
seed_opensearch:
condition: service_completed_successfully # wait for the container to exit without any errors
ports:
- "8000:8000"


# create a basic opensearch cluster
# Create a basic opensearch cluster
# Once this has been run. it can be tested with:
# curl -X GET 'http://localhost:9200/my-index/_search' -H 'Content-Type: application/json' -d' { "query": {"match_all": { }}}'
opensearch:
image: opensearchproject/opensearch:2.5.0
container_name: opensearch
Expand Down
2 changes: 1 addition & 1 deletion test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_search_with_valid_jwt():
investigations = [{"id": "101"}, {"id": "103"}]
token = create_jwt(investigations)

# Send a GET request to the /search endpoint with the JWT in the Authorization header
# Send a POST request to the /search endpoint with the JWT in the Authorization header
response = client.post(
"/search",
json=search_body,
Expand Down

0 comments on commit 359dbb6

Please sign in to comment.