Skip to content

Commit a8eb629

Browse files
authored
Merge pull request #209 from gawel/wip/pong-after-sasl-auth
sasl: reset ping/pong after auth (#208)
2 parents 76d6849 + 3f8a883 commit a8eb629

File tree

8 files changed

+38
-48
lines changed

8 files changed

+38
-48
lines changed

.github/workflows/tox.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python: [3.7, 3.8, 3.9, "3.10", "3.11"]
11+
python: ["3.11", "3.12"]
1212

1313
steps:
1414
- uses: actions/checkout@v3
@@ -24,4 +24,4 @@ jobs:
2424
run: tox -e py
2525
- name: Run flake8 / docs
2626
run: tox -e flake8,docs
27-
if: matrix.python == 3.8
27+
if: matrix.python == 3.12

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,6 @@
241241
# How to display URL addresses: 'footnote', 'no', or 'inline'.
242242
#texinfo_show_urls = 'footnote'
243243

244-
import pkg_resources
245-
version = pkg_resources.get_distribution("irc3").version
244+
from importlib.metadata import version
245+
version = version("irc3")
246246
release = version

irc3/base.py

+8-22
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,15 @@
55
import signal
66
import logging
77
import logging.config
8+
from importlib import metadata
89
from . import utils
910
from . import config
1011
from .compat import asyncio
1112
from .compat import reload_module
1213
from collections import defaultdict
1314

14-
try:
15-
import pkg_resources
16-
from pkg_resources import iter_entry_points
17-
HAS_PKG_RESOURCES = True
18-
except ImportError: # pragma: no cover
19-
HAS_PKG_RESOURCES = False
20-
version = ''
21-
else:
22-
try:
23-
version = pkg_resources.get_distribution('irc3').version
24-
except pkg_resources.DistributionNotFound:
25-
version = ''
15+
16+
version = metadata.version('irc3')
2617

2718

2819
class Registry:
@@ -200,16 +191,11 @@ def include(self, *modules, **kwargs):
200191
try:
201192
module = utils.maybedotted(module)
202193
except LookupError as exc:
203-
if HAS_PKG_RESOURCES:
204-
entry_points = iter_entry_points(
205-
'irc3.loader',
206-
module
207-
)
208-
try:
209-
module = next(entry_points).load()
210-
except StopIteration:
211-
raise exc
212-
else:
194+
try:
195+
(module,) = metadata.entry_points(group='irc3.loader',
196+
name=module)
197+
module = module.load()
198+
except (ImportError, ValueError):
213199
raise exc
214200
# we have to manualy check for plugins. venusian no longer
215201
# support to attach both a class and methods

irc3/plugins/sasl.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
import irc3
3+
from irc3 import utils
34
import base64
45
__doc__ = '''
56
===================================================
@@ -60,4 +61,6 @@ def authenticate(self, **kwargs):
6061

6162
def cap_end(self, **kwargs):
6263
self.bot.send_line('CAP END')
64+
core = self.bot.get_plugin(utils.maybedotted('irc3.plugins.core.Core'))
65+
core.pong(event='PING')
6366
self.bot.detach_events(*self.events)

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[tool:pytest]
2+
asyncio_default_fixture_loop_scope=function
23
addopts = -p no:warnings
34
-p no:unraisableexception
45
--doctest-modules

tests/test_casefold.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ class TestCasefold(BotTestCase):
99
def test_ascii(self):
1010
bot = self.callFTU(server_config={'CASEMAPPING': 'ascii'})
1111

12-
self.assertEquals(bot.casefold('#testchan\\123[]56'),
13-
'#testchan\\123[]56')
14-
self.assertEquals(bot.casefold('#tESt[]chAn'), '#test[]chan')
15-
self.assertEquals(bot.casefold('#TEsT\\CHaN'), '#test\\chan')
12+
self.assertEqual(bot.casefold('#testchan\\123[]56'),
13+
'#testchan\\123[]56')
14+
self.assertEqual(bot.casefold('#tESt[]chAn'), '#test[]chan')
15+
self.assertEqual(bot.casefold('#TEsT\\CHaN'), '#test\\chan')
1616

17-
self.assertEquals(bot.casefold('#TEsT\\CHaN'), '#test\\chan')
17+
self.assertEqual(bot.casefold('#TEsT\\CHaN'), '#test\\chan')
1818

1919
def test_rfc1459(self):
2020
bot = self.callFTU(server_config={'CASEMAPPING': 'rfc1459'})
2121

22-
self.assertEquals(bot.casefold('#testchan\\123[]56'),
23-
'#testchan|123{}56')
24-
self.assertEquals(bot.casefold('#tESt[]chAn'), '#test{}chan')
25-
self.assertEquals(bot.casefold('#TEsT\\CHaN'), '#test|chan')
22+
self.assertEqual(bot.casefold('#testchan\\123[]56'),
23+
'#testchan|123{}56')
24+
self.assertEqual(bot.casefold('#tESt[]chAn'), '#test{}chan')
25+
self.assertEqual(bot.casefold('#TEsT\\CHaN'), '#test|chan')
2626

27-
self.assertEquals(bot.casefold('#TEsT\\CHaN'), '#test|chan')
27+
self.assertEqual(bot.casefold('#TEsT\\CHaN'), '#test|chan')

tests/test_quakenet.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ def digest(user, algo):
2121
str.lower, algo)
2222

2323
res1 = digest(user1, "md5")
24-
self.assertEquals(res1, '2ed1a1f1d2cd5487d2e18f27213286b9')
24+
self.assertEqual(res1, '2ed1a1f1d2cd5487d2e18f27213286b9')
2525

2626
res2 = digest(user2, "md5")
27-
self.assertEquals(res2, '8990cb478218b6c0063daf08dd7e1a72')
27+
self.assertEqual(res2, '8990cb478218b6c0063daf08dd7e1a72')
2828

2929
res3 = digest(user1, "sha1")
30-
self.assertEquals(res3, 'd0328d41426bd2ace183467ce0a6305445e3d497')
30+
self.assertEqual(res3, 'd0328d41426bd2ace183467ce0a6305445e3d497')
3131

3232
res4 = digest(user2, "sha1")
33-
self.assertEquals(res4, '4de3f1c86dd0f59da44852d507e193c339c4b108')
33+
self.assertEqual(res4, '4de3f1c86dd0f59da44852d507e193c339c4b108')
3434

3535
res5 = digest(user1, "sha256")
36-
self.assertEquals(res5, 'f6eced34321a69c270472d06c50e959c48e9fd323'
37-
'b2c5d3194f44b50a118a7ea')
36+
self.assertEqual(res5, 'f6eced34321a69c270472d06c50e959c48e9fd323'
37+
'b2c5d3194f44b50a118a7ea')
3838

3939
res6 = digest(user2, "sha256")
40-
self.assertEquals(res6, '504056d53b2fc4fd783dc4f086dabc59f845d201e650'
41-
'b96dfa95dacc8cac2892')
40+
self.assertEqual(res6, '504056d53b2fc4fd783dc4f086dabc59f845d201e650'
41+
'b96dfa95dacc8cac2892')
4242

4343
def test_simple_auth(self):
4444
bot = self.callFTU()

tox.ini

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py37,py38,py39,py310,py311,flake8,docs
2+
envlist = py311,py312,flake8,docs
33

44
[testenv]
55
skipsdist=true
@@ -18,7 +18,7 @@ deps =
1818
[testenv:flake8]
1919
skipsdist=true
2020
skip_install=true
21-
basepython = python3.8
21+
basepython = python3.12
2222
commands =
2323
flake8
2424
deps =
@@ -27,7 +27,7 @@ deps =
2727
[testenv:docs]
2828
skip_install=false
2929
skipsdist=true
30-
basepython = python3.8
30+
basepython = python3.12
3131
changedir = docs
3232
deps =
3333
sphinx
@@ -39,7 +39,7 @@ commands =
3939
[testenv:build]
4040
skip_install=false
4141
skipsdist=true
42-
basepython = python3.8
42+
basepython = python3.12
4343
commands =
4444
python -m irc3._parse_rfc
4545
python -m irc3._gen_doc

0 commit comments

Comments
 (0)