Skip to content

Commit

Permalink
lint and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
raftmsohani committed Jul 11, 2024
1 parent cab98c5 commit 08cc8d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 31 deletions.
8 changes: 4 additions & 4 deletions tdrs-backend/tdpservice/users/api/login_redirect_oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ def get(self, request, *args, **kwargs):
state = secrets.token_hex(32)
nonce = secrets.token_hex(32)
"""Get request and manage login information with AMS OpenID."""
configuration = self.get_ams_configuration()
if not configuration[0]:
rendered = render_to_string('error_pages/500.html', {'error': configuration[1]})
configuration, error = self.get_ams_configuration()
if error is not None:
rendered = render_to_string('error_pages/500.html', {'error': error})
return HttpResponse(rendered,
status=200)
status=500)
auth_params = {
"client_id": settings.AMS_CLIENT_ID,
"nonce": nonce,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf import settings
"""Test the LoginRedirectAMS class."""
from unittest import mock
from tdpservice.users.api.login_redirect_oidc import LoginRedirectAMS

Expand All @@ -8,11 +8,11 @@ def test_get_ams_configuration(requests_get_mock):
requests_get_mock.return_value.status_code = 200
requests_get_mock.return_value.json.return_value = {"key": "test"}
returned_value = LoginRedirectAMS.get_ams_configuration()
assert returned_value == {"key": "test"}
assert returned_value == ({'key': 'test'}, None)

# Test if the configuration is not returned
requests_get_mock.return_value.status_code = 500
returned_value = LoginRedirectAMS.get_ams_configuration()
returned_value, error = LoginRedirectAMS.get_ams_configuration()
assert returned_value is None

@mock.patch("requests.get")
Expand All @@ -26,20 +26,17 @@ class DummyRequest:

requests_get_mock.return_value.status_code = 200
requests_get_mock.return_value.json.return_value = {"authorization_endpoint": "dummy_authorization_endpoint"}

secrets_token_hex_mock.return_value = "dummy_state_nonce"

login_redirect_ams = LoginRedirectAMS()

response = login_redirect_ams.get(DummyRequest)
assert response.url == "dummy_authorization_endpoint?client_id=&nonce=dummy_state_nonce&redirect_uri=http%3A" +\
"%2F%2Flocalhost%3A3000%2Fv1%2Foidc%2Fams&response_type=code&state=dummy_state_nonce&scope=openid+email"


# Test if the AMS server is down
requests_get_mock.return_value.status_code = 500
login_redirect_ams = LoginRedirectAMS()
response = login_redirect_ams.get("request")
assert response.status_code == 500


1 change: 0 additions & 1 deletion tdrs-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ COPY nginx/local/default.conf.template /etc/nginx/default.conf.template
COPY nginx/local/locations.conf /etc/nginx/locations.conf
#COPY nginx/local/under_maintenance.html /etc/nginx/under_maintenance.html
COPY nginx/src/503.html /usr/share/nginx/html/503_.html
COPY nginx/src/50x.html /usr/share/nginx/html/50x.html
COPY nginx/src/static/ /usr/share/nginx/html/static/
17 changes: 0 additions & 17 deletions tdrs-frontend/nginx/src/50x.html

This file was deleted.

0 comments on commit 08cc8d0

Please sign in to comment.