<s> import sys <EOL> import os . path <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( '<STR_LIT:..>' ) ) <EOL> import hcpsdk <EOL> print ( hcpsdk . version ( ) ) <EOL> import unittest <EOL> import ssl <EOL> import socket <EOL> import http . client <EOL> from pprint import pprint <EOL> import init_tests as it <EOL> class TestHcpsdk_1_Access_https_certfile ( unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> print ( '<STR_LIT>' ) <EOL> self . T_HCPFILE = '<STR_LIT>' <EOL> self . ctxt = ssl . create_default_context ( purpose = ssl . Purpose . SERVER_AUTH , <EOL> cafile = '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( self . ctxt . cert_store_stats ( ) ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( ( self . ctxt . get_ca_certs ( ) ) ) <EOL> self . hcptarget = hcpsdk . Target ( it . P_NS_GOOD , it . P_AUTH , it . P_SSLPORT , <EOL> dnscache = it . P_DNSCACHE , sslcontext = self . ctxt ) <EOL> self . con = hcpsdk . Connection ( self . hcptarget ) <EOL> def tearDown ( self ) : <EOL> self . con . close ( ) <EOL> del self . hcptarget <EOL> def test_1_10_put ( self ) : <EOL> """<STR_LIT>""" <EOL> T_BUF = '<STR_LIT>' * <NUM_LIT:64> <EOL> r = self . con . PUT ( self . T_HCPFILE , T_BUF ) <EOL> self . assertEqual ( r . status , <NUM_LIT> ) <EOL> def test_1_20_head ( self ) : <EOL> """<STR_LIT>""" <EOL> r = self . con . HEAD ( self . T_HCPFILE ) <EOL> self . assertEqual ( r . status , <NUM_LIT:200> ) <EOL> def test_1_30_post ( self ) : <EOL> """<STR_LIT>""" <EOL> r = self . con . POST ( self . T_HCPFILE , { '<STR_LIT:index>' : '<STR_LIT:true>' } ) <EOL> self . assertEqual ( r . status , <NUM_LIT:200> ) <EOL> def test_1_90_delete ( self ) : <EOL> """<STR_LIT>""" <EOL> r = self . con . DELETE ( self . T_HCPFILE ) <EOL> self . assertEqual ( r . status , <NUM_LIT:200> ) <EOL> class TestHcpsdk_2_Access_https_systemCA ( unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> print ( '<STR_LIT>' ) <EOL> self . T_HCPFILE = '<STR_LIT>' <EOL> self . ctxt = ssl . create_default_context ( ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( self . ctxt . cert_store_stats ( ) ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( ( self . ctxt . get_ca_certs ( ) ) ) <EOL> self . hcptarget = hcpsdk . Target ( it . P_NS_GOOD , it . P_AUTH , it . P_SSLPORT , <EOL> dnscache = it . P_DNSCACHE , sslcontext = self . ctxt ) <EOL> self . con = hcpsdk . Connection ( self . hcptarget ) <EOL> def tearDown ( self ) : <EOL> self . con . close ( ) <EOL> del self . hcptarget <EOL> def test_2_10_put ( self ) : <EOL> """<STR_LIT>""" <EOL> T_BUF = '<STR_LIT>' * <NUM_LIT:64> <EOL> r = self . con . PUT ( self . T_HCPFILE , T_BUF ) <EOL> print ( self . con . response_status , self . con . response_reason ) <EOL> self . assertEqual ( r . status , <NUM_LIT> ) <EOL> def test_2_90_delete ( self ) : <EOL> """<STR_LIT>""" <EOL> r = self . con . DELETE ( self . T_HCPFILE ) <EOL> print ( self . con . response_status , self . con . response_reason ) <EOL> self . assertEqual ( r . status , <NUM_LIT:200> ) <EOL> class TestHcpsdk_3_Access_https_certfile_fail ( unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> print ( '<STR_LIT>' ) <EOL> self . T_HCPFILE = '<STR_LIT>' <EOL> self . ctxt = ssl . create_default_context ( purpose = ssl . Purpose . SERVER_AUTH , <EOL> cafile = '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( self . ctxt . cert_store_stats ( ) ) <EOL> print ( '<STR_LIT>' ) <EOL> pprint ( ( self . ctxt . get_ca_certs ( ) ) ) <EOL> self . hcptarget = hcpsdk . Target ( it . P_NS_GOOD , it . P_AUTH , it . P_SSLPORT , <EOL> dnscache = it . P_DNSCACHE , sslcontext = self . ctxt ) <EOL> self . con = hcpsdk . Connection ( self . hcptarget ) <EOL> def tearDown ( self ) : <EOL> self . con . close ( ) <EOL> del self . hcptarget <EOL> def test_3_10_put ( self ) : <EOL> """<STR_LIT>""" <EOL> T_BUF = '<STR_LIT>' * <NUM_LIT:64> <EOL> with self . assertRaises ( hcpsdk . HcpsdkCertificateError ) : <EOL> r = self . con . PUT ( self . T_HCPFILE , T_BUF ) <EOL> def test_3_90_delete ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( hcpsdk . HcpsdkCertificateError ) : <EOL> r = self . con . DELETE ( self . T_HCPFILE ) <EOL> class TestHcpsdk_4_Access_Fail ( unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> self . T_HCPFILE = '<STR_LIT>' <EOL> self . hcptarget = hcpsdk . Target ( it . P_NS_GOOD , it . P_AUTH , it . P_SSLPORT , dnscache = it . P_DNSCACHE ) <EOL> self . con = hcpsdk . Connection ( self . hcptarget ) <EOL> def tearDown ( self ) : <EOL> self . con . close ( ) <EOL> del self . hcptarget <EOL> def test_4_10_get ( self ) : <EOL> """<STR_LIT>""" <EOL> self . r = self . con . GET ( self . T_HCPFILE ) <EOL> print ( self . con . response_status , self . con . response_reason ) <EOL> self . assertEqual ( self . r . status , <NUM_LIT> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
