use of com.testsigma.agent.dto.AgentDTO in project testsigma by testsigmahq.
the class AgentBrowserService method sync.
public void sync() throws AgentDeletedException {
try {
if (!startSync()) {
return;
}
log.info("Syncing agent details");
String hostName = AgentService.getComputerName();
String uuid = agentConfig.getUUID();
AgentDTO agentDTO = new AgentDTO();
AgentOs osType = AgentOs.getLocalAgentOs();
agentDTO.setOsType(osType);
agentDTO.setOsVersion(AgentService.getOsVersion());
agentDTO.setHostName(hostName);
agentDTO.setIpAddress(NetworkUtil.getCurrentIpAddress());
agentDTO.setAgentVersion(this.agentConfig.getAgentVersion());
agentDTO.setBrowserList(this.getBrowserList());
String authHeader = WebAppHttpClient.BEARER + " " + this.agentConfig.getJwtApiKey();
HttpResponse<AgentDTO> response = httpClient.put(ServerURLBuilder.agentURL(uuid), agentDTO, new TypeReference<>() {
}, authHeader);
log.debug(response);
if (response.getStatusCode() == HttpStatus.OK.value()) {
log.info("Successfully updated latest agent details...");
} else {
log.info("Failed to sync latest hybrid agent details to application server");
log.info("Error code: " + response.getStatusCode() + " - " + response.getStatusMessage());
}
} catch (AgentDeletedException e) {
throw e;
} catch (Exception e) {
log.error(e.getMessage(), e);
}
log.debug("Finished syncing agent details");
}
use of com.testsigma.agent.dto.AgentDTO in project testsigma by testsigmahq.
the class HomeController method register.
@PutMapping(value = "/{uuid}/register", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> register(@PathVariable("uuid") String uuid, @RequestParam(value = "jwtApiKey", required = false) String jwtApiKey) {
ResponseEntity<String> response = new ResponseEntity<String>(HttpStatus.ACCEPTED);
try {
log.debug("Received sync request for agent with uuid - " + uuid);
String hostName = AgentService.getComputerName();
AgentOs osType = AgentOs.getLocalAgentOs();
AgentDTO agentDTO = new AgentDTO();
agentDTO.setHostName(hostName);
agentDTO.setOsVersion(AgentService.getOsVersion());
agentDTO.setAgentVersion(this.agentConfig.getAgentVersion());
agentDTO.setBrowserList(agentBrowserService.getBrowserList());
agentDTO.setHostName(hostName);
agentDTO.setOsType(osType);
String authHeader = WebAppHttpClient.BEARER + " " + jwtApiKey;
HttpResponse<AgentDTO> syncResponse = httpClient.put(ServerURLBuilder.agentURL(uuid), agentDTO, new TypeReference<>() {
}, authHeader);
if (syncResponse.getStatusCode() == HttpStatus.OK.value()) {
agentConfig.setJwtApiKey(jwtApiKey);
agentConfig.setUUID(uuid);
agentConfig.setRegistered("true");
agentConfig.saveConfig();
BaseScheduler.setSkip(Boolean.FALSE);
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(androidDeviceListener);
ExecutorService executorService1 = Executors.newSingleThreadExecutor();
executorService1.submit(iosDeviceListener);
} else {
response = new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
return response;
}
use of com.testsigma.agent.dto.AgentDTO in project testsigma by testsigmahq.
the class AgentsController method getAgentInfo.
@GetMapping(value = "/agent_info")
public ResponseEntity<AgentDTO> getAgentInfo() {
log.info("Processing request /api/v1/agent/agent_info");
AgentDTO agentDTO = new AgentDTO();
agentDTO.setHostName(AgentService.getComputerName());
agentDTO.setOsType(AgentOs.getLocalAgentOs());
agentDTO.setOsVersion(AgentService.getOsVersion());
agentDTO.setAgentVersion(this.agentConfig.getAgentVersion());
agentDTO.setIsRegistered(this.agentConfig.getRegistered());
agentDTO.setUniqueId(this.agentConfig.getUUID());
agentDTO.setIpAddress(NetworkUtil.getCurrentIpAddress());
return new ResponseEntity<>(agentDTO, HttpStatus.OK);
}
use of com.testsigma.agent.dto.AgentDTO in project testsigma by testsigmahq.
the class RootController method welcomePage.
@RequestMapping(value = { "/" }, method = RequestMethod.GET)
public String welcomePage(Model model) throws Exception {
try {
String uuid = agentConfig.getUUID();
log.debug("Fetching agent information with UUID - " + uuid);
String authHeader = WebAppHttpClient.BEARER + " " + this.agentConfig.getJwtApiKey();
HttpResponse<AgentDTO> response = httpClient.get(ServerURLBuilder.agentURL(uuid), new TypeReference<>() {
}, authHeader);
if (response.getStatusCode() == HttpStatus.OK.value()) {
AgentDTO agentDTO = response.getResponseEntity();
model.addAttribute("registered", this.agentConfig.getRegistered());
model.addAttribute("agentName", agentDTO.getTitle());
model.addAttribute("hostName", agentDTO.getHostName());
model.addAttribute("osType", agentDTO.getOsType().getName());
model.addAttribute("ipAddress", agentDTO.getIpAddress());
model.addAttribute("agentVersion", agentDTO.getAgentVersion());
} else {
model.addAttribute("registered", false);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
// View name
return "dashboard";
}
Aggregations