Skip to content

Commit

Permalink
Merge pull request #179 from slimta/pysasl-v1
Browse files Browse the repository at this point in the history
Upgrade to pysasl 1.0
  • Loading branch information
icgood authored Nov 6, 2022
2 parents 6179d4b + 8ba2550 commit 9e94df1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: build

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

jobs:
build:
Expand All @@ -13,12 +13,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pytest >= 4
pytest-cov
pyright
pymox
pymox @ git+https://github.com/slimta/pymox-maint.git@0723b819d25d2d1f8507456d299ae70f864e3ea4
testfixtures
flake8
twine
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
license = f.read()

setup(name='python-slimta',
version='5.0.4',
version='5.0.5',
author='Ian Good',
author_email='[email protected]',
description='Lightweight, asynchronous SMTP libraries.',
Expand All @@ -39,7 +39,7 @@
include_package_data=True,
packages=find_namespace_packages(include=['slimta.*']),
install_requires=['gevent >= 1.1',
'pysasl >= 0.5.0',
'pysasl >= 1',
'pycares >= 1'],
extras_require={'spf': ['pyspf', 'py3dns'],
'redis': ['redis'],
Expand All @@ -54,7 +54,8 @@
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10'])
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11'])


# vim:et:fdm=marker:sts=4:sw=4:ts=4
7 changes: 4 additions & 3 deletions slimta/smtp/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
import re
import base64

from pysasl import AuthenticationError, ServerChallenge, ChallengeResponse
from pysasl.creds import AuthenticationCredentials
from pysasl.mechanism import ServerChallenge, ChallengeResponse
from pysasl.creds.client import ClientCredentials
from pysasl.exception import AuthenticationError

from . import SmtpError
from .reply import Reply
Expand Down Expand Up @@ -167,7 +168,7 @@ def client_attempt(self, authcid, secret, authzid, mech_name):
mechanism = self.auth.get_client(mech_name)
if not mechanism:
raise InvalidMechanismError()
creds = AuthenticationCredentials(authcid, secret, authzid)
creds = ClientCredentials(authcid, secret, authzid)
responses = []
resp = mechanism.client_attempt(creds, responses)
chal, reply = self._client_respond(
Expand Down
13 changes: 7 additions & 6 deletions test/test_slimta_smtp_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from mox import MoxTestBase, IsA
from gevent.ssl import SSLSocket
from pysasl import SASLAuth
from pysasl.identity import ClearIdentity

from slimta.smtp.io import IO
from slimta.smtp.auth import AuthSession, \
Expand Down Expand Up @@ -38,16 +39,16 @@ def test_plain_noarg(self):
auth = AuthSession(SASLAuth.defaults(), self.io)
result = auth.server_attempt(b'PLAIN')
self.assertEqual(u'testuser', result.authcid)
self.assertEqual(u'testpassword', result.secret)
self.assertEqual(u'testzid', result.authzid)
self.assertTrue(result.verify(ClearIdentity(u'testuser', u'testpassword')))

def test_plain(self):
self.mox.ReplayAll()
auth = AuthSession(SASLAuth.defaults(), self.io)
result = auth.server_attempt(b'PLAIN dGVzdHppZAB0ZXN0dXNlcgB0ZXN0cGFzc3dvcmQ=')
self.assertEqual(u'testuser', result.authcid)
self.assertEqual(u'testpassword', result.secret)
self.assertEqual(u'testzid', result.authzid)
self.assertTrue(result.verify(ClearIdentity(u'testuser', u'testpassword')))

def test_plain_canceled(self):
self.sock.sendall(b'334 \r\n')
Expand All @@ -68,8 +69,8 @@ def test_login_noarg(self):
auth = AuthSession(SASLAuth.defaults(), self.io)
result = auth.server_attempt(b'LOGIN')
self.assertEqual(u'testuser', result.authcid)
self.assertEqual(u'testpassword', result.secret)
self.assertEqual(None, result.authzid)
self.assertEqual(u'testuser', result.authzid)
self.assertTrue(result.verify(ClearIdentity(u'testuser', u'testpassword')))

def test_login(self):
self.sock.sendall(b'334 UGFzc3dvcmQ6\r\n')
Expand All @@ -78,8 +79,8 @@ def test_login(self):
auth = AuthSession(SASLAuth.defaults(), self.io)
result = auth.server_attempt(b'LOGIN dGVzdHVzZXI=')
self.assertEqual(u'testuser', result.authcid)
self.assertEqual(u'testpassword', result.secret)
self.assertEqual(None, result.authzid)
self.assertEqual(u'testuser', result.authzid)
self.assertTrue(result.verify(ClearIdentity(u'testuser', u'testpassword')))

def test_client_bad_mech(self):
self.sock.sendall(b'AUTH LOGIN\r\n')
Expand Down

0 comments on commit 9e94df1

Please sign in to comment.