|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
| 14 | + |
| 15 | +import synapse.app.homeserver |
14 | 16 | from synapse.config import ConfigError
|
15 | 17 | from synapse.config.homeserver import HomeServerConfig
|
16 | 18 |
|
17 |
| -from tests.unittest import TestCase |
| 19 | +from tests.config.utils import ConfigFileTestCase |
18 | 20 | from tests.utils import default_config
|
19 | 21 |
|
20 | 22 |
|
21 |
| -class RegistrationConfigTestCase(TestCase): |
| 23 | +class RegistrationConfigTestCase(ConfigFileTestCase): |
22 | 24 | def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self):
|
23 | 25 | """
|
24 | 26 | session_lifetime should logically be larger than, or at least as large as,
|
@@ -76,3 +78,19 @@ def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self):
|
76 | 78 | HomeServerConfig().parse_config_dict(
|
77 | 79 | {"session_lifetime": "31m", "refresh_token_lifetime": "31m", **config_dict}
|
78 | 80 | )
|
| 81 | + |
| 82 | + def test_refuse_to_start_if_open_registration_and_no_verification(self): |
| 83 | + self.generate_config() |
| 84 | + self.add_lines_to_config( |
| 85 | + [ |
| 86 | + " ", |
| 87 | + "enable_registration: true", |
| 88 | + "registrations_require_3pid: []", |
| 89 | + "enable_registration_captcha: false", |
| 90 | + "registration_requires_token: false", |
| 91 | + ] |
| 92 | + ) |
| 93 | + |
| 94 | + # Test that allowing open registration without verification raises an error |
| 95 | + with self.assertRaises(ConfigError): |
| 96 | + synapse.app.homeserver.setup(["-c", self.config_file]) |
0 commit comments