コード例 #1
0
ファイル: test_30_mdstore.py プロジェクト: HaToHo/pysaml2
def test_mdx_single_sign_on_service():
    entity_id = "http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php"

    url = "http://mdx.example.com/entities/{}".format(
        quote_plus(MetaDataMDX.sha1_entity_transform(entity_id)))
    responses.add(responses.GET, url, body=TEST_METADATA_STRING, status=200,
                  content_type=SAML_METADATA_CONTENT_TYPE)

    mdx = MetaDataMDX("http://mdx.example.com")
    sso_loc = mdx.single_sign_on_service(entity_id, BINDING_HTTP_REDIRECT)
    assert sso_loc[0]["location"] == "http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php"
コード例 #2
0
def test_mdx_single_sign_on_service():
    entity_id = "http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php"

    url = "http://mdx.example.com/entities/{}".format(
        parse.quote_plus(MetaDataMDX.sha1_entity_transform(entity_id)))
    responses.add(responses.GET, url, body=TEST_METADATA_STRING, status=200,
                  content_type=SAML_METADATA_CONTENT_TYPE)

    mdx = MetaDataMDX("http://mdx.example.com")
    sso_loc = mdx.single_sign_on_service(entity_id, BINDING_HTTP_REDIRECT)
    assert sso_loc[0]["location"] == "http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php"
コード例 #3
0
def test_mdx_metadata_freshness_period_expired():
    """Ensure that metadata is not refreshed if not expired."""

    entity_id = "http://xenosmilus.umdc.umu.se/simplesaml/saml2/idp/metadata.php"
    url = "http://mdx.example.com/entities/{}".format(
        parse.quote_plus(MetaDataMDX.sha1_entity_transform(entity_id)))

    responses.add(
        responses.GET,
        url,
        body=TEST_METADATA_STRING,
        status=200,
        content_type=SAML_METADATA_CONTENT_TYPE,
    )

    mdx = MetaDataMDX("http://mdx.example.com",
                      freshness_period="P0Y0M0DT0H2M0S")
    mdx._is_metadata_fresh = Mock(return_value=False)

    mdx.single_sign_on_service(entity_id, BINDING_HTTP_REDIRECT)
    assert entity_id in mdx.entity

    mdx.single_sign_on_service(entity_id, BINDING_HTTP_REDIRECT)
    assert len(responses.calls) == 2
コード例 #4
0
from django.conf import settings
from djangosaml2idp.utils import repr_saml
from saml2.attribute_converter import ac_factory
from saml2.config import IdPConfig
from saml2.mdstore import MetadataStore, MetaDataMDX
from saml2.metadata import entity_descriptor

try:
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
except:
    BASE_DIR = os.getcwd()
    print('BASE_DIR is', BASE_DIR)
conf = IdPConfig()

# conf.load_file("idp_conf_mdb")
conf.load(copy.deepcopy(settings.SAML_IDP_CONFIG))

mdx = MetaDataMDX("https://ds.testunical.it")
mdx.service("https://sp1.testunical.it/saml2/metadata/", "spsso_descriptor",
            'assertion_consumer_service')
mdx.certs("https://sp1.testunical.it/saml2/metadata/", "spsso", use="signing")

mdx.single_sign_on_service("https://idp1.testunical.it/idp/metadata")
mdx.service("https://idp1.testunical.it/idp/metadata", 'idpsso', 'sso_service')
mdx.certs("https://idp1.testunical.it/idp/metadata",
          "idpsso",
          use="encryption")

# all metadata as a dict here:
mdx.entity