1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
from saml2 import saml
from saml2.saml import Subject
from saml2.samlp import Response
from saml2.argtree import set_arg, add_path, is_set
from saml2.argtree import find_paths
__author__ = 'roland'
def test_path():
result = find_paths(Subject, 'in_response_to')
assert result == [
['subject_confirmation', 'subject_confirmation_data', 'in_response_to']]
result = find_paths(Response, 'in_response_to')
assert result == [
['assertion', 'subject', 'subject_confirmation',
'subject_confirmation_data', 'in_response_to'],
['in_response_to']
]
def test_set_arg():
r = set_arg(Subject, 'in_response_to', '123456')
assert r == [{'subject_confirmation': {
'subject_confirmation_data': {'in_response_to': '123456'}}}]
def test_multi():
t = {}
t = add_path(t, ['subject_confirmation','method',saml.SCM_BEARER])
add_path(t['subject_confirmation'],
['subject_confirmation_data','in_response_to','1234'])
assert t == {
'subject_confirmation': {
'subject_confirmation_data': {'in_response_to': '1234'},
'method': 'urn:oasis:names:tc:SAML:2.0:cm:bearer'}
}
def test_is_set():
t = {}
t = add_path(t, ['subject_confirmation','method',saml.SCM_BEARER])
add_path(t['subject_confirmation'],
['subject_confirmation_data','in_response_to','1234'])
assert is_set(t, ['subject_confirmation','method'])
assert is_set(t, ['subject_confirmation', 'subject_confirmation_data',
'receiver']) is False
|