reenable password tests

This commit is contained in:
Shivaram Lingamneni 2018-12-28 13:42:26 -05:00
parent b42bb1ade1
commit 6497f97951
2 changed files with 16 additions and 5 deletions

View File

@ -2,6 +2,8 @@ import os
import time
import subprocess
import bcrypt
from irctest.basecontrollers import NotImplementedByController
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
@ -17,8 +19,12 @@ server:
check-ident: false
password: {hashed_password}
max-sendq: 16k
allow-plaintext-resume: true
connection-limits:
cidr-len-ipv4: 24
cidr-len-ipv6: 120
@ -77,6 +83,11 @@ history:
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):
software_name = 'Oragono'
supported_sasl_mechanisms = {
@ -84,8 +95,6 @@ class OragonoController(BaseServerController, DirectoryBasedController):
}
def create_config(self):
super().create_config()
with self.open_file('ircd.yaml'):
pass
def kill_proc(self):
self.proc.kill()
@ -96,9 +105,6 @@ class OragonoController(BaseServerController, DirectoryBasedController):
if valid_metadata_keys or invalid_metadata_keys:
raise NotImplementedByController(
'Defining valid and invalid METADATA keys.')
if password is not None:
#TODO(dan): fix dis
raise NotImplementedByController('PASS command')
self.create_config()
tls_config = ""
if ssl:
@ -111,12 +117,16 @@ class OragonoController(BaseServerController, DirectoryBasedController):
)
assert self.proc is None
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:
fd.write(TEMPLATE_CONFIG.format(
directory=self.directory,
hostname=hostname,
port=port,
tls=tls_config,
hashed_password=hashed_password,
))
subprocess.call(['oragono', 'initdb',
'--conf', os.path.join(self.directory, 'server.yml'), '--quiet'])

View File

@ -2,3 +2,4 @@ limnoria > 2012.08.04 # Needs MultipleReplacer, from 1a64f105
psutil >= 3.1.0 # Fixes #640
ecdsa
pyxmpp2_scram
bcrypt