コード例 #1
0
def signed_attributes_fixture(signed_data_fixture, certificates_fixture):
    leaf_cert, _ = certificates_fixture
    signer_info = applepay_utils.get_first_from_iterable(
        filter_func=lambda signer: signer['sid'].chosen[
            'serial_number'].native == leaf_cert.serial_number,
        iterable=signed_data_fixture['signer_infos'])
    return signer_info['signed_attrs']
コード例 #2
0
def test_get_first_from_iterable_does_not_match():
    # Given an iterable
    i = range(5)

    # Given a filter function which will not find any matches
    def f(x):
        return False

    # When we get the first match get_first_from_iterableom the iterable
    first_match = applepay_utils.get_first_from_iterable(f, i)

    # Then the returned match is None
    assert first_match is None
コード例 #3
0
def test_get_first_from_iterable_finds_first_of_many_matches():
    # Given an iterable
    i = range(5)

    # Given a filter function which will find more than 1 match
    def f(x):
        return x in range(1, 5)

    # When we get the first match from the iterable
    first_match = applepay_utils.get_first_from_iterable(f, i)

    # Then the returned match is the expected value
    assert first_match == 1
コード例 #4
0
def test_get_first_from_iterable_finds_single_match():
    # Given an iterable
    i = range(5)

    # Given a filter function which will find 1 match
    def f(x):
        return x == 3

    # When we get the first match from the iterable
    first_match = applepay_utils.get_first_from_iterable(f, i)

    # Then the returned match is the expected value
    assert first_match == 3