mirror of
https://github.com/progval/irctest.git
synced 2025-04-07 07:49:52 +00:00
reenable password tests
This commit is contained in:
@ -2,6 +2,8 @@ import os
|
|||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
import bcrypt
|
||||||
|
|
||||||
from irctest.basecontrollers import NotImplementedByController
|
from irctest.basecontrollers import NotImplementedByController
|
||||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||||
|
|
||||||
@ -17,8 +19,12 @@ server:
|
|||||||
|
|
||||||
check-ident: false
|
check-ident: false
|
||||||
|
|
||||||
|
password: {hashed_password}
|
||||||
|
|
||||||
max-sendq: 16k
|
max-sendq: 16k
|
||||||
|
|
||||||
|
allow-plaintext-resume: true
|
||||||
|
|
||||||
connection-limits:
|
connection-limits:
|
||||||
cidr-len-ipv4: 24
|
cidr-len-ipv4: 24
|
||||||
cidr-len-ipv6: 120
|
cidr-len-ipv6: 120
|
||||||
@ -77,6 +83,11 @@ history:
|
|||||||
client-length: 128
|
client-length: 128
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def hash_password(password):
|
||||||
|
if isinstance(password, str):
|
||||||
|
password = password.encode('utf-8')
|
||||||
|
return bcrypt.hashpw(password, bcrypt.gensalt(4)).decode('utf-8')
|
||||||
|
|
||||||
class OragonoController(BaseServerController, DirectoryBasedController):
|
class OragonoController(BaseServerController, DirectoryBasedController):
|
||||||
software_name = 'Oragono'
|
software_name = 'Oragono'
|
||||||
supported_sasl_mechanisms = {
|
supported_sasl_mechanisms = {
|
||||||
@ -84,8 +95,6 @@ class OragonoController(BaseServerController, DirectoryBasedController):
|
|||||||
}
|
}
|
||||||
def create_config(self):
|
def create_config(self):
|
||||||
super().create_config()
|
super().create_config()
|
||||||
with self.open_file('ircd.yaml'):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def kill_proc(self):
|
def kill_proc(self):
|
||||||
self.proc.kill()
|
self.proc.kill()
|
||||||
@ -96,9 +105,6 @@ class OragonoController(BaseServerController, DirectoryBasedController):
|
|||||||
if valid_metadata_keys or invalid_metadata_keys:
|
if valid_metadata_keys or invalid_metadata_keys:
|
||||||
raise NotImplementedByController(
|
raise NotImplementedByController(
|
||||||
'Defining valid and invalid METADATA keys.')
|
'Defining valid and invalid METADATA keys.')
|
||||||
if password is not None:
|
|
||||||
#TODO(dan): fix dis
|
|
||||||
raise NotImplementedByController('PASS command')
|
|
||||||
self.create_config()
|
self.create_config()
|
||||||
tls_config = ""
|
tls_config = ""
|
||||||
if ssl:
|
if ssl:
|
||||||
@ -111,12 +117,16 @@ class OragonoController(BaseServerController, DirectoryBasedController):
|
|||||||
)
|
)
|
||||||
assert self.proc is None
|
assert self.proc is None
|
||||||
self.port = port
|
self.port = port
|
||||||
|
hashed_password = '' # oragono will understand this as 'no password required'
|
||||||
|
if password is not None:
|
||||||
|
hashed_password = hash_password(password)
|
||||||
with self.open_file('server.yml') as fd:
|
with self.open_file('server.yml') as fd:
|
||||||
fd.write(TEMPLATE_CONFIG.format(
|
fd.write(TEMPLATE_CONFIG.format(
|
||||||
directory=self.directory,
|
directory=self.directory,
|
||||||
hostname=hostname,
|
hostname=hostname,
|
||||||
port=port,
|
port=port,
|
||||||
tls=tls_config,
|
tls=tls_config,
|
||||||
|
hashed_password=hashed_password,
|
||||||
))
|
))
|
||||||
subprocess.call(['oragono', 'initdb',
|
subprocess.call(['oragono', 'initdb',
|
||||||
'--conf', os.path.join(self.directory, 'server.yml'), '--quiet'])
|
'--conf', os.path.join(self.directory, 'server.yml'), '--quiet'])
|
||||||
|
@ -2,3 +2,4 @@ limnoria > 2012.08.04 # Needs MultipleReplacer, from 1a64f105
|
|||||||
psutil >= 3.1.0 # Fixes #640
|
psutil >= 3.1.0 # Fixes #640
|
||||||
ecdsa
|
ecdsa
|
||||||
pyxmpp2_scram
|
pyxmpp2_scram
|
||||||
|
bcrypt
|
||||||
|
Reference in New Issue
Block a user