当前位置: 首页>>代码示例>>Python>>正文


Python mdie.to_dict函数代码示例

本文整理汇总了Python中saml2.mdie.to_dict函数的典型用法代码示例。如果您正苦于以下问题:Python to_dict函数的具体用法?Python to_dict怎么用?Python to_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了to_dict函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_filter_values_req_opt_1

def test_filter_values_req_opt_1():
    r = to_dict(
        Attribute(
            name="urn:oid:2.5.4.5",
            name_format=NAME_FORMAT_URI,
            friendly_name="serialNumber",
            attribute_value=[AttributeValue(text="54321")],
        ),
        ONTS,
    )
    o = to_dict(
        Attribute(
            name="urn:oid:2.5.4.5",
            name_format=NAME_FORMAT_URI,
            friendly_name="serialNumber",
            attribute_value=[AttributeValue(text="12345"), AttributeValue(text="abcd0")],
        ),
        ONTS,
    )

    ava = {"serialNumber": ["12345", "54321"]}

    ava = filter_on_attributes(ava, [r], [o])
    assert ava.keys() == ["serialNumber"]
    assert _eq(ava["serialNumber"], ["12345", "54321"])
开发者ID:justquick,项目名称:pysaml2,代码行数:25,代码来源:test_20_assertion.py

示例2: test_filter_values_req_opt_2

def test_filter_values_req_opt_2():
    r = [
        to_dict(
            Attribute(
                friendly_name="surName",
                name="urn:oid:2.5.4.4",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
            ONTS),
        to_dict(
            Attribute(
                friendly_name="givenName",
                name="urn:oid:2.5.4.42",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
            ONTS),
        to_dict(
            Attribute(
                friendly_name="mail",
                name="urn:oid:0.9.2342.19200300.100.1.3",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
            ONTS)]
    o = [
        to_dict(
            Attribute(
                friendly_name="title",
                name="urn:oid:2.5.4.12",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
            ONTS)]

    ava = {"surname": ["Hedberg"], "givenName": ["Roland"],
           "eduPersonAffiliation": ["staff"], "uid": ["rohe0002"]}

    raises(MissingValue, "filter_on_attributes(ava, r, o)")
开发者ID:jakew1ll,项目名称:pysaml2,代码行数:32,代码来源:test_20_assertion.py

示例3: test_req_opt

def test_req_opt():
    req = [
        to_dict(
            md.RequestedAttribute(
                friendly_name="surname", name="urn:oid:2.5.4.4",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
                is_required="true"), ONTS),
        to_dict(
            md.RequestedAttribute(
                friendly_name="givenname",
                name="urn:oid:2.5.4.42",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
                is_required="true"), ONTS),
        to_dict(
            md.RequestedAttribute(
                friendly_name="edupersonaffiliation",
                name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
                is_required="true"), ONTS)]

    opt = [
        to_dict(
            md.RequestedAttribute(
                friendly_name="title",
                name="urn:oid:2.5.4.12",
                name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
                is_required="false"), ONTS)]

    policy = Policy()
    ava = {'givenname': 'Roland', 'surname': 'Hedberg',
           'uid': 'rohe0002', 'edupersonaffiliation': 'staff'}

    sp_entity_id = "urn:mace:example.com:saml:curt:sp"
    fava = policy.filter(ava, sp_entity_id, None, req, opt)
    assert fava
开发者ID:jakew1ll,项目名称:pysaml2,代码行数:35,代码来源:test_20_assertion.py

示例4: test_filter_values_req_2

def test_filter_values_req_2():
    a1 = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI, friendly_name="serialNumber"), ONTS)
    a2 = to_dict(Attribute(name="urn:oid:2.5.4.4", name_format=NAME_FORMAT_URI, friendly_name="surName"), ONTS)

    required = [a1, a2]
    ava = {"serialNumber": ["12345"], "givenName": ["Lars"]}

    raises(MissingValue, filter_on_attributes, ava, required)
开发者ID:justquick,项目名称:pysaml2,代码行数:8,代码来源:test_20_assertion.py

示例5: test_filter_on_attributes_without_friendly_name

def test_filter_on_attributes_without_friendly_name():
    ava = {"eduPersonTargetedID": "[email protected]", "eduPersonAffiliation": "test",
           "extra": "foo"}
    eptid = to_dict(
            Attribute(name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10", name_format=NAME_FORMAT_URI), ONTS)
    ep_affiliation = to_dict(
            Attribute(name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1", name_format=NAME_FORMAT_URI), ONTS)

    restricted_ava = filter_on_attributes(ava, required=[eptid], optional=[ep_affiliation],
                                          acs=ac_factory())
    assert restricted_ava == {"eduPersonTargetedID": "[email protected]",
                              "eduPersonAffiliation": "test"}
开发者ID:Lefford,项目名称:pysaml2,代码行数:12,代码来源:test_20_assertion.py

示例6: test_filter_values_req_opt_0

def test_filter_values_req_opt_0():
    r = to_dict(
        Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
                  friendly_name="serialNumber",
                  attribute_value=[AttributeValue(text="54321")]), ONTS)
    o = to_dict(
        Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
                  friendly_name="serialNumber",
                  attribute_value=[AttributeValue(text="12345")]), ONTS)

    ava = {"serialNumber": ["12345", "54321"]}

    ava = filter_on_attributes(ava, [r], [o], acs=ac_factory())
    assert list(ava.keys()) == ["serialNumber"]
    assert _eq(ava["serialNumber"], ["12345", "54321"])
开发者ID:SUNET,项目名称:pysaml2,代码行数:15,代码来源:test_20_assertion.py

示例7: test_filter_on_attributes_with_missing_required_attribute

def test_filter_on_attributes_with_missing_required_attribute():
    ava = {"extra": "foo"}
    eptid = to_dict(Attribute(
            friendly_name="eduPersonTargetedID", name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10",
            name_format=NAME_FORMAT_URI), ONTS)
    with pytest.raises(MissingValue):
        filter_on_attributes(ava, required=[eptid])
开发者ID:Lefford,项目名称:pysaml2,代码行数:7,代码来源:test_20_assertion.py

示例8: test_filter_on_attributes_with_missing_optional_attribute

def test_filter_on_attributes_with_missing_optional_attribute():
    ava = {"extra": "foo"}
    eptid = to_dict(Attribute(
        friendly_name="eduPersonTargetedID",
        name="urn:oid:1.3.6.1.4.1.5923.1.1.1.10",
        name_format=NAME_FORMAT_URI), ONTS)
    assert filter_on_attributes(ava, optional=[eptid], acs=ac_factory()) == {}
开发者ID:SUNET,项目名称:pysaml2,代码行数:7,代码来源:test_20_assertion.py

示例9: test_filter_on_attributes_with_missing_name_format

def test_filter_on_attributes_with_missing_name_format():
    ava = {"eduPersonTargetedID": "[email protected]",
           "eduPersonAffiliation": "test",
           "extra": "foo"}
    eptid = to_dict(Attribute(friendly_name="eduPersonTargetedID",
                              name="urn:myown:eptid",
                              name_format=''), ONTS)
    ava = filter_on_attributes(ava, optional=[eptid], acs=ac_factory())
    assert ava['eduPersonTargetedID'] == "[email protected]"
开发者ID:SUNET,项目名称:pysaml2,代码行数:9,代码来源:test_20_assertion.py

示例10: test_filter_values_req_4

def test_filter_values_req_4():
    a = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
                    friendly_name="serialNumber", attribute_value=[
                        AttributeValue(text="54321")]), ONTS)
    
    required = [a]
    ava = { "serialNumber": ["12345"]}
    
    raises(MissingValue, filter_on_attributes, ava, required)
开发者ID:caustin,项目名称:pysaml2,代码行数:9,代码来源:test_20_assertion.py

示例11: test_filter_on_attributes_1

def test_filter_on_attributes_1():
    a = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI, friendly_name="serialNumber"), ONTS)

    required = [a]
    ava = {"serialNumber": ["12345"], "givenName": ["Lars"]}

    ava = filter_on_attributes(ava, required)
    assert ava.keys() == ["serialNumber"]
    assert ava["serialNumber"] == ["12345"]
开发者ID:justquick,项目名称:pysaml2,代码行数:9,代码来源:test_20_assertion.py

示例12: test_filter_on_attributes_2

def test_filter_on_attributes_2():
    
    a = to_dict(Attribute(friendly_name="surName",name="urn:oid:2.5.4.4",
                          name_format=NAME_FORMAT_URI), ONTS)
    required = [a]
    ava = {"sn":["kakavas"]}

    ava = filter_on_attributes(ava,required,acs=ac_factory())
    assert list(ava.keys()) == ['sn']
    assert ava["sn"] == ["kakavas"]
开发者ID:SUNET,项目名称:pysaml2,代码行数:10,代码来源:test_20_assertion.py

示例13: test_filter_on_attributes_0

def test_filter_on_attributes_0():
    a = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
                          friendly_name="serialNumber"), ONTS)

    required = [a]
    ava = {"serialNumber": ["12345"]}

    ava = filter_on_attributes(ava, required, acs=ac_factory())
    assert list(ava.keys()) == ["serialNumber"]
    assert ava["serialNumber"] == ["12345"]
开发者ID:SUNET,项目名称:pysaml2,代码行数:10,代码来源:test_20_assertion.py

示例14: test_filter_values_req_6

def test_filter_values_req_6():
    a = to_dict(Attribute(name="urn:oid:2.5.4.5", name_format=NAME_FORMAT_URI,
                    friendly_name="serialNumber", attribute_value=[
                        AttributeValue(text="54321")]),ONTS)
    
    required = [a]
    ava = { "serialNumber": ["12345", "54321"]}
    
    ava = filter_on_attributes(ava, required)
    assert ava.keys() == ["serialNumber"]
    assert ava["serialNumber"] == ["54321"]
开发者ID:caustin,项目名称:pysaml2,代码行数:11,代码来源:test_20_assertion.py

示例15: store_assertion

    def store_assertion(self, assertion, to_sign):
        name_id = assertion.subject.name_id
        nkey = sha1(code_binary(name_id)).hexdigest()

        doc = {
            "name_id_key": nkey,
            "assertion_id": assertion.id,
            "assertion": to_dict(assertion, ONTS.values(), True),
            "to_sign": to_sign
        }

        _ = self.assertion.insert(doc)
开发者ID:SpamapS,项目名称:pysaml2,代码行数:12,代码来源:mongo_store.py


注:本文中的saml2.mdie.to_dict函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。