Skip to content

Commit

Permalink
coretasks: fix SASL EXTERNAL without password set
Browse files Browse the repository at this point in the history
  • Loading branch information
half-duplex committed Nov 12, 2023
1 parent 51300a1 commit cd904a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sopel/coretasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ def _handle_sasl_capability(
)
return plugin.CapabilityNegotiation.ERROR

# Check SASL configuration (password is required)
# Check SASL configuration (password is required for PLAIN/SCRAM)
password, mech = _get_sasl_pass_and_mech(bot)
if not password:
if mech != "EXTERNAL" and not password:
raise config.ConfigurationError(
'SASL authentication required but no password available; '
'please check your configuration file.',
Expand Down
20 changes: 20 additions & 0 deletions test/coretasks/test_coretasks_sasl.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,26 @@ def test_sasl_plain_no_password(
), 'No password is a configuration error and the bot must quit.'


# https://github.com/sopel-irc/sopel/issues/2560
def test_sasl_external_no_password(
botfactory: BotFactory,
configfactory: ConfigFactory,
) -> None:
tmpconfig = configfactory("conf.ini", TMP_CONFIG_SASL_NO_PASSWORD)
mockbot = botfactory.preloaded(tmpconfig, preloads=["coretasks"])
mockbot.settings.core.auth_target = "EXTERNAL"
mockbot.backend.connected = True

# connect and capability negotiation
mockbot.on_connect()
mockbot.on_message(":irc.example.com CAP * LS :sasl=PLAIN,EXTERNAL")
n = len(mockbot.backend.message_sent)
mockbot.on_message(":irc.example.com CAP * ACK :sasl")
assert mockbot.backend.message_sent[n:] == rawlist(
"AUTHENTICATE EXTERNAL"
), "SASL EXTERNAL did not continue without a password configured."


def test_sasl_plain_bad_password(botfactory: BotFactory, tmpconfig) -> None:
mockbot = botfactory.preloaded(tmpconfig, preloads=['coretasks'])
mockbot.backend.connected = True
Expand Down

0 comments on commit cd904a9

Please sign in to comment.