def test(self, dummy_node): blacklist = set(['admin', 'root', 'postmaster']) # Should not raise for valid usernames schemas.unblacklisted_username(dummy_node, "john", blacklist) schemas.unblacklisted_username(dummy_node, "Abigail", blacklist) # Should raise for usernames in blacklist pytest.raises(colander.Invalid, schemas.unblacklisted_username, dummy_node, "admin", blacklist) # Should raise for case variants of usernames in blacklist pytest.raises(colander.Invalid, schemas.unblacklisted_username, dummy_node, "PostMaster", blacklist)
def test_unblacklisted_username(config): request = DummyRequest() node = colander.SchemaNode(colander.String()).bind(request=request) blacklist = set(['admin', 'root', 'postmaster']) # Should not raise for valid usernames schemas.unblacklisted_username(node, "john", blacklist) schemas.unblacklisted_username(node, "Abigail", blacklist) # Should raise for usernames in blacklist pytest.raises(colander.Invalid, schemas.unblacklisted_username, node, "admin", blacklist) # Should raise for case variants of usernames in blacklist pytest.raises(colander.Invalid, schemas.unblacklisted_username, node, "PostMaster", blacklist)