Skip to content

Commit

Permalink
Merge pull request #209 from gawel/wip/pong-after-sasl-auth
Browse files Browse the repository at this point in the history
sasl: reset ping/pong after auth (#208)
  • Loading branch information
gawel authored Jan 3, 2025
2 parents 76d6849 + 3f8a883 commit a8eb629
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.7, 3.8, 3.9, "3.10", "3.11"]
python: ["3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand All @@ -24,4 +24,4 @@ jobs:
run: tox -e py
- name: Run flake8 / docs
run: tox -e flake8,docs
if: matrix.python == 3.8
if: matrix.python == 3.12
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,6 @@
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

import pkg_resources
version = pkg_resources.get_distribution("irc3").version
from importlib.metadata import version
version = version("irc3")
release = version
30 changes: 8 additions & 22 deletions irc3/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,15 @@
import signal
import logging
import logging.config
from importlib import metadata
from . import utils
from . import config
from .compat import asyncio
from .compat import reload_module
from collections import defaultdict

try:
import pkg_resources
from pkg_resources import iter_entry_points
HAS_PKG_RESOURCES = True
except ImportError: # pragma: no cover
HAS_PKG_RESOURCES = False
version = ''
else:
try:
version = pkg_resources.get_distribution('irc3').version
except pkg_resources.DistributionNotFound:
version = ''

version = metadata.version('irc3')


class Registry:
Expand Down Expand Up @@ -200,16 +191,11 @@ def include(self, *modules, **kwargs):
try:
module = utils.maybedotted(module)
except LookupError as exc:
if HAS_PKG_RESOURCES:
entry_points = iter_entry_points(
'irc3.loader',
module
)
try:
module = next(entry_points).load()
except StopIteration:
raise exc
else:
try:
(module,) = metadata.entry_points(group='irc3.loader',
name=module)
module = module.load()
except (ImportError, ValueError):
raise exc
# we have to manualy check for plugins. venusian no longer
# support to attach both a class and methods
Expand Down
3 changes: 3 additions & 0 deletions irc3/plugins/sasl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import irc3
from irc3 import utils
import base64
__doc__ = '''
===================================================
Expand Down Expand Up @@ -60,4 +61,6 @@ def authenticate(self, **kwargs):

def cap_end(self, **kwargs):
self.bot.send_line('CAP END')
core = self.bot.get_plugin(utils.maybedotted('irc3.plugins.core.Core'))
core.pong(event='PING')
self.bot.detach_events(*self.events)
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[tool:pytest]
asyncio_default_fixture_loop_scope=function
addopts = -p no:warnings
-p no:unraisableexception
--doctest-modules
Expand Down
20 changes: 10 additions & 10 deletions tests/test_casefold.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ class TestCasefold(BotTestCase):
def test_ascii(self):
bot = self.callFTU(server_config={'CASEMAPPING': 'ascii'})

self.assertEquals(bot.casefold('#testchan\\123[]56'),
'#testchan\\123[]56')
self.assertEquals(bot.casefold('#tESt[]chAn'), '#test[]chan')
self.assertEquals(bot.casefold('#TEsT\\CHaN'), '#test\\chan')
self.assertEqual(bot.casefold('#testchan\\123[]56'),
'#testchan\\123[]56')
self.assertEqual(bot.casefold('#tESt[]chAn'), '#test[]chan')
self.assertEqual(bot.casefold('#TEsT\\CHaN'), '#test\\chan')

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

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

self.assertEquals(bot.casefold('#testchan\\123[]56'),
'#testchan|123{}56')
self.assertEquals(bot.casefold('#tESt[]chAn'), '#test{}chan')
self.assertEquals(bot.casefold('#TEsT\\CHaN'), '#test|chan')
self.assertEqual(bot.casefold('#testchan\\123[]56'),
'#testchan|123{}56')
self.assertEqual(bot.casefold('#tESt[]chAn'), '#test{}chan')
self.assertEqual(bot.casefold('#TEsT\\CHaN'), '#test|chan')

self.assertEquals(bot.casefold('#TEsT\\CHaN'), '#test|chan')
self.assertEqual(bot.casefold('#TEsT\\CHaN'), '#test|chan')
16 changes: 8 additions & 8 deletions tests/test_quakenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ def digest(user, algo):
str.lower, algo)

res1 = digest(user1, "md5")
self.assertEquals(res1, '2ed1a1f1d2cd5487d2e18f27213286b9')
self.assertEqual(res1, '2ed1a1f1d2cd5487d2e18f27213286b9')

res2 = digest(user2, "md5")
self.assertEquals(res2, '8990cb478218b6c0063daf08dd7e1a72')
self.assertEqual(res2, '8990cb478218b6c0063daf08dd7e1a72')

res3 = digest(user1, "sha1")
self.assertEquals(res3, 'd0328d41426bd2ace183467ce0a6305445e3d497')
self.assertEqual(res3, 'd0328d41426bd2ace183467ce0a6305445e3d497')

res4 = digest(user2, "sha1")
self.assertEquals(res4, '4de3f1c86dd0f59da44852d507e193c339c4b108')
self.assertEqual(res4, '4de3f1c86dd0f59da44852d507e193c339c4b108')

res5 = digest(user1, "sha256")
self.assertEquals(res5, 'f6eced34321a69c270472d06c50e959c48e9fd323'
'b2c5d3194f44b50a118a7ea')
self.assertEqual(res5, 'f6eced34321a69c270472d06c50e959c48e9fd323'
'b2c5d3194f44b50a118a7ea')

res6 = digest(user2, "sha256")
self.assertEquals(res6, '504056d53b2fc4fd783dc4f086dabc59f845d201e650'
'b96dfa95dacc8cac2892')
self.assertEqual(res6, '504056d53b2fc4fd783dc4f086dabc59f845d201e650'
'b96dfa95dacc8cac2892')

def test_simple_auth(self):
bot = self.callFTU()
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py37,py38,py39,py310,py311,flake8,docs
envlist = py311,py312,flake8,docs

[testenv]
skipsdist=true
Expand All @@ -18,7 +18,7 @@ deps =
[testenv:flake8]
skipsdist=true
skip_install=true
basepython = python3.8
basepython = python3.12
commands =
flake8
deps =
Expand All @@ -27,7 +27,7 @@ deps =
[testenv:docs]
skip_install=false
skipsdist=true
basepython = python3.8
basepython = python3.12
changedir = docs
deps =
sphinx
Expand All @@ -39,7 +39,7 @@ commands =
[testenv:build]
skip_install=false
skipsdist=true
basepython = python3.8
basepython = python3.12
commands =
python -m irc3._parse_rfc
python -m irc3._gen_doc
Expand Down

0 comments on commit a8eb629

Please sign in to comment.