Best Testsigma code snippet using com.testsigma.agent.ws.server.AgentWebServer.getCertificate
Source: AgentWebServer.java
...73 AgentWebServerConfigDTO agentWebServerConfigDTO = agentWebServerService.getWebServerCertificate();74 if (agentWebServerConfigDTO == null) {75 throw new Exception("Could not fetch agent web server config from Testsigma cloud...");76 }77 this.certificate = getCertificate(agentWebServerConfigDTO);78 this.key = agentWebServerConfigDTO.getKey();79 this.isCertificateFetched = true;80 }81 }82 private void startDefaultHttpConnector() {83 log.info("Starting agent HTTP connector at port - " + this.defaultHttpPort);84 }85 private void startDefaultHttpsConnector() throws Exception {86 this.defaultHttpsServerConnector = this.startHttpsConnector(Integer.parseInt(this.defaultHttpsPort));87 }88 private void stopDefaultHttpConnector() {89 log.info("Stopping agent HTTP connector running on port - " + this.defaultHttpPort);90 }91 private void stopDefaultHttpsConnector() throws Exception {92 if ((this.defaultHttpsServerConnector != null) && (this.defaultHttpsServerConnector.isRunning())) {93 log.info("Stopping agent HTTP connector running on port - " + this.defaultHttpsPort);94 this.defaultHttpsServerConnector.stop();95 }96 this.defaultHttpsServerConnector = null;97 }98 private ServerConnector startHttpsConnector(int httpsPort) throws Exception {99 log.info("Starting agent HTTPS connector at port - " + httpsPort);100 ServerConnector serverConnector;101 SslContextFactory.Server context = new SslContextFactory.Server();102 KeyStore keyStore = KeyStore.getInstance("PKCS12");103 try (ByteArrayInputStream certificateStream = new ByteArrayInputStream(this.certificate)) {104 keyStore.load(certificateStream, new String(this.key, StandardCharsets.UTF_8).toCharArray());105 }106 context.setKeyStore(keyStore);107 context.setKeyStorePassword(new String(this.key, StandardCharsets.UTF_8));108 serverConnector = new ServerConnector(this.server, context);109 serverConnector.setPort(httpsPort);110 serverConnector.start();111 this.server.addConnector(serverConnector);112 return serverConnector;113 }114 private byte[] getCertificate(AgentWebServerConfigDTO agentWebServerConfigDTO) {115 try {116 if (agentWebServerConfigDTO.getCertificatePresignedURL() != null) {117 String fileName = FilenameUtils.getName(agentWebServerConfigDTO.getCertificatePresignedURL().getPath());118 File destinationFile = Paths.get(FileUtils.getTempDirectory().toString(), fileName).toFile();119 FileUtils.copyURLToFile(agentWebServerConfigDTO.getCertificatePresignedURL(), destinationFile, (60 * 1000), (60 * 1000));120 if (destinationFile.exists()) {121 return FileUtils.readFileToByteArray(destinationFile);122 } else {123 log.error("Couldn't not fetch certificate from - " + agentWebServerConfigDTO.getCertificatePresignedURL());124 }125 }126 } catch (Exception e) {127 log.error(e.getMessage());128 }129 return agentWebServerConfigDTO.getCertificate();130 }131}...
Check out the latest blogs from LambdaTest on this topic:
If you are a web tester then somewhere down the road you will have to come across Selenium, an open-source test automation framework that has been on boom ever since its launch in 2004.
This article is a part of our Content Hub. For more in-depth resources, check out our content hub on Mobile App Testing Tutorial.
Smartphones have changed the way humans interact with technology. Be it travel, fitness, lifestyle, video games, or even services, it’s all just a few touches away (quite literally so). We only need to look at the growing throngs of smartphone or tablet users vs. desktop users to grasp this reality.
Desired Capabilities is a class used to declare a set of basic requirements such as combinations of browsers, operating systems, browser versions, etc. to perform automated cross browser testing of a web application.
The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!