Exemple #1
0
def test_api_update_ed_signed():
    ''' update ed_signed via API
        requires PVZDweb runnning on dev database (no fixture yet for this)
    '''
    fn = Path(ed_path(22, dir=fixture_testdata_basedir()))
    with fn.open('rb') as fd:
        django_file = django.core.files.File(fd)
        mds = MDstatement()
        count = MDstatement.objects.filter(
            entityID='https://idp22.identinetics.com/idp.xml',
            statusgroup=STATUSGROUP_FRONTEND)
        if count:
            mds = MDstatement.objects.get(
                entityID='https://idp22.identinetics.com/idp.xml',
                statusgroup=STATUSGROUP_FRONTEND)
            mds.ed_signed = ''
            mds.save()
        else:
            django_file = django.core.files.File(fd)
            mds = MDstatement()
            mds.ed_file_upload.save(fn.name, django_file, save=True)
        update_id = mds.id

    client = coreapi.Client()
    schema = client.get("http://localhost:8000/docs/")

    action = ["mdstatement", "partial_update"]
    params = {
        "id": update_id,
        "admin_note": "Updated ed_signed from REST API",
        "ed_signed": fn.read_text(),
    }
    result = client.action(schema, action, params=params)
Exemple #2
0
def test_remove_enveloped_signature(ed10):
    ed10.remove_enveloped_signature()
    fn10_edit = tempfile.NamedTemporaryFile(mode='w',
                                            prefix='test10_edit',
                                            suffix='.xml').name
    ed10.write(fn10_edit)
    with open(ed_path(17)) as fd17:
        with open(fn10_edit) as fn10_edit:
            assert_equal(fd17.read(), fn10_edit.read(), fn=fn10_edit.name)
Exemple #3
0
def test_set_registrationinfo(ed1):
    # make expected equal to actual with fake registrationInstant = "1900-01-01T00:00:00Z"
    SAMLEntityDescriptorPVP.set_registrationinfo(
        ed1.ed.tree,
        SAML_MDPRI_REGISTRATIONAUTHORITY,
        fixed_date_for_unittest=True)
    fn1_edit = tempfile.NamedTemporaryFile(mode='w',
                                           prefix='test1_edit',
                                           suffix='xml').name
    ed1.write(fn1_edit)
    with open(ed_path(16)) as fd2:
        with open(fn1_edit) as fd1:
            assert_equal(fd2.read(), fd1.read())
    os.unlink(fn1_edit)
Exemple #4
0
def test_insert_and_update(config_file, expected_result_fn, ed_path_no):
    fn = Path(ed_path(ed_path_no, dir=fixture_testdata_basedir()))
    with fn.open('rb') as fd:
        django_file = django.core.files.File(fd)
        mds = MDstatement()
        mds.ed_file_upload.save(fn.name, django_file, save=True)
    expected_result = fixture_result(expected_result_fn)
    assert_equal(expected_result, MDstatement.objects.all()[0].serialize_json(), ed_path_no=ed_path_no)
    if ed_path_no < 4:
        mds = MDstatement.objects.get(id=ed_path_no)
        mds.admin_note = f"some text fromt test {ed_path_no}"
        mds.save()
        mds = MDstatement.objects.get(id=ed_path_no)
        assert mds.admin_note == f"some text fromt test {ed_path_no}"
Exemple #5
0
def test_create_delete():
    delete_requ = SAMLEntityDescriptorPVP.create_delete(
        'https://idp4.example.com/idp.xml')
    with open(ed_path(4)) as fd:
        assert_equal(fd.read(), delete_requ)
Exemple #6
0
def test_checkCerts13(policydict1):
    with pytest.raises(MultipleEntitiesNotAllowed):
        _ = SAMLEntityDescriptorPVP(ed_path(13), policydict1)
Exemple #7
0
def test_validate_xsd8(policydict1):
    with pytest.raises(lxml.etree.XMLSyntaxError):
        _ = SAMLEntityDescriptorPVP(ed_path(8), policydict1)
Exemple #8
0
def ed3():
    return SAMLEntityDescriptor(ed_path=ed_path(3))
Exemple #9
0
def result20():
    with open(ed_path(20)) as fd:
        return fd.read()
Exemple #10
0
def result19():
    with open(ed_path(19)) as fd:
        return fd.read()
Exemple #11
0
def ed_path06(testdata_basedir):
    return ed_path(6, dir=opj(testdata_basedir, 'saml'))
def ed_path_testin(file_index: int):
    return ed_path(file_index)