本文整理汇总了Python中saml2.config.SPConfig.context方法的典型用法代码示例。如果您正苦于以下问题:Python SPConfig.context方法的具体用法?Python SPConfig.context怎么用?Python SPConfig.context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类saml2.config.SPConfig
的用法示例。
在下文中一共展示了SPConfig.context方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_conf_syslog
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import context [as 别名]
def test_conf_syslog():
c = SPConfig().load_file("server_conf_syslog")
c.context = "sp"
# otherwise the logger setting is not changed
root_logger.level = logging.NOTSET
root_logger.handlers = []
print c.logger
c.setup_logger()
assert root_logger.level != logging.NOTSET
assert root_logger.level == logging.INFO
assert len(root_logger.handlers) == 1
assert isinstance(root_logger.handlers[0],
logging.handlers.SysLogHandler)
handler = root_logger.handlers[0]
print handler.__dict__
assert handler.facility == "local3"
assert handler.address == ('localhost', 514)
if sys.version >= (2, 7):
assert handler.socktype == 2
else:
pass
assert root_logger.name == "saml2"
assert root_logger.level == 20
示例2: test_wayf
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import context [as 别名]
def test_wayf():
c = SPConfig().load_file("server_conf")
c.context = "sp"
idps = c.metadata.with_descriptor("idpsso")
ent = idps.values()[0]
assert name(ent) == 'Example Co.'
assert name(ent, "se") == 'Exempel AB'
c.setup_logger()
assert root_logger.level != logging.NOTSET
assert root_logger.level == logging.INFO
assert len(root_logger.handlers) == 1
assert isinstance(root_logger.handlers[0],
logging.handlers.RotatingFileHandler)
handler = root_logger.handlers[0]
assert handler.backupCount == 5
try:
assert handler.maxBytes == 100000
except AssertionError:
assert handler.maxBytes == 500000
assert handler.mode == "a"
assert root_logger.name == "saml2"
assert root_logger.level == 20
示例3: test_conf_syslog
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import context [as 别名]
def test_conf_syslog():
c = SPConfig().load_file("server_conf_syslog")
c.context = "sp"
# otherwise the logger setting is not changed
root_logger.level = logging.NOTSET
while root_logger.handlers:
handler = root_logger.handlers[-1]
root_logger.removeHandler(handler)
handler.flush()
handler.close()
print(c.logger)
c.setup_logger()
assert root_logger.level != logging.NOTSET
assert root_logger.level == logging.INFO
assert len(root_logger.handlers) == 1
assert isinstance(root_logger.handlers[0],
logging.handlers.SysLogHandler)
handler = root_logger.handlers[0]
print(handler.__dict__)
assert handler.facility == "local3"
assert handler.address == ('localhost', 514)
if ((sys.version_info.major == 2 and sys.version_info.minor >= 7) or
sys.version_info.major > 2):
assert handler.socktype == 2
else:
pass
assert root_logger.name == "saml2"
assert root_logger.level == 20
示例4: test_2
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import context [as 别名]
def test_2():
c = SPConfig().load(sp2)
c.context = "sp"
print c
assert c.endpoints
assert c.idp
assert c.optional_attributes
assert c.name
assert c.required_attributes
assert len(c.idp) == 1
assert c.idp.keys() == [""]
assert c.idp.values() == ["https://example.com/saml2/idp/SSOService.php"]
assert c.only_use_keys_in_metadata is None
示例5: test_2
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import context [as 别名]
def test_2():
c = SPConfig().load(sp2)
c.context = "sp"
print(c)
assert c._sp_endpoints
assert c.getattr("endpoints", "sp")
assert c._sp_idp
assert c._sp_optional_attributes
assert c.name
assert c._sp_required_attributes
assert len(c._sp_idp) == 1
assert list(c._sp_idp.keys()) == [""]
assert list(c._sp_idp.values()) == ["https://example.com/saml2/idp/SSOService.php"]
assert c.only_use_keys_in_metadata is True
示例6: test_1
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import context [as 别名]
def test_1():
c = SPConfig().load(sp1)
c.context = "sp"
print c
assert c._sp_endpoints
assert c._sp_name
assert c._sp_idp
md = c.metadata
assert isinstance(md, MetaData)
assert len(c._sp_idp) == 1
assert c._sp_idp.keys() == ["urn:mace:example.com:saml:roland:idp"]
assert c._sp_idp.values() == [{'single_sign_on_service':
{'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect':
'http://localhost:8088/sso/'}}]
assert c.only_use_keys_in_metadata
示例7: test_minimum
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import context [as 别名]
def test_minimum():
minimum = {
"entityid": "urn:mace:example.com:saml:roland:sp",
"service": {
"sp": {
"endpoints": {"assertion_consumer_service": ["http://sp.example.org/"]},
"name": "test",
"idp": {"": "https://example.com/idp/SSOService.php"},
}
},
# "xmlsec_binary" : "/usr/local/bin/xmlsec1",
}
c = SPConfig().load(minimum)
c.context = "sp"
assert c is not None
示例8: test_wayf
# 需要导入模块: from saml2.config import SPConfig [as 别名]
# 或者: from saml2.config.SPConfig import context [as 别名]
def test_wayf():
c = SPConfig().load_file("server_conf")
c.context = "sp"
idps = c.idps()
assert idps == {'urn:mace:example.com:saml:roland:idp': 'Example Co.'}
idps = c.idps(["se","en"])
assert idps == {'urn:mace:example.com:saml:roland:idp': 'Exempel AB'}
c.setup_logger()
assert root_logger.level != logging.NOTSET
assert root_logger.level == logging.INFO
assert len(root_logger.handlers) == 1
assert isinstance(root_logger.handlers[0],
logging.handlers.RotatingFileHandler)
handler = root_logger.handlers[0]
assert handler.backupCount == 5
assert handler.maxBytes == 100000
assert handler.mode == "a"
assert root_logger.name == "saml2"
assert root_logger.level == 20