use of javax.annotation.security.PermitAll in project traccar by tananaev.
the class SessionResource method add.
@PermitAll
@POST
public User add(@FormParam("email") String email, @FormParam("password") String password) throws StorageException {
User user = Context.getPermissionsManager().login(email, password);
if (user != null) {
request.getSession().setAttribute(USER_ID_KEY, user.getId());
LogAction.login(user.getId());
return user;
} else {
LogAction.failedLogin(ServletHelper.retrieveRemoteAddress(request));
throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
}
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class FolderResource method importTestcase.
@POST
@Path("{folderId}/importTestcase")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@PermitAll
public Testcase importTestcase(@PathParam("folderId") long folderId, @FormDataParam("file") InputStream inputStream, @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
Testcase testcase = objectMapper.readValue(inputStream, Testcase.class);
long testcaseId = testcaseDAO.createByImport(testcase, folderId);
Testcase result = new Testcase();
result.setId(testcaseId);
return result;
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class TeststepResource method run.
/**
* Run a test step individually (not as part of test case running).
* This is a stateless operation, i.e. not persisting anything in database.
* @param teststep
* @return
*/
@POST
@Path("{teststepId}/run")
@PermitAll
public BasicTeststepRun run(Teststep teststep) throws Exception {
// fetch request binary if its type is file
if (teststep.getRequestType() == TeststepRequestType.FILE) {
teststep.setRequest(teststepDAO.getBinaryRequestById(teststep.getId()));
}
// fetch API request binary if its type is file
if (Teststep.TYPE_FTP.equals(teststep.getType()) && teststep.getApiRequest() instanceof FtpPutRequestFileFromFile) {
teststep.setApiRequest(teststepDAO.getAPIRequestById(teststep.getId()));
}
// gather referenceable string properties and endpoint properties
List<UserDefinedProperty> testcaseUDPs = udpDAO.findByTestcaseId(teststep.getTestcaseId());
Map<String, String> referenceableStringProperties = IronTestUtils.udpListToMap(testcaseUDPs);
referenceableStringProperties.put(IMPLICIT_PROPERTY_NAME_TEST_STEP_START_TIME, IMPLICIT_PROPERTY_DATE_TIME_FORMAT.format(new Date()));
DataTable dataTable = dataTableDAO.getTestcaseDataTable(teststep.getTestcaseId(), true);
Map<String, Endpoint> referenceableEndpointProperties = new HashMap<>();
if (dataTable.getRows().size() > 0) {
IronTestUtils.checkDuplicatePropertyNameBetweenDataTableAndUPDs(referenceableStringProperties.keySet(), dataTable);
referenceableStringProperties.putAll(dataTable.getStringPropertiesInRow(0));
referenceableEndpointProperties.putAll(dataTable.getEndpointPropertiesInRow(0));
}
// run the test step
TeststepRunner teststepRunner = TeststepRunnerFactory.getInstance().newTeststepRunner(teststep, utilsDAO, referenceableStringProperties, referenceableEndpointProperties, null);
BasicTeststepRun basicTeststepRun = teststepRunner.run();
// for better display in browser, transform JSON/XML response to be pretty-printed
switch(teststep.getType()) {
case Teststep.TYPE_SOAP:
HTTPAPIResponse soapAPIResponse = (HTTPAPIResponse) basicTeststepRun.getResponse();
soapAPIResponse.setHttpBody(XMLUtils.prettyPrintXML(soapAPIResponse.getHttpBody()));
break;
case Teststep.TYPE_HTTP:
HTTPAPIResponse httpAPIResponse = (HTTPAPIResponse) basicTeststepRun.getResponse();
httpAPIResponse.setHttpBody(IronTestUtils.prettyPrintJSONOrXML(httpAPIResponse.getHttpBody()));
break;
case Teststep.TYPE_MQ:
if (Teststep.ACTION_DEQUEUE.equals(teststep.getAction())) {
MQDequeueResponse mqDequeueResponse = (MQDequeueResponse) basicTeststepRun.getResponse();
if (mqDequeueResponse != null) {
mqDequeueResponse.setBodyAsText(IronTestUtils.prettyPrintJSONOrXML(mqDequeueResponse.getBodyAsText()));
if (mqDequeueResponse.getMqrfh2Header() != null) {
for (MQRFH2Folder mqrfh2Folder : mqDequeueResponse.getMqrfh2Header().getFolders()) {
mqrfh2Folder.setString(IronTestUtils.prettyPrintJSONOrXML(mqrfh2Folder.getString()));
}
}
}
}
break;
default:
break;
}
return basicTeststepRun;
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class TeststepResource method update.
@PUT
@Path("{teststepId}")
@PermitAll
@JsonView(ResourceJsonViews.TeststepEdit.class)
public TeststepWrapper update(Teststep teststep) throws Exception {
// Restore otherProperties from system database for existing JSONValidAgainstJSONSchema or XMLValidAgainstXSD
// assertions, as they are not supposed to be updated through this API (currently used for UI only).
// Without this code, whenever a new JSONValidAgainstJSONSchema or XMLValidAgainstXSD assertion is added, or an
// existing JSONValidAgainstJSONSchema or XMLValidAgainstXSD assertion is deleted, all existing
// JSONValidAgainstJSONSchema or XMLValidAgainstXSD assertions in the same test step will see their
// otherProperties.fileBytes set to null in system database.
List<Assertion> assertions = teststep.getAssertions();
for (Assertion assertion : assertions) {
if (assertion.getId() != null && (Assertion.TYPE_JSON_VALID_AGAINST_JSON_SCHEMA.endsWith(assertion.getType()) || Assertion.TYPE_XML_VALID_AGAINST_XSD.endsWith(assertion.getType()))) {
assertion.setOtherProperties(assertionDAO.findById(assertion.getId()).getOtherProperties());
}
}
teststepDAO.update(teststep);
TeststepWrapper wrapper = new TeststepWrapper();
Teststep newTeststep = teststep.getRequestType() == TeststepRequestType.FILE ? teststepDAO.findById_NoRequest(teststep.getId()) : teststepDAO.findById_Complete(teststep.getId());
wrapper.setTeststep(newTeststep);
populateParametersInWrapper(wrapper);
return wrapper;
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class EnvironmentResource method create.
@POST
@Path("environments")
@PermitAll
public Environment create() {
Environment result = new Environment();
result.setId(environmentDAO.insert());
return result;
}
Aggregations