Added copy_into method
This commit is contained in:
@@ -56,6 +56,17 @@ class Config(object):
|
||||
|
||||
def serves(self):
|
||||
return [t for t in ["sp", "idp", "aa"] if self._attr[t]]
|
||||
|
||||
def copy_into(self, typ=""):
|
||||
if typ == "sp":
|
||||
copy = SPConfig()
|
||||
elif typ in ["idp", "aa"]:
|
||||
copy = IdPConfig()
|
||||
else:
|
||||
copy = Config()
|
||||
copy.context = typ
|
||||
copy._attr = self._attr.copy()
|
||||
return copy
|
||||
|
||||
def __getattribute__(self, item):
|
||||
if item == "context":
|
||||
|
||||
@@ -217,4 +217,17 @@ def test_sp():
|
||||
BINDING_HTTP_POST) == ["http://localhost:8088/slo"]
|
||||
assert cnf.endpoint("assertion_consumer_service") == \
|
||||
"http://lingon.catalogix.se:8087/"
|
||||
assert len(cnf.idps()) == 1
|
||||
assert len(cnf.idps()) == 1
|
||||
|
||||
def test_dual():
|
||||
cnf = Config().load_file("idp_sp_conf")
|
||||
cnf.serves() == ["sp", "idp"]
|
||||
|
||||
spcnf = cnf.copy_into("sp")
|
||||
assert isinstance(spcnf, SPConfig)
|
||||
assert spcnf.context == "sp"
|
||||
|
||||
idpcnf = cnf.copy_into("idp")
|
||||
assert isinstance(idpcnf, IdPConfig)
|
||||
assert idpcnf.context == "idp"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user