How to use getheader method in tempest

Best Python code snippet using tempest_python

wpheaders.py

Source:wpheaders.py Github

copy

Full Screen

...31 print ""32 try:33 url = self.check.checkurl(self.url,'')34 r = self.req.send(url)35 if r.info().getheader('accept-charset'):36 print 'Accept-Charset: %s'%(r.info().getheader('accept-charset'))37 if r.info().getheader('accept-encoding'):38 print 'Accept-Encoding: %s'%(r.info().getheader('accept-encoding'))39 if r.info().getheader('accept-language'):40 print 'accept-language: %s'%(r.info().getheader('accept-language'))41 if r.info().getheader('accept-ranges'):42 print 'Accept-Ranges: %s'%(r.info().getheader('accept-ranges'))43 if r.info().getheader('access-control-allow-credentials'):44 print 'Access-Control-Allow-Credentials: %s'%(r.info().getheader('access-control-allow-credentials'))45 if r.info().getheader('access-control-allow-headers'):46 print 'Access-Control-Allow-Headers: %s'%(r.info().getheader('access-control-allow-headers'))47 if r.info().getheader('access-control-allow-methods'):48 print 'Access-Control-Allow-Methods: %s'%(r.info().getheader('access-control-allow-methods'))49 if r.info().getheader('access-control-allow-origin'):50 print 'Access-Control-Allow-Origin: %s'%(r.info().getheader('access-control-allow-origin'))51 if r.info().getheader('access-control-expose-headers'):52 print 'Access-Control-Expose-Headers: %s'%(r.info().getheader('access-control-expose-headers'))53 if r.info().getheader('access-control-max-age'):54 print 'Access-Control-Max-Age: %s'%(r.info().getheader('access-control-max-age'))55 if r.info().getheader('age'):56 print 'Age: %s'%(r.info().getheader('age'))57 if r.info().getheader('allow'):58 print 'Allow: %s'%(r.info().getheader('allow'))59 if r.info().getheader('alternates'):60 print 'Alternates: %s'%(r.info().getheader('alternates'))61 if r.info().getheader('authorization'):62 print 'Authorization: %s'%(r.info().getheader('authorization'))63 if r.info().getheader('cache-control'):64 print 'Cache-Control: %s'%(r.info().getheader('cache-control'))65 if r.info().getheader('connection'):66 print 'Connection: %s'%(r.info().getheader('connection'))67 if r.info().getheader('content-encoding'):68 print 'Content-Encoding: %s'%(r.info().getheader('content-encoding'))69 if r.info().getheader('content-language'):70 print 'Content-Language: %s'%(r.info().getheader('content-language'))71 if r.info().getheader('content-length'):72 print 'Content-Length: %s'%(r.info().getheader('content-length'))73 if r.info().getheader('content-location'):74 print 'Content-Location: %s'%(r.info().getheader('content-location'))75 if r.info().getheader('content-md5'):76 print 'Content-md5: %s'%(r.info().getheader('content-md5'))77 if r.info().getheader('content-range'):78 print 'Content-Range: %s'%(r.info().getheader('content-range'))79 if r.info().getheader('content-security-policy'):80 print 'Content-Security-Policy: %s'%(r.info ().getheader('content-security-policy'))81 if r.info().getheader('content-security-policy-report-only'):82 print 'Content-Security-Policy-Report-Only: %s'%(r.info().getheader('content-security-policy-report-only'))83 if r.info().getheader('content-type'):84 print 'Content-Type: %s'%(r.info().getheader('content-type'))85 if r.info().getheader('dasl'):86 print 'Dasl: %s'%(r.info().getheader('dasl'))87 if r.info().getheader('date'):88 print 'Date: %s'%(r.info().getheader('date'))89 if r.info().getheader('dav'):90 print 'Dav: %s'%r.info().getheader('dav')91 if r.info().getheader('etag'):92 print 'Etag: %s'%(r.info().getheader('etag'))93 if r.info().getheader('from'):94 print 'From: %s'%(r.info().getheader('from'))95 if r.info().getheader('host'):96 print 'Host: %s'%(r.info().getheader('host'))97 if r.info().getheader('keep-alive'):98 print 'Keep-Alive: %s'%(r.info().getheader('keep-alive'))99 if r.info().getheader('last-modified'):100 print 'Last-Modified: %s'%(r.info().getheader('last-modified'))101 if r.info().getheader('location'):102 print 'Location: %s'%(r.info().getheader('location'))103 if r.info().getheader('max-forwards'):104 print 'Max-Forwards: %s'%(r.info().getheader('max-forwards'))105 if r.info().getheader('persistent-auth'):106 print 'Persistent-Auth: %s'%(r.info().getheader('persistent-auth'))107 if r.info().getheader('pragma'):108 print 'Pragma: %s'%(r.info().getheader('pragma'))109 if r.info().getheader('proxy-authenticate'):110 print 'Proxy-Authenticate: %s'%(r.info().getheader('proxy-authenticate'))111 if r.info().getheader('proxy-authorization'):112 print 'Proxy-Authorization: %s'%(r.info().getheader('proxy-authorization'))113 if r.info().getheader('proxy-connection'):114 print 'Proxy-Connection: %s'%(r.info().getheader('proxy-connection'))115 if r.info().getheader('public'):116 print 'Public: %s'%(r.info().getheader('public'))117 if r.info().getheader('range'):118 print 'Range: %s'%(r.info().getheader('range'))119 if r.info().getheader('referer'):120 print 'Referer: %s'%(r.info().getheader('referer'))121 if r.info().getheader('server'):122 print 'Server: %s'%(r.info().getheader('server'))123 if r.info().getheader('set-cookie'):124 print 'Set-Cookie: %s'%(r.info().getheader('set-cookie'))125 if r.info().getheader('status'):126 print 'Status: %s'%(r.info().getheader('status'))127 if r.info().getheader('strict-transport-security'):128 print 'Strict-Transport-Security: %s'%(r.info().getheader('strict-transport-security'))129 if r.info().getheader('transfer-encoding'):130 print 'Transfer-Encoding: %s'%(r.info().getheader('transfer-encoding'))131 if r.info().getheader('upgrade'):132 print 'Upgrade: %s'%(r.info().getheader('upgrade'))133 if r.info().getheader('vary'):134 print 'Vary: %s'%(r.info().getheader('vary'))135 if r.info().getheader('via'):136 print 'Via: %s'%(r.info().getheader('via'))137 if r.info().getheader('warning'):138 print 'Warning: %s'%(r.info().getheader('warning'))139 if r.info().getheader('www-authenticate'):140 print 'www-Authenticate: %s'%(r.info().getheader('www-authenticate'))141 if r.info().getheader('x-content-security-policy'):142 print 'X-Content-Security-Policy: %s'%(r.info().getheader('x-content-security-policy'))143 if r.info().getheader('x-content-type-options'):144 print 'X-Content-Type-Options: %s'%(r.info().getheader('x-content-type-options'))145 if r.info().getheader('x-frame-options'):146 print 'X-Frame-Options: %s'%(r.info().getheader('x-frame-options'))147 if r.info().getheader('x-id'):148 print 'X-Id: %s'%(r.info().getheader('x-id'))149 if r.info().getheader('x-mod-pagespeed'):150 print 'X-Mod-Pagespeed: %s'%(r.info().getheader('x-mod-pagespeed'))151 if r.info().getheader('x-pad'):152 print 'X-Pad: %s'%(r.info().getheader('x-pad'))153 if r.info().getheader('x-page-speed'):154 print 'X-Page-Speed: %s'%(r.info().getheader('x-page-speed'))155 if r.info().getheader('x-permitted-cross-domain-policies'):156 print 'X-Permitted-Cross-Domain-Policies: %s'%(r.info().getheader('x-permitted-cross-domain-policies'))157 if r.info().getheader('x-pingback'):158 print 'X-Pingback: %s'%(r.info().getheader('x-pingback'))159 if r.info().getheader('x-powered-by'):160 print 'X-Powered-By: %s'%(r.info().getheader('x-powered-by'))161 if r.info().getheader('x-robots-tag'):162 print 'X-Robots-Tag: %s'%(r.info().getheader('x-robots-tag'))163 if r.info().getheader('x-ua-compatible'):164 print 'X-UA-Compatible: %s'%(r.info().getheader('x-ua-compatible'))165 if r.info().getheader('x-varnish'):166 print 'X-Varnish: %s'%(r.info().getheader('x-varnish'))167 if r.info().getheader('x-xss-protection'):168 print 'X-XSS-Protection: %s'%(r.info().getheader('x-xss-protection'))169 except Exception as error:170 pass...

Full Screen

Full Screen

client_test.py

Source:client_test.py Github

copy

Full Screen

...35 http_request=atom.http_core.HttpRequest(36 uri=atom.http_core.Uri('http', 'example.org',37 path='/')))]38 for response in responses:39 self.assert_(response.getheader('Echo-Host') == 'example.org:None')40 self.assert_(response.getheader('Echo-Uri') == '/')41 self.assert_(response.getheader('Echo-Scheme') == 'http')42 self.assert_(response.getheader('Echo-Method') == 'GET')43 self.assert_(response.getheader('User-Agent').startswith('gdata-py/'))44 def test_auth_request_with_no_client_defaults(self):45 client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())46 token = atom.auth.BasicAuth('Jeff', '123')47 response = client.request('POST', 'https://example.net:8080/',48 auth_token=token)49 self.assert_(response.getheader('Echo-Host') == 'example.net:8080')50 self.assert_(response.getheader('Echo-Uri') == '/')51 self.assert_(response.getheader('Echo-Scheme') == 'https')52 self.assert_(response.getheader('Authorization') == 'Basic SmVmZjoxMjM=')53 self.assert_(response.getheader('Echo-Method') == 'POST')54 def test_request_with_client_defaults(self):55 client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient(),56 'example.com', atom.auth.BasicAuth('Jeff', '123'))57 self.assert_(client.host == 'example.com')58 self.assert_(client.auth_token is not None)59 self.assert_(client.auth_token.basic_cookie == 'SmVmZjoxMjM=')60 response = client.request('GET', 'http://example.org/')61 self.assert_(response.getheader('Echo-Host') == 'example.org:None')62 self.assert_(response.getheader('Echo-Uri') == '/')63 self.assert_(response.getheader('Echo-Scheme') == 'http')64 self.assert_(response.getheader('Echo-Method') == 'GET')65 self.assert_(response.getheader('Authorization') == 'Basic SmVmZjoxMjM=')66 response = client.request('GET', '/')67 self.assert_(response.getheader('Echo-Host') == 'example.com:None')68 self.assert_(response.getheader('Echo-Uri') == '/')69 self.assert_(response.getheader('Echo-Scheme') == 'http')70 self.assert_(response.getheader('Authorization') == 'Basic SmVmZjoxMjM=')71 response = client.request('GET', '/',72 http_request=atom.http_core.HttpRequest(73 uri=atom.http_core.Uri(port=99)))74 self.assert_(response.getheader('Echo-Host') == 'example.com:99')75 self.assert_(response.getheader('Echo-Uri') == '/')76 def test_get(self):77 client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())78 response = client.get('http://example.com/simple')79 self.assert_(response.getheader('Echo-Host') == 'example.com:None')80 self.assert_(response.getheader('Echo-Uri') == '/simple')81 self.assert_(response.getheader('Echo-Method') == 'GET')82 response = client.Get(uri='http://example.com/simple2')83 self.assert_(response.getheader('Echo-Uri') == '/simple2')84 self.assert_(response.getheader('Echo-Method') == 'GET')85 def test_modify_request_using_args(self):86 client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())87 class RequestModifier(object):88 def modify_request(self, http_request):89 http_request.headers['Special'] = 'Set'90 response = client.get('http://example.com/modified',91 extra=RequestModifier())92 self.assert_(response.getheader('Echo-Host') == 'example.com:None')93 self.assert_(response.getheader('Echo-Uri') == '/modified')94 self.assert_(response.getheader('Echo-Method') == 'GET')95 self.assert_(response.getheader('Special') == 'Set')96 def test_modify_request_using_object_str(self):97 client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())98 class RequestModifier(object):99 def __str__(self):100 return 'value'101 response = client.get('http://example.com/modified',102 name=RequestModifier())103 self.assert_(response.getheader('Echo-Host') == 'example.com:None')104 self.assert_(response.getheader('Echo-Uri') == '/modified?name=value')105 self.assert_(response.getheader('Echo-Method') == 'GET')106 def test_modify_request_using_string(self):107 client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())108 response = client.get('http://example.com/modified',109 name='value')110 self.assert_(response.getheader('Echo-Host') == 'example.com:None')111 self.assert_(response.getheader('Echo-Uri') == '/modified?name=value')112 self.assert_(response.getheader('Echo-Method') == 'GET')113 def test_post(self):114 client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())115 class TestData(object):116 def modify_request(self, http_request):117 http_request.add_body_part('test body', 'text/testdata')118 response = client.Post(uri='http://example.com/', data=TestData())119 self.assert_(response.getheader('Echo-Host') == 'example.com:None')120 self.assert_(response.getheader('Echo-Uri') == '/')121 self.assert_(response.getheader('Echo-Method') == 'POST')122 self.assert_(response.getheader('Content-Length') == str(len('test body')))123 self.assert_(response.getheader('Content-Type') == 'text/testdata')124 self.assert_(response.read(2) == 'te')125 self.assert_(response.read() == 'st body')126 response = client.post(data=TestData(), uri='http://example.com/')127 self.assert_(response.read() == 'test body')128 self.assert_(response.getheader('Content-Type') == 'text/testdata')129 # Don't pass in a body, but use an extra kwarg to add the body to the130 # http_request.131 response = client.post(x=TestData(), uri='http://example.com/')132 self.assert_(response.read() == 'test body')133 def test_put(self):134 body_text = '<put>test</put>'135 client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient())136 class TestData(object):137 def modify_request(self, http_request):138 http_request.add_body_part(body_text, 'application/xml')139 response = client.put('http://example.org', TestData())140 self.assert_(response.getheader('Echo-Host') == 'example.org:None')141 self.assert_(response.getheader('Echo-Uri') == '/')142 self.assert_(response.getheader('Echo-Method') == 'PUT')143 self.assert_(response.getheader('Content-Length') == str(len(body_text)))144 self.assert_(response.getheader('Content-Type') == 'application/xml')145 response = client.put(uri='http://example.org', data=TestData())146 self.assert_(response.getheader('Content-Length') == str(len(body_text)))147 self.assert_(response.getheader('Content-Type') == 'application/xml')148 def test_delete(self):149 client = atom.client.AtomPubClient(atom.mock_http_core.EchoHttpClient(),150 source='my new app')151 response = client.Delete('http://example.com/simple')152 self.assertEqual(response.getheader('Echo-Host'), 'example.com:None')153 self.assertEqual(response.getheader('Echo-Uri'), '/simple')154 self.assertEqual(response.getheader('Echo-Method'), 'DELETE')155 response = client.delete(uri='http://example.com/d')156 self.assertEqual(response.getheader('Echo-Uri'), '/d')157 self.assertEqual(response.getheader('Echo-Method'), 'DELETE')158 self.assert_(159 response.getheader('User-Agent').startswith('my new app gdata-py/'))160def suite():161 return unittest.TestSuite((unittest.makeSuite(AtomPubClientEchoTest, 'test'),162 ))163if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful