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

#10209: fix ftp authentication using bytes instead of str #1609

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

grimmjow8
Copy link

@grimmjow8 grimmjow8 commented Jun 26, 2021

Scope and purpose

twisted.cred.credentials.IUsernamePassword declares username and password should be bytes. However, FTP constructs a twisted.cred.credentials.UsernamePassword usinf str. When using the twisted.cred.checkers.FilePasswordDB checker, authentication always fails.

This PR aims to address the issue and fix it by converting username and password to bytes when constructing the checker.

Contributor Checklist:

  • The associated ticket in Trac is here: https://twistedmatrix.com/trac/ticket/10209
  • I ran tox -e lint to format my patch to meet the Twisted Coding Standard
  • I have created a newsfragment in src/twisted/newsfragments/ (see: News files)
  • The title of the PR starts with the associated Trac ticket number (without the # character).
  • I have updated the automated tests and checked that all checks for the PR are green.
  • I have submitted the associated Trac ticket for review by adding the word review to the keywords field in Trac, and putting a link to this PR in the comment; it shows up in https://twisted.reviews/ now.
  • The merge commit will use the below format
    The first line is automatically generated by GitHub based on PR ID and branch name.
    The other lines generated by GitHub should be replaced.
Merge pull request #123 from twisted/4356-branch-name-with-trac-id

Author: <github_username>, <github_usernames_if_more_authors>
Reviewer: <github_username>, <github_username_if_more_reviewers>
Fixes: ticket:<trac_ticket_number>, ticket:<another_if_more_in_one_PR>

Long description providing a summary of these changes.
(as long as you wish)

Copy link
Contributor

@twm twm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grimmjow8 Could you resolve these MyPy errors?

mypy run-test: commands[0] | mypy --cache-dir=/home/runner/work/twisted/twisted/.tox/mypy_cache src
src/twisted/protocols/test/test_ftp.py:18:5: error: Function is missing a type annotation  [no-untyped-def]
src/twisted/protocols/test/test_ftp.py:31:5: error: Function is missing a type annotation  [no-untyped-def]
src/twisted/protocols/test/test_ftp.py:43:5: error: Function is missing a return type annotation  [no-untyped-def]
src/twisted/protocols/test/test_ftp.py:43:5: note: Use "-> None" if function does not return a value
src/twisted/protocols/test/test_ftp.py:51:24: error: Incompatible types in assignment (expression has type "MockPortal", variable has type "None")  [assignment]
src/twisted/protocols/test/test_ftp.py:58:31: error: "None" has no attribute "credentials"  [attr-defined]
src/twisted/protocols/test/test_ftp.py:59:31: error: "None" has no attribute "credentials"  [attr-defined]
Found 6 errors in 1 file (checked 845 source files)

@twm twm changed the title 10209: fix ftp authentication using bytes instead of str #10209: fix ftp authentication using bytes instead of str Oct 29, 2022

class MockDefer:
"""
Mock of L{twisted.internet.defer}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this mock? Please use an actual Deferred.

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

Successfully merging this pull request may close these issues.

None yet

5 participants