Commit 069e2497 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Add basic auth test (local only)

Add /de to all endpoint requests.
parent 0de03b91
Pipeline #23832 passed with stages
in 2 minutes and 10 seconds
......@@ -72,7 +72,7 @@ class MonitorDrupalJsonApiInstitution(Resource):
institution_data_de['relationships']['field_extended_address']
for addressElement in drupalResponseAddressParagraphs['data']:
drupalResponseAddress = \
requests.get(current_app.config['drupal-api-url'] + '/jsonapi/paragraph/' +
requests.get(current_app.config['drupal-api-url'] + '/de/jsonapi/paragraph/' +
'job_mapper_service/' + addressElement['id'],
headers=headers).json()['data']
fieldAdressess = drupalResponseAddress['attributes']['field_address']
......@@ -93,7 +93,7 @@ class MonitorDrupalJsonApiInstitution(Resource):
recordSetIds = []
drupalResponseRecordSets = \
requests.get(current_app.config['drupal-api-url'] + '/jsonapi/node/' +
requests.get(current_app.config['drupal-api-url'] + '/de/jsonapi/node/' +
'record_set?filter[field_institution.id][value]=' +
institutionId, headers=headers).json()['data']
for recordSet in drupalResponseRecordSets:
......@@ -106,6 +106,7 @@ class MonitorDrupalJsonApiInstitution(Resource):
current_app.logger.error(msg)
return {
'status': 'FAILURE',
'message': ex,
'topic_value': topic_value
}, 500
except Exception as ex:
......@@ -114,6 +115,7 @@ class MonitorDrupalJsonApiInstitution(Resource):
current_app.logger.error(msg)
return {
'status': 'FAILURE',
'message': ex,
'topic_value': topic_value
}, 500
topic_value = {
......
import unittest
import os
import requests
from requests.auth import HTTPBasicAuth
class TestBasicAuth(unittest.TestCase):
def test_get_institution(self):
institution_id = '901b3831-3700-4974-a358-ef3e39dc6438'
url = f"{os.environ['DRUPAL_API_URL']}/de/jsonapi/node/institution/{institution_id}"
headers = {
'X-API-Key': os.environ['DRUPAL_API_KEY']
}
user = os.environ['DRUPAL_USERNAME']
password = os.environ['DRUPAL_PASSWORD']
response = requests.get(url, headers=headers, auth=HTTPBasicAuth(user, password))
assert response.ok
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment