-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Why these changes are being introduced: The function needs to check for a `challenge` parameter in incoming GET requests and respond with that parameter's value. This is how Alma makes the initial webhook connection during configuration. How this addresses that need: * Adds functionality and tests to check the request method, respond appropriately to GET requests, and provide error responses to other request methods and incorrectly supplied parameters * Updates the README local development instructions to reflect changes * Also updates the Dockerfile and Makefile to handle pipenv's creation of a Requirements.txt file within the container Side effects of this change: GET requests to the URL function must now include a `challenge` parameter to receive a success response. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/ENSY-66
- Loading branch information
Showing
8 changed files
with
121 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
FROM public.ecr.aws/lambda/python:3.9 | ||
|
||
# Copy function code | ||
COPY lambdas ${LAMBDA_TASK_ROOT}/lambdas | ||
COPY lambdas ${LAMBDA_TASK_ROOT}/lambdas | ||
COPY . ${LAMBDA_TASK_ROOT}/ | ||
COPY . ${LAMBDA_TASK_ROOT}/ | ||
|
||
# Install dependencies | ||
COPY requirements.txt . | ||
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}" | ||
RUN pip3 install pipenv | ||
RUN pipenv requirements | ||
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}" | ||
|
||
# Default handler. See README for how to override to a different handler. | ||
CMD [ "lambdas.webhook.lambda_handler" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def test_env(): | ||
os.environ = {"WORKSPACE": "test"} | ||
yield | ||
|
||
|
||
@pytest.fixture() | ||
def get_request(): | ||
request_data = { | ||
"queryStringParameters": {"challenge": "challenge-accepted"}, | ||
"requestContext": { | ||
"http": { | ||
"method": "GET", | ||
}, | ||
}, | ||
} | ||
yield request_data | ||
|
||
|
||
@pytest.fixture() | ||
def get_request_missing_parameter(): | ||
request_data = { | ||
"requestContext": { | ||
"http": { | ||
"method": "GET", | ||
}, | ||
}, | ||
} | ||
yield request_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters