'Test the REGISTRATION_EMAIL_PATTERNS_ALLOWED setting, a feature which
can be used to only allow people register if their email matches a
against a whitelist of regexs.'

@override_settings(REGISTRATION_EMAIL_PATTERNS_ALLOWED=['.*@edx.org', '^.*@(.*\\.)?example\\.com$', '^(^\\w+\\.\\w+)@school.tld$'])
@ddt.data(('bob@we-are.bad', False), ('bob@edx.org.we-are.bad', False), ('staff@edx.org', True), ('student@example.com', True), ('student@sub.example.com', True), ('mr.teacher@school.tld', True), ('student1234@school.tld', False))
@ddt.unpack
def test_email_pattern_requirements(self, email, expect_success):

    params = dict(self.minimal_params)
    params['email'] = email
    if expect_success:
        self.assert_success(params)
    else:
        self.assert_error(params, 'email', 'Unauthorized    email    address.')
