def test_email(self): email = fields.Email(default="*****@*****.**") self.assertEqual(email.default, "*****@*****.**") email.validate("*****@*****.**") with self.assertRaises(ValidationError): email.validate("test")
class Student(Base): ID = fields.Integer() name = fields.String() email = fields.Email() tel = fields.Tel() web = fields.URL() birthday = fields.Date()
class Wallet(Base): ID = fields.Integer(required=True) origin = fields.Typed(dict, default=dict) addresses = fields.Factory(Address) key = fields.Bytes() email = fields.Email() url = fields.URL(required=False, allow_empty=True) data = fields.Json(allow_empty=False)
class Certbot(Base): DEFAULT_NAME = "certbot" DEFAULT_LOGS_DIR = j.sals.fs.join_paths(j.core.dirs.LOGDIR, DEFAULT_NAME) DEFAULT_CONFIG_DIR = j.sals.fs.join_paths(j.core.dirs.CFGDIR, DEFAULT_NAME) DEFAULT_WORK_DIR = j.sals.fs.join_paths(j.core.dirs.VARDIR, DEFAULT_NAME) # the following options match the certbot command arguments domain = fields.String(required=True) non_interactive = fields.Boolean(default=True) agree_tos = fields.Boolean(default=True) logs_dir = fields.String(default=DEFAULT_LOGS_DIR) config_dir = fields.String(default=DEFAULT_CONFIG_DIR) work_dir = fields.String(default=DEFAULT_WORK_DIR) email = fields.Email() server = fields.URL() eab_kid = fields.String() eab_hmac_key = fields.String() # for existing certificates key_path = fields.String() cert_path = fields.String() fullchain_path = fields.String() @property def run_cmd(self): args = [self.DEFAULT_NAME] for name, value in self.to_dict().items(): if name.endswith("_"): continue if value: # append only if the field has a value name = name.replace("_", "-") args.append(f"--{name}") # append the value itself only if it's a boolean value # boolean options are set by adding name only if not isinstance(value, bool): args.append(value) return args @property def install_cmd(self): # replace "certbot" with "certbot install" cmd = self.run_cmd cmd.insert(1, "install") return cmd @property def renew_cmd(self): # replace "certbot" with "certbot install" renew_certbot = Certbot(work_dir=self.work_dir, config_dir=self.config_dir, logs_dir=self.logs_dir, domain="") cmd = renew_certbot.run_cmd cmd.insert(1, "renew") return cmd
class LetsencryptCertbot(NginxCertbot): """ default installation is for let's encrypt (manual plugin), no need for other options currently, we support only email """ # change required value to True here email = fields.Email(required=True)
class Farm(Base): id = fields.Integer() threebot_id = fields.Integer() iyo_organization = fields.String(default="") name = fields.String(default="") wallet_addresses = fields.List(fields.Object(WalletAddress)) location = fields.Object(Location) email = fields.Email() resource_prices = fields.List(fields.Object(ResourceUnitPrice)) prefix_zero = fields.IPRange() def __str__(self): return " - ".join([x for x in [self.name, str(self.location)] if x])
class Farm(Base): id = fields.Integer() threebot_id = fields.Integer() iyo_organization = fields.String(default="") name = fields.String(default="") wallet_addresses = fields.List(fields.Object(WalletAddress)) location = fields.Object(Location) email = fields.Email() resource_prices = fields.List(fields.Object(ResourceUnitPrice)) prefix_zero = fields.IPRange() ipaddresses = fields.List(fields.Object(FarmerIP)) enable_custom_pricing = fields.Boolean(default=False) farm_cloudunits_price = fields.Object(CloudUnitMonthPrice) is_grid3_compliant = fields.Boolean(default=False) def __str__(self): return " - ".join([x for x in [self.name, str(self.location)] if x])
class CustomCertbot(NginxCertbot): # change email and server required value to True here email = fields.Email(required=True) server = fields.URL(required=True)