From eb17e9a9d91445854f020b1a0191306217583840 Mon Sep 17 00:00:00 2001 From: chas galey Date: Wed, 3 Jan 2024 09:31:34 -0700 Subject: [PATCH 01/23] Propose Elastic Authentication capabilities --- .../elastic/config/ElasticsearchConfig.java | 33 +++++++++++++++++-- .../resources/application.properties.example | 2 ++ .../resources/application-test.properties | 2 ++ .../resources/application.properties.example | 2 ++ 4 files changed, 37 insertions(+), 2 deletions(-) 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..fcf5cfd94 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,13 +24,36 @@ public class ElasticsearchConfig { @Value("${elasticsearch.http}") private String elasticsearchHttp; + @Value("${elasticsearch.password}") + private String elasticsearchPassword; + @Value("${elasticsearch.username}") + 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)); - RestHighLevelClient client = new RestHighLevelClient(builder); - return client; + + if (! 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); + } + }); + } + + + return new RestHighLevelClient(builder); } } \ No newline at end of file diff --git a/elastic/src/main/resources/application.properties.example b/elastic/src/main/resources/application.properties.example index 380f79b2a..def6d31b9 100644 --- a/elastic/src/main/resources/application.properties.example +++ b/elastic/src/main/resources/application.properties.example @@ -1,3 +1,5 @@ +# elasticsearch.username= +# elasticsearch.password= elasticsearch.host=localhost elasticsearch.port=9200 elasticsearch.http=http 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..db9abac78 100644 --- a/example/src/main/resources/application.properties.example +++ b/example/src/main/resources/application.properties.example @@ -51,6 +51,8 @@ spring.main.allow-circular-references=true spring.mvc.pathmatch.matching-strategy=ant_path_matcher #Configuration for Elasticsearch +# elasticsearch.username= +# elasticsearch.password= elasticsearch.host=localhost elasticsearch.port=9200 elasticsearch.http=http From e055abb94f0c81ff5a3057e78e7660b7eb55f67f Mon Sep 17 00:00:00 2001 From: chas galey Date: Tue, 16 Jan 2024 11:01:19 -0700 Subject: [PATCH 02/23] fix review feedback --- .../openmbee/mms/elastic/config/ElasticsearchConfig.java | 5 +++-- elastic/src/main/resources/application.properties.example | 8 +++++--- example/src/main/resources/application.properties.example | 6 ++++-- 3 files changed, 12 insertions(+), 7 deletions(-) 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 fcf5cfd94..66e92cc69 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 @@ -37,7 +37,7 @@ public RestHighLevelClient restClient() { RestClientBuilder builder = RestClient.builder(new HttpHost(elasticsearchHost, elasticsearchPort, elasticsearchHttp)); builder.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(10000).setSocketTimeout(1000000)); - if (! elasticsearchPassword.isEmpty() && ! elasticsearchUsername.isEmpty()) { + if (elasticsearchPassword != null && elasticsearchUsername != null && !elasticsearchPassword.isEmpty() && !elasticsearchUsername.isEmpty()) { final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, @@ -53,7 +53,8 @@ public HttpAsyncClientBuilder customizeHttpClient( } - return new RestHighLevelClient(builder); + RestHighLevelClient client = new RestHighLevelClient(builder); + return client; } } \ No newline at end of file diff --git a/elastic/src/main/resources/application.properties.example b/elastic/src/main/resources/application.properties.example index def6d31b9..0725b51f5 100644 --- a/elastic/src/main/resources/application.properties.example +++ b/elastic/src/main/resources/application.properties.example @@ -1,5 +1,3 @@ -# elasticsearch.username= -# elasticsearch.password= elasticsearch.host=localhost elasticsearch.port=9200 elasticsearch.http=http @@ -7,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/src/main/resources/application.properties.example b/example/src/main/resources/application.properties.example index db9abac78..8aa9a0b11 100644 --- a/example/src/main/resources/application.properties.example +++ b/example/src/main/resources/application.properties.example @@ -51,8 +51,6 @@ spring.main.allow-circular-references=true spring.mvc.pathmatch.matching-strategy=ant_path_matcher #Configuration for Elasticsearch -# elasticsearch.username= -# elasticsearch.password= elasticsearch.host=localhost elasticsearch.port=9200 elasticsearch.http=http @@ -65,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 From 04abd4f37a2271fcb56ef29e974546954d61746e Mon Sep 17 00:00:00 2001 From: Bryan Orozco Date: Wed, 7 Feb 2024 08:17:53 -0800 Subject: [PATCH 03/23] wip: status check-in --- .../mms/core/services/BranchService.java | 1 + .../branches/BranchesController.java | 6 +- .../crud/services/DefaultBranchService.java | 67 ++++++++++++++++--- 3 files changed, 62 insertions(+), 12 deletions(-) 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..1adc2427c 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 parentCommitId, 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..6db4b002d 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 @@ -9,6 +9,7 @@ import org.openmbee.mms.core.objects.RefsResponse; import org.openmbee.mms.core.objects.Rejection; import org.openmbee.mms.core.services.BranchService; +import org.openmbee.mms.core.services.NodeService; import org.openmbee.mms.crud.controllers.BaseController; import org.openmbee.mms.json.RefJson; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +18,7 @@ import org.springframework.security.core.Authentication; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import java.util.ArrayList; import java.util.List; @@ -97,8 +99,8 @@ public RefsResponse createRefs( 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..7abeac682 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,6 +14,7 @@ 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; @@ -45,6 +42,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) { @@ -145,11 +151,6 @@ 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()); @@ -182,6 +183,52 @@ public RefJson createBranch(String projectId, RefJson branch) { } } + public RefJson createBranchfromCommit(String projectId, RefJson branch, NodeService nodeService) { + Instant now = Instant.now(); + ContextHolder.setContext(projectId); + // Check commit exists + // Create a new branch, from the branch that the commit was made under + // Get all elements in the commit and update the branch. + // Get all deleted elements and remove them from branch + // Return branch +// for (Node n: nodeRepository.findAll()) { +// System.out.println(n.getNodeId()); +// } + +// Optional parentCommit = commitRepository.findByCommitId(branch.getParentCommitId()); +// String parentCommitID = parentCommit.map(Commit::getCommitId).orElse("UNKNOWN"); // TODO: Need to remove UNKNOWN else +// +// String parentRef = parentCommit.map(Commit::getBranchId).orElse("UNKNOWN"); // TODO: Need to remove UNKNOWN else +// +// RefJson newBranch = this.createBranch(projectId, branch); + +// List nodes = nodeRepository.findAll(); // database table +// try { +// Collection result = nodeGetHelper.processGetJsonFromNodes(nodes, parentCommitID, nodeService) +// .getActiveElementMap().values(); // elastic search +// result.forEach(res ->{ +// System.out.println(res.getDocId()); +// }); +// } catch (Exception e) { +// logger.error("Error in commitChanges: ", e); +// throw new InternalErrorException("Error committing changes: " + e.getMessage()); +// } + + // database table needs to match elastic search docIDs +// +// nodeRepository.saveAll(nodes); +// for (Node n: nodeRepository.findAll()) { +// System.out.println(n.getNodeId()); +// } +// +// for (Node n: nodeRepository.findAll()) { +// nodes.add(n.getNodeId()); +// } + + RefJson b = new RefJson(); + return b; + } + public RefsResponse deleteBranch(String projectId, String id) { ContextHolder.setContext(projectId); RefsResponse branchesResponse = new RefsResponse(); From 1c2fa9a703fd67a472bf789f366eafd435691bfe Mon Sep 17 00:00:00 2001 From: Bryan Orozco Date: Fri, 16 Feb 2024 12:10:01 -0800 Subject: [PATCH 04/23] feat: create ref from commit --- .../mms/core/services/BranchService.java | 2 +- .../branches/BranchesController.java | 4 - .../crud/services/DefaultBranchService.java | 113 +- .../mms/crud/services/NodeGetHelper.java | 1 + example/crud.postman_collection.json | 1577 +++++++++-------- 5 files changed, 922 insertions(+), 775 deletions(-) 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 1adc2427c..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,7 +10,7 @@ public interface BranchService { RefsResponse getBranch(String projectId, String id); RefJson createBranch(String projectId, RefJson branch); - RefJson createBranchfromCommit(String projectId, RefJson parentCommitId, NodeService nodeService); + 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 6db4b002d..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 @@ -9,7 +9,6 @@ import org.openmbee.mms.core.objects.RefsResponse; import org.openmbee.mms.core.objects.Rejection; import org.openmbee.mms.core.services.BranchService; -import org.openmbee.mms.core.services.NodeService; import org.openmbee.mms.crud.controllers.BaseController; import org.openmbee.mms.json.RefJson; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +17,6 @@ import org.springframework.security.core.Authentication; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import java.util.ArrayList; import java.util.List; @@ -98,8 +96,6 @@ public RefsResponse createRefs( if (branch.getParentCommitId() == null || branch.getParentCommitId().isEmpty()) { res = branchService.createBranch(projectId, branch); } else { - //TODO implement branching from historical commit - res = branchService.createBranchfromCommit(projectId, branch, getNodeService(projectId)); } 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 7abeac682..68b4230ee 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 @@ -18,6 +18,7 @@ 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; @@ -153,11 +154,24 @@ public RefJson createBranch(String projectId, RefJson branch) { 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) { @@ -182,51 +196,54 @@ public RefJson createBranch(String projectId, RefJson branch) { throw new InternalErrorException(e); } } - - public RefJson createBranchfromCommit(String projectId, RefJson branch, NodeService nodeService) { + 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); - // Check commit exists - // Create a new branch, from the branch that the commit was made under - // Get all elements in the commit and update the branch. - // Get all deleted elements and remove them from branch - // Return branch -// for (Node n: nodeRepository.findAll()) { -// System.out.println(n.getNodeId()); -// } - -// Optional parentCommit = commitRepository.findByCommitId(branch.getParentCommitId()); -// String parentCommitID = parentCommit.map(Commit::getCommitId).orElse("UNKNOWN"); // TODO: Need to remove UNKNOWN else -// -// String parentRef = parentCommit.map(Commit::getBranchId).orElse("UNKNOWN"); // TODO: Need to remove UNKNOWN else -// -// RefJson newBranch = this.createBranch(projectId, branch); - -// List nodes = nodeRepository.findAll(); // database table -// try { -// Collection result = nodeGetHelper.processGetJsonFromNodes(nodes, parentCommitID, nodeService) -// .getActiveElementMap().values(); // elastic search -// result.forEach(res ->{ -// System.out.println(res.getDocId()); -// }); -// } catch (Exception e) { -// logger.error("Error in commitChanges: ", e); -// throw new InternalErrorException("Error committing changes: " + e.getMessage()); -// } - - // database table needs to match elastic search docIDs -// -// nodeRepository.saveAll(nodes); -// for (Node n: nodeRepository.findAll()) { -// System.out.println(n.getNodeId()); -// } -// -// for (Node n: nodeRepository.findAll()) { -// nodes.add(n.getNodeId()); -// } - - RefJson b = new RefJson(); - return b; + 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.getRefId()); + + // 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 + for (Node node : nodes) { + if(nodeCommitData.containsKey(node.getNodeId())){ + node.setDocId(nodeCommitData.get(node.getNodeId()).getDocId()); + node.setDeleted(false); + } else { + node.setDeleted(true); + } + } + nodeRepository.updateAll(nodes); + + return branchFromCommit; } public RefsResponse deleteBranch(String projectId, String id) { 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..96d97bd61 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 @@ -129,6 +129,7 @@ private NodeGetInfo processCommit(NodeGetInfo info, String commitId, NodeService rejectNotFound(info, nodeId); // element not found at commit time } } else if (info.getExistingNodeMap().get(nodeId).isDeleted()) { // latest element is before commit, but deleted + // TODO check if time of deletion is after the commit time rejectDeleted(info, nodeId, indexElement); } else { // latest element version is version at commit, not deleted info.getActiveElementMap().put(nodeId, indexElement); diff --git a/example/crud.postman_collection.json b/example/crud.postman_collection.json index 2bcb351bc..e6dde837e 100644 --- a/example/crud.postman_collection.json +++ b/example/crud.postman_collection.json @@ -1,8 +1,9 @@ { "info": { - "_postman_id": "83c02ec5-771f-4414-9675-5989af423702", + "_postman_id": "1da77eed-083d-4cb2-86fb-2ea37cf99434", "name": "crud", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "3693486" }, "item": [ { @@ -11,7 +12,6 @@ { "listen": "test", "script": { - "id": "e461c018-db96-4ae9-8552-ea794604e7c9", "exec": [ "", "pm.test(\"Status code is 200\", function () {", @@ -67,7 +67,6 @@ { "listen": "test", "script": { - "id": "523b4238-18ab-457b-8aad-af0c45cd7298", "exec": [ "pm.test(\"response has org a\", function () {", " var jsonData = pm.response.json();", @@ -109,7 +108,6 @@ { "listen": "test", "script": { - "id": "3eaaac55-3d76-45dc-8913-665359597d55", "exec": [ "pm.test(\"response has at least 1 org\", function () {", " var jsonData = pm.response.json();", @@ -154,7 +152,6 @@ { "listen": "test", "script": { - "id": "edaf2d75-3139-4dee-9c27-011d342127db", "exec": [ "pm.test(\"response has project aa\", function () {", " var jsonData = pm.response.json();", @@ -196,7 +193,6 @@ { "listen": "test", "script": { - "id": "0a2a87fa-9bbf-4543-9375-a7fef902f76c", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -237,7 +233,6 @@ { "listen": "test", "script": { - "id": "8e0473f9-66d1-4f32-8ff0-265a6e359490", "exec": [ "pm.test(\"response has at least 1 project\", function () {", " var jsonData = pm.response.json();", @@ -282,7 +277,6 @@ { "listen": "test", "script": { - "id": "fa11f100-64f3-4a2c-bcb1-ed44e1f47253", "exec": [ "pm.test(\"response has project aa\", function () {", " var jsonData = pm.response.json();", @@ -324,7 +318,6 @@ { "listen": "test", "script": { - "id": "1733a3bc-a43d-49b6-863a-cf2b899368df", "exec": [ "pm.test(\"response has project aa with extra field\", function () {", " var jsonData = pm.response.json();", @@ -370,7 +363,6 @@ { "listen": "test", "script": { - "id": "5734965a-24fd-45ee-b6f9-3cafb777208a", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -412,102 +404,101 @@ }, "response": [] }, - { - "name": "get all elements returns last commitId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response has 3 elements and correct commitId\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(3);", - " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitId1\"))", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text", - "disabled": true - } - ], - "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "post elements with wrong lastCommitId results in 409", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response code is 409\", function () {", - " pm.response.to.have.status(409);", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{ \"lastCommitId\": \"blah\",\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, + { + "name": "get all elements returns last commitId", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 3 elements and correct commitId\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(3);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitId1\"))", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text", + "disabled": true + } + ], + "url": { + "raw": "{{host}}/projects/aa/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "post elements with wrong lastCommitId results in 409", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response code is 409\", function () {", + " pm.response.to.have.status(409);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{ \"lastCommitId\": \"blah\",\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, { "name": "update x", "event": [ { "listen": "test", "script": { - "id": "90d2953d-b3a9-49e6-a341-ab7d26ea5bd4", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -555,7 +546,6 @@ { "listen": "test", "script": { - "id": "5108608d-d411-4eb9-ad4a-a385e2bc35e6", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -603,7 +593,6 @@ { "listen": "test", "script": { - "id": "da640696-721b-4d24-bf14-be712a3c251d", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -651,7 +640,6 @@ { "listen": "test", "script": { - "id": "7482648e-a716-47e3-a291-73881ee89515", "exec": [ "pm.test(\"response has 4 commits\", function () {", " var jsonData = pm.response.json();", @@ -697,7 +685,6 @@ { "listen": "test", "script": { - "id": "0807c98f-e9a9-4c50-9f26-57d40781b0a9", "exec": [ "pm.test(\"response has 3 commits\", function () {", " var jsonData = pm.response.json();", @@ -744,7 +731,6 @@ { "listen": "test", "script": { - "id": "e9a7cd38-9443-452f-ab4e-10a015563228", "exec": [ "pm.test(\"response has 2 commits\", function () {", " var jsonData = pm.response.json();", @@ -790,7 +776,6 @@ { "listen": "test", "script": { - "id": "42f760d7-9177-4112-9902-6920419f4815", "exec": [ "pm.test(\"response has 2 commits\", function () {", " var jsonData = pm.response.json();", @@ -835,7 +820,6 @@ { "listen": "test", "script": { - "id": "90832c91-7b3f-484b-99d5-2a22411a0782", "exec": [ "pm.test(\"first commit has 3 added\", function () {", " var jsonData = pm.response.json();", @@ -870,7 +854,6 @@ { "listen": "test", "script": { - "id": "405c0a55-b089-42c0-ae0f-bf62903e9114", "exec": [ "pm.test(\"elements have expected names\", function () {", " var jsonData = pm.response.json();", @@ -933,7 +916,6 @@ { "listen": "test", "script": { - "id": "4ff8a308-edb9-4035-be10-7ee850e81b1d", "exec": [ "pm.test(\"branch created with right parentRef and commit id\", function () {", " var jsonData = pm.response.json();", @@ -979,7 +961,6 @@ { "listen": "test", "script": { - "id": "4314629f-5f7b-4848-bfc1-4855b548c13f", "exec": [ "pm.test(\"branch refa has extraField\", function () {", " var jsonData = pm.response.json();", @@ -1028,7 +1009,6 @@ { "listen": "test", "script": { - "id": "058cd4ef-fbfb-40f6-b11a-51f0decb4ad7", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -1071,7 +1051,6 @@ { "listen": "test", "script": { - "id": "579a59ee-097c-4006-84cd-03148c3cf0cb", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1114,7 +1093,6 @@ { "listen": "test", "script": { - "id": "48e8c19e-4aa8-4a96-9ae4-5e4a7d1e5a62", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1157,13 +1135,12 @@ { "listen": "test", "script": { - "id": "7cca3a7a-4b10-4051-addd-c902cb6f5400", "exec": [ "pm.test(\"elements in new ref have right _inRefIds\", function () {", " var jsonData = pm.response.json();", " jsonData.elements.forEach(function(e) {", " pm.expect(e._inRefIds).to.include('refa');", - " pm.expect(e._refId).to.equal('refa');", + " pm.expect(e._refId).to.equal('refa');", " })", "});" ], @@ -1190,51 +1167,50 @@ }, "response": [] }, - { - "name": "check response element _refId matches request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"return element in new ref have right _refId\", function () {", - " var jsonData = pm.response.json();", - " jsonData.elements.forEach(function(e) {", - " pm.expect(e._refId).to.equal('refa');", - " })", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/x", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements", - "x" - ] - } - }, - "response": [] - }, + { + "name": "check response element _refId matches request", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"return element in new ref have right _refId\", function () {", + " var jsonData = pm.response.json();", + " jsonData.elements.forEach(function(e) {", + " pm.expect(e._refId).to.equal('refa');", + " })", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/refa/elements/x", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "refa", + "elements", + "x" + ] + } + }, + "response": [] + }, { "name": "update x and y on refa", "event": [ { "listen": "test", "script": { - "id": "a2143942-d897-4a4f-a629-bfa46a7dc505", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -1277,37 +1253,27 @@ "response": [] }, { - "name": "update z on refa and add element q", + "name": "get current elements at refa before updating them", "event": [ { "listen": "test", "script": { - "id": "1f6b9962-67de-44a8-a812-b25f42a8d077", "exec": [ - "pm.test(\"response has elements\", function () {", + "pm.test(\"return latest elements on refa\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(2);", - "});", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitXYRef\"))", "", - "pm.environment.set(\"commitZQRef\", pm.response.json().elements[0]._commitId);" + " pm.environment.set(\"commitXYRefElements\", pm.response.json());", + "});", + "" ], "type": "text/javascript" } } ], "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated5\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"q\",\n\t\t\t\"name\": \"q\"\n\t\t}\n\t]\n}" - }, + "method": "GET", + "header": [], "url": { "raw": "{{host}}/projects/aa/refs/refa/elements", "host": [ @@ -1325,19 +1291,18 @@ "response": [] }, { - "name": "update z on master and add element p", + "name": "update z on refa and add element q", "event": [ { "listen": "test", "script": { - "id": "0686db2c-2f1a-412d-928d-965b25a71470", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", " pm.expect(jsonData.elements.length).to.eql(2);", "});", "", - "pm.environment.set(\"commitZP\", pm.response.json().elements[0]._commitId);" + "pm.environment.set(\"commitZQRef\", pm.response.json().elements[0]._commitId);" ], "type": "text/javascript" } @@ -1354,10 +1319,10 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated6\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"p\",\n\t\t\t\"name\": \"p\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated5\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"q\",\n\t\t\t\"name\": \"q\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", + "raw": "{{host}}/projects/aa/refs/refa/elements", "host": [ "{{host}}" ], @@ -1365,7 +1330,7 @@ "projects", "aa", "refs", - "master", + "refa", "elements" ] } @@ -1373,120 +1338,107 @@ "response": [] }, { - "name": "check master commit history", + "name": "create branch from invalid parentCommitId", "event": [ { "listen": "test", "script": { - "id": "eb0d752b-95db-466a-a5c2-d9b48cc6c146", "exec": [ - "pm.test(\"response has 5 commits\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(5);", - "});", - "", - "pm.test(\"commit history is right\", function() {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZP\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId4\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId2\"))", - " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "" + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", + "});" ], "type": "text/javascript" } } ], "request": { - "method": "GET", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"refs\": [\n {\n \"name\": \"branch_from_commit\",\n \"type\": \"Branch\",\n \"parentCommitId\": \"invalid\",\n \"id\": \"branch_from_commit\"\n }\n ]\n}" + }, "url": { - "raw": "{{host}}/projects/aa/refs/master/commits", + "raw": "{{host}}/projects/aa/refs", "host": [ "{{host}}" ], "path": [ "projects", "aa", - "refs", - "master", - "commits" + "refs" ] } }, "response": [] }, { - "name": "check refa commit history", + "name": "create branch from commit", "event": [ { "listen": "test", "script": { - "id": "03347469-fdcc-4bef-8a72-02763ee852dd", "exec": [ - "pm.test(\"response has 6 commits\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(6);", - "});", - "", - "pm.test(\"commit history is right\", function() {", + "pm.test(\"branch created from parentCommitId\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZQRef\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitXYRef\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId4\"))", - " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId2\"))", - " pm.expect(jsonData.commits[5].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "" + " pm.expect(jsonData.refs[0].id).to.eql('branch_from_commit');", + " pm.expect(jsonData.refs[0].parentRefId).to.eql('refa');", + "});" ], "type": "text/javascript" } } ], "request": { - "method": "GET", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"refs\": [\n {\n \"name\": \"branch_from_commit\",\n \"type\": \"Branch\",\n \"parentCommitId\": \"{{commitXYRef}}\",\n \"id\": \"branch_from_commit\"\n }\n ]\n}" + }, "url": { - "raw": "{{host}}/projects/aa/refs/refa/commits", + "raw": "{{host}}/projects/aa/refs", "host": [ "{{host}}" ], "path": [ "projects", "aa", - "refs", - "refa", - "commits" + "refs" ] } }, "response": [] }, { - "name": "check x commit history on refa", + "name": "check elements from branch made from commit", "event": [ { "listen": "test", "script": { - "id": "8fe61517-a474-4ca7-91ea-aacfe01bb060", "exec": [ - "pm.test(\"response has 3 commits\", function () {", + "pm.test(\"Commit in ref match commit before updating refa\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(4);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('commitXYRef'));", "});", "", - "pm.test(\"commit history is right\", function() {", + "pm.test(\"Elements made in ref match what was created under commit\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId2\"))", - " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "", - "" + " pm.expect(jsonData).to.equal(pm.environment.get('commitXYRefElements'));", + "});" ], "type": "text/javascript" } @@ -1496,7 +1448,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/x/commits", + "raw": "{{host}}/projects/aa/refs/{{branch_from_commit_ref}}/elements", "host": [ "{{host}}" ], @@ -1504,44 +1456,272 @@ "projects", "aa", "refs", - "refa", - "elements", - "x", - "commits" + "{{branch_from_commit_ref}}", + "elements" ] } }, "response": [] }, { - "name": "check y commit history on refa", + "name": "update z on master and add element p", "event": [ { "listen": "test", "script": { - "id": "cb0e814e-b415-4dfc-88b1-c70aedd0e1d2", "exec": [ - "pm.test(\"response has 3 commits\", function () {", + "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(3);", + " pm.expect(jsonData.elements.length).to.eql(2);", "});", "", - "pm.test(\"commit history is right\", function() {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "", - "" + "pm.environment.set(\"commitZP\", pm.response.json().elements[0]._commitId);" ], "type": "text/javascript" } } ], "request": { - "method": "GET", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated6\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"p\",\n\t\t\t\"name\": \"p\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "get elements at commit", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"commit id matches before updating refa\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitXYRef\"))", + "});", + "", + "pm.test(\"elements in refa match resutls before updating refa\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(pm.response.json()).to.equal(pm.environment.get('commitXYRefElements'));", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/refa/elements?commitId={{commitXYRef}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "refa", + "elements" + ], + "query": [ + { + "key": "commitId", + "value": "{{commitXYRef}}" + } + ] + } + }, + "response": [] + }, + { + "name": "check master commit history", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 5 commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits.length).to.eql(5);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZP\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId4\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId2\"))", + " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/master/commits", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "commits" + ] + } + }, + "response": [] + }, + { + "name": "check refa commit history", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 6 commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits.length).to.eql(6);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZQRef\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitXYRef\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId4\"))", + " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId2\"))", + " pm.expect(jsonData.commits[5].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/refa/commits", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "refa", + "commits" + ] + } + }, + "response": [] + }, + { + "name": "check x commit history on refa", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 3 commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits.length).to.eql(4);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId2\"))", + " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/refa/elements/x/commits", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "refa", + "elements", + "x", + "commits" + ] + } + }, + "response": [] + }, + { + "name": "check y commit history on refa", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 3 commits\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits.length).to.eql(3);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], "url": { "raw": "{{host}}/projects/aa/refs/refa/elements/y/commits", "host": [ @@ -1566,7 +1746,6 @@ { "listen": "test", "script": { - "id": "3225e877-45f8-4b8b-81f0-037fab73a0d8", "exec": [ "pm.test(\"response has 3 commits\", function () {", " var jsonData = pm.response.json();", @@ -1612,7 +1791,6 @@ { "listen": "test", "script": { - "id": "2f0cb424-4943-4808-8504-decf5a5f13a0", "exec": [ "pm.test(\"has 4 results\", function () {", " var jsonData = pm.response.json();", @@ -1658,7 +1836,6 @@ { "listen": "test", "script": { - "id": "3dc49cda-109d-4301-b605-5c34bd2e6356", "exec": [ "pm.test(\"has 4 results\", function () {", " var jsonData = pm.response.json();", @@ -1707,7 +1884,6 @@ { "listen": "test", "script": { - "id": "89a56141-ec9b-429c-bfa3-36d0e43edfe4", "exec": [ "pm.test(\"has 3 results and 1 rejected\", function () {", " var jsonData = pm.response.json();", @@ -1754,7 +1930,6 @@ { "listen": "test", "script": { - "id": "6ac63f9d-1dec-4f8d-af53-31a821f98803", "exec": [ "pm.test(\"has 3 results and 2 rejected\", function () {", " var jsonData = pm.response.json();", @@ -1807,7 +1982,6 @@ { "listen": "test", "script": { - "id": "64884b31-07b9-45d6-80d9-aaaee57e6cf0", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1847,7 +2021,6 @@ { "listen": "test", "script": { - "id": "a5fb1b5b-390a-4238-a587-a8d5f8c2c08c", "exec": [ "pm.test(\"Status code is 410\", function () {", " pm.response.to.have.status(410);", @@ -1883,7 +2056,6 @@ { "listen": "test", "script": { - "id": "2891567e-05ac-41db-bbef-a408ae6fb4f4", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1933,7 +2105,6 @@ { "listen": "test", "script": { - "id": "6c242219-5862-44dd-9aa2-cf684c27b485", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1987,7 +2158,6 @@ { "listen": "test", "script": { - "id": "cc0bb3da-5473-48b8-b706-3f64bedfec62", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2032,7 +2202,6 @@ { "listen": "test", "script": { - "id": "ea871dc1-9d88-4481-9c1b-2090a25233e9", "exec": [ "pm.test(\"response has org a\", function () {", " var jsonData = pm.response.json();", @@ -2074,7 +2243,6 @@ { "listen": "test", "script": { - "id": "4120ad4c-9cb5-4b51-bf53-f608d68f0298", "exec": [ "pm.test(\"response has project cc\", function () {", " var jsonData = pm.response.json();", @@ -2116,7 +2284,6 @@ { "listen": "test", "script": { - "id": "cc901e7b-9269-4396-8acb-0606f11dc4db", "exec": [ "", "pm.test(\"Status code is 400, cannot make branch in empty project\", function () {", @@ -2160,7 +2327,6 @@ { "listen": "test", "script": { - "id": "b28e0221-9f3d-49d7-87de-280586509c47", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2205,7 +2371,6 @@ { "listen": "test", "script": { - "id": "66049694-521b-43cf-92ae-dc6c8cc8405a", "exec": [ "pm.test(\"branch created\", function () {", " var jsonData = pm.response.json();", @@ -2249,7 +2414,6 @@ { "listen": "test", "script": { - "id": "5043a523-c8be-4509-bc2f-ea8b040a2bf2", "exec": [ "pm.test(\"branch deleted\", function () {", " var jsonData = pm.response.json();", @@ -2288,7 +2452,6 @@ { "listen": "test", "script": { - "id": "83c40f4d-cbf7-4e16-8c6f-9931a78df22f", "exec": [ " ", "pm.test(\"Status code is 410\", function () {", @@ -2331,7 +2494,6 @@ { "listen": "test", "script": { - "id": "7b4f2fdb-68d9-4e0e-8980-774baa4f9413", "exec": [ "", "pm.test(\"Status code is 400\", function () {", @@ -2371,7 +2533,6 @@ { "listen": "test", "script": { - "id": "49b6fb54-9300-4433-983c-8d4ca6a84e35", "exec": [ "pm.test(\"project soft deleted\", function () {", " var jsonData = pm.response.json();", @@ -2408,7 +2569,6 @@ { "listen": "test", "script": { - "id": "cdac43db-2126-404b-af6a-91d4c5eac600", "exec": [ "pm.test(\"Status code is 410\", function () {", " pm.response.to.have.status(410);", @@ -2447,7 +2607,6 @@ { "listen": "test", "script": { - "id": "121ac082-4e34-4a42-9fdd-15bb6545898d", "exec": [ "pm.test(\"Status code is 400, org not empty\", function () {", " pm.response.to.have.status(400);", @@ -2483,7 +2642,6 @@ { "listen": "test", "script": { - "id": "b5729049-9a5a-4660-b97b-2658d7027f84", "exec": [ "pm.test(\"project hard deleted\", function () {", " var jsonData = pm.response.json();", @@ -2526,7 +2684,6 @@ { "listen": "test", "script": { - "id": "0a4fcb5e-c5b6-4ea5-b4ec-36babadffaff", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2562,7 +2719,6 @@ { "listen": "test", "script": { - "id": "ac5d3658-38e9-423f-b985-d903cceb0740", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -2642,7 +2798,6 @@ { "listen": "test", "script": { - "id": "2ba7a873-1bdf-4e86-8329-7069064232a9", "exec": [ "pm.test(\"webhook created with returned id\", function () {", " var jsonData = pm.response.json();", @@ -2688,7 +2843,6 @@ { "listen": "test", "script": { - "id": "8410e98d-60b6-40bf-b17a-91c78b5f1dda", "exec": [ "pm.test(\"project aa has one webhook\", function () {", " var jsonData = pm.response.json();", @@ -2738,7 +2892,6 @@ { "listen": "test", "script": { - "id": "e0baf005-f27c-42d9-9763-6b194ecccd3f", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2784,7 +2937,6 @@ { "listen": "test", "script": { - "id": "009db0b6-7e14-42d8-89ae-33cdb7a20a6f", "exec": [ "pm.test(\"project aa has no webhooks\", function () {", " var jsonData = pm.response.json();", @@ -2833,7 +2985,6 @@ { "listen": "test", "script": { - "id": "5d411406-9444-4333-9b15-43c0ae716821", "exec": [ "pm.test(\"Status code is 400\", function () {\r", " pm.response.to.have.status(400);\r", @@ -2879,7 +3030,6 @@ { "listen": "test", "script": { - "id": "53ab3019-1cc1-4da3-aece-5c157766f627", "exec": [ "pm.test(\"response has org c\", function () {", " var jsonData = pm.response.json();", @@ -2923,7 +3073,6 @@ { "listen": "test", "script": { - "id": "8d61501e-4a5b-4a71-9f1d-ad00c75893bd", "exec": [ "pm.test(\"org id number is right\", function() {", " var jsonData = pm.response.json();", @@ -2962,7 +3111,6 @@ { "listen": "test", "script": { - "id": "39291cc7-7dbe-4eb9-ad83-857b839bfda8", "exec": [ "pm.test(\"response has project random\", function () {", " var jsonData = pm.response.json();", @@ -3000,98 +3148,97 @@ }, "response": [] }, - { - "name": "get org c projects", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response has 1 project random\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.projects.length).to.eql(1);", - " pm.expect(jsonData.projects[0].name).to.eql('random');", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json", - "disabled": true - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{host}}/projects?orgId={{orgIdC}}", - "host": [ - "{{host}}" - ], - "path": [ - "projects" - ], - "query": [ - { - "key": "orgId", - "value": "{{orgIdC}}" - } - ] - } - }, - "response": [] - }, { - "name": "add element random to project random without id", + "name": "get org c projects", "event": [ { "listen": "test", "script": { - "id": "4c60e596-758d-4347-8a0c-ef9071a78421", "exec": [ - "pm.test(\"response has element random\", function () {", + "pm.test(\"response has 1 project random\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements[0].name).to.eql('random');", - "});", - "", - "pm.environment.set(\"elementRandomId\", pm.response.json().elements[0].id);" + " pm.expect(jsonData.projects.length).to.eql(1);", + " pm.expect(jsonData.projects[0].name).to.eql('random');", + "});" ], "type": "text/javascript" } } ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { - "method": "POST", + "method": "GET", "header": [ { "key": "Content-Type", "type": "text", - "value": "application/json" + "value": "application/json", + "disabled": true } ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/projects/{{projectRandomId}}/refs/master/elements", + "raw": "{{host}}/projects?orgId={{orgIdC}}", "host": [ "{{host}}" ], "path": [ - "projects", - "{{projectRandomId}}", + "projects" + ], + "query": [ + { + "key": "orgId", + "value": "{{orgIdC}}" + } + ] + } + }, + "response": [] + }, + { + "name": "add element random to project random without id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has element random\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements[0].name).to.eql('random');", + "});", + "", + "pm.environment.set(\"elementRandomId\", pm.response.json().elements[0].id);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/{{projectRandomId}}/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "{{projectRandomId}}", "refs", "master", "elements" @@ -3106,7 +3253,6 @@ { "listen": "test", "script": { - "id": "fa70a5cd-4079-4216-b4f6-b4202c26cfc0", "exec": [ "pm.test(\"response has ref random\", function () {", " var jsonData = pm.response.json();", @@ -3152,7 +3298,6 @@ { "listen": "test", "script": { - "id": "e1a34e6f-ae27-4a4f-8294-a7c9f86d9512", "exec": [ "pm.test(\"element is there\", function() {", " var jsonData = pm.response.json();", @@ -3195,7 +3340,6 @@ { "listen": "test", "script": { - "id": "90859114-65cc-41c2-8b34-015f1464201a", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3236,7 +3380,6 @@ { "listen": "test", "script": { - "id": "c410396b-451f-4120-bbd6-69fa66effe42", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3277,7 +3420,6 @@ { "listen": "test", "script": { - "id": "bfbfce50-298d-4d87-b403-951ab3e2f574", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -3320,7 +3462,6 @@ { "listen": "test", "script": { - "id": "c140808f-619f-4b5e-ab06-ae1124039678", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -3363,7 +3504,6 @@ { "listen": "test", "script": { - "id": "563236de-9fa5-4902-aa08-b271cdee278e", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3408,7 +3548,6 @@ { "listen": "test", "script": { - "id": "9f8b1c3b-629e-4080-bd96-c7ea7a29faf0", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3453,7 +3592,6 @@ { "listen": "test", "script": { - "id": "f9e479b7-97e5-41f2-b801-7c1f7f4553ec", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3491,7 +3629,6 @@ { "listen": "test", "script": { - "id": "58d3d7d2-416b-4ac3-8933-7b54c2691fd4", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3531,7 +3668,6 @@ { "listen": "test", "script": { - "id": "5eacc2a2-caea-4256-aa97-bf6e50bd3b68", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3567,362 +3703,362 @@ }, "response": [] }, - { - "name": "get nonexistent commit", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "url": { - "raw": "{{host}}/projects/aa/commits/missing", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "commits", - "missing" - ] - } - }, - "response": [] - }, - { - "name": "create branch with long id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "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\"name\": \"long\",\n \"id\": \"a123456789012345678901234567890123456789012345678901234567890\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs" - ] - } - }, - "response": [] - }, - { - "name": "post to long branch", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"blah\",\n\t\t\t\"id\": \"blah\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/a123456789012345678901234567890123456789012345678901234567890/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "a123456789012345678901234567890123456789012345678901234567890", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "create project zz", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"zz\", \n\t\t\t\"name\": \"zz\",\n\t\t\t\"orgId\": \"a\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects", - "host": [ - "{{host}}" - ], - "path": [ - "projects" - ] - } - }, - "response": [] - }, - { - "name": "add elements to project zz", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/zz/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "zz", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "update and delete elements in same commit", - "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.expect(jsonData.deleted.length).to.eql(1);", - "});", - "", - "pm.environment.set(\"hybridCommit\", pm.response.json().commitId);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" - }, - "url": { - "raw": "{{host}}/projects/zz/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "zz", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "get deleted element", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 410\", function () {", - " pm.response.to.have.status(410);", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" - }, - "url": { - "raw": "{{host}}/projects/zz/refs/master/elements/z", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "zz", - "refs", - "master", - "elements", - "z" - ] - } - }, - "response": [] - }, - { - "name": "get commit object", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"commit has right data\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].updated.length).to.eql(2);", - " pm.expect(jsonData.commits[0].deleted.length).to.eql(1);", - "", - "});", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" - }, - "url": { - "raw": "{{host}}/projects/zz/commits/{{hybridCommit}}", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "zz", - "commits", - "{{hybridCommit}}" - ] - } - }, - "response": [] - } + { + "name": "get nonexistent commit", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{host}}/projects/aa/commits/missing", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "commits", + "missing" + ] + } + }, + "response": [] + }, + { + "name": "create branch with long id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "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\"name\": \"long\",\n \"id\": \"a123456789012345678901234567890123456789012345678901234567890\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs" + ] + } + }, + "response": [] + }, + { + "name": "post to long branch", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"blah\",\n\t\t\t\"id\": \"blah\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs/a123456789012345678901234567890123456789012345678901234567890/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "a123456789012345678901234567890123456789012345678901234567890", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "create project zz", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"zz\", \n\t\t\t\"name\": \"zz\",\n\t\t\t\"orgId\": \"a\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects", + "host": [ + "{{host}}" + ], + "path": [ + "projects" + ] + } + }, + "response": [] + }, + { + "name": "add elements to project zz", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "update and delete elements in same commit", + "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.expect(jsonData.deleted.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"hybridCommit\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "get deleted element", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 410\", function () {", + " pm.response.to.have.status(410);", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/refs/master/elements/z", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "refs", + "master", + "elements", + "z" + ] + } + }, + "response": [] + }, + { + "name": "get commit object", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"commit has right data\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].updated.length).to.eql(2);", + " pm.expect(jsonData.commits[0].deleted.length).to.eql(1);", + "", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/commits/{{hybridCommit}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "commits", + "{{hybridCommit}}" + ] + } + }, + "response": [] + } ], "auth": { "type": "bearer", @@ -3938,7 +4074,6 @@ { "listen": "prerequest", "script": { - "id": "cd69ddc1-20da-4c86-919c-ad9bf455d71d", "type": "text/javascript", "exec": [ "" @@ -3948,13 +4083,11 @@ { "listen": "test", "script": { - "id": "480b7515-91c4-49b1-9bee-f5af24bb9524", "type": "text/javascript", "exec": [ "" ] } } - ], - "protocolProfileBehavior": {} + ] } \ No newline at end of file From 130306de4bb36dac66276cfa0ea7b5a8ba0744f7 Mon Sep 17 00:00:00 2001 From: Bryan Orozco Date: Fri, 16 Feb 2024 12:44:07 -0800 Subject: [PATCH 05/23] test: added test case for tag --- example/crud.postman_collection.json | 94 ++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 4 deletions(-) diff --git a/example/crud.postman_collection.json b/example/crud.postman_collection.json index e6dde837e..ded4d800c 100644 --- a/example/crud.postman_collection.json +++ b/example/crud.postman_collection.json @@ -1388,8 +1388,9 @@ "exec": [ "pm.test(\"branch created from parentCommitId\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.refs[0].id).to.eql('branch_from_commit');", + " pm.expect(jsonData.refs[0].id).to.eql('branch_from_commit_id');", " pm.expect(jsonData.refs[0].parentRefId).to.eql('refa');", + " pm.expect(jsonData.refs[0].type).to.eql('Branch');", "});" ], "type": "text/javascript" @@ -1407,7 +1408,52 @@ ], "body": { "mode": "raw", - "raw": "{\n \"refs\": [\n {\n \"name\": \"branch_from_commit\",\n \"type\": \"Branch\",\n \"parentCommitId\": \"{{commitXYRef}}\",\n \"id\": \"branch_from_commit\"\n }\n ]\n}" + "raw": "{\n \"refs\": [\n {\n \"name\": \"branch_from_commit\",\n \"type\": \"Branch\",\n \"parentCommitId\": \"{{commitXYRef}}\",\n \"id\": \"branch_from_commit_id\"\n }\n ]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs" + ] + } + }, + "response": [] + }, + { + "name": "create tag from commit", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"branch created from parentCommitId\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.refs[0].id).to.eql('tag_from_commit_id');", + " pm.expect(jsonData.refs[0].parentRefId).to.eql('refa');", + " pm.expect(jsonData.refs[0].type).to.eql('Tag');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"refs\": [\n {\n \"name\": \"tag_from_commit\",\n \"type\": \"Tag\",\n \"parentCommitId\": \"{{commitXYRef}}\",\n \"id\": \"tag_from_commit_id\"\n }\n ]\n}" }, "url": { "raw": "{{host}}/projects/aa/refs", @@ -1448,7 +1494,47 @@ "method": "GET", "header": [], "url": { - "raw": "{{host}}/projects/aa/refs/{{branch_from_commit_ref}}/elements", + "raw": "{{host}}/projects/aa/refs/branch_from_commit_id/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "branch_from_commit_id", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "check elements from tag made from commit", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Commit in ref match commit before updating refa\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get('commitXYRef'));", + "});", + "", + "pm.test(\"Elements made in ref match what was created under commit\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData).to.equal(pm.environment.get('commitXYRefElements'));", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/tag_from_commit_id/elements", "host": [ "{{host}}" ], @@ -1456,7 +1542,7 @@ "projects", "aa", "refs", - "{{branch_from_commit_ref}}", + "tag_from_commit_id", "elements" ] } From bf74662e17356d1eccbab4503bf7f9ea5cad46e7 Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Fri, 16 Feb 2024 17:16:37 -0800 Subject: [PATCH 06/23] bugfix: check if element was deleted before commit but after last modified time --- .../openmbee/mms/core/dao/CommitIndexDAO.java | 2 ++ .../mms/crud/services/NodeGetHelper.java | 29 ++++++++++++++++++- .../mms/elastic/CommitElasticDAOImpl.java | 27 +++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) 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/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..09c0dbbb8 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); @@ -129,7 +139,24 @@ private NodeGetInfo processCommit(NodeGetInfo info, String commitId, NodeService 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); + } + List commits = commitIndex.elementDeletedHistory(nodeId, refCommitIds); + boolean isDeleted = false; + 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 + isDeleted = true; + } + } + if (isDeleted) { + 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); } 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 From 798ebc264ac5491362fc85a5a9ded012bbed0cb1 Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Sat, 17 Feb 2024 09:54:42 -0800 Subject: [PATCH 07/23] pull out elementDeleted to function --- .../mms/crud/services/NodeGetHelper.java | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) 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 09c0dbbb8..617f73bee 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 @@ -132,9 +132,14 @@ 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())); + boolean isDeleted = elementDeleted(nodeId, commitId, time, realModified, refCommitIds); + if (isDeleted) { + rejectDeleted(info, nodeId, indexElement); + } else { + e.get().setRefId(ContextHolder.getContext().getBranchId()); + info.getActiveElementMap().put(nodeId, e.get()); + } } else { rejectNotFound(info, nodeId); // element not found at commit time } @@ -142,16 +147,7 @@ private NodeGetInfo processCommit(NodeGetInfo info, String commitId, NodeService if (refCommitIds == null) { // need list of commitIds of current ref to filter on refCommitIds = getRefCommitIds(time); } - List commits = commitIndex.elementDeletedHistory(nodeId, refCommitIds); - boolean isDeleted = false; - 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 - isDeleted = true; - } - } + boolean isDeleted = elementDeleted(nodeId, commitId, time, modified, refCommitIds); if (isDeleted) { rejectDeleted(info, nodeId, indexElement); } else { @@ -164,6 +160,21 @@ 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); + boolean isDeleted = false; + 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 + isDeleted = true; + break; + } + } + return isDeleted; + } + public NodeGetInfo processGetJson(List elements, Instant time, NodeService service) { Optional ref = branchRepository.findByBranchId(getContext().getBranchId()); if (ref.isPresent()) { From 03f78639ab45373be79613800518360ffb85a950 Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Sat, 17 Feb 2024 14:46:06 -0800 Subject: [PATCH 08/23] add tests --- .circleci/config.yml | 5 +- example/getAtCommits.postman_collection.json | 884 +++++++++++++++++++ 2 files changed, 887 insertions(+), 2 deletions(-) create mode 100644 example/getAtCommits.postman_collection.json diff --git a/.circleci/config.yml b/.circleci/config.yml index df27e029d..f8446b1a0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,19 +20,20 @@ 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 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/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 From e1080c04b210344424a5d34a69d5b904bf9eb3b9 Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Sat, 17 Feb 2024 15:15:13 -0800 Subject: [PATCH 09/23] simplify lines --- .../openmbee/mms/crud/services/NodeGetHelper.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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 617f73bee..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 @@ -133,9 +133,8 @@ private NodeGetInfo processCommit(NodeGetInfo info, String commitId, NodeService formatter.format(time), refCommitIds); if (e.isPresent()) { // found version of element at commit time Instant realModified = Instant.from(formatter.parse(e.get().getModified())); - boolean isDeleted = elementDeleted(nodeId, commitId, time, realModified, refCommitIds); - if (isDeleted) { - rejectDeleted(info, nodeId, indexElement); + 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()); @@ -147,8 +146,7 @@ private NodeGetInfo processCommit(NodeGetInfo info, String commitId, NodeService if (refCommitIds == null) { // need list of commitIds of current ref to filter on refCommitIds = getRefCommitIds(time); } - boolean isDeleted = elementDeleted(nodeId, commitId, time, modified, refCommitIds); - if (isDeleted) { + if (elementDeleted(nodeId, commitId, time, modified, refCommitIds)) { rejectDeleted(info, nodeId, indexElement); } else { info.getActiveElementMap().put(nodeId, indexElement); @@ -162,17 +160,15 @@ private NodeGetInfo processCommit(NodeGetInfo info, String commitId, NodeService private boolean elementDeleted(String nodeId, String commitId, Instant time, Instant modified, List refCommitIds) { List commits = commitIndex.elementDeletedHistory(nodeId, refCommitIds); - boolean isDeleted = false; 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 - isDeleted = true; - break; + return true; } } - return isDeleted; + return false; } public NodeGetInfo processGetJson(List elements, Instant time, NodeService service) { From d11ce4980713a6b1fbfb8e59f8dc28d09998963c Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Wed, 21 Feb 2024 11:33:01 -0800 Subject: [PATCH 10/23] set default elastic cred to null so existing deployments don't need to update properties --- .../openmbee/mms/elastic/config/ElasticsearchConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 66e92cc69..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 @@ -24,15 +24,15 @@ public class ElasticsearchConfig { @Value("${elasticsearch.http}") private String elasticsearchHttp; - @Value("${elasticsearch.password}") + @Value("${elasticsearch.password:#{null}}") private String elasticsearchPassword; - @Value("${elasticsearch.username}") + @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)); From 4170355046f4412a0be6d6e4fe8cbaafb65e4d00 Mon Sep 17 00:00:00 2001 From: Bryan Orozco Date: Mon, 26 Feb 2024 10:30:28 -0800 Subject: [PATCH 11/23] reverted postman collection and updated branch service --- .../crud/services/DefaultBranchService.java | 7 + example/crud.postman_collection.json | 2673 ++++++++--------- 2 files changed, 1234 insertions(+), 1446 deletions(-) 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 68b4230ee..0c80cdf89 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 @@ -236,6 +236,7 @@ public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRe 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); } else { node.setDeleted(true); @@ -243,6 +244,12 @@ public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRe } nodeRepository.updateAll(nodes); + Set docIds = new HashSet<>(); + for (Node n: nodeRepository.findAllByDeleted(false)) { + docIds.add(n.getDocId()); + } + try { nodeIndex.addToRef(docIds); } catch(Exception e) {} + return branchFromCommit; } diff --git a/example/crud.postman_collection.json b/example/crud.postman_collection.json index ded4d800c..2bcb351bc 100644 --- a/example/crud.postman_collection.json +++ b/example/crud.postman_collection.json @@ -1,9 +1,8 @@ { "info": { - "_postman_id": "1da77eed-083d-4cb2-86fb-2ea37cf99434", + "_postman_id": "83c02ec5-771f-4414-9675-5989af423702", "name": "crud", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "3693486" + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { @@ -12,6 +11,7 @@ { "listen": "test", "script": { + "id": "e461c018-db96-4ae9-8552-ea794604e7c9", "exec": [ "", "pm.test(\"Status code is 200\", function () {", @@ -67,6 +67,7 @@ { "listen": "test", "script": { + "id": "523b4238-18ab-457b-8aad-af0c45cd7298", "exec": [ "pm.test(\"response has org a\", function () {", " var jsonData = pm.response.json();", @@ -108,6 +109,7 @@ { "listen": "test", "script": { + "id": "3eaaac55-3d76-45dc-8913-665359597d55", "exec": [ "pm.test(\"response has at least 1 org\", function () {", " var jsonData = pm.response.json();", @@ -152,6 +154,7 @@ { "listen": "test", "script": { + "id": "edaf2d75-3139-4dee-9c27-011d342127db", "exec": [ "pm.test(\"response has project aa\", function () {", " var jsonData = pm.response.json();", @@ -193,6 +196,7 @@ { "listen": "test", "script": { + "id": "0a2a87fa-9bbf-4543-9375-a7fef902f76c", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -233,6 +237,7 @@ { "listen": "test", "script": { + "id": "8e0473f9-66d1-4f32-8ff0-265a6e359490", "exec": [ "pm.test(\"response has at least 1 project\", function () {", " var jsonData = pm.response.json();", @@ -277,6 +282,7 @@ { "listen": "test", "script": { + "id": "fa11f100-64f3-4a2c-bcb1-ed44e1f47253", "exec": [ "pm.test(\"response has project aa\", function () {", " var jsonData = pm.response.json();", @@ -318,6 +324,7 @@ { "listen": "test", "script": { + "id": "1733a3bc-a43d-49b6-863a-cf2b899368df", "exec": [ "pm.test(\"response has project aa with extra field\", function () {", " var jsonData = pm.response.json();", @@ -363,6 +370,7 @@ { "listen": "test", "script": { + "id": "5734965a-24fd-45ee-b6f9-3cafb777208a", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -404,101 +412,102 @@ }, "response": [] }, - { - "name": "get all elements returns last commitId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response has 3 elements and correct commitId\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(3);", - " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitId1\"))", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text", - "disabled": true - } - ], - "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "post elements with wrong lastCommitId results in 409", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response code is 409\", function () {", - " pm.response.to.have.status(409);", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "{ \"lastCommitId\": \"blah\",\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, + { + "name": "get all elements returns last commitId", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 3 elements and correct commitId\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(3);", + " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitId1\"))", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text", + "disabled": true + } + ], + "url": { + "raw": "{{host}}/projects/aa/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "post elements with wrong lastCommitId results in 409", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response code is 409\", function () {", + " pm.response.to.have.status(409);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{ \"lastCommitId\": \"blah\",\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, { "name": "update x", "event": [ { "listen": "test", "script": { + "id": "90d2953d-b3a9-49e6-a341-ab7d26ea5bd4", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -546,6 +555,7 @@ { "listen": "test", "script": { + "id": "5108608d-d411-4eb9-ad4a-a385e2bc35e6", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -593,6 +603,7 @@ { "listen": "test", "script": { + "id": "da640696-721b-4d24-bf14-be712a3c251d", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -640,6 +651,7 @@ { "listen": "test", "script": { + "id": "7482648e-a716-47e3-a291-73881ee89515", "exec": [ "pm.test(\"response has 4 commits\", function () {", " var jsonData = pm.response.json();", @@ -685,6 +697,7 @@ { "listen": "test", "script": { + "id": "0807c98f-e9a9-4c50-9f26-57d40781b0a9", "exec": [ "pm.test(\"response has 3 commits\", function () {", " var jsonData = pm.response.json();", @@ -731,6 +744,7 @@ { "listen": "test", "script": { + "id": "e9a7cd38-9443-452f-ab4e-10a015563228", "exec": [ "pm.test(\"response has 2 commits\", function () {", " var jsonData = pm.response.json();", @@ -776,6 +790,7 @@ { "listen": "test", "script": { + "id": "42f760d7-9177-4112-9902-6920419f4815", "exec": [ "pm.test(\"response has 2 commits\", function () {", " var jsonData = pm.response.json();", @@ -820,6 +835,7 @@ { "listen": "test", "script": { + "id": "90832c91-7b3f-484b-99d5-2a22411a0782", "exec": [ "pm.test(\"first commit has 3 added\", function () {", " var jsonData = pm.response.json();", @@ -854,6 +870,7 @@ { "listen": "test", "script": { + "id": "405c0a55-b089-42c0-ae0f-bf62903e9114", "exec": [ "pm.test(\"elements have expected names\", function () {", " var jsonData = pm.response.json();", @@ -916,6 +933,7 @@ { "listen": "test", "script": { + "id": "4ff8a308-edb9-4035-be10-7ee850e81b1d", "exec": [ "pm.test(\"branch created with right parentRef and commit id\", function () {", " var jsonData = pm.response.json();", @@ -961,6 +979,7 @@ { "listen": "test", "script": { + "id": "4314629f-5f7b-4848-bfc1-4855b548c13f", "exec": [ "pm.test(\"branch refa has extraField\", function () {", " var jsonData = pm.response.json();", @@ -1009,6 +1028,7 @@ { "listen": "test", "script": { + "id": "058cd4ef-fbfb-40f6-b11a-51f0decb4ad7", "exec": [ "pm.test(\"Status code is 400\", function () {", " pm.response.to.have.status(400);", @@ -1051,6 +1071,7 @@ { "listen": "test", "script": { + "id": "579a59ee-097c-4006-84cd-03148c3cf0cb", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1093,6 +1114,7 @@ { "listen": "test", "script": { + "id": "48e8c19e-4aa8-4a96-9ae4-5e4a7d1e5a62", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1135,12 +1157,13 @@ { "listen": "test", "script": { + "id": "7cca3a7a-4b10-4051-addd-c902cb6f5400", "exec": [ "pm.test(\"elements in new ref have right _inRefIds\", function () {", " var jsonData = pm.response.json();", " jsonData.elements.forEach(function(e) {", " pm.expect(e._inRefIds).to.include('refa');", - " pm.expect(e._refId).to.equal('refa');", + " pm.expect(e._refId).to.equal('refa');", " })", "});" ], @@ -1167,50 +1190,51 @@ }, "response": [] }, - { - "name": "check response element _refId matches request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"return element in new ref have right _refId\", function () {", - " var jsonData = pm.response.json();", - " jsonData.elements.forEach(function(e) {", - " pm.expect(e._refId).to.equal('refa');", - " })", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/x", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements", - "x" - ] - } - }, - "response": [] - }, + { + "name": "check response element _refId matches request", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"return element in new ref have right _refId\", function () {", + " var jsonData = pm.response.json();", + " jsonData.elements.forEach(function(e) {", + " pm.expect(e._refId).to.equal('refa');", + " })", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/projects/aa/refs/refa/elements/x", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "refa", + "elements", + "x" + ] + } + }, + "response": [] + }, { "name": "update x and y on refa", "event": [ { "listen": "test", "script": { + "id": "a2143942-d897-4a4f-a629-bfa46a7dc505", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -1252,50 +1276,13 @@ }, "response": [] }, - { - "name": "get current elements at refa before updating them", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"return latest elements on refa\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitXYRef\"))", - "", - " pm.environment.set(\"commitXYRefElements\", pm.response.json());", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements" - ] - } - }, - "response": [] - }, { "name": "update z on refa and add element q", "event": [ { "listen": "test", "script": { + "id": "1f6b9962-67de-44a8-a812-b25f42a8d077", "exec": [ "pm.test(\"response has elements\", function () {", " var jsonData = pm.response.json();", @@ -1338,15 +1325,19 @@ "response": [] }, { - "name": "create branch from invalid parentCommitId", + "name": "update z on master and add element p", "event": [ { "listen": "test", "script": { + "id": "0686db2c-2f1a-412d-928d-965b25a71470", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", - "});" + "pm.test(\"response has elements\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(2);", + "});", + "", + "pm.environment.set(\"commitZP\", pm.response.json().elements[0]._commitId);" ], "type": "text/javascript" } @@ -1363,128 +1354,139 @@ ], "body": { "mode": "raw", - "raw": "{\n \"refs\": [\n {\n \"name\": \"branch_from_commit\",\n \"type\": \"Branch\",\n \"parentCommitId\": \"invalid\",\n \"id\": \"branch_from_commit\"\n }\n ]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated6\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"p\",\n\t\t\t\"name\": \"p\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/aa/refs", + "raw": "{{host}}/projects/aa/refs/master/elements", "host": [ "{{host}}" ], "path": [ "projects", "aa", - "refs" + "refs", + "master", + "elements" ] } }, "response": [] }, { - "name": "create branch from commit", + "name": "check master commit history", "event": [ { "listen": "test", "script": { + "id": "eb0d752b-95db-466a-a5c2-d9b48cc6c146", "exec": [ - "pm.test(\"branch created from parentCommitId\", function () {", + "pm.test(\"response has 5 commits\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.refs[0].id).to.eql('branch_from_commit_id');", - " pm.expect(jsonData.refs[0].parentRefId).to.eql('refa');", - " pm.expect(jsonData.refs[0].type).to.eql('Branch');", - "});" + " pm.expect(jsonData.commits.length).to.eql(5);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZP\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId4\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId2\"))", + " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "" ], "type": "text/javascript" } } ], "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"refs\": [\n {\n \"name\": \"branch_from_commit\",\n \"type\": \"Branch\",\n \"parentCommitId\": \"{{commitXYRef}}\",\n \"id\": \"branch_from_commit_id\"\n }\n ]\n}" - }, + "method": "GET", + "header": [], "url": { - "raw": "{{host}}/projects/aa/refs", + "raw": "{{host}}/projects/aa/refs/master/commits", "host": [ "{{host}}" ], "path": [ "projects", "aa", - "refs" + "refs", + "master", + "commits" ] } }, "response": [] }, { - "name": "create tag from commit", + "name": "check refa commit history", "event": [ { "listen": "test", "script": { + "id": "03347469-fdcc-4bef-8a72-02763ee852dd", "exec": [ - "pm.test(\"branch created from parentCommitId\", function () {", + "pm.test(\"response has 6 commits\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.refs[0].id).to.eql('tag_from_commit_id');", - " pm.expect(jsonData.refs[0].parentRefId).to.eql('refa');", - " pm.expect(jsonData.refs[0].type).to.eql('Tag');", - "});" + " pm.expect(jsonData.commits.length).to.eql(6);", + "});", + "", + "pm.test(\"commit history is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZQRef\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitXYRef\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId4\"))", + " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId2\"))", + " pm.expect(jsonData.commits[5].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "" ], "type": "text/javascript" } } ], "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"refs\": [\n {\n \"name\": \"tag_from_commit\",\n \"type\": \"Tag\",\n \"parentCommitId\": \"{{commitXYRef}}\",\n \"id\": \"tag_from_commit_id\"\n }\n ]\n}" - }, + "method": "GET", + "header": [], "url": { - "raw": "{{host}}/projects/aa/refs", + "raw": "{{host}}/projects/aa/refs/refa/commits", "host": [ "{{host}}" ], "path": [ "projects", "aa", - "refs" + "refs", + "refa", + "commits" ] } }, "response": [] }, { - "name": "check elements from branch made from commit", + "name": "check x commit history on refa", "event": [ { "listen": "test", "script": { + "id": "8fe61517-a474-4ca7-91ea-aacfe01bb060", "exec": [ - "pm.test(\"Commit in ref match commit before updating refa\", function () {", + "pm.test(\"response has 3 commits\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commitId).to.eql(pm.environment.get('commitXYRef'));", + " pm.expect(jsonData.commits.length).to.eql(4);", "});", "", - "pm.test(\"Elements made in ref match what was created under commit\", function () {", + "pm.test(\"commit history is right\", function() {", " var jsonData = pm.response.json();", - " pm.expect(jsonData).to.equal(pm.environment.get('commitXYRefElements'));", - "});" + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId2\"))", + " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId1\"))", + "})", + "", + "" ], "type": "text/javascript" } @@ -1494,7 +1496,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{host}}/projects/aa/refs/branch_from_commit_id/elements", + "raw": "{{host}}/projects/aa/refs/refa/elements/x/commits", "host": [ "{{host}}" ], @@ -1502,255 +1504,33 @@ "projects", "aa", "refs", - "branch_from_commit_id", - "elements" + "refa", + "elements", + "x", + "commits" ] } }, "response": [] }, { - "name": "check elements from tag made from commit", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Commit in ref match commit before updating refa\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commitId).to.eql(pm.environment.get('commitXYRef'));", - "});", - "", - "pm.test(\"Elements made in ref match what was created under commit\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData).to.equal(pm.environment.get('commitXYRefElements'));", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/tag_from_commit_id/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "tag_from_commit_id", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "update z on master and add element p", - "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(\"commitZP\", pm.response.json().elements[0]._commitId);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"updated6\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"p\",\n\t\t\t\"name\": \"p\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "get elements at commit", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"commit id matches before updating refa\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commitId).to.eql(pm.environment.get(\"commitXYRef\"))", - "});", - "", - "pm.test(\"elements in refa match resutls before updating refa\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(pm.response.json()).to.equal(pm.environment.get('commitXYRefElements'));", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements?commitId={{commitXYRef}}", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements" - ], - "query": [ - { - "key": "commitId", - "value": "{{commitXYRef}}" - } - ] - } - }, - "response": [] - }, - { - "name": "check master commit history", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response has 5 commits\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(5);", - "});", - "", - "pm.test(\"commit history is right\", function() {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZP\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId4\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId2\"))", - " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/master/commits", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "commits" - ] - } - }, - "response": [] - }, - { - "name": "check refa commit history", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response has 6 commits\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(6);", - "});", - "", - "pm.test(\"commit history is right\", function() {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZQRef\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitXYRef\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId4\"))", - " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[4].id).to.eql(pm.environment.get(\"commitId2\"))", - " pm.expect(jsonData.commits[5].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/refa/commits", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "commits" - ] - } - }, - "response": [] - }, - { - "name": "check x commit history on refa", + "name": "check y commit history on refa", "event": [ { "listen": "test", "script": { + "id": "cb0e814e-b415-4dfc-88b1-c70aedd0e1d2", "exec": [ "pm.test(\"response has 3 commits\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(4);", + " pm.expect(jsonData.commits.length).to.eql(3);", "});", "", "pm.test(\"commit history is right\", function() {", " var jsonData = pm.response.json();", " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId2\"))", - " pm.expect(jsonData.commits[3].id).to.eql(pm.environment.get(\"commitId1\"))", + " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId1\"))", "})", "", "" @@ -1763,7 +1543,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/x/commits", + "raw": "{{host}}/projects/aa/refs/refa/elements/y/commits", "host": [ "{{host}}" ], @@ -1773,7 +1553,7 @@ "refs", "refa", "elements", - "x", + "y", "commits" ] } @@ -1781,11 +1561,12 @@ "response": [] }, { - "name": "check y commit history on refa", + "name": "check z commit history on refa", "event": [ { "listen": "test", "script": { + "id": "3225e877-45f8-4b8b-81f0-037fab73a0d8", "exec": [ "pm.test(\"response has 3 commits\", function () {", " var jsonData = pm.response.json();", @@ -1794,54 +1575,8 @@ "", "pm.test(\"commit history is right\", function() {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitXYRef\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId3\"))", - " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId1\"))", - "})", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/y/commits", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements", - "y", - "commits" - ] - } - }, - "response": [] - }, - { - "name": "check z commit history on refa", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"response has 3 commits\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits.length).to.eql(3);", - "});", - "", - "pm.test(\"commit history is right\", function() {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZQRef\"))", - " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId4\"))", + " pm.expect(jsonData.commits[0].id).to.eql(pm.environment.get(\"commitZQRef\"))", + " pm.expect(jsonData.commits[1].id).to.eql(pm.environment.get(\"commitId4\"))", " pm.expect(jsonData.commits[2].id).to.eql(pm.environment.get(\"commitId1\"))", "})", "" @@ -1863,435 +1598,25 @@ "aa", "refs", "refa", - "elements", - "z", - "commits" - ] - } - }, - "response": [] - }, - { - "name": "get latest elements at refa", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"has 4 results\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(4);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\"\n\t\t},{\n\t\t\t\"id\": \"q\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "get latest elements at master", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"has 4 results\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(4);", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\"\n\t\t},{\n\t\t\t\"id\": \"q\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "get mix of elements at master with missing", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"has 3 results and 1 rejected\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(3);", - " pm.expect(jsonData.rejected.length).to.eql(1);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\"\n\t\t},{\n\t\t\t\"id\": \"q\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/master/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "master", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "get mix of elements at refa with commit", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"has 3 results and 2 rejected\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(3);", - " pm.expect(jsonData.rejected.length).to.eql(2);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\"\n\t\t},{\n\t\t\t\"id\": \"q\"\n\t\t}, {\n\t\t\t\"id\": \"p\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements?commitId={{commitXYRef}}", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements" - ], - "query": [ - { - "key": "commitId", - "value": "{{commitXYRef}}" - } - ] - } - }, - "response": [] - }, - { - "name": "delete x on refa", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "DELETE", - "header": [], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/x", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements", - "x" - ] - } - }, - "response": [] - }, - { - "name": "get x on refa deleted", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 410\", function () {", - " pm.response.to.have.status(410);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/x", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements", - "x" - ] - } - }, - "response": [] - }, - { - "name": "resurrect x on refa", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"response has element\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(1);", - "});" - ], - "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\": \"x\",\n\t\t\t\"name\": \"updated4\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements" - ] - } - }, - "response": [] - }, - { - "name": "get resurrected x on refa", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "pm.test(\"response has element\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(1);", - "});" - ], - "type": "text/javascript" - } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements/x", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements", - "x" - ] - } - }, - "response": [] - }, - { - "name": "add ownerId for cameo element on refa", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"updated7\",\n\t\t\t\"ownerId\": \"z\"\n\t\t}\n\t]\n}" - }, - "url": { - "raw": "{{host}}/projects/aa/refs/refa/elements", - "host": [ - "{{host}}" - ], - "path": [ - "projects", - "aa", - "refs", - "refa", - "elements" + "elements", + "z", + "commits" ] } }, "response": [] }, { - "name": "add org b", + "name": "get latest elements at refa", "event": [ { "listen": "test", "script": { + "id": "2f0cb424-4943-4808-8504-decf5a5f13a0", "exec": [ - "pm.test(\"response has org a\", function () {", + "pm.test(\"has 4 results\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.orgs[0].id).to.eql('b');", + " pm.expect(jsonData.elements.length).to.eql(4);", "});" ], "type": "text/javascript" @@ -2299,48 +1624,56 @@ } ], "request": { - "method": "POST", + "method": "PUT", "header": [ { "key": "Content-Type", - "value": "application/json", - "type": "text" + "type": "text", + "value": "application/json" } ], "body": { "mode": "raw", - "raw": "{\n\t\"orgs\": [\n\t\t{\n\t\t\t\"id\": \"b\",\n\t\t\t\"name\": \"b\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\"\n\t\t},{\n\t\t\t\"id\": \"q\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/orgs", + "raw": "{{host}}/projects/aa/refs/refa/elements", "host": [ "{{host}}" ], "path": [ - "orgs" + "projects", + "aa", + "refs", + "refa", + "elements" ] } }, "response": [] }, { - "name": "add project cc under org b", + "name": "get latest elements at master", "event": [ { "listen": "test", "script": { + "id": "3dc49cda-109d-4301-b605-5c34bd2e6356", "exec": [ - "pm.test(\"response has project cc\", function () {", + "pm.test(\"has 4 results\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.projects[0].id).to.eql('cc');", + " pm.expect(jsonData.elements.length).to.eql(4);", "});" ], "type": "text/javascript" } } ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { - "method": "POST", + "method": "GET", "header": [ { "key": "Content-Type", @@ -2350,30 +1683,36 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"cc\", \n\t\t\t\"name\": \"cc\",\n\t\t\t\"orgId\": \"b\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\"\n\t\t},{\n\t\t\t\"id\": \"q\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects", + "raw": "{{host}}/projects/aa/refs/master/elements", "host": [ "{{host}}" ], "path": [ - "projects" + "projects", + "aa", + "refs", + "master", + "elements" ] } }, "response": [] }, { - "name": "create branch del under cc with no commit", + "name": "get mix of elements at master with missing", "event": [ { "listen": "test", "script": { + "id": "89a56141-ec9b-429c-bfa3-36d0e43edfe4", "exec": [ - "", - "pm.test(\"Status code is 400, cannot make branch in empty project\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"has 3 results and 1 rejected\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(3);", + " pm.expect(jsonData.rejected.length).to.eql(1);", "});" ], "type": "text/javascript" @@ -2381,7 +1720,7 @@ } ], "request": { - "method": "POST", + "method": "PUT", "header": [ { "key": "Content-Type", @@ -2391,31 +1730,36 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"id\": \"del\",\n\t\t\t\"name\": \"del\",\n\t\t\t\"type\": \"Branch\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\"\n\t\t},{\n\t\t\t\"id\": \"q\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/cc/refs", + "raw": "{{host}}/projects/aa/refs/master/elements", "host": [ "{{host}}" ], "path": [ "projects", - "cc", - "refs" + "aa", + "refs", + "master", + "elements" ] } }, "response": [] }, { - "name": "make a commit on project cc", + "name": "get mix of elements at refa with commit", "event": [ { "listen": "test", "script": { + "id": "6ac63f9d-1dec-4f8d-af53-31a821f98803", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"has 3 results and 2 rejected\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(3);", + " pm.expect(jsonData.rejected.length).to.eql(2);", "});" ], "type": "text/javascript" @@ -2423,7 +1767,7 @@ } ], "request": { - "method": "POST", + "method": "PUT", "header": [ { "key": "Content-Type", @@ -2433,34 +1777,40 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"random\", \n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\"\n\t\t},\n\t\t{\n\t\t\t\"id\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\"\n\t\t},{\n\t\t\t\"id\": \"q\"\n\t\t}, {\n\t\t\t\"id\": \"p\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/cc/refs/master/elements", + "raw": "{{host}}/projects/aa/refs/refa/elements?commitId={{commitXYRef}}", "host": [ "{{host}}" ], "path": [ "projects", - "cc", + "aa", "refs", - "master", + "refa", "elements" + ], + "query": [ + { + "key": "commitId", + "value": "{{commitXYRef}}" + } ] } }, "response": [] }, { - "name": "create branch del under cc", + "name": "delete x on refa", "event": [ { "listen": "test", "script": { + "id": "64884b31-07b9-45d6-80d9-aaaee57e6cf0", "exec": [ - "pm.test(\"branch created\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.refs[0].id).to.eql('del');", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -2468,42 +1818,39 @@ } ], "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], + "method": "DELETE", + "header": [], "body": { "mode": "raw", - "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"id\": \"del\",\n\t\t\t\"name\": \"del\",\n\t\t\t\"type\": \"Branch\"\n\t\t}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/projects/cc/refs", + "raw": "{{host}}/projects/aa/refs/refa/elements/x", "host": [ "{{host}}" ], "path": [ "projects", - "cc", - "refs" + "aa", + "refs", + "refa", + "elements", + "x" ] } }, "response": [] }, { - "name": "delete branch del", + "name": "get x on refa deleted", "event": [ { "listen": "test", "script": { + "id": "a5fb1b5b-390a-4238-a587-a8d5f8c2c08c", "exec": [ - "pm.test(\"branch deleted\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.refs[0].id).to.eql('del');", + "pm.test(\"Status code is 410\", function () {", + " pm.response.to.have.status(410);", "});" ], "type": "text/javascript" @@ -2511,118 +1858,139 @@ } ], "request": { - "method": "DELETE", + "method": "GET", "header": [], - "body": { - "mode": "raw", - "raw": "" - }, "url": { - "raw": "{{host}}/projects/cc/refs/del", + "raw": "{{host}}/projects/aa/refs/refa/elements/x", "host": [ "{{host}}" ], "path": [ "projects", - "cc", + "aa", "refs", - "del" + "refa", + "elements", + "x" ] } }, "response": [] }, { - "name": "get deleted branch", + "name": "resurrect x on refa", "event": [ { "listen": "test", "script": { + "id": "2891567e-05ac-41db-bbef-a408ae6fb4f4", "exec": [ - " ", - "pm.test(\"Status code is 410\", function () {", - " pm.response.to.have.status(410);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});", - "" + "", + "pm.test(\"response has element\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});" ], "type": "text/javascript" } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { - "method": "GET", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"updated4\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/cc/refs/del", + "raw": "{{host}}/projects/aa/refs/refa/elements", "host": [ "{{host}}" ], "path": [ "projects", - "cc", + "aa", "refs", - "del" + "refa", + "elements" ] } }, "response": [] }, { - "name": "delete branch master", + "name": "get resurrected x on refa", "event": [ { "listen": "test", "script": { + "id": "6c242219-5862-44dd-9aa2-cf684c27b485", "exec": [ - "", - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});", - "" + "", + "pm.test(\"response has element\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements.length).to.eql(1);", + "});" ], "type": "text/javascript" } } ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { - "method": "DELETE", - "header": [], + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], "body": { "mode": "raw", "raw": "" }, "url": { - "raw": "{{host}}/projects/cc/refs/master", + "raw": "{{host}}/projects/aa/refs/refa/elements/x", "host": [ "{{host}}" ], "path": [ "projects", - "cc", + "aa", "refs", - "master" + "refa", + "elements", + "x" ] } }, "response": [] }, { - "name": "delete project cc", + "name": "add ownerId for cameo element on refa", "event": [ { "listen": "test", "script": { + "id": "cc0bb3da-5473-48b8-b706-3f64bedfec62", "exec": [ - "pm.test(\"project soft deleted\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.projects[0].id).to.eql('cc');", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" @@ -2630,72 +1998,87 @@ } ], "request": { - "method": "DELETE", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"updated7\",\n\t\t\t\"ownerId\": \"z\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/cc", + "raw": "{{host}}/projects/aa/refs/refa/elements", "host": [ "{{host}}" ], "path": [ "projects", - "cc" + "aa", + "refs", + "refa", + "elements" ] } }, "response": [] }, { - "name": "get project cc", + "name": "add org b", "event": [ { "listen": "test", "script": { + "id": "ea871dc1-9d88-4481-9c1b-2090a25233e9", "exec": [ - "pm.test(\"Status code is 410\", function () {", - " pm.response.to.have.status(410);", + "pm.test(\"response has org a\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.orgs[0].id).to.eql('b');", "});" ], "type": "text/javascript" } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { - "method": "GET", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"orgs\": [\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/cc", + "raw": "{{host}}/orgs", "host": [ "{{host}}" ], "path": [ - "projects", - "cc" + "orgs" ] } }, "response": [] }, { - "name": "delete org b", + "name": "add project cc under org b", "event": [ { "listen": "test", "script": { + "id": "4120ad4c-9cb5-4b51-bf53-f608d68f0298", "exec": [ - "pm.test(\"Status code is 400, org not empty\", function () {", - " pm.response.to.have.status(400);", + "pm.test(\"response has project cc\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.projects[0].id).to.eql('cc');", "});" ], "type": "text/javascript" @@ -2703,35 +2086,41 @@ } ], "request": { - "method": "DELETE", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"cc\", \n\t\t\t\"name\": \"cc\",\n\t\t\t\"orgId\": \"b\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/orgs/b", + "raw": "{{host}}/projects", "host": [ "{{host}}" ], "path": [ - "orgs", - "b" + "projects" ] } }, "response": [] }, { - "name": "hard delete project cc", + "name": "create branch del under cc with no commit", "event": [ { "listen": "test", "script": { + "id": "cc901e7b-9269-4396-8acb-0606f11dc4db", "exec": [ - "pm.test(\"project hard deleted\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.projects[0].id).to.eql('cc');", + "", + "pm.test(\"Status code is 400, cannot make branch in empty project\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -2739,37 +2128,39 @@ } ], "request": { - "method": "DELETE", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"id\": \"del\",\n\t\t\t\"name\": \"del\",\n\t\t\t\"type\": \"Branch\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/cc?hard=true", + "raw": "{{host}}/projects/cc/refs", "host": [ "{{host}}" ], "path": [ "projects", - "cc" - ], - "query": [ - { - "key": "hard", - "value": "true" - } + "cc", + "refs" ] } }, "response": [] }, { - "name": "delete empty org b", + "name": "make a commit on project cc", "event": [ { "listen": "test", "script": { + "id": "b28e0221-9f3d-49d7-87de-280586509c47", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2780,73 +2171,89 @@ } ], "request": { - "method": "DELETE", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"random\", \n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/orgs/b", + "raw": "{{host}}/projects/cc/refs/master/elements", "host": [ "{{host}}" ], "path": [ - "orgs", - "b" + "projects", + "cc", + "refs", + "master", + "elements" ] } }, "response": [] }, { - "name": "get org b", + "name": "create branch del under cc", "event": [ { "listen": "test", "script": { + "id": "66049694-521b-43cf-92ae-dc6c8cc8405a", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"branch created\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.refs[0].id).to.eql('del');", "});" ], "type": "text/javascript" } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { - "method": "GET", - "header": [], + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"id\": \"del\",\n\t\t\t\"name\": \"del\",\n\t\t\t\"type\": \"Branch\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/orgs/b", + "raw": "{{host}}/projects/cc/refs", "host": [ "{{host}}" ], "path": [ - "orgs", - "b" + "projects", + "cc", + "refs" ] } }, "response": [] }, { - "name": "recreate project cc under org a", + "name": "delete branch del", "event": [ { "listen": "test", "script": { + "id": "5043a523-c8be-4509-bc2f-ea8b040a2bf2", "exec": [ - "pm.test(\"response has project cc\", function () {", + "pm.test(\"branch deleted\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.projects[0].id).to.eql('cc');", + " pm.expect(jsonData.refs[0].id).to.eql('del');", "});" ], "type": "text/javascript" @@ -2854,137 +2261,122 @@ } ], "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], + "method": "DELETE", + "header": [], "body": { "mode": "raw", - "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"cc\", \n\t\t\t\"name\": \"cc\",\n\t\t\t\"orgId\": \"a\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/projects", + "raw": "{{host}}/projects/cc/refs/del", "host": [ "{{host}}" ], "path": [ - "projects" + "projects", + "cc", + "refs", + "del" ] } }, "response": [] }, { - "name": "create webhook on project aa", + "name": "get deleted branch", "event": [ { "listen": "test", "script": { + "id": "83c40f4d-cbf7-4e16-8c6f-9931a78df22f", "exec": [ - "pm.test(\"webhook created with returned id\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.webhooks[0]).to.have.property('id');", + " ", + "pm.test(\"Status code is 410\", function () {", + " pm.response.to.have.status(410);", "});", - " ", "" ], "type": "text/javascript" } } ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], + "method": "GET", + "header": [], "body": { "mode": "raw", - "raw": "{\n\t\"webhooks\": [\n\t\t{\"url\": \"https://random.org\"}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/projects/aa/webhooks", + "raw": "{{host}}/projects/cc/refs/del", "host": [ "{{host}}" ], "path": [ "projects", - "aa", - "webhooks" + "cc", + "refs", + "del" ] } }, "response": [] }, { - "name": "get webhooks", + "name": "delete branch master", "event": [ { "listen": "test", "script": { + "id": "7b4f2fdb-68d9-4e0e-8980-774baa4f9413", "exec": [ - "pm.test(\"project aa has one webhook\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.webhooks[0]).to.have.property('id');", - " pm.expect(jsonData.webhooks.length).to.eql(1);", + "", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});", - " ", "" ], "type": "text/javascript" } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], + "method": "DELETE", + "header": [], "body": { "mode": "raw", "raw": "" }, "url": { - "raw": "{{host}}/projects/aa/webhooks", + "raw": "{{host}}/projects/cc/refs/master", "host": [ "{{host}}" ], "path": [ "projects", - "aa", - "webhooks" + "cc", + "refs", + "master" ] } }, "response": [] }, { - "name": "delete webhook", + "name": "delete project cc", "event": [ { "listen": "test", "script": { + "id": "49b6fb54-9300-4433-983c-8d4ca6a84e35", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - " ", - "" + "pm.test(\"project soft deleted\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.projects[0].id).to.eql('cc');", + "});" ], "type": "text/javascript" } @@ -2992,44 +2384,35 @@ ], "request": { "method": "DELETE", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], + "header": [], "body": { "mode": "raw", - "raw": "{\n\t\"webhooks\": [\n\t\t{\"url\": \"https://random.org\"}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/projects/aa/webhooks", + "raw": "{{host}}/projects/cc", "host": [ "{{host}}" ], "path": [ "projects", - "aa", - "webhooks" + "cc" ] } }, "response": [] }, { - "name": "get webhooks again", + "name": "get project cc", "event": [ { "listen": "test", "script": { + "id": "cdac43db-2126-404b-af6a-91d4c5eac600", "exec": [ - "pm.test(\"project aa has no webhooks\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.webhooks.length).to.eql(0);", - "});", - " ", - "" + "pm.test(\"Status code is 410\", function () {", + " pm.response.to.have.status(410);", + "});" ], "type": "text/javascript" } @@ -3040,40 +2423,34 @@ }, "request": { "method": "GET", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], + "header": [], "body": { "mode": "raw", "raw": "" }, "url": { - "raw": "{{host}}/projects/aa/webhooks", + "raw": "{{host}}/projects/cc", "host": [ "{{host}}" ], "path": [ "projects", - "aa", - "webhooks" + "cc" ] } }, "response": [] }, { - "name": "add project with invalid schema", + "name": "delete org b", "event": [ { "listen": "test", "script": { + "id": "121ac082-4e34-4a42-9fdd-15bb6545898d", "exec": [ - "pm.test(\"Status code is 400\", function () {\r", - " pm.response.to.have.status(400);\r", + "pm.test(\"Status code is 400, org not empty\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -3081,224 +2458,198 @@ } ], "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text" - } - ], + "method": "DELETE", + "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"projects\": [\r\n {\r\n \"orgId\": \"a\",\r\n \"name\": \"string\",\r\n \"id\": \"string\",\r\n \"schema\":\"invalid\"\r\n }\r\n ]\r\n}", - "options": { - "raw": { - "language": "json" - } - } + "raw": "" }, "url": { - "raw": "{{host}}/projects", + "raw": "{{host}}/orgs/b", "host": [ "{{host}}" ], "path": [ - "projects" + "orgs", + "b" ] } }, "response": [] }, { - "name": "add org c without id", + "name": "hard delete project cc", "event": [ { "listen": "test", "script": { + "id": "b5729049-9a5a-4660-b97b-2658d7027f84", "exec": [ - "pm.test(\"response has org c\", function () {", + "pm.test(\"project hard deleted\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.orgs[0].name).to.eql('c');", - "});", - "", - "pm.environment.set(\"orgIdC\", pm.response.json().orgs[0].id);" + " pm.expect(jsonData.projects[0].id).to.eql('cc');", + "});" ], "type": "text/javascript" } } ], "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], + "method": "DELETE", + "header": [], "body": { "mode": "raw", - "raw": "{\n\t\"orgs\": [\n\t\t{\n\t\t\t\"name\": \"c\"\n\t\t}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/orgs", + "raw": "{{host}}/projects/cc?hard=true", "host": [ "{{host}}" ], "path": [ - "orgs" + "projects", + "cc" + ], + "query": [ + { + "key": "hard", + "value": "true" + } ] } }, "response": [] }, { - "name": "get org c", + "name": "delete empty org b", "event": [ { "listen": "test", "script": { + "id": "0a4fcb5e-c5b6-4ea5-b4ec-36babadffaff", "exec": [ - "pm.test(\"org id number is right\", function() {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.orgs[0].id).to.eql(pm.environment.get(\"orgIdC\"))", - "})" + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" ], "type": "text/javascript" } } ], "request": { - "method": "GET", - "header": [ - { - "key": "Content-Type", - "value": "application/json", - "type": "text" - } - ], + "method": "DELETE", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, "url": { - "raw": "{{host}}/orgs/{{orgIdC}}", + "raw": "{{host}}/orgs/b", "host": [ "{{host}}" ], "path": [ "orgs", - "{{orgIdC}}" + "b" ] } }, "response": [] }, { - "name": "add project random to org c without id", + "name": "get org b", "event": [ { "listen": "test", "script": { + "id": "ac5d3658-38e9-423f-b985-d903cceb0740", "exec": [ - "pm.test(\"response has project random\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.projects[0].name).to.eql('random');", - "});", - "", - "pm.environment.set(\"projectRandomId\", pm.response.json().projects[0].id);" + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", + "});" ], "type": "text/javascript" } } ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "type": "text", - "value": "application/json" - } - ], + "method": "GET", + "header": [], "body": { "mode": "raw", - "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"name\": \"random\",\n\t\t\t\"orgId\": \"{{orgIdC}}\"\n\t\t}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/projects", + "raw": "{{host}}/orgs/b", "host": [ "{{host}}" ], "path": [ - "projects" + "orgs", + "b" ] } }, "response": [] }, { - "name": "get org c projects", + "name": "recreate project cc under org a", "event": [ { "listen": "test", "script": { "exec": [ - "pm.test(\"response has 1 project random\", function () {", + "pm.test(\"response has project cc\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.projects.length).to.eql(1);", - " pm.expect(jsonData.projects[0].name).to.eql('random');", + " pm.expect(jsonData.projects[0].id).to.eql('cc');", "});" ], "type": "text/javascript" } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { - "method": "GET", + "method": "POST", "header": [ { "key": "Content-Type", "type": "text", - "value": "application/json", - "disabled": true + "value": "application/json" } ], "body": { "mode": "raw", - "raw": "" + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"cc\", \n\t\t\t\"name\": \"cc\",\n\t\t\t\"orgId\": \"a\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects?orgId={{orgIdC}}", + "raw": "{{host}}/projects", "host": [ "{{host}}" ], "path": [ "projects" - ], - "query": [ - { - "key": "orgId", - "value": "{{orgIdC}}" - } ] } }, "response": [] }, { - "name": "add element random to project random without id", + "name": "create webhook on project aa", "event": [ { "listen": "test", "script": { + "id": "2ba7a873-1bdf-4e86-8329-7069064232a9", "exec": [ - "pm.test(\"response has element random\", function () {", + "pm.test(\"webhook created with returned id\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements[0].name).to.eql('random');", + " pm.expect(jsonData.webhooks[0]).to.have.property('id');", "});", - "", - "pm.environment.set(\"elementRandomId\", pm.response.json().elements[0].id);" + " ", + "" ], "type": "text/javascript" } @@ -3315,44 +2666,47 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"webhooks\": [\n\t\t{\"url\": \"https://random.org\"}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/{{projectRandomId}}/refs/master/elements", + "raw": "{{host}}/projects/aa/webhooks", "host": [ "{{host}}" ], "path": [ "projects", - "{{projectRandomId}}", - "refs", - "master", - "elements" + "aa", + "webhooks" ] } }, "response": [] }, { - "name": "create ref without id on project random", + "name": "get webhooks", "event": [ { "listen": "test", "script": { + "id": "8410e98d-60b6-40bf-b17a-91c78b5f1dda", "exec": [ - "pm.test(\"response has ref random\", function () {", + "pm.test(\"project aa has one webhook\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.refs[0].name).to.eql('random');", + " pm.expect(jsonData.webhooks[0]).to.have.property('id');", + " pm.expect(jsonData.webhooks.length).to.eql(1);", "});", - "", - "pm.environment.set(\"refRandomId\", pm.response.json().refs[0].id);" + " ", + "" ], "type": "text/javascript" } } ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { - "method": "POST", + "method": "GET", "header": [ { "key": "Content-Type", @@ -3362,81 +2716,92 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/projects/{{projectRandomId}}/refs", + "raw": "{{host}}/projects/aa/webhooks", "host": [ "{{host}}" ], "path": [ "projects", - "{{projectRandomId}}", - "refs" + "aa", + "webhooks" ] } }, "response": [] }, { - "name": "get random element in random ref", + "name": "delete webhook", "event": [ { "listen": "test", "script": { + "id": "e0baf005-f27c-42d9-9763-6b194ecccd3f", "exec": [ - "pm.test(\"element is there\", function() {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements[0].name).to.eql('random');", - "})" + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + " ", + "" ], "type": "text/javascript" } } ], "request": { - "method": "GET", + "method": "DELETE", "header": [ { "key": "Content-Type", - "value": "application/json", - "type": "text" + "type": "text", + "value": "application/json" } ], + "body": { + "mode": "raw", + "raw": "{\n\t\"webhooks\": [\n\t\t{\"url\": \"https://random.org\"}\n\t]\n}" + }, "url": { - "raw": "{{host}}/projects/{{projectRandomId}}/refs/{{refRandomId}}/elements/{{elementRandomId}}", + "raw": "{{host}}/projects/aa/webhooks", "host": [ "{{host}}" ], "path": [ "projects", - "{{projectRandomId}}", - "refs", - "{{refRandomId}}", - "elements", - "{{elementRandomId}}" + "aa", + "webhooks" ] } }, "response": [] }, { - "name": "add project to nonexistent org", + "name": "get webhooks again", "event": [ { "listen": "test", "script": { + "id": "009db0b6-7e14-42d8-89ae-33cdb7a20a6f", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", - "});" + "pm.test(\"project aa has no webhooks\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.webhooks.length).to.eql(0);", + "});", + " ", + "" ], "type": "text/javascript" } } ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { - "method": "POST", + "method": "GET", "header": [ { "key": "Content-Type", @@ -3446,29 +2811,32 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"name\": \"bad\",\n\t\t\t\"orgId\": \"missing\"\n\t\t}\n\t]\n}" + "raw": "" }, "url": { - "raw": "{{host}}/projects", + "raw": "{{host}}/projects/aa/webhooks", "host": [ "{{host}}" ], "path": [ - "projects" + "projects", + "aa", + "webhooks" ] } }, "response": [] }, { - "name": "add project without org", + "name": "add project with invalid schema", "event": [ { "listen": "test", "script": { + "id": "5d411406-9444-4333-9b15-43c0ae716821", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"Status code is 400\", function () {\r", + " pm.response.to.have.status(400);\r", "});" ], "type": "text/javascript" @@ -3480,13 +2848,18 @@ "header": [ { "key": "Content-Type", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" } ], "body": { "mode": "raw", - "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"name\": \"bad\"\n\t\t}\n\t]\n}" + "raw": "{\r\n \"projects\": [\r\n {\r\n \"orgId\": \"a\",\r\n \"name\": \"string\",\r\n \"id\": \"string\",\r\n \"schema\":\"invalid\"\r\n }\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } }, "url": { "raw": "{{host}}/projects", @@ -3501,15 +2874,19 @@ "response": [] }, { - "name": "create branch from commit", + "name": "add org c without id", "event": [ { "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", - "});" + "script": { + "id": "53ab3019-1cc1-4da3-aece-5c157766f627", + "exec": [ + "pm.test(\"response has org c\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.orgs[0].name).to.eql('c');", + "});", + "", + "pm.environment.set(\"orgIdC\", pm.response.json().orgs[0].id);" ], "type": "text/javascript" } @@ -3526,74 +2903,73 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"name\": \"bad\",\n\t\t\t\"parentCommitId\": \"bad\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"orgs\": [\n\t\t{\n\t\t\t\"name\": \"c\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/aa/refs", + "raw": "{{host}}/orgs", "host": [ "{{host}}" ], "path": [ - "projects", - "aa", - "refs" + "orgs" ] } }, "response": [] }, { - "name": "create branch from nonexistent ref", + "name": "get org c", "event": [ { "listen": "test", "script": { + "id": "8d61501e-4a5b-4a71-9f1d-ad00c75893bd", "exec": [ - "pm.test(\"Status code is 400\", function () {", - " pm.response.to.have.status(400);", - "});" + "pm.test(\"org id number is right\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.orgs[0].id).to.eql(pm.environment.get(\"orgIdC\"))", + "})" ], "type": "text/javascript" } } ], "request": { - "method": "POST", + "method": "GET", "header": [ { "key": "Content-Type", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"name\": \"bad\",\n\t\t\t\"parentRefId\": \"missing\"\n\t\t}\n\t]\n}" - }, "url": { - "raw": "{{host}}/projects/aa/refs", + "raw": "{{host}}/orgs/{{orgIdC}}", "host": [ "{{host}}" ], "path": [ - "projects", - "aa", - "refs" + "orgs", + "{{orgIdC}}" ] } }, "response": [] }, { - "name": "post elements to nonexistent project", + "name": "add project random to org c without id", "event": [ { "listen": "test", "script": { + "id": "39291cc7-7dbe-4eb9-ad83-857b839bfda8", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", - "});" + "pm.test(\"response has project random\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.projects[0].name).to.eql('random');", + "});", + "", + "pm.environment.set(\"projectRandomId\", pm.response.json().projects[0].id);" ], "type": "text/javascript" } @@ -3610,34 +2986,86 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"bad\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"name\": \"random\",\n\t\t\t\"orgId\": \"{{orgIdC}}\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/aaa/refs/master/elements", + "raw": "{{host}}/projects", "host": [ "{{host}}" ], "path": [ - "projects", - "aaa", - "refs", - "master", - "elements" + "projects" ] } }, "response": [] }, + { + "name": "get org c projects", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"response has 1 project random\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.projects.length).to.eql(1);", + " pm.expect(jsonData.projects[0].name).to.eql('random');", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json", + "disabled": true + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{host}}/projects?orgId={{orgIdC}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects" + ], + "query": [ + { + "key": "orgId", + "value": "{{orgIdC}}" + } + ] + } + }, + "response": [] + }, { - "name": "post elements to nonexistent ref", + "name": "add element random to project random without id", "event": [ { "listen": "test", "script": { + "id": "4c60e596-758d-4347-8a0c-ef9071a78421", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", - "});" + "pm.test(\"response has element random\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements[0].name).to.eql('random');", + "});", + "", + "pm.environment.set(\"elementRandomId\", pm.response.json().elements[0].id);" ], "type": "text/javascript" } @@ -3654,18 +3082,18 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"bad\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/aa/refs/missing/elements", + "raw": "{{host}}/projects/{{projectRandomId}}/refs/master/elements", "host": [ "{{host}}" ], "path": [ "projects", - "aa", + "{{projectRandomId}}", "refs", - "missing", + "master", "elements" ] } @@ -3673,22 +3101,26 @@ "response": [] }, { - "name": "get nonexistent project", + "name": "create ref without id on project random", "event": [ { "listen": "test", "script": { + "id": "fa70a5cd-4079-4216-b4f6-b4202c26cfc0", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", - "});" + "pm.test(\"response has ref random\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.refs[0].name).to.eql('random');", + "});", + "", + "pm.environment.set(\"refRandomId\", pm.response.json().refs[0].id);" ], "type": "text/javascript" } } ], "request": { - "method": "GET", + "method": "POST", "header": [ { "key": "Content-Type", @@ -3696,29 +3128,36 @@ "value": "application/json" } ], + "body": { + "mode": "raw", + "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"name\": \"random\"\n\t\t}\n\t]\n}" + }, "url": { - "raw": "{{host}}/projects/zz", + "raw": "{{host}}/projects/{{projectRandomId}}/refs", "host": [ "{{host}}" ], "path": [ "projects", - "zz" + "{{projectRandomId}}", + "refs" ] } }, "response": [] }, { - "name": "get nonexistent ref", + "name": "get random element in random ref", "event": [ { "listen": "test", "script": { + "id": "e1a34e6f-ae27-4a4f-8294-a7c9f86d9512", "exec": [ - "pm.test(\"Status code is 404\", function () {", - " pm.response.to.have.status(404);", - "});" + "pm.test(\"element is there\", function() {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.elements[0].name).to.eql('random');", + "})" ], "type": "text/javascript" } @@ -3729,31 +3168,34 @@ "header": [ { "key": "Content-Type", - "type": "text", - "value": "application/json" + "value": "application/json", + "type": "text" } ], "url": { - "raw": "{{host}}/projects/aa/refs/missing", + "raw": "{{host}}/projects/{{projectRandomId}}/refs/{{refRandomId}}/elements/{{elementRandomId}}", "host": [ "{{host}}" ], "path": [ "projects", - "aa", + "{{projectRandomId}}", "refs", - "missing" + "{{refRandomId}}", + "elements", + "{{elementRandomId}}" ] } }, "response": [] }, { - "name": "get element in nonexistent ref", + "name": "add project to nonexistent org", "event": [ { "listen": "test", "script": { + "id": "90859114-65cc-41c2-8b34-015f1464201a", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3764,7 +3206,7 @@ } ], "request": { - "method": "GET", + "method": "POST", "header": [ { "key": "Content-Type", @@ -3772,29 +3214,29 @@ "value": "application/json" } ], + "body": { + "mode": "raw", + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"name\": \"bad\",\n\t\t\t\"orgId\": \"missing\"\n\t\t}\n\t]\n}" + }, "url": { - "raw": "{{host}}/projects/aa/refs/missing/elements/asdf", + "raw": "{{host}}/projects", "host": [ "{{host}}" ], "path": [ - "projects", - "aa", - "refs", - "missing", - "elements", - "asdf" + "projects" ] } }, "response": [] }, { - "name": "get nonexistent commit", + "name": "add project without org", "event": [ { "listen": "test", "script": { + "id": "c410396b-451f-4120-bbd6-69fa66effe42", "exec": [ "pm.test(\"Status code is 404\", function () {", " pm.response.to.have.status(404);", @@ -3805,7 +3247,7 @@ } ], "request": { - "method": "GET", + "method": "POST", "header": [ { "key": "Content-Type", @@ -3813,30 +3255,32 @@ "value": "application/json" } ], + "body": { + "mode": "raw", + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"name\": \"bad\"\n\t\t}\n\t]\n}" + }, "url": { - "raw": "{{host}}/projects/aa/commits/missing", + "raw": "{{host}}/projects", "host": [ "{{host}}" ], "path": [ - "projects", - "aa", - "commits", - "missing" + "projects" ] } }, "response": [] }, { - "name": "create branch with long id", + "name": "create branch from commit", "event": [ { "listen": "test", "script": { + "id": "bfbfce50-298d-4d87-b403-951ab3e2f574", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -3854,7 +3298,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"name\": \"long\",\n \"id\": \"a123456789012345678901234567890123456789012345678901234567890\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"name\": \"bad\",\n\t\t\t\"parentCommitId\": \"bad\"\n\t\t}\n\t]\n}" }, "url": { "raw": "{{host}}/projects/aa/refs", @@ -3871,14 +3315,15 @@ "response": [] }, { - "name": "post to long branch", + "name": "create branch from nonexistent ref", "event": [ { "listen": "test", "script": { + "id": "c140808f-619f-4b5e-ab06-ae1124039678", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 400\", function () {", + " pm.response.to.have.status(400);", "});" ], "type": "text/javascript" @@ -3896,33 +3341,32 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"blah\",\n\t\t\t\"id\": \"blah\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"refs\": [\n\t\t{\n\t\t\t\"name\": \"bad\",\n\t\t\t\"parentRefId\": \"missing\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/aa/refs/a123456789012345678901234567890123456789012345678901234567890/elements", + "raw": "{{host}}/projects/aa/refs", "host": [ "{{host}}" ], "path": [ "projects", "aa", - "refs", - "a123456789012345678901234567890123456789012345678901234567890", - "elements" + "refs" ] } }, "response": [] }, { - "name": "create project zz", + "name": "post elements to nonexistent project", "event": [ { "listen": "test", "script": { + "id": "563236de-9fa5-4902-aa08-b271cdee278e", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" @@ -3940,29 +3384,34 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"zz\", \n\t\t\t\"name\": \"zz\",\n\t\t\t\"orgId\": \"a\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"bad\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects", + "raw": "{{host}}/projects/aaa/refs/master/elements", "host": [ "{{host}}" ], "path": [ - "projects" + "projects", + "aaa", + "refs", + "master", + "elements" ] } }, "response": [] }, { - "name": "add elements to project zz", + "name": "post elements to nonexistent ref", "event": [ { "listen": "test", "script": { + "id": "9f8b1c3b-629e-4080-bd96-c7ea7a29faf0", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" @@ -3980,18 +3429,18 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"bad\"\n\t\t}\n\t]\n}" }, "url": { - "raw": "{{host}}/projects/zz/refs/master/elements", + "raw": "{{host}}/projects/aa/refs/missing/elements", "host": [ "{{host}}" ], "path": [ "projects", - "zz", + "aa", "refs", - "master", + "missing", "elements" ] } @@ -3999,26 +3448,23 @@ "response": [] }, { - "name": "update and delete elements in same commit", + "name": "get nonexistent project", "event": [ { "listen": "test", "script": { + "id": "f9e479b7-97e5-41f2-b801-7c1f7f4553ec", "exec": [ - "pm.test(\"response has elements\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.elements.length).to.eql(2);", - " pm.expect(jsonData.deleted.length).to.eql(1);", - "});", - "", - "pm.environment.set(\"hybridCommit\", pm.response.json().commitId);" + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", + "});" ], "type": "text/javascript" } } ], "request": { - "method": "POST", + "method": "GET", "header": [ { "key": "Content-Type", @@ -4026,44 +3472,35 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" - }, "url": { - "raw": "{{host}}/projects/zz/refs/master/elements", + "raw": "{{host}}/projects/zz", "host": [ "{{host}}" ], "path": [ "projects", - "zz", - "refs", - "master", - "elements" + "zz" ] } }, "response": [] }, { - "name": "get deleted element", + "name": "get nonexistent ref", "event": [ { "listen": "test", "script": { + "id": "58d3d7d2-416b-4ac3-8933-7b54c2691fd4", "exec": [ - "pm.test(\"Status code is 410\", function () {", - " pm.response.to.have.status(410);", + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -4073,50 +3510,37 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" - }, "url": { - "raw": "{{host}}/projects/zz/refs/master/elements/z", + "raw": "{{host}}/projects/aa/refs/missing", "host": [ "{{host}}" ], "path": [ "projects", - "zz", + "aa", "refs", - "master", - "elements", - "z" + "missing" ] } }, "response": [] }, { - "name": "get commit object", + "name": "get element in nonexistent ref", "event": [ { "listen": "test", "script": { + "id": "5eacc2a2-caea-4256-aa97-bf6e50bd3b68", "exec": [ - "pm.test(\"commit has right data\", function () {", - " var jsonData = pm.response.json();", - " pm.expect(jsonData.commits[0].updated.length).to.eql(2);", - " pm.expect(jsonData.commits[0].deleted.length).to.eql(1);", - "", - "});", - "", - "" + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", + "});" ], "type": "text/javascript" } } ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { "method": "GET", "header": [ @@ -4126,25 +3550,379 @@ "value": "application/json" } ], - "body": { - "mode": "raw", - "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" - }, "url": { - "raw": "{{host}}/projects/zz/commits/{{hybridCommit}}", + "raw": "{{host}}/projects/aa/refs/missing/elements/asdf", "host": [ "{{host}}" ], "path": [ "projects", - "zz", - "commits", - "{{hybridCommit}}" + "aa", + "refs", + "missing", + "elements", + "asdf" ] } }, "response": [] - } + }, + { + "name": "get nonexistent commit", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{host}}/projects/aa/commits/missing", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "commits", + "missing" + ] + } + }, + "response": [] + }, + { + "name": "create branch with long id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "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\"name\": \"long\",\n \"id\": \"a123456789012345678901234567890123456789012345678901234567890\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs" + ] + } + }, + "response": [] + }, + { + "name": "post to long branch", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"name\": \"blah\",\n\t\t\t\"id\": \"blah\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/aa/refs/a123456789012345678901234567890123456789012345678901234567890/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "aa", + "refs", + "a123456789012345678901234567890123456789012345678901234567890", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "create project zz", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"projects\": [\n\t\t{\n\t\t\t\"id\": \"zz\", \n\t\t\t\"name\": \"zz\",\n\t\t\t\"orgId\": \"a\",\n\t\t\t\"schema\": \"default\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects", + "host": [ + "{{host}}" + ], + "path": [ + "projects" + ] + } + }, + "response": [] + }, + { + "name": "add elements to project zz", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"x\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"y\"\n\t\t}, {\n\t\t\t\"id\": \"z\",\n\t\t\t\"name\": \"z\"\n\t\t}\n\t]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "update and delete elements in same commit", + "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.expect(jsonData.deleted.length).to.eql(1);", + "});", + "", + "pm.environment.set(\"hybridCommit\", pm.response.json().commitId);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/refs/master/elements", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "refs", + "master", + "elements" + ] + } + }, + "response": [] + }, + { + "name": "get deleted element", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 410\", function () {", + " pm.response.to.have.status(410);", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/refs/master/elements/z", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "refs", + "master", + "elements", + "z" + ] + } + }, + "response": [] + }, + { + "name": "get commit object", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"commit has right data\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.commits[0].updated.length).to.eql(2);", + " pm.expect(jsonData.commits[0].deleted.length).to.eql(1);", + "", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"elements\": [\n\t\t{\n\t\t\t\"id\": \"x\",\n\t\t\t\"name\": \"xx\"\n\t\t}, {\n\t\t\t\"id\": \"y\", \n\t\t\t\"name\": \"yy\"\n\t\t}\n\t],\n \"deletes\": [{\"id\": \"z\"}]\n}" + }, + "url": { + "raw": "{{host}}/projects/zz/commits/{{hybridCommit}}", + "host": [ + "{{host}}" + ], + "path": [ + "projects", + "zz", + "commits", + "{{hybridCommit}}" + ] + } + }, + "response": [] + } ], "auth": { "type": "bearer", @@ -4160,6 +3938,7 @@ { "listen": "prerequest", "script": { + "id": "cd69ddc1-20da-4c86-919c-ad9bf455d71d", "type": "text/javascript", "exec": [ "" @@ -4169,11 +3948,13 @@ { "listen": "test", "script": { + "id": "480b7515-91c4-49b1-9bee-f5af24bb9524", "type": "text/javascript", "exec": [ "" ] } } - ] + ], + "protocolProfileBehavior": {} } \ No newline at end of file From 9f86bb681256af51ebf70787f68a52d009d819ee Mon Sep 17 00:00:00 2001 From: Bryan Orozco Date: Mon, 26 Feb 2024 15:09:44 -0800 Subject: [PATCH 12/23] updated DefaultBranchService.java --- .../mms/crud/services/DefaultBranchService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 0c80cdf89..5fcea2068 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 @@ -182,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(branch.getParentCommitId() == null) { + 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; From af678d950a0ca9e2c203b3aac8901b13bece894f Mon Sep 17 00:00:00 2001 From: Bryan Orozco Date: Tue, 27 Feb 2024 12:47:18 -0800 Subject: [PATCH 13/23] added postman test collection and update to DefaultBranchService.java --- .circleci/config.yml | 3 +- .../crud/services/DefaultBranchService.java | 11 +- ...keBranchFromCommit.postman_collection.json | 652 ++++++++++++++++++ 3 files changed, 659 insertions(+), 7 deletions(-) create mode 100644 example/makeBranchFromCommit.postman_collection.json diff --git a/.circleci/config.yml b/.circleci/config.yml index f8446b1a0..c573fef52 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,8 @@ jobs: 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 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/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java b/crud/src/main/java/org/openmbee/mms/crud/services/DefaultBranchService.java index 5fcea2068..b05618642 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 @@ -137,6 +137,7 @@ public RefJson createBranch(String projectId, RefJson branch) { branch.setDeleted(false); branch.setProjectId(projectId); branch.setStatus("created"); + boolean fromCommit = !branch.getParentCommitId().isEmpty(); if (branch.getDocId() == null || branch.getDocId().isEmpty()) { String docId = branchIndex.createDocId(branch); @@ -182,7 +183,7 @@ public RefJson createBranch(String projectId, RefJson branch) { try { branchIndex.update(branch); branchRepository.save(b); - if(branch.getParentCommitId() == null) { + if(!fromCommit) { Set docIds = new HashSet<>(); for (Node n: nodeRepository.findAllByDeleted(false)) { docIds.add(n.getDocId()); @@ -222,7 +223,7 @@ public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRe RefJson branchFromCommit = this.createBranch(projectId, parentCommitIdRef); - ContextHolder.setContext(projectId, branchFromCommit.getRefId()); + ContextHolder.setContext(projectId, branchFromCommit.getId()); // Get current nodes from database List nodes = nodeRepository.findAll(); @@ -236,21 +237,19 @@ public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRe } // 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); - Set docIds = new HashSet<>(); - for (Node n: nodeRepository.findAllByDeleted(false)) { - docIds.add(n.getDocId()); - } try { nodeIndex.addToRef(docIds); } catch(Exception e) {} return branchFromCommit; 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 From db448e5ab1e497e87d2834166ca06184883cb3c3 Mon Sep 17 00:00:00 2001 From: Bryan Orozco Date: Tue, 27 Feb 2024 13:03:07 -0800 Subject: [PATCH 14/23] fix: npe update --- .../org/openmbee/mms/crud/services/DefaultBranchService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b05618642..7abc363f1 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 @@ -137,7 +137,7 @@ public RefJson createBranch(String projectId, RefJson branch) { branch.setDeleted(false); branch.setProjectId(projectId); branch.setStatus("created"); - boolean fromCommit = !branch.getParentCommitId().isEmpty(); + boolean fromCommit = branch.getParentCommitId() == null ? false : true; if (branch.getDocId() == null || branch.getDocId().isEmpty()) { String docId = branchIndex.createDocId(branch); From 961921ae292b487ad2d828d1859e6e73a19aafad Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Wed, 28 Feb 2024 14:44:20 -0800 Subject: [PATCH 15/23] fix: readthedocs build --- .readthedocs.yaml | 6 +++--- docs/requirements.txt | 1 + elastic/README.rst | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 docs/requirements.txt 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/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. From 255ffd06e6a6f8a50aa0ff5e1c0ee1e73b0fef28 Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Mon, 4 Mar 2024 10:16:55 -0800 Subject: [PATCH 16/23] set appropriate status if branching from commit --- .../openmbee/mms/crud/services/DefaultBranchService.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 7abc363f1..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 @@ -136,9 +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); @@ -222,7 +221,6 @@ public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRe ContextHolder.setContext(projectId, parentRef); RefJson branchFromCommit = this.createBranch(projectId, parentCommitIdRef); - ContextHolder.setContext(projectId, branchFromCommit.getId()); // Get current nodes from database @@ -249,7 +247,8 @@ public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRe } } nodeRepository.updateAll(nodes); - + branchFromCommit.setStatus("created"); + branchIndex.update(branchFromCommit); try { nodeIndex.addToRef(docIds); } catch(Exception e) {} return branchFromCommit; From 80338bcb52cee3ec785c478b1d9f64d1a8af174b Mon Sep 17 00:00:00 2001 From: Jason Han Date: Tue, 5 Mar 2024 12:30:50 -0800 Subject: [PATCH 17/23] Updating Spring boot and spring dependencies --- gradle.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 336ca74f4..aec65bdcc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ version=4.0.19 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.13.5 elasticVersion=7.8.1 \ No newline at end of file From f92e54a1c3b813eea3f2ca83130532dd89ff617d Mon Sep 17 00:00:00 2001 From: Jason Han Date: Tue, 5 Mar 2024 13:32:07 -0800 Subject: [PATCH 18/23] Use tika-core instead of tika-parser --- storage/storage.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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' From b0157dd6d3c62c41448be5222bebdb585c6b8e64 Mon Sep 17 00:00:00 2001 From: Jason Han Date: Tue, 5 Mar 2024 20:15:08 -0800 Subject: [PATCH 19/23] Add the jackson bom to manage jackson dependencies throughout subprojects. --- build.gradle | 14 +++++++++----- gradle.properties | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 6dc76ae86..6acae354a 100644 --- a/build.gradle +++ b/build.gradle @@ -29,10 +29,10 @@ ext { 'spring-aspects' : "org.springframework:spring-aspects:$springFrameworkVersion", 'spring-data-commons' : "org.springframework.data:spring-data-commons:$springDataVersion", 'spring-data-jpa' : "org.springframework.data:spring-data-jpa:$springDataVersion", - 'jackson-annotations' : "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion", - 'jackson-databind' : "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion", - 'jackson-datatype-hibernate5' : "com.fasterxml.jackson.datatype:jackson-datatype-hibernate5:$jacksonVersion", - 'jackson-datatype-jsr310' : "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion", + 'jackson-annotations' : "com.fasterxml.jackson.core:jackson-annotations", + 'jackson-databind' : "com.fasterxml.jackson.core:jackson-databind", + 'jackson-datatype-hibernate5' : "com.fasterxml.jackson.datatype:jackson-datatype-hibernate5", + 'jackson-datatype-jsr310' : "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", 'spring-boot-starter-test' : 'org.springframework.boot:spring-boot-starter-test:2.2.4.RELEASE' ] } @@ -146,6 +146,10 @@ subprojects { exclude group: "org.slf4j", module: "slf4j-log4j12" exclude group: "log4j", module: "log4j" } + + dependencies { + implementation enforcedPlatform("com.fasterxml.jackson:jackson-bom:${jacksonVersion}") + } } signing { @@ -157,4 +161,4 @@ subprojects { sign publishing.publications.mavenJava } } -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 336ca74f4..9a0df13c1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,5 +5,5 @@ springBootVersion=2.7.17 springFrameworkVersion=5.3.30 springSecurityVersion=5.7.10 springDataVersion=2.7.14 -jacksonVersion=2.13.3 +jacksonVersion=2.16.1 elasticVersion=7.8.1 \ No newline at end of file From eda4fff5429a006f940091bc97ca1b471418ec18 Mon Sep 17 00:00:00 2001 From: Jason Han Date: Tue, 5 Mar 2024 20:50:19 -0800 Subject: [PATCH 20/23] Change duplicateStrategy to WARN instead of include. --- example/example.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From eef572535c016f3cc5dc990ec72c3857c2600fdd Mon Sep 17 00:00:00 2001 From: Jason Han Date: Wed, 6 Mar 2024 15:53:54 -0800 Subject: [PATCH 21/23] Update versions for release --- docs/conf.py | 4 ++-- gradle.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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/gradle.properties b/gradle.properties index 7763f812f..c01e8f3db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=4.0.19 +version=4.0.20 group=org.openmbee.mms springBootVersion=2.7.18 From cb5b9aac9307617ff18d89a790d26e1ec2e4dee4 Mon Sep 17 00:00:00 2001 From: Jason Han Date: Wed, 6 Mar 2024 16:35:46 -0800 Subject: [PATCH 22/23] Don't use enforced platform. Also add the jackson-bom version to spring dependency management. --- build.gradle | 3 ++- data/data.gradle | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 6acae354a..da556a270 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 @@ -148,7 +149,7 @@ subprojects { } dependencies { - implementation enforcedPlatform("com.fasterxml.jackson:jackson-bom:${jacksonVersion}") + api platform("com.fasterxml.jackson:jackson-bom:${jacksonVersion}") } } 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 From 95a9d95e11970ea5e3a4c0df2ed40078fcecf74e Mon Sep 17 00:00:00 2001 From: Jason Han Date: Wed, 6 Mar 2024 17:17:22 -0800 Subject: [PATCH 23/23] Don't use the BOM and Spring Dependency Management together. --- build.gradle | 12 ++++-------- gradle.properties | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index da556a270..5df7cf391 100644 --- a/build.gradle +++ b/build.gradle @@ -29,10 +29,10 @@ ext { 'spring-aspects' : "org.springframework:spring-aspects:$springFrameworkVersion", 'spring-data-commons' : "org.springframework.data:spring-data-commons:$springDataVersion", 'spring-data-jpa' : "org.springframework.data:spring-data-jpa:$springDataVersion", - 'jackson-annotations' : "com.fasterxml.jackson.core:jackson-annotations", - 'jackson-databind' : "com.fasterxml.jackson.core:jackson-databind", - 'jackson-datatype-hibernate5' : "com.fasterxml.jackson.datatype:jackson-datatype-hibernate5", - 'jackson-datatype-jsr310' : "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", + 'jackson-annotations' : "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion", + 'jackson-databind' : "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion", + 'jackson-datatype-hibernate5' : "com.fasterxml.jackson.datatype:jackson-datatype-hibernate5:$jacksonVersion", + 'jackson-datatype-jsr310' : "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion", 'spring-boot-starter-test' : 'org.springframework.boot:spring-boot-starter-test:2.2.4.RELEASE' ] } @@ -147,10 +147,6 @@ subprojects { exclude group: "org.slf4j", module: "slf4j-log4j12" exclude group: "log4j", module: "log4j" } - - dependencies { - api platform("com.fasterxml.jackson:jackson-bom:${jacksonVersion}") - } } signing { diff --git a/gradle.properties b/gradle.properties index c01e8f3db..64311ee4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,5 @@ 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