diff --git a/.circleci/config.yml b/.circleci/config.yml index df27e029d..c573fef52 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,19 +20,21 @@ jobs: - setup_remote_docker - - run: + - run: name: "Create and start all services from the docker-compose configuration" command: | cp example/src/main/resources/application.properties.example ./example/src/main/resources/application.properties docker-compose up --build -d docker run --network container:mms curlimages/curl --retry 8 --retry-delay 10 --retry-max-time 90 --retry-connrefused http://mms:8080/healthcheck - - run: + - run: name: "Run and test Postman Collection" command: | docker create -v /etc/newman --name mms_test_configs alpine:3.4 /bin/true docker cp example/. mms_test_configs:/etc/newman docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run crud.postman_collection.json -e test-env.json --delay-request 500 + docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run getAtCommits.postman_collection.json -e test-env.json --delay-request 500 + docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run makeBranchFromCommit.postman_collection.json -e test-env.json --delay-request 500 docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run cameo.postman_collection.json -e test-env.json --delay-request 1000 docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run jupyter.postman_collection.json -e test-env.json --delay-request 500 docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run localauth.postman_collection.json -e test-env.json --delay-request 500 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index a0c403c64..57f555c9e 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -17,6 +17,6 @@ sphinx: # We recommend specifying your dependencies to enable reproducible builds: # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html -# python: -# install: -# - requirements: docs/requirements.txt \ No newline at end of file +python: + install: + - requirements: docs/requirements.txt \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6dc76ae86..5df7cf391 100644 --- a/build.gradle +++ b/build.gradle @@ -62,6 +62,7 @@ subprojects { group = "org.openmbee.mms" version = rootProject.version + ext['jackson-bom.version'] = jacksonVersion Map commonDependencies = rootProject.ext.commonDependencies @@ -157,4 +158,4 @@ subprojects { sign publishing.publications.mavenJava } } -} +} \ No newline at end of file diff --git a/core/src/main/java/org/openmbee/mms/core/dao/CommitIndexDAO.java b/core/src/main/java/org/openmbee/mms/core/dao/CommitIndexDAO.java index 34926b267..41d91fb04 100644 --- a/core/src/main/java/org/openmbee/mms/core/dao/CommitIndexDAO.java +++ b/core/src/main/java/org/openmbee/mms/core/dao/CommitIndexDAO.java @@ -25,6 +25,8 @@ public interface CommitIndexDAO { List elementHistory(String id, Set commitIds); + List elementDeletedHistory(String id, Collection commitIds); + CommitJson update(CommitJson commitJson); } diff --git a/core/src/main/java/org/openmbee/mms/core/services/BranchService.java b/core/src/main/java/org/openmbee/mms/core/services/BranchService.java index 83831dad8..bc61f413d 100644 --- a/core/src/main/java/org/openmbee/mms/core/services/BranchService.java +++ b/core/src/main/java/org/openmbee/mms/core/services/BranchService.java @@ -10,6 +10,7 @@ public interface BranchService { RefsResponse getBranch(String projectId, String id); RefJson createBranch(String projectId, RefJson branch); + RefJson createBranchfromCommit(String projectId, RefJson branch, NodeService nodeService); RefsResponse deleteBranch(String projectId, String id); } diff --git a/crud/src/main/java/org/openmbee/mms/crud/controllers/branches/BranchesController.java b/crud/src/main/java/org/openmbee/mms/crud/controllers/branches/BranchesController.java index 851701b83..598821731 100644 --- a/crud/src/main/java/org/openmbee/mms/crud/controllers/branches/BranchesController.java +++ b/crud/src/main/java/org/openmbee/mms/crud/controllers/branches/BranchesController.java @@ -96,9 +96,7 @@ public RefsResponse createRefs( if (branch.getParentCommitId() == null || branch.getParentCommitId().isEmpty()) { res = branchService.createBranch(projectId, branch); } else { - //TODO implement branching from historical commit - response.addRejection(new Rejection(branch, 400, "Branching from historical commits is not implemented.")); - continue; + res = branchService.createBranchfromCommit(projectId, branch, getNodeService(projectId)); } permissionService.initBranchPerms(projectId, branch.getId(), true, auth.getName()); diff --git a/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java b/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java index 365bc3379..0945aa916 100644 --- a/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java +++ b/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java @@ -5,11 +5,7 @@ import org.openmbee.mms.core.config.Constants; import org.openmbee.mms.core.config.ContextHolder; import org.openmbee.mms.core.config.Formats; -import org.openmbee.mms.core.dao.BranchDAO; -import org.openmbee.mms.core.dao.BranchIndexDAO; -import org.openmbee.mms.core.dao.CommitDAO; -import org.openmbee.mms.core.dao.NodeDAO; -import org.openmbee.mms.core.dao.NodeIndexDAO; +import org.openmbee.mms.core.dao.*; import org.openmbee.mms.core.exceptions.BadRequestException; import org.openmbee.mms.core.exceptions.DeletedException; import org.openmbee.mms.core.exceptions.InternalErrorException; @@ -18,9 +14,11 @@ import org.openmbee.mms.core.objects.RefsResponse; import org.openmbee.mms.core.services.BranchService; import org.openmbee.mms.core.services.EventService; +import org.openmbee.mms.core.services.NodeService; import org.openmbee.mms.data.domains.scoped.Branch; import org.openmbee.mms.data.domains.scoped.Commit; import org.openmbee.mms.data.domains.scoped.Node; +import org.openmbee.mms.json.ElementJson; import org.openmbee.mms.json.RefJson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +43,15 @@ public class DefaultBranchService implements BranchService { private NodeIndexDAO nodeIndex; protected Collection eventPublisher; + protected NodeGetHelper nodeGetHelper; + + + + @Autowired + public void setNodeGetHelper(NodeGetHelper nodeGetHelper) { + this.nodeGetHelper = nodeGetHelper; + } + @Autowired public void setBranchRepository(BranchDAO branchRepository) { @@ -129,8 +136,8 @@ public RefJson createBranch(String projectId, RefJson branch) { branch.setCreated(Formats.FORMATTER.format(now)); branch.setDeleted(false); branch.setProjectId(projectId); - branch.setStatus("created"); - + boolean fromCommit = branch.getParentCommitId() == null ? false : true; + branch.setStatus(fromCommit ? "creating" : "created"); if (branch.getDocId() == null || branch.getDocId().isEmpty()) { String docId = branchIndex.createDocId(branch); branch.setDocId(docId); @@ -145,18 +152,26 @@ public RefJson createBranch(String projectId, RefJson branch) { b.setParentRefId(Constants.MASTER_BRANCH); } - //This service cannot create branches from historic versions - if (branch.getParentCommitId() != null) { - throw new BadRequestException("Internal Error: Invalid branch creation logic."); - } - Optional refOption = branchRepository.findByBranchId(b.getParentRefId()); if (refOption.isPresent()) { - Optional parentCommit = commitRepository.findLatestByRef(refOption.get()); - parentCommit.ifPresent(parent -> { - b.setParentCommit(parent.getId()); - branch.setParentCommitId(parent.getCommitId()); //commit id is same as its docId - }); + if(branch.getParentCommitId() != null){ + Optional commitRequestId = commitRepository.findByCommitId(branch.getParentCommitId()); + commitRequestId.ifPresentOrElse(commit -> { + Optional parentCommit = commitRepository.findByRefAndTimestamp(refOption.get(), commit.getTimestamp()); + parentCommit.ifPresent(parent -> { + b.setParentCommit(parent.getId()); + branch.setParentCommitId(parent.getCommitId()); + }); + }, + () -> { throw new BadRequestException(new RefsResponse().addMessage("parentCommitId not found " + now.toString())); + }); + } else { + Optional parentCommit = commitRepository.findLatestByRef(refOption.get()); + parentCommit.ifPresent(parent -> { + b.setParentCommit(parent.getId()); + branch.setParentCommitId(parent.getCommitId()); //commit id is same as its docId + }); + } } if (b.getParentCommit() == null) { @@ -167,11 +182,14 @@ public RefJson createBranch(String projectId, RefJson branch) { try { branchIndex.update(branch); branchRepository.save(b); - Set docIds = new HashSet<>(); - for (Node n: nodeRepository.findAllByDeleted(false)) { - docIds.add(n.getDocId()); + if(!fromCommit) { + Set docIds = new HashSet<>(); + for (Node n: nodeRepository.findAllByDeleted(false)) { + docIds.add(n.getDocId()); + } + + try { nodeIndex.addToRef(docIds); } catch(Exception e) {} } - try { nodeIndex.addToRef(docIds); } catch(Exception e) {} eventPublisher.forEach((pub) -> pub.publish( EventObject.create(projectId, branch.getId(), "branch_created", branch))); return branch; @@ -181,6 +199,60 @@ public RefJson createBranch(String projectId, RefJson branch) { throw new InternalErrorException(e); } } + public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRef, NodeService nodeService) { + Instant now = Instant.now(); + + if(parentCommitIdRef.getParentCommitId().isEmpty()){ + throw new BadRequestException(new RefsResponse().addMessage("parentCommitId not provided " + now.toString())); + } + + ContextHolder.setContext(projectId); + Optional parentCommit = commitRepository.findByCommitId(parentCommitIdRef.getParentCommitId()); + + // Get Commit object + String parentCommitID = parentCommit.map(Commit::getCommitId).orElseThrow(() -> + new BadRequestException(new RefsResponse().addMessage("parentCommitId not found " + now.toString()))); + + // Get Commit parentRef, the branch will be created from this + String parentRef = parentCommit.map(Commit::getBranchId).orElseThrow(() -> + new BadRequestException(new RefsResponse().addMessage("Ref from parentCommitId not found" + now.toString()))); + + parentCommitIdRef.setParentRefId(parentRef); + ContextHolder.setContext(projectId, parentRef); + + RefJson branchFromCommit = this.createBranch(projectId, parentCommitIdRef); + ContextHolder.setContext(projectId, branchFromCommit.getId()); + + // Get current nodes from database + List nodes = nodeRepository.findAll(); + // Get elements from index + Collection result = nodeGetHelper.processGetJsonFromNodes(nodes, parentCommitID, nodeService) + .getActiveElementMap().values(); + + Map nodeCommitData = new HashMap<>(); + for (ElementJson element : result) { + nodeCommitData.put(element.getId(), element); + } + + // Update database table to match index + Set docIds = new HashSet<>(); + for (Node node : nodes) { + if(nodeCommitData.containsKey(node.getNodeId())){ + node.setDocId(nodeCommitData.get(node.getNodeId()).getDocId()); + node.setLastCommit(nodeCommitData.get(node.getNodeId()).getCommitId()); + node.setDeleted(false); + docIds.add(node.getDocId()); + } else { + node.setDeleted(true); + } + } + nodeRepository.updateAll(nodes); + branchFromCommit.setStatus("created"); + branchIndex.update(branchFromCommit); + try { nodeIndex.addToRef(docIds); } catch(Exception e) {} + + return branchFromCommit; + } public RefsResponse deleteBranch(String projectId, String id) { ContextHolder.setContext(projectId); diff --git a/crud/src/main/java/org/openmbee/mms/crud/services/NodeGetHelper.java b/crud/src/main/java/org/openmbee/mms/crud/services/NodeGetHelper.java index 61faa7226..00e14f78f 100644 --- a/crud/src/main/java/org/openmbee/mms/crud/services/NodeGetHelper.java +++ b/crud/src/main/java/org/openmbee/mms/crud/services/NodeGetHelper.java @@ -13,7 +13,10 @@ import org.openmbee.mms.data.domains.scoped.Branch; import org.openmbee.mms.data.domains.scoped.Commit; import org.openmbee.mms.data.domains.scoped.Node; +import org.openmbee.mms.core.dao.CommitIndexDAO; +import org.openmbee.mms.json.CommitJson; import org.openmbee.mms.json.ElementJson; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import static org.openmbee.mms.core.config.ContextHolder.getContext; @@ -21,6 +24,13 @@ @Service public class NodeGetHelper extends NodeOperation { + protected CommitIndexDAO commitIndex; + + @Autowired + public void setCommitIndex(CommitIndexDAO commitIndex) { + this.commitIndex = commitIndex; + } + public NodeGetInfo processGetJsonFromNodes(List nodes, NodeService service) { NodeGetInfo info = initInfoFromNodes(nodes, null); return processLatest(info, service); @@ -122,14 +132,25 @@ private NodeGetInfo processCommit(NodeGetInfo info, String commitId, NodeService Optional e = nodeIndex.getElementLessThanOrEqualTimestamp(nodeId, formatter.format(time), refCommitIds); if (e.isPresent()) { // found version of element at commit time - //TODO determine if element was deleted at the time? - e.get().setRefId(ContextHolder.getContext().getBranchId()); - info.getActiveElementMap().put(nodeId, e.get()); + Instant realModified = Instant.from(formatter.parse(e.get().getModified())); + if (elementDeleted(nodeId, commitId, time, realModified, refCommitIds)) { + rejectDeleted(info, nodeId, e.get()); + } else { + e.get().setRefId(ContextHolder.getContext().getBranchId()); + info.getActiveElementMap().put(nodeId, e.get()); + } } else { rejectNotFound(info, nodeId); // element not found at commit time } } else if (info.getExistingNodeMap().get(nodeId).isDeleted()) { // latest element is before commit, but deleted - rejectDeleted(info, nodeId, indexElement); + if (refCommitIds == null) { // need list of commitIds of current ref to filter on + refCommitIds = getRefCommitIds(time); + } + if (elementDeleted(nodeId, commitId, time, modified, refCommitIds)) { + rejectDeleted(info, nodeId, indexElement); + } else { + info.getActiveElementMap().put(nodeId, indexElement); + } } else { // latest element version is version at commit, not deleted info.getActiveElementMap().put(nodeId, indexElement); } @@ -137,6 +158,19 @@ private NodeGetInfo processCommit(NodeGetInfo info, String commitId, NodeService return info; } + private boolean elementDeleted(String nodeId, String commitId, Instant time, Instant modified, List refCommitIds) { + List commits = commitIndex.elementDeletedHistory(nodeId, refCommitIds); + for (CommitJson c: commits) { + Instant deletedTime = Instant.from(formatter.parse(c.getCreated())); + if ((deletedTime.isBefore(time) || c.getId().equals(commitId)) && deletedTime.isAfter(modified)) { + //there's a delete between element last modified time and requested commit time + //or element is deleted at commit + return true; + } + } + return false; + } + public NodeGetInfo processGetJson(List elements, Instant time, NodeService service) { Optional ref = branchRepository.findByBranchId(getContext().getBranchId()); if (ref.isPresent()) { diff --git a/data/data.gradle b/data/data.gradle index a4b4c31c0..ee1f7eaa4 100644 --- a/data/data.gradle +++ b/data/data.gradle @@ -10,4 +10,4 @@ dependencies { api commonDependencies.'hibernate-core' testImplementation commonDependencies.'spring-boot-starter-test' -} +} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 24beaec43..877a104e7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,7 +26,7 @@ master_doc = 'index' # The full version, including alpha/beta/rc tags -release = '4.0.19' +release = '4.0.20' # -- General configuration --------------------------------------------------- @@ -57,4 +57,4 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ['_static'] \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..52b04f2ec --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1 @@ +sphinx_rtd_theme \ No newline at end of file diff --git a/elastic/README.rst b/elastic/README.rst index fb849369d..eec5cf46e 100644 --- a/elastic/README.rst +++ b/elastic/README.rst @@ -21,6 +21,16 @@ The following are a list of options to configure the Elastic Module for MMS. elasticsearch.http The transport protocol to use to connect to the Elasticsearch server or cluster. Required. + elasticsearch.username + Username, Optional. + + | `Default: null` + + elasticsearch.password + Password, Optional. + + | `Default: null` + elasticsearch.limit.result The maximum number of results a single search request should return. Optional. diff --git a/elastic/src/main/java/org/openmbee/mms/elastic/CommitElasticDAOImpl.java b/elastic/src/main/java/org/openmbee/mms/elastic/CommitElasticDAOImpl.java index 9cb2ce422..7c760023a 100644 --- a/elastic/src/main/java/org/openmbee/mms/elastic/CommitElasticDAOImpl.java +++ b/elastic/src/main/java/org/openmbee/mms/elastic/CommitElasticDAOImpl.java @@ -124,6 +124,33 @@ private QueryBuilder getCommitHistoryQuery(String id, Set commitIds) { return query; } + @Override + public List elementDeletedHistory(String id, Collection commitIds) { + QueryBuilder query = QueryBuilders.boolQuery() + .filter(QueryBuilders.termQuery("deleted.id", id)) + .filter(QueryBuilders.termsQuery(CommitJson.ID, commitIds)); + try { + List commits = new ArrayList<>(); + SearchHits hits = getCommitResults(query); + if (hits.getTotalHits().value == 0) { + return new ArrayList<>(); + } + for (SearchHit hit : hits.getHits()) { + Map source = hit.getSourceAsMap();// gets "_source" + CommitJson ob = newInstance(); + ob.putAll(source); + ob.remove(CommitJson.ADDED); + ob.remove(CommitJson.UPDATED); + ob.remove(CommitJson.DELETED); + commits.add(ob); + } + return commits; + } catch (IOException e) { + logger.error(e.getMessage(), e); + throw new InternalErrorException(e); + } + } + /** * Returns the commit history of a element *

Returns a list of commit metadata for the specified id diff --git a/elastic/src/main/java/org/openmbee/mms/elastic/config/ElasticsearchConfig.java b/elastic/src/main/java/org/openmbee/mms/elastic/config/ElasticsearchConfig.java index 7a8866c50..be2380345 100644 --- a/elastic/src/main/java/org/openmbee/mms/elastic/config/ElasticsearchConfig.java +++ b/elastic/src/main/java/org/openmbee/mms/elastic/config/ElasticsearchConfig.java @@ -1,8 +1,14 @@ package org.openmbee.mms.elastic.config; import org.apache.http.HttpHost; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; +import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback; import org.elasticsearch.client.RestHighLevelClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; @@ -18,11 +24,35 @@ public class ElasticsearchConfig { @Value("${elasticsearch.http}") private String elasticsearchHttp; + @Value("${elasticsearch.password:#{null}}") + private String elasticsearchPassword; + @Value("${elasticsearch.username:#{null}}") + private String elasticsearchUsername; + @Bean(name = "clientElastic", destroyMethod = "close") public RestHighLevelClient restClient() { + + RestClientBuilder builder = RestClient.builder(new HttpHost(elasticsearchHost, elasticsearchPort, elasticsearchHttp)); builder.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(10000).setSocketTimeout(1000000)); + + if (elasticsearchPassword != null && elasticsearchUsername != null && !elasticsearchPassword.isEmpty() && !elasticsearchUsername.isEmpty()) { + final CredentialsProvider credentialsProvider = + new BasicCredentialsProvider(); + credentialsProvider.setCredentials(AuthScope.ANY, + new UsernamePasswordCredentials(elasticsearchUsername, elasticsearchPassword)); + builder.setHttpClientConfigCallback(new HttpClientConfigCallback() { + @Override + public HttpAsyncClientBuilder customizeHttpClient( + HttpAsyncClientBuilder httpClientBuilder) { + return httpClientBuilder + .setDefaultCredentialsProvider(credentialsProvider); + } + }); + } + + RestHighLevelClient client = new RestHighLevelClient(builder); return client; } diff --git a/elastic/src/main/resources/application.properties.example b/elastic/src/main/resources/application.properties.example index 380f79b2a..0725b51f5 100644 --- a/elastic/src/main/resources/application.properties.example +++ b/elastic/src/main/resources/application.properties.example @@ -5,4 +5,8 @@ elasticsearch.limit.result=100 elasticsearch.limit.term=100 elasticsearch.limit.scrollTimeout=1000 elasticsearch.limit.get=100000 -elasticsearch.limit.index=5000 \ No newline at end of file +elasticsearch.limit.index=5000 + +#Optional Elasticsearch Basic Authentication Credentials +elasticsearch.username= +elasticsearch.password= \ No newline at end of file diff --git a/example/example.gradle b/example/example.gradle index bc279fa9e..5eca0e129 100644 --- a/example/example.gradle +++ b/example/example.gradle @@ -46,6 +46,6 @@ configurations { } } bootJar { - duplicatesStrategy = DuplicatesStrategy.INCLUDE + duplicatesStrategy = DuplicatesStrategy.WARN } ext['elasticsearch.version'] = "$elasticVersion" diff --git a/example/getAtCommits.postman_collection.json b/example/getAtCommits.postman_collection.json new file mode 100644 index 000000000..db2bb4538 --- /dev/null +++ b/example/getAtCommits.postman_collection.json @@ -0,0 +1,884 @@ +{ + "info": { + "_postman_id": "c3e5107f-904c-47a4-8c31-e6bfa70f9ac4", + "name": "GetAtCommits", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "7302261" + }, + "item": [ + { + "name": "login using admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + " ", + "});", + "", + "pm.test(\"response has token\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.token).to.be.a('string');", + " pm.environment.set(\"token\", jsonData.token);", + "", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"username\": \"{{adminUsername}}\",\n\t\"password\": \"{{adminPassword}}\"\n}" + }, + "url": { + "raw": "{{host}}/authentication", + "host": [ + "{{host}}" + ], + "path": [ + "authentication" + ] + } + }, + "response": [] + }, + { + "name": "add org", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has org commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.orgs[0].id).to.eql('commits');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"orgs\": [\n\t\t{\n\t\t\t\"id\": \"commits\",\n\t\t\t\"name\": \"commits\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/orgs", + "host": [ + "{{host}}" + ], + "path": [ + "orgs" + ] + } + }, + "response": [] + }, + { + "name": "add project", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has project commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.projects[0].id).to.eql('commits');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"commits\", \n\t\t\t\"name\": \"commits\",\n\t\t\t\"orgId\": \"commits\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects", + "host": [ + "{{host}}" + ], + "path": [ + "projects" + ] + } + }, + "response": [] + }, + { + "name": "add a and b", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(2);", + "});", + "", + "pm.environment.set(\"addABCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"a\",\n\t\t\t\"name\": \"a\"\n\t\t}, {\n\t\t\t\"id\": \"b\", \n\t\t\t\"name\": \"b\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "add c", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"addCCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"c\",\n\t\t\t\"name\": \"c\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "add d", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"addDCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"d\",\n\t\t\t\"name\": \"d\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "delete a", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"deleteACommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements/a", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements", + "a" + ] + } + }, + "response": [] + }, + { + "name": "update b", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"updateBCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n {\n\t\t\t\"id\": \"b\", \n\t\t\t\"name\": \"b updated\"\n\t\t}\n\t]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "delete c", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"deleteCCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n {\n\t\t\t\"id\": \"c\"\n\t\t}\n\t]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "add e", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"addECommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"e\",\n\t\t\t\"name\": \"e\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "recurrect c", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"resurrectCCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"c\",\n\t\t\t\"name\": \"c\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "get elements at initial commit", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has a and b\", function () {", + " var jsonData = pm.response.json();", + "", + " pm.expect(jsonData.elements.length).to.eql(2);", + " var result = jsonData.elements.map(e => ({id: e.id}));", + " pm.expect(result).to.deep.have.members([{id: 'a'}, {id: 'b'}]);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('addABCommitId'));", + " ", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements?commitId={{addABCommitId}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ], + "query": [ + { + "key": "commitId", + "value": "{{addABCommitId}}" + } + ] + } + }, + "response": [] + }, + { + "name": "get elements at add d", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has a,b,c,d\", function () {", + " var jsonData = pm.response.json();", + "", + " pm.expect(jsonData.elements.length).to.eql(4);", + " var result = jsonData.elements.map(e => ({id: e.id}));", + " pm.expect(result).to.deep.have.members([{id: 'a'}, {id: 'b'}, {id: 'c'}, {id: 'd'}]);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('addDCommitId'));", + " ", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements?commitId={{addDCommitId}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ], + "query": [ + { + "key": "commitId", + "value": "{{addDCommitId}}" + } + ] + } + }, + "response": [] + }, + { + "name": "get elements at delete a", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has b,c,d\", function () {", + " var jsonData = pm.response.json();", + "", + " pm.expect(jsonData.elements.length).to.eql(3);", + " var result = jsonData.elements.map(e => ({id: e.id}));", + " pm.expect(result).to.deep.have.members([{id: 'b'}, {id: 'c'}, {id: 'd'}]);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('deleteACommitId'));", + " ", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements?commitId={{deleteACommitId}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ], + "query": [ + { + "key": "commitId", + "value": "{{deleteACommitId}}" + } + ] + } + }, + "response": [] + }, + { + "name": "get elements at update b", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has b,c,d with updated b name\", function () {", + " var jsonData = pm.response.json();", + "", + " pm.expect(jsonData.elements.length).to.eql(3);", + " var result = jsonData.elements.map(e => ({id: e.id, name: e.name}));", + " pm.expect(result).to.deep.have.members([{id: 'b', name: 'b updated'}, {id: 'c', name: 'c'}, {id: 'd', name: 'd'}]);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('updateBCommitId'));", + " ", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements?commitId={{updateBCommitId}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ], + "query": [ + { + "key": "commitId", + "value": "{{updateBCommitId}}" + } + ] + } + }, + "response": [] + }, + { + "name": "get elements at add e", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has b,d,e\", function () {", + " var jsonData = pm.response.json();", + "", + " pm.expect(jsonData.elements.length).to.eql(3);", + " var result = jsonData.elements.map(e => ({id: e.id}));", + " pm.expect(result).to.deep.have.members([{id: 'b'}, {id: 'd'}, {id: 'e'}]);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('addECommitId'));", + " ", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements?commitId={{addECommitId}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ], + "query": [ + { + "key": "commitId", + "value": "{{addECommitId}}" + } + ] + } + }, + "response": [] + }, + { + "name": "get elements at resurrect c", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has b,c,d,e\", function () {", + " var jsonData = pm.response.json();", + "", + " pm.expect(jsonData.elements.length).to.eql(4);", + " var result = jsonData.elements.map(e => ({id: e.id}));", + " pm.expect(result).to.deep.have.members([{id: 'b'}, {id: 'c'}, {id: 'd'}, {id: 'e'}]);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('resurrectCCommitId'));", + " ", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{host}}/projects/commits/refs/master/elements?commitId={{resurrectCCommitId}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "commits", + "refs", + "master", + "elements" + ], + "query": [ + { + "key": "commitId", + "value": "{{resurrectCCommitId}}" + } + ] + } + }, + "response": [] + } + ], + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ] +} \ No newline at end of file diff --git a/example/makeBranchFromCommit.postman_collection.json b/example/makeBranchFromCommit.postman_collection.json new file mode 100644 index 000000000..817a46cf2 --- /dev/null +++ b/example/makeBranchFromCommit.postman_collection.json @@ -0,0 +1,652 @@ +{ + "info": { + "_postman_id": "1ddbdc4a-79cc-4bec-8118-7e600e908b38", + "name": "MakeBranchFromCommit", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "3693486" + }, + "item": [ + { + "name": "login using admin", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + " ", + "});", + "", + "pm.test(\"response has token\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.token).to.be.a('string');", + " pm.environment.set(\"token\", jsonData.token);", + "", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"username\": \"{{adminUsername}}\",\n\t\"password\": \"{{adminPassword}}\"\n}" + }, + "url": { + "raw": "{{host}}/authentication", + "host": [ + "{{host}}" + ], + "path": [ + "authentication" + ] + } + }, + "response": [] + }, + { + "name": "add org", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has org branch_from_commit\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.orgs[0].id).to.eql('branch_from_commit_org');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"orgs\": [\n\t\t{\n\t\t\t\"id\": \"branch_from_commit_org\",\n\t\t\t\"name\": \"branch_from_commit_org\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/orgs", + "host": [ + "{{host}}" + ], + "path": [ + "orgs" + ] + } + }, + "response": [] + }, + { + "name": "add project", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has project branch_from_commit\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.projects[0].id).to.eql('branch_from_commit');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"branch_from_commit\", \n\t\t\t\"name\": \"branch_from_commit\",\n\t\t\t\"orgId\": \"branch_from_commit_org\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects", + "host": [ + "{{host}}" + ], + "path": [ + "projects" + ] + } + }, + "response": [] + }, + { + "name": "add a and b to master", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(2);", + "});", + "", + "pm.environment.set(\"addABCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"a\",\n\t\t\t\"name\": \"a\"\n\t\t}, {\n\t\t\t\"id\": \"b\", \n\t\t\t\"name\": \"b\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "add c to master", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"addCCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"c\",\n\t\t\t\"name\": \"c\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "add d to master", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"addDCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"d\",\n\t\t\t\"name\": \"d\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "delete a in refa", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"deleteACommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs/master/elements/a", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs", + "master", + "elements", + "a" + ] + } + }, + "response": [] + }, + { + "name": "update b in refa", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"updateBCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n {\n\t\t\t\"id\": \"b\", \n\t\t\t\"name\": \"b updated\"\n\t\t}\n\t]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "delete c in refa", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"deleteCCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n {\n\t\t\t\"id\": \"c\"\n\t\t}\n\t]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "add e to refa", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"addECommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"e\",\n\t\t\t\"name\": \"e\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "recurrect c in refa", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"resurrectCCommitId\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"c\",\n\t\t\t\"name\": \"c\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "create branch from \"add c to master\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"branch created with right parentRef and commit id\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.refs[0].id).to.eql('addCCommitId_branch');", + " pm.expect(jsonData.refs[0].parentRefId).to.eql('master');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"id\": \"addCCommitId_branch\",\n\t\t\t\"name\": \"addCCommitId_branch\",\n\t\t\t\"type\": \"Branch\",\n\t\t\t\"parentCommitId\": \"{{addCCommitId}}\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs" + ] + } + }, + "response": [] + }, + { + "name": "get elements from branch from \"add c to master\"", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has a,b,c\", function () {", + " var jsonData = pm.response.json();", + "", + " pm.expect(jsonData.elements.length).to.eql(3);", + " var result = jsonData.elements.map(e => ({id: e.id}));", + " pm.expect(result).to.deep.have.members([{id: 'a'}, {id: 'b'}, {id: 'c'}]);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('addCCommitId'));", + " ", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{host}}/projects/branch_from_commit/refs/addCCommitId_branch/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "branch_from_commit", + "refs", + "addCCommitId_branch", + "elements" + ] + } + }, + "response": [] + } + ], + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ] +} \ No newline at end of file diff --git a/example/src/main/resources/application-test.properties b/example/src/main/resources/application-test.properties index f36a8f0c7..4ad63d33b 100644 --- a/example/src/main/resources/application-test.properties +++ b/example/src/main/resources/application-test.properties @@ -50,6 +50,8 @@ spring.main.allow-circular-references=true spring.mvc.pathmatch.matching-strategy=ant_path_matcher #Configuration for Elasticsearch +# elasticsearch.username= +# elasticsearch.password= elasticsearch.host=elasticsearch elasticsearch.port=9200 elasticsearch.http=http diff --git a/example/src/main/resources/application.properties.example b/example/src/main/resources/application.properties.example index 128954249..8aa9a0b11 100644 --- a/example/src/main/resources/application.properties.example +++ b/example/src/main/resources/application.properties.example @@ -63,6 +63,10 @@ elasticsearch.limit.get=100000 elasticsearch.limit.index=5000 elasticsearch.limit.commit=100000 +#optional Elasticsearch Basic Authentication Credentials +elasticsearch.username= +elasticsearch.password= + #Configuration for TWC #port is for REST interface #aliases are for clustered usages diff --git a/gradle.properties b/gradle.properties index 336ca74f4..64311ee4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,10 @@ -version=4.0.19 +version=4.0.20 group=org.openmbee.mms -springBootVersion=2.7.17 -springFrameworkVersion=5.3.30 -springSecurityVersion=5.7.10 -springDataVersion=2.7.14 -jacksonVersion=2.13.3 +springBootVersion=2.7.18 +springFrameworkVersion=5.3.31 +springSecurityVersion=5.7.11 +springDataVersion=2.7.18 +jacksonVersion=2.16.1 +jacksonBomVersion=2.16.1 elasticVersion=7.8.1 \ No newline at end of file diff --git a/storage/storage.gradle b/storage/storage.gradle index a83e25503..1d39be869 100644 --- a/storage/storage.gradle +++ b/storage/storage.gradle @@ -1,8 +1,8 @@ dependencies { api project(':artifacts') - implementation 'com.amazonaws:aws-java-sdk-s3:1.11.874' - implementation 'org.apache.tika:tika-parsers:1.24.1' + implementation 'com.amazonaws:aws-java-sdk-s3:1.12.638' + implementation 'org.apache.tika:tika-core:2.9.1' implementation commonDependencies.'servlet-api' testImplementation commonDependencies.'spring-boot-starter-test'