Ejemplo n.º 1
0
def test_found_both_certificates(candidate_certificates_fixture):
    # Given two candidate certificates that match the leaf and intermediate OIDs
    candidate_certificates = candidate_certificates_fixture

    # When the leaf and intermediate certifcates are extracted from the list of candidates
    leaf_cert, intermediate_cert = applepay_utils.get_leaf_and_intermediate_certs(
        candidate_certificates)

    # Then a leaf and intermediate certificate are found
    assert leaf_cert
    assert intermediate_cert
Ejemplo n.º 2
0
def test_missing_both_certificates(candidate_certificates_fixture):
    # Given no certificates
    candidate_certificates = []

    # When the leaf and intermediate certifcates are extracted from the list of candidates
    leaf_cert, intermediate_cert = applepay_utils.get_leaf_and_intermediate_certs(
        candidate_certificates)

    # Then not leaf certifice is found
    assert not leaf_cert

    # Then no intermediate certificate is found
    assert not intermediate_cert
Ejemplo n.º 3
0
def test_missing_intermediate_certificate(candidate_certificates_fixture):
    # Given only one candidate certificate that matches the leaf OID
    candidate_certificates = candidate_certificates_fixture[:1]

    # When the leaf and intermediate certifcates are extracted from the list of candidates
    leaf_cert, intermediate_cert = applepay_utils.get_leaf_and_intermediate_certs(
        candidate_certificates)

    # Then a leaf certifice is found
    assert leaf_cert

    # Then no intermediate certificate is found
    assert not intermediate_cert
Ejemplo n.º 4
0
def test_no_matching_intermediate_certificate(candidate_certificates_fixture):
    # Given two candidate certificates where the leaf cert matches the OID
    # but the intermediate does not.  This is accomplished by removing the last extension which is
    # the intermediate cert OID extension.
    candidate_certificates = copy.deepcopy(
        candidate_certificates_fixture
    )  # copy the fixture since we are modifying it
    i = len(
        candidate_certificates[1].chosen['tbs_certificate']['extensions']) - 1
    del candidate_certificates[1].chosen['tbs_certificate']['extensions'][i]

    # When the leaf and intermediate certifcates are extracted from the list of candidates
    leaf_cert, intermediate_cert = applepay_utils.get_leaf_and_intermediate_certs(
        candidate_certificates)

    # Then the leaf certifice is found
    assert leaf_cert

    # Then no intermediate certificate is found
    assert not intermediate_cert
Ejemplo n.º 5
0
def certificates_fixture(candidate_certificates_fixture):
    """Returns a tuple of valid der-encoded root, intermeidate
    and leaf certificates"""
    return applepay_utils.get_leaf_and_intermediate_certs(
        candidate_certificates_fixture)