diff --git a/.dredd/hooks/capabilities.go b/.dredd/hooks/capabilities.go index a8904a96a..b82d73b2a 100644 --- a/.dredd/hooks/capabilities.go +++ b/.dredd/hooks/capabilities.go @@ -234,6 +234,7 @@ func alterRequestBody(t *trans.Transaction) { bodyFieldProcessor("integration_id", integration.ID, &request) } if integrationextractor != nil { + //bodyFieldProcessor("integration_id", integrationextractor.IntegrationID, &request) bodyFieldProcessor("extractor_id", integrationextractor.ID, &request) } if integrationextractvalue != nil { @@ -246,7 +247,7 @@ func alterRequestBody(t *trans.Transaction) { // Inject object ID to body for PUT requests if strings.ToLower(t.Request.Method) == "put" { - putRequestPathRE := regexp.MustCompile(`/api/(?:project/\d+/)?\w+/(\d+)/?(?:integrations/\d+/|integrations/\d+/extractor/\d+)?(?:integration/\d+/extractor/\d+/matcher/\d+)?(?:integration/\d+/extractor/\d+/value/\d+)?$`) + putRequestPathRE := regexp.MustCompile(`/api/(?:project/\d+/)?\w+/(\d+)/?(?:integrations/\d+/|integrations/\d+/extractors/\d+)?(?:integrations/\d+/extractors/\d+/matchers/\d+)?(?:integrations/\d+/extractors/\d+/values/\d+)?$`) m := putRequestPathRE.FindStringSubmatch(t.FullPath) if len(m) > 0 { objectID, err := strconv.Atoi(m[1]) diff --git a/.dredd/hooks/main.go b/.dredd/hooks/main.go index eacd014e2..0b378ba36 100644 --- a/.dredd/hooks/main.go +++ b/.dredd/hooks/main.go @@ -79,61 +79,23 @@ func main() { transaction.Request.Body = "{ \"user_id\": " + strconv.Itoa(userPathTestUser.ID) + ",\"role\": \"owner\"}" }) - h.Before("project > /api/project/{project_id}/integrations > get all integrations > 200 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration"}) - }) - - h.Before("project > /api/project/{project_id}/integrations/{integration_id} > Get Integration > 200 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors > Get Integration Extractors > 200 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors > Add Integration Extractor > 204 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id} > Updates Integration extractor > 204 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id} > Removes integration extractor > 204 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/values > Get Integration Extracted Values linked to integration extractor > 200 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor", "integrationextractvalue"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/values > Add Integration Extracted Value > 204 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor", "integrationextractvalue"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/value/{extractvalue_id} > Removes integration extract value > 204 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor", "integrationextractvalue"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/values > Add Integration Extracted Value > 204 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/value/{extractvalue_id} > Updates Integration ExtractValue > 204 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor", "integrationmatcher"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/matchers > Get Integration Matcher linked to integration extractor > 200 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/matchers > Add Integration Matcher > 204 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor"}) - }) - - h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/matcher/{matcher_id} > Updates Integration Matcher > 204 > application/json", func(t *trans.Transaction) { - addCapabilities([]string{"repository", "inventory", "environment", "template", "integration", "integrationextractor", "integrationmatcher"}) - }) + h.Before("project > /api/project/{project_id}/integrations > get all integrations > 200 > application/json", capabilityWrapper("integration")) + h.Before("project > /api/project/{project_id}/integrations/{integration_id} > Get Integration > 200 > application/json", capabilityWrapper("integration")) + h.Before("project > /api/project/{project_id}/integrations/{integration_id} > Update Integration > 204 > application/json", capabilityWrapper("integration")) + h.Before("project > /api/project/{project_id}/integrations/{integration_id} > Remove integration > 204 > application/json", capabilityWrapper("integration")) + + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors > Get Integration Extractors > 200 > application/json", capabilityWrapper("integrationextractor")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors > Add Integration Extractor > 204 > application/json", capabilityWrapper("integration")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id} > Updates Integration extractor > 204 > application/json", capabilityWrapper("integrationextractor")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id} > Removes integration extractor > 204 > application/json", capabilityWrapper("integrationextractor")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values > Get Integration Extracted Values linked to integration extractor > 200 > application/json", capabilityWrapper("integrationextractvalue")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values > Add Integration Extracted Value > 204 > application/json", capabilityWrapper("integrationextractvalue")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values/{extractvalue_id} > Removes integration extract value > 204 > application/json", capabilityWrapper("integrationextractvalue")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values > Add Integration Extracted Value > 204 > application/json", capabilityWrapper("integrationextractor")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values/{extractvalue_id} > Updates Integration ExtractValue > 204 > application/json", capabilityWrapper("integrationmatcher")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers > Get Integration Matcher linked to integration extractor > 200 > application/json", capabilityWrapper("integrationextractor")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers > Add Integration Matcher > 204 > application/json", capabilityWrapper("integrationextractor")) + h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers/{matcher_id} > Updates Integration Matcher > 204 > application/json", capabilityWrapper("integrationmatcher")) h.Before("project > /api/project/{project_id}/keys/{key_id} > Updates access key > 204 > application/json", capabilityWrapper("access_key")) h.Before("project > /api/project/{project_id}/keys/{key_id} > Removes access key > 204 > application/json", capabilityWrapper("access_key")) diff --git a/api-docs.yml b/api-docs.yml index 3e4a0d51c..5044c70d4 100644 --- a/api-docs.yml +++ b/api-docs.yml @@ -1553,7 +1553,7 @@ paths: responses: 204: description: Integration Extractor Created - /project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}: + /project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}: parameters: - $ref: "#/parameters/project_id" - $ref: "#/parameters/integration_id" @@ -1578,7 +1578,7 @@ paths: responses: 204: description: integration extractor removed - /project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/values: + /project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values: parameters: - $ref: "#/parameters/project_id" - $ref: "#/parameters/integration_id" @@ -1609,7 +1609,7 @@ paths: description: Integration Extract Value Created 400: description: Bad Integration Extract Value params - /project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/value/{extractvalue_id}: + /project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/values/{extractvalue_id}: parameters: - $ref: "#/parameters/project_id" - $ref: "#/parameters/integration_id" @@ -1637,7 +1637,7 @@ paths: responses: 204: description: integration extract value removed - /project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/matchers: + /project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers: parameters: - $ref: "#/parameters/project_id" - $ref: "#/parameters/integration_id" @@ -1668,7 +1668,7 @@ paths: description: Integration Matcher Created 400: description: Bad Integration Matcher params - /project/{project_id}/integrations/{integration_id}/extractor/{extractor_id}/matcher/{matcher_id}: + /project/{project_id}/integrations/{integration_id}/extractors/{extractor_id}/matchers/{matcher_id}: parameters: - $ref: "#/parameters/project_id" - $ref: "#/parameters/integration_id" diff --git a/api/router.go b/api/router.go index 98ba2056a..1e8c5fc94 100644 --- a/api/router.go +++ b/api/router.go @@ -286,7 +286,7 @@ func Route() *mux.Router { projectIntegrationsAPI.HandleFunc("/{integration_id}/extractors", projects.GetIntegrationExtractors).Methods("GET") projectIntegrationsAPI.HandleFunc("/{integration_id}/extractors", projects.AddIntegrationExtractor).Methods("POST") - projectIntegrationExtractorAPI := projectIntegrationsAPI.PathPrefix("/{integration_id}/extractor").Subrouter() + projectIntegrationExtractorAPI := projectIntegrationsAPI.PathPrefix("/{integration_id}/extractors").Subrouter() projectIntegrationExtractorAPI.Use(projects.IntegrationExtractorMiddleware) projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}", projects.GetIntegrationExtractor).Methods("GET", "HEAD") @@ -299,15 +299,15 @@ func Route() *mux.Router { projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/values", projects.GetIntegrationExtractValues).Methods("GET", "HEAD") projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/values", projects.AddIntegrationExtractValue).Methods("POST") - projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/matcher/{matcher_id}", projects.GetIntegrationMatcher).Methods("GET", "HEAD") - projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/matcher/{matcher_id}", projects.UpdateIntegrationMatcher).Methods("PUT") - projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/matcher/{matcher_id}", projects.DeleteIntegrationMatcher).Methods("DELETE") - projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/matcher/{matcher_id}/refs", projects.GetIntegrationMatcherRefs).Methods("GET", "HEAD") + projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/matchers/{matcher_id}", projects.GetIntegrationMatcher).Methods("GET", "HEAD") + projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/matchers/{matcher_id}", projects.UpdateIntegrationMatcher).Methods("PUT") + projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/matchers/{matcher_id}", projects.DeleteIntegrationMatcher).Methods("DELETE") + projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/matchers/{matcher_id}/refs", projects.GetIntegrationMatcherRefs).Methods("GET", "HEAD") - projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/value/{value_id}", projects.GetIntegrationExtractValue).Methods("GET", "HEAD") - projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/value/{value_id}", projects.UpdateIntegrationExtractValue).Methods("PUT") - projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/value/{value_id}", projects.DeleteIntegrationExtractValue).Methods("DELETE") - projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/value/{value_id}/refs", projects.GetIntegrationExtractValueRefs).Methods("GET") + projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/values/{value_id}", projects.GetIntegrationExtractValue).Methods("GET", "HEAD") + projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/values/{value_id}", projects.UpdateIntegrationExtractValue).Methods("PUT") + projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/values/{value_id}", projects.DeleteIntegrationExtractValue).Methods("DELETE") + projectIntegrationExtractorAPI.HandleFunc("/{extractor_id}/values/{value_id}/refs", projects.GetIntegrationExtractValueRefs).Methods("GET") if os.Getenv("DEBUG") == "1" { defer debugPrintRoutes(r) diff --git a/db/Integration.go b/db/Integration.go index a542fb6f9..f652935b8 100644 --- a/db/Integration.go +++ b/db/Integration.go @@ -8,7 +8,7 @@ import ( type IntegrationAuthMethod string const ( - IntegrationAuthNone = "none" + IntegrationAuthNone = "" IntegrationAuthToken = "token" IntegrationAuthHmac = "hmac" ) diff --git a/db/sql/integration.go b/db/sql/integration.go index 73987f988..5076a7614 100644 --- a/db/sql/integration.go +++ b/db/sql/integration.go @@ -19,7 +19,7 @@ func (d *SqlDb) CreateIntegration(integration db.Integration) (newIntegration db "id", "insert into project__integration "+ "(project_id, name, template_id, auth_method, auth_secret_id, auth_header) values "+ - "(?, ?, ?)", + "(?, ?, ?, ?, ?, ?)", integration.ProjectID, integration.Name, integration.TemplateID, @@ -319,7 +319,7 @@ func (d *SqlDb) UpdateIntegrationExtractValue(integrationExtractValue db.Integra } _, err = d.exec( - "update project__integration_extract_value set value_source=?, body_data_type=?, key=?, variable=?, name=? where id=?", + "update project__integration_extract_value set value_source=?, body_data_type=?, `key`=?, `variable`=?, `name`=? where `id`=?", integrationExtractValue.ValueSource, integrationExtractValue.BodyDataType, integrationExtractValue.Key, @@ -418,7 +418,7 @@ func (d *SqlDb) UpdateIntegrationMatcher(integrationMatcher db.IntegrationMatche } _, err = d.exec( - "update project__integration_matcher set match_type=?, method=?, body_data_type=?, key=?, value=?, name=? where id=?", + "update project__integration_matcher set match_type=?, `method`=?, body_data_type=?, `key`=?, `value`=?, `name`=? where `id`=?", integrationMatcher.MatchType, integrationMatcher.Method, integrationMatcher.BodyDataType, diff --git a/web/src/components/IntegrationExtractValueForm.vue b/web/src/components/IntegrationExtractValueForm.vue index 7145f04a7..e19349410 100644 --- a/web/src/components/IntegrationExtractValueForm.vue +++ b/web/src/components/IntegrationExtractValueForm.vue @@ -117,10 +117,10 @@ export default { }, methods: { getItemsUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}/values`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}/values`; }, getSingleItemUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}/value/${this.itemId}`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}/values/${this.itemId}`; }, }, }; diff --git a/web/src/components/IntegrationExtractorForm.vue b/web/src/components/IntegrationExtractorForm.vue index 7bad1720f..29331731d 100644 --- a/web/src/components/IntegrationExtractorForm.vue +++ b/web/src/components/IntegrationExtractorForm.vue @@ -36,7 +36,7 @@ export default { return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors`; }, getSingleItemUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.itemId}`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.itemId}`; }, }, }; diff --git a/web/src/components/IntegrationMatcherForm.vue b/web/src/components/IntegrationMatcherForm.vue index 99916a01a..cd16e7350 100644 --- a/web/src/components/IntegrationMatcherForm.vue +++ b/web/src/components/IntegrationMatcherForm.vue @@ -138,10 +138,10 @@ export default { }, methods: { getItemsUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}/matchers`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}/matchers`; }, getSingleItemUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}/matcher/${this.itemId}`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}/matchers/${this.itemId}`; }, }, }; diff --git a/web/src/views/project/IntegrationExtractValue.vue b/web/src/views/project/IntegrationExtractValue.vue index 97708225c..24d7eaa7e 100644 --- a/web/src/views/project/IntegrationExtractValue.vue +++ b/web/src/views/project/IntegrationExtractValue.vue @@ -158,10 +158,10 @@ export default { }]; }, getItemsUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}/values`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}/values`; }, getSingleItemUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}/value/${this.itemId}`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}/values/${this.itemId}`; }, getEventName() { return 'w-integration-extract-value'; diff --git a/web/src/views/project/IntegrationExtractorCrumb.vue b/web/src/views/project/IntegrationExtractorCrumb.vue index f3e5cf70a..55eb9000f 100644 --- a/web/src/views/project/IntegrationExtractorCrumb.vue +++ b/web/src/views/project/IntegrationExtractorCrumb.vue @@ -44,7 +44,7 @@ export default { this.extractor = (await axios({ method: 'get', - url: `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}`, + url: `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}`, responseType: 'json', })).data; }, @@ -80,7 +80,7 @@ export default { return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors`; }, getSingleItemUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}`; }, getEventName() { return 'w-integration-matcher'; diff --git a/web/src/views/project/IntegrationExtractors.vue b/web/src/views/project/IntegrationExtractors.vue index 6be331bf6..e1d66c7b2 100644 --- a/web/src/views/project/IntegrationExtractors.vue +++ b/web/src/views/project/IntegrationExtractors.vue @@ -154,7 +154,7 @@ export default { return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors`; }, getSingleItemUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.itemId}`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.itemId}`; }, getEventName() { return 'w-integration-extractor'; diff --git a/web/src/views/project/IntegrationMatcher.vue b/web/src/views/project/IntegrationMatcher.vue index 11107cab6..a75fce00a 100644 --- a/web/src/views/project/IntegrationMatcher.vue +++ b/web/src/views/project/IntegrationMatcher.vue @@ -164,10 +164,10 @@ export default { }]; }, getItemsUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}/matchers`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}/matchers`; }, getSingleItemUrl() { - return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractor/${this.extractorId}/matcher/${this.itemId}`; + return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors/${this.extractorId}/matchers/${this.itemId}`; }, getEventName() { return 'w-integration-matcher';