def test_realm(self): element = Auth(username='******', password='******', realm='realm') rendered_doc = tag_wrapper(element.to_xml(), 'result') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['result']['elementProp']['stringProp']: if tag['@name'] == 'Authorization.realm': assert tag['#text'] == 'realm'
def test_url(self): element = Auth(username='******', password='******', url='http://121.0.0.1:8097/request') rendered_doc = tag_wrapper(element.to_xml(), 'result') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['result']['elementProp']['stringProp']: if tag['@name'] == 'Authorization.url': assert tag['#text'] == 'http://121.0.0.1:8097/request'
def test_mechanism(self): element = Auth(username='******', password='******', mechanism=AuthMechanism.KERBEROS) rendered_doc = tag_wrapper(element.to_xml(), 'result') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['result']['elementProp']['stringProp']: if tag['@name'] == 'Authorization.mechanism': assert tag['#text'] == 'KERBEROS'
def test_auth(self): element = HTTPAuthManager(auth_list=[Auth(username='******', password='******'),\ Auth(username='******', password='******')]) rendered_doc = tag_wrapper(element.to_xml(), 'result') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['result']['AuthManager']['collectionProp'][ 'elementProp']: if tag['@name'] == 'var': assert tag['stringProp'][1]['#text'] == 'var' assert tag['stringProp'][2]['#text'] == '12'
def test_type_check(self): with pytest.raises(TypeError): Auth(username=123, password='******')
def test_positive(self): Auth(username='******', password='******', mechanism=AuthMechanism.BASIC)
def test_type_check(self): with pytest.raises(TypeError): Auth(username='******', password='******', mechanism='BASIC')
def test_positive(self): Auth(username='******', password='******', realm='s')
def test_type_check(self): with pytest.raises(TypeError): Auth(username='******', password='******', realm=1)
def test_positive(self): Auth(username='******', password='******', url='https://google.com/')
def test_positive(self): Auth(username='******', password='******', domain='1')
def test_hashtree_contain(self): element = HTTPAuthManager(auth_list=[Auth(username='******', password='******'),\ Auth(username='******', password='******')]) rendered_doc = tag_wrapper(element.to_xml(), 'result') assert '<hashTree />' in rendered_doc
def test_positive1(self): HTTPAuthManager(auth_list=[Auth(username='******', password='******'),\ Auth(username='******', password='******')])
def test_type_check5(self): with pytest.raises(TypeError): HTTPAuthManager( auth_list=[Auth(username='******', password='******'), '23'])