def saveExpectation(self, expectationDict, group, APIShortName): requestCommand=expectationDict['command'] if not self.__isSupportedCommand(requestCommand): raise Exception(requestCommand, " request does not support") workingPath=self.getWorkingPath(group, APIShortName, requestCommand) expectationFile=self.getExpectationPath(workingPath) fileHandler=FileWrapper(expectationFile) return fileHandler.saveDictAsJsonFile(expectationDict)
def loadExpectation(self, requestDict, group, APIShortName): requestCommand=expectationDict['command'] if not self.__isSupportedCommand(requestCommand): raise Exception(requestCommand, " request does not support") workingPath=self.getWorkingPath(group, APIShortName, requestCommand) expectationFile=self.getExpectationPath(workingPath) fileHandler=FileWrapper(expectationFile) if not fileHandler.isExist() or fileHandler.expired(): return {} return fileHandler.loadDictFromJsonFile()
def __saveAndSign(self, signNode, parentNode="Message"): workingPath=self.getWorkingPath(signNode) targetFile=os.path.join(workingPath, "message.txt") print targetFile file=FileWrapper(targetFile) xmlContent=self.doc.toprettyxml(indent=' ') file.write(xmlContent) file_name = os.path.dirname(__file__) projectPath = os.path.abspath(file_name) signerPath=os.path.join(projectPath, 'MessageSigner.jar') command='java -jar %s -f %s -m "XML(RSA_SHA1)" -n %s -pn %s -p %s -pp %s' % (signerPath, targetFile, signNode, parentNode, self.privatePath, self.privatePassword) signedMessage=util.runCmd(command) #print signedMessage return signedMessage