def __init__(self, testResult='', testHeader=''): """ This class describes the model of the test result document, and provides a xml <=> python encoder The following xml : <?xml version="1.0" encoding="utf-8" ?> <file> <properties"> <comments> <comment> <author>author</author> <datetime>...</datetime> <post>...</post> </comment> .... </comments> </properties> <testheader>...</testheader> <testresult>...</testresult> </file> """ self.codecX2D = PyXmlDict.Xml2Dict() self.codecD2X = PyDictXml.Dict2Xml(coding=None) self.properties = {'properties': {'comments': {'comment': []}}} self.testresult = testResult self.testheader = testHeader
def __init__(self, userName='******', timeout="10.0", parameters=[]): """ This class describes the model of one script document, and provides a xml <=> python encoder The following xml : <?xml version="1.0" encoding="utf-8" ?> <file> <properties"> <parameters> <parameter> <name>...</name> <type>...</type> <description>...</description> <value>...</value> </parameter> </parameters> </properties> </file> """ GenericModel.GenericModel.__init__(self) # init xml encoder self.codecX2D = PyXmlDict.Xml2Dict() self.codecD2X = PyDictXml.Dict2Xml(coding=None) # init file properties self.properties = { 'properties': { 'parameters': { 'parameter': [{ 'type': 'bool', 'name': 'DEBUG', 'description': '', 'value': 'False', 'color': '', 'scope': 'local' }, { 'type': 'float', 'name': 'TIMEOUT', 'description': '', 'value': timeout, 'color': '', 'scope': 'local' }] } } } if len(parameters): self.properties["properties"]["parameters"][ "parameter"] = parameters
def __init__(self, parent, debug=False, coding='UTF-8', name=None, shared=False): """ XML coder-decoder to object @param parent: testcase @type parent: testcase @param name: library name used with from origin/to destination (default=None) @type name: string/none @param debug: True to activate debug mode (default=False) @type debug: boolean @param coding: expected value in UTF-8, ISO, etc ... @type coding: string @param shared: shared adapter (default=False) @type shared: boolean """ TestLibraryLib.Library.__init__(self, name = __NAME__, parent = parent, debug=debug, realname=name, shared=shared) self.codecX2D = Xml2Dict.Xml2Dict( ) self.codecD2X = Dict2Xml.Dict2Xml( coding = coding ) self.rootXML = None self.ns = {}
def __init__(self, userName='******', testDef='', defLibrary='', defAdapter='', timeout="10.0", inputs=[], outputs=[]): """ This class describes the model of one script document, and provides a xml <=> python encoder The following xml : <?xml version="1.0" encoding="utf-8" ?> <file> <properties"> <descriptions> <description> <key>author</key> <value>...</value> </description> <description> <key>creation date</key> <value>...</value> </description> <description> <key>summary</key> <value>...</value> </description> <description> <key>prerequisites</key> <value>...</value> </description> <description> <key>comments</key> <value> <comments> <comment> <author>author</author> <datetime>...</datetime> <post>...</post> </comment> .... </comments> </value> </description> </descriptions> <inputs-parameters> <parameter> <name>...</name> <type>...</type> <description>...</description> <value>...</value> </parameter> </inputs-parameters> <outputs-parameters> <parameter> <name>...</name> <type>...</type> <description>...</description> <value>...</value> </parameter> </outputs-parameters> <probes> <probe> <active>...</active> <args>...</args> <name>...</name> <type>...</type> </probe> </probes> <agents> <agent> <name>...</name> <type>...</type> <description>...</description> <value>...</value> </agent> </agents> </properties> <testdefinition>...</testdefinition> <testdevelopment>...</testdevelopment> <snapshots> <snapshot> <name>....</name> <timestamp>...</timestamp> <properties>...</properties> <testdef>....</testdef> </snapshot> </snapshots> </file> """ GenericModel.GenericModel.__init__(self) today = datetime.datetime.today() self.dateToday = today.strftime("%d/%m/%Y %H:%M:%S") self.currentUser = userName self.defLibrary = defLibrary self.defAdapter = defAdapter # new in v17 self.timeout = timeout self.inputs = inputs self.outputs = outputs # end of new # init xml encoder self.codecX2D = PyXmlDict.Xml2Dict() self.codecD2X = PyDictXml.Dict2Xml(coding=None) # files properties self.properties = {'properties': { 'descriptions': { 'description': [ {'key': 'author', 'value': self.currentUser}, {'key': 'creation date', 'value': self.dateToday}, {'key': 'summary', 'value': 'Just a basic sample.'}, {'key': 'prerequisites', 'value': 'None.'}, {'key': 'comments', 'value': {'comments': {'comment': []}}}, {'key': 'libraries', 'value': self.defLibrary}, {'key': 'adapters', 'value': self.defAdapter}, {'key': 'state', 'value': 'Writing'}, {'key': 'name', 'value': 'TESTCASE'}, {'key': 'requirement', 'value': 'REQ_01'}, ]}, 'probes': { 'probe': [{'active': 'False', 'args': '', 'name': 'probe01', 'type': 'default'}] }, 'inputs-parameters': { 'parameter': copy.deepcopy(DEFAULT_INPUTS) }, 'outputs-parameters': { 'parameter': copy.deepcopy(DEFAULT_OUTPUTS) }, 'agents': { 'agent': copy.deepcopy(DEFAULT_AGENTS) }, } } # new in v17 for p in self.properties["properties"]["inputs-parameters"]["parameter"]: if p["name"] == "TIMEOUT": p["value"] = self.timeout for p in self.properties["properties"]["outputs-parameters"]["parameter"]: if p["name"] == "TIMEOUT": p["value"] = self.timeout if len(self.inputs): self.properties["properties"]["inputs-parameters"]["parameter"] = self.inputs if len(self.outputs): self.properties["properties"]["outputs-parameters"]["parameter"] = self.outputs # end of new # file contents self.testdef = testDef # dev duration self.testdev = time.time()
def __init__(self, parent, name=None, bindIp='', bindPort=0, destinationIp='127.0.0.1', destinationPort=80, debug=False, logEventSent=True, logEventReceived=True, xmlns0='http://schemas.xmlsoap.org/soap/envelope/', xmlns1='', xmlns2='', xmlns3='', xmlns4='', xmlns5='', xmlns6='', xmlns7='', xmlns8='', httpAgent='ExtensiveTesting', httpVersion='HTTP/1.1', httpConnection='close', agentSupport=False, agent=None, shared=False, httpAuthentication=False, proxyIp='', proxyPort=3128, proxyHost='', proxyEnabled=False, proxyType=AdapterTCP.PROXY_HTTP, verbose=True, sslSupport=False, sslVersion=AdapterSSL.SSLv23, checkCert=AdapterSSL.CHECK_CERT_NO, caCerts=None, checkHost=False, hostCn=None, certfile=None, keyfile=None ): """ This class enables to send and receive SOAP data @param bindIp: bind ip (default='') @type bindIp: string @param bindPort: bind port (default=0) @type bindPort: integer @param destinationIp: destination ip (default=127.0.0.1) @type destinationIp: string @param destinationPort: destination port (default=80) @type destinationPort: integer @param xmlns0: xml namespace @type xmlns0: string @param xmlns1: xml namespace @type xmlns1: string @param xmlns2: xml namespace @type xmlns2: string @param xmlns3: xml namespace @type xmlns3: string @param xmlns4: xml namespace @type xmlns4: string @param xmlns5: xml namespace @type xmlns5: string @param xmlns6: xml namespace @type xmlns6: string @param xmlns7: xml namespace @type xmlns7: string @param xmlns8: xml namespace @type xmlns8: string @param supportAuthentication: support digest authentication (default=False) @type supportAuthentication: boolean @param httpAgent: http agent (default value=ExtensiveTesting) @type httpAgent: string @param httpConnection: SutAdapters.HTTP.CONN_CLOSE (default) | SutAdapters.HTTP.CONN_KEEPALIVE | None @type httpConnection: strconstant @param httpVersion: SutAdapters.HTTP.VERSION_10 | SutAdapters.HTTP.VERSION_11 (default) @type httpVersion: strconstant @param sslSupport: ssl support (default=False) @type sslSupport: boolean @param sslVersion: SutAdapters.SSL.SSLv2 | SutAdapters.SSL.SSLv23 (default) | SutAdapters.SSL.SSLv3 | SutAdapters.SSL.TLSv1 | SutAdapters.SSL.TLSv11 | SutAdapters.SSL.TLSv12 @type sslVersion: strconstant @param checkCert: SutAdapters.SSL.CHECK_CERT_NO (default) | SutAdapters.SSL.CHECK_CERT_OPTIONAL | SutAdapters.SSL.CHECK_CERT_REQUIRED @type checkCert: strconstant @param caCerts: path to the certificate authority (default=None) @type caCerts: string/none @param checkHost: validate the common name field (default=False) @type checkHost: boolean @param hostCn: common name to check (default=None) @type hostCn: string/none @param parent: parent testcase @type parent: testcase @param name: adapter name used with from origin/to destination (default=None) @type name: string/none @param debug: active debug mode (default=False) @type debug: boolean @param agentSupport: agent support to use a remote socket (default=False) @type agentSupport: boolean @param agent: agent to use when this mode is activated @type agent: string/None @param shared: shared adapter (default=False) @type shared: boolean @param proxyType: SutAdapters.TCP.PROXY_HTTP (default) | SutAdapters.TCP.PROXY_SOCKS4 | SutAdapters.TCP.PROXY_SOCKS5 @type proxyType: strconstant @param proxyIp: proxy ip @type proxyIp: string @param proxyPort: proxy port @type proxyPort: integer @param proxyHost: proxy host (automatic dns resolution) @type proxyHost: string @param proxyEnabled: True to support proxy (default=False) @type proxyEnabled: boolean @param certfile: path to the cert file (default=None) @type certfile: string/none @param keyfile: path to the key file (default=None) @type keyfile: string/none """ # init adapter TestAdapterLib.Adapter.__init__(self, name = __NAME__, parent = parent, debug=debug, shared=shared, realname=name, agentSupport=agentSupport, agent=agent, showEvts=verbose, showSentEvts=verbose, showRecvEvts=verbose, caller=TestAdapterLib.caller(), agentType=AGENT_TYPE_EXPECTED) self.logEventSent = logEventSent self.logEventReceived = logEventReceived self.ADP_HTTP = AdapterHTTP.Client( parent=parent, bindIp=bindIp, bindPort=bindPort, destinationIp=destinationIp, destinationPort=destinationPort, proxyIp=proxyIp, proxyPort=proxyPort, proxyHost=proxyHost, proxyEnabled=proxyEnabled, proxyType=proxyType, destinationHost='', socketTimeout=300.0, socketFamily=4, saveContent=False, httpVersion=httpVersion, httpAgent=httpAgent, httpConnection=httpConnection, httpChunckedData=False, sslSupport=sslSupport, sslVersion=sslVersion, checkCert=checkCert, debug=debug, caCerts=caCerts, checkHost=checkHost, hostCn=hostCn, logEventSent=False, logEventReceived=False, agentSupport=agentSupport, agent=agent, shared=shared, name=name, verbose=verbose, keyfile=keyfile, certfile=certfile ) self.ADP_HTTP.handleIncomingResponse = self.handleIncomingResponse self.codecX2D = Xml2Dict.Xml2Dict(coding='utf8') self.codecD2X = Dict2Xml.Dict2Xml(coding = 'utf8') self.cfg = {} self.cfg['xmlns0'] = xmlns0 self.cfg['xmlns1'] = xmlns1 self.cfg['xmlns2'] = xmlns2 self.cfg['xmlns3'] = xmlns3 self.cfg['xmlns4'] = xmlns4 self.cfg['xmlns5'] = xmlns5 self.cfg['xmlns6'] = xmlns6 self.cfg['xmlns7'] = xmlns7 self.cfg['xmlns8'] = xmlns8 self.cfg['http-agent'] = httpAgent self.cfg['agent-support'] = agentSupport self.cfg['http_support_authentication'] = httpAuthentication self.cfg['http_digest_timeout'] = 10.0 if agentSupport: self.cfg['agent'] = agent self.cfg['agent-name'] = agent['name'] # digest library self.rfc2617 = LibraryAuth.Digest(parent=parent, debug=debug) self.__checkConfig()
def __init__(self, userName='******', testData=''): """ This class describes the model of one script document, and provides a xml <=> python encoder The following xml : <?xml version="1.0" encoding="utf-8" ?> <file> <properties"> <descriptions> <description> <key>author</key> <value>...</value> </description> <description> <key>creation date</key> <value>...</value> </description> <description> <key>summary</key> <value>...</value> </description> </descriptions> <parameters> <parameter> <name>...</name> <type>...</type> <description>...</description> <value>...</value> </parameter> </parameters> </properties> <testdata>...</testdata> </file> """ GenericModel.GenericModel.__init__(self) today = datetime.datetime.today() self.dateToday = today.strftime("%d/%m/%Y %H:%M:%S") self.currentUser = userName # init xml codec self.codecX2D = PyXmlDict.Xml2Dict() self.codecD2X = PyDictXml.Dict2Xml(coding=None) # files properties self.properties = { 'properties': { 'descriptions': { 'description': [{ 'key': 'author', 'value': self.currentUser }, { 'key': 'creation date', 'value': self.dateToday }, { 'key': 'summary', 'value': 'Just a basic sample.' }, { 'key': 'data mode', 'value': DEFAULT_MODE }] }, 'inputs-parameters': { 'parameter': [{ 'type': 'str', 'name': 'PARAM1', 'description': '', 'value': 'Sample', 'color': '', 'scope': 'local' }] } } } self.testdata = testData