| 53 | |
| 54 | |
| 55 | class _SingleResponse: |
| 56 | def __init__( |
| 57 | self, |
| 58 | resp: tuple[x509.Certificate, x509.Certificate] | None, |
| 59 | resp_hash: tuple[bytes, bytes, int] | None, |
| 60 | algorithm: hashes.HashAlgorithm, |
| 61 | cert_status: OCSPCertStatus, |
| 62 | this_update: datetime.datetime, |
| 63 | next_update: datetime.datetime | None, |
| 64 | revocation_time: datetime.datetime | None, |
| 65 | revocation_reason: x509.ReasonFlags | None, |
| 66 | ): |
| 67 | _verify_algorithm(algorithm) |
| 68 | if not isinstance(this_update, datetime.datetime): |
| 69 | raise TypeError("this_update must be a datetime object") |
| 70 | if next_update is not None and not isinstance( |
| 71 | next_update, datetime.datetime |
| 72 | ): |
| 73 | raise TypeError("next_update must be a datetime object or None") |
| 74 | |
| 75 | self._resp = resp |
| 76 | self._resp_hash = resp_hash |
| 77 | self._algorithm = algorithm |
| 78 | self._this_update = this_update |
| 79 | self._next_update = next_update |
| 80 | |
| 81 | if not isinstance(cert_status, OCSPCertStatus): |
| 82 | raise TypeError( |
| 83 | "cert_status must be an item from the OCSPCertStatus enum" |
| 84 | ) |
| 85 | if cert_status is not OCSPCertStatus.REVOKED: |
| 86 | if revocation_time is not None: |
| 87 | raise ValueError( |
| 88 | "revocation_time can only be provided if the certificate " |
| 89 | "is revoked" |
| 90 | ) |
| 91 | if revocation_reason is not None: |
| 92 | raise ValueError( |
| 93 | "revocation_reason can only be provided if the certificate" |
| 94 | " is revoked" |
| 95 | ) |
| 96 | else: |
| 97 | if not isinstance(revocation_time, datetime.datetime): |
| 98 | raise TypeError("revocation_time must be a datetime object") |
| 99 | |
| 100 | if revocation_reason is not None and not isinstance( |
| 101 | revocation_reason, x509.ReasonFlags |
| 102 | ): |
| 103 | raise TypeError( |
| 104 | "revocation_reason must be an item from the ReasonFlags " |
| 105 | "enum or None" |
| 106 | ) |
| 107 | |
| 108 | self._cert_status = cert_status |
| 109 | self._revocation_time = revocation_time |
| 110 | self._revocation_reason = revocation_reason |
| 111 | |
| 112 |
no outgoing calls
no test coverage detected