示例#1
0
 def verify_and_load(
     cls,
     *args,
     expected_id: Optional[EntryID] = None,
     expected_version: Optional[int] = None,
     **kwargs,
 ) -> "BaseManifest":
     data = super().verify_and_load(*args, **kwargs)
     if expected_id is not None and data.id != expected_id:
         raise DataValidationError(
             f"Invalid entry ID: expected `{expected_id}`, got `{data.id}`")
     if expected_version is not None and data.version != expected_version:
         raise DataValidationError(
             f"Invalid version: expected `{expected_version}`, got `{data.version}`"
         )
     return data
示例#2
0
 def verify_and_load(
     cls,
     *args,
     expected_user: Optional[UserID] = None,
     expected_human_handle: Optional[HumanHandle] = None,
     **kwargs,
 ) -> "UserCertificateContent":
     data = super().verify_and_load(*args, **kwargs)
     if expected_user is not None and data.user_id != expected_user:
         raise DataValidationError(
             f"Invalid user ID: expected `{expected_user}`, got `{data.user_id}`"
         )
     if expected_human_handle is not None and data.human_handle != expected_human_handle:
         raise DataValidationError(
             f"Invalid human handle: expected `{expected_human_handle}`, got `{data.human_handle}`"
         )
     return data
示例#3
0
 def verify_and_load(
     cls: Type[BaseManifestTypeVar],
     *args: object,
     expected_id: Optional[EntryID] = None,
     expected_version: Optional[int] = None,
     **kwargs: object,
 ) -> BaseManifestTypeVar:
     data = super().verify_and_load(*args,
                                    **kwargs)  # type: ignore[arg-type]
     if expected_id is not None and data.id != expected_id:
         raise DataValidationError(
             f"Invalid entry ID: expected `{expected_id}`, got `{data.id}`")
     if expected_version is not None and data.version != expected_version:
         raise DataValidationError(
             f"Invalid version: expected `{expected_version}`, got `{data.version}`"
         )
     return data
示例#4
0
 def verify_and_load(
     cls, *args, expected_user: Optional[UserID] = None, **kwargs
 ) -> "RevokedUserCertificateContent":
     data = super().verify_and_load(*args, **kwargs)
     if expected_user is not None and data.user_id != expected_user:
         raise DataValidationError(
             f"Invalid user ID: expected `{expected_user}`, got `{data.user_id}`"
         )
     return data
示例#5
0
 def verify_and_load(cls,
                     *args,
                     expected_device: Optional[DeviceID] = None,
                     **kwargs) -> "DeviceCertificateContent":
     data = super().verify_and_load(*args, **kwargs)
     if expected_device is not None and data.device_id != expected_device:
         raise DataValidationError(
             f"Invalid device ID: expected `{expected_device}`, got `{data.device_id}`"
         )
     return data
示例#6
0
 def verify_and_load(cls,
                     *args,
                     expected_parent: Optional[EntryID] = None,
                     **kwargs) -> BaseAPISignedData:
     data = super().verify_and_load(*args, **kwargs)
     if expected_parent is not None and data.parent != expected_parent:
         raise DataValidationError(
             f"Invalid parent ID: expected `{expected_parent}`, got `{data.parent}`"
         )
     return data
示例#7
0
 def verify_and_load(
     cls,
     *args,
     expected_id: Optional[EntryID] = None,
     expected_version: Optional[int] = None,
     **kwargs,
 ) -> "Manifest":
     data = super().verify_and_load(*args, **kwargs)
     if data.author is None and data.version != 0:
         raise DataValidationError(
             "Manifest cannot be signed by root verify key")
     if expected_id is not None and data.id != expected_id:
         raise DataValidationError(
             f"Invalid entry ID: expected `{expected_id}`, got `{data.id}`")
     if expected_version is not None and data.version != expected_version:
         raise DataValidationError(
             f"Invalid version: expected `{expected_version}`, got `{data.version}`"
         )
     return data
示例#8
0
 def verify_and_load(
     cls,
     *args,
     expected_realm: Optional[UUID] = None,
     expected_user: Optional[UserID] = None,
     expected_role: Optional[RealmRole] = None,
     **kwargs,
 ) -> "RealmRoleCertificateContent":
     data = super().verify_and_load(*args, **kwargs)
     if expected_user is not None and data.user_id != expected_user:
         raise DataValidationError(
             f"Invalid user ID: expected `{expected_user}`, got `{data.user_id}`"
         )
     if expected_realm is not None and data.realm_id != expected_realm:
         raise DataValidationError(
             f"Invalid realm ID: expected `{expected_realm}`, got `{data.realm_id}`"
         )
     if expected_role is not None and data.role != expected_role:
         raise DataValidationError(
             f"Invalid role: expected `{expected_role}`, got `{data.role}`")
     return data
示例#9
0
 def verify_and_load(  # type: ignore[override]
     cls: Type["FileManifest"],
     *args: object,
     expected_parent: Optional[EntryID] = None,
     **kwargs: object,
 ) -> "FileManifest":
     data = super().verify_and_load(*args,
                                    **kwargs)  # type: ignore[arg-type]
     if expected_parent is not None and data.parent != expected_parent:
         raise DataValidationError(
             f"Invalid parent ID: expected `{expected_parent}`, got `{data.parent}`"
         )
     return data