def test_register_form_password(self): """Test RegisterForm password.""" from invenio.modules.accounts.forms import RegisterForm not_valid_pwd = "x" * (self.min_len - 1) valid_pwd = "x" * self.min_len form = RegisterForm( email="*****@*****.**", nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is True form = RegisterForm( email="*****@*****.**", nickname="testvalidnickname", password=not_valid_pwd, password2=not_valid_pwd ) assert form.validate() is False form = RegisterForm( email="*****@*****.**", nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd+"different" ) assert form.validate() is False
def test_register_form_nickname(self): """Test RegisterForm nickname.""" from invenio.modules.accounts.forms import RegisterForm valid_pwd = "x" * self.min_len form = RegisterForm( email="*****@*****.**", nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is True form = RegisterForm( email="*****@*****.**", nickname="", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False form = RegisterForm( email="*****@*****.**", nickname="notvalid@user", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False form = RegisterForm( email="*****@*****.**", nickname="notvalid,user", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False form = RegisterForm( email="*****@*****.**", nickname=" testnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False form = RegisterForm( email="*****@*****.**", nickname="testnickname ", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False form = RegisterForm( email="*****@*****.**", nickname="guest", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False
def test_register_form_email(self): """Test RegisterForm email.""" from invenio.modules.accounts.forms import RegisterForm from invenio.base.globals import cfg cfg['CFG_ACCESS_CONTROL_LIMIT_REGISTRATION_TO_DOMAIN'] = '' valid_pwd = "x" * self.min_len form = RegisterForm( email="*****@*****.**", nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is True form = RegisterForm( email="", nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False form = RegisterForm( email=self.email, nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False form = RegisterForm( email="email@fuu", nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False form = RegisterForm( email="email.fuu", nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False cfg['CFG_ACCESS_CONTROL_LIMIT_REGISTRATION_TO_DOMAIN'] = 'fuu.it' form = RegisterForm( email="*****@*****.**", nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is False email = "fu@" + cfg['CFG_ACCESS_CONTROL_LIMIT_REGISTRATION_TO_DOMAIN'] form = RegisterForm( email=email, nickname="testvalidnickname", password=valid_pwd, password2=valid_pwd ) assert form.validate() is True