Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHCLOUD-35536 - Updated IndentityHeaderMiddleware to follow latest Django recommendations #1237

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

EvanCasey13
Copy link
Contributor

@EvanCasey13 EvanCasey13 commented Oct 14, 2024

Link(s) to Jira

Description of Intent of Change(s)

Updated the IdentityHeaderMiddleware to use latest Django middleware style & updated all Indentity Header Middleware tests to handle the new style of middleware recommended by Django.

Django middleware new recommendations
[1]https://docs.djangoproject.com/en/5.1/topics/http/middleware/

To run updated tests for IdentityHeaderMiddleware only use this command

tox -- tests/rbac -k IdentityHeaderMiddlewareTest

The response object being None occurred due to these two IF statements that queried the path for certain strings, which some tests had causing them to return None in Middleware.py

  if any([request.path.startswith(prefix) for prefix in settings.INTERNAL_API_PATH_PREFIXES]):
            # This request is for a private API endpoint
          return

        if is_no_auth(request):
          return 

Local Testing

How can the feature be exercised?
How can the bug be exploited and fix confirmed?
Is any special local setup required?

Checklist

  • if API spec changes are required, is the spec updated?
  • are there any pre/post merge actions required? if so, document here.
  • are theses changes covered by unit tests?
  • if warranted, are documentation changes accounted for?
  • does this require migration changes?
    • if yes, are they backwards compatible?
  • is there known, direct impact to dependent teams/components?
    • if yes, how will this be handled?

Secure Coding Practices Checklist Link

Secure Coding Practices Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

@app-sre-bot
Copy link

Can one of the admins verify this patch?

@lpichler
Copy link
Contributor

/retest

@petracihalova
Copy link
Contributor

/ok_to_test

@Ellen-Yi-Dong
Copy link
Contributor

/retest

@Ellen-Yi-Dong
Copy link
Contributor

Ellen-Yi-Dong commented Oct 16, 2024

Test the status endpoint. ... ERROR

======================================================================
ERROR: test_status_endpoint (tests.api.status.test_status.StatusViewTest)
Test the status endpoint.

Traceback (most recent call last):
File "/var/workdir/tests/api/status/test_status.py", line 64, in test_status_endpoint
response = self.client.get(url)
File "/var/workdir/.tox/py39/lib/python3.9/site-packages/django/test/client.py", line 927, in get
response = super().get(path, data=data, secure=secure, headers=headers, **extra)
File "/var/workdir/.tox/py39/lib/python3.9/site-packages/django/test/client.py", line 457, in get
return self.generic(
File "/var/workdir/.tox/py39/lib/python3.9/site-packages/django/test/client.py", line 609, in generic
return self.request(**r)
File "/var/workdir/.tox/py39/lib/python3.9/site-packages/django/test/client.py", line 891, in request
self.check_exception(response)
File "/var/workdir/.tox/py39/lib/python3.9/site-packages/django/test/client.py", line 738, in check_exception
raise exc_value
File "/var/workdir/.tox/py39/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/var/workdir/.tox/py39/lib/python3.9/site-packages/django/utils/deprecation.py", line 136, in call
response = self.process_response(request, response)
File "/var/workdir/.tox/py39/lib/python3.9/site-packages/django/middleware/common.py", line 107, in process_response
if response.status_code == 404 and self.should_redirect_with_slash(request):
AttributeError: 'NoneType' object has no attribute 'status_code'

Error appearing in the unit tests ^^^

(if you don't mind sending me your username when you view this url (top right hand corner): then I can grant you access to the konflux pipeline to view the logs. You might need to go to overview tab first and press the orange button first if you have never worked with konflux before. Thank you so much!

@EvanCasey13
Copy link
Contributor Author

/retest

1 similar comment
@petracihalova
Copy link
Contributor

/retest

@petracihalova
Copy link
Contributor

/retest

1 similar comment
@EvanCasey13
Copy link
Contributor Author

/retest

@EvanCasey13
Copy link
Contributor Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants