def test__validate_user_class(self, app, user_class): """ This test verifies that the _validate_user_class method properly checks the user_class that Praetorian will use for required attributes """ with pytest.raises(PraetorianError) as err_info: Praetorian._validate_user_class(NoLookupUser) assert "must have a lookup class method" in err_info.value.message with pytest.raises(PraetorianError) as err_info: Praetorian._validate_user_class(NoIdentifyUser) assert "must have an identify class method" in err_info.value.message assert Praetorian._validate_user_class(user_class)
def test__validate_user_class__skips_rolenames_check_if_roles_are_disabled( self, app, user_class, ): class NoRolenamesUser: identity = 0 password = '' @classmethod def identify(cls, id): pass @classmethod def lookup(cls, username): pass app.config['PRAETORIAN_ROLES_DISABLED'] = True guard = Praetorian(app, user_class) assert guard._validate_user_class(NoRolenamesUser)