Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Check that the disable_registration config key is handled correctly #595

Merged
merged 1 commit into from
Feb 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/config/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ def test_load_succeeds_if_macaroon_secret_key_missing(self):
config2 = HomeServerConfig.load_config("", ["-c", self.file])
self.assertEqual(config1.macaroon_secret_key, config2.macaroon_secret_key)

def test_disable_registration(self):
self.generate_config()
self.add_lines_to_config([
"enable_registration: true",
"disable_registration: true",
])
# Check that disable_registration clobbers enable_registration.
config = HomeServerConfig.load_config("", ["-c", self.file])
self.assertFalse(config.enable_registration)

# Check that either config value is clobbered by the command line.
config = HomeServerConfig.load_config("", [
"-c", self.file, "--enable-registration"
])
self.assertTrue(config.enable_registration)

def generate_config(self):
HomeServerConfig.load_config("", [
"--generate-config",
Expand All @@ -76,3 +92,8 @@ def generate_config_and_remove_lines_containing(self, needle):
contents = [l for l in contents if needle not in l]
with open(self.file, "w") as f:
f.write("".join(contents))

def add_lines_to_config(self, lines):
with open(self.file, "a") as f:
for line in lines:
f.write(line + "\n")