Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(3)  |  Derive(0)  |  Import(1)
Verify whether *cert* is valid for *some* ID within *service_ids*.

:type cert_patters: List of service ID patterns usually extracted
    from a certificate.
:type service_ids: `list` of service ID classes like :class:`DNS_ID`.

:raises URIMismatchError: If at least one :class:`URIPattern` and at least
    one :class:`URI_ID` are specified but none of them match.

:raises SRVMismatchError: If at least one :class:`SRVPattern` and at least(more...)

        def verify_service_identity(cert_patterns, service_ids):
    """
    Verify whether *cert* is valid for *some* ID within *service_ids*.

    :type cert_patters: List of service ID patterns usually extracted
        from a certificate.
    :type service_ids: `list` of service ID classes like :class:`DNS_ID`.

    :raises URIMismatchError: If at least one :class:`URIPattern` and at least
        one :class:`URI_ID` are specified but none of them match.

    :raises SRVMismatchError: If at least one :class:`SRVPattern` and at least
        one :class:`SRV_ID` are specified but none of them match.

    :raises URIMismatchError: If at least one :class:`URIPattern` and at least
        one :class:`URI_ID` are specified but none of them match.

    :raises VerificationError: If no matches are found at all.

    :return: A list of tuples of matching ``(certificate_pattern,
        service_id)``.
    """
    matched_ids = _find_matches(cert_patterns, service_ids)
    if not matched_ids:
        raise VerificationError(
            "No service reference ID could be validated against certificate."
        )

    for sid in service_ids:
        if (
            _contains_instance_of(cert_patterns, sid.pattern_class)
            and not _contains_instance_of((i for (p, i) in matched_ids),
                                          sid.__class__)
        ):
            raise sid.exc_on_mismatch

    return matched_ids
        


src/s/e/service_identity-0.2/tests/test_common.py   service_identity(Download)
import service_identity._common
 
from service_identity._common import (
    CertificateError,
    DNSMismatchError,
    def test_vsi_dns_id_success(self):
        """
        Return pairs of certificate ids and service ids on matches.
        """
        rv = verify_service_identity(extract_ids(CERT_DNS_ONLY),
        i = SRV_ID(u("_mail.example.net"))
        rv = verify_service_identity(
            [DNSPattern(b"example.net"), p],
            [DNS_ID(u("example.net")), i],
        )
        uri_id = URI_ID(u("sip:example.net"))
        rv = verify_service_identity(
            [DNSPattern(b"example.net"), p],
            [DNS_ID(u("example.net")), uri_id],
        )