From eb64054acdb086f4616b91996213fa33f36d3d21 Mon Sep 17 00:00:00 2001 From: "St. Lawrence, Zachary" Date: Thu, 21 Jan 2021 19:56:44 -0500 Subject: [PATCH 01/16] DEVOPSPROV-1390 fix for papi using comments and not comment for comments despite what documentation says --- pkg/papi/rule.go | 4 +++- pkg/papi/rule_test.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/papi/rule.go b/pkg/papi/rule.go index 81e9e930..c231bad0 100644 --- a/pkg/papi/rule.go +++ b/pkg/papi/rule.go @@ -47,7 +47,7 @@ type ( AdvancedOverride string `json:"advancedOverride,omitempty"` Behaviors []RuleBehavior `json:"behaviors,omitempty"` Children []Rules `json:"children,omitempty"` - Comment string `json:"comment,omitempty"` + Comments string `json:"comments,omitempty"` Criteria []RuleBehavior `json:"criteria,omitempty"` CriteriaLocked bool `json:"criteriaLocked,omitempty"` CustomOverride *RuleCustomOverride `json:"customOverride,omitempty"` @@ -90,6 +90,7 @@ type ( UpdateRulesRequest struct { PropertyID string PropertyVersion int + Comments string ContractID string DryRun bool GroupID string @@ -107,6 +108,7 @@ type ( UpdateRulesResponse struct { AccountID string `json:"accountId"` ContractID string `json:"contractId"` + Comments string `json:"comments,omitempty"` GroupID string `json:"groupId"` PropertyID string `json:"propertyId"` PropertyVersion int `json:"propertyVersion"` diff --git a/pkg/papi/rule_test.go b/pkg/papi/rule_test.go index 85bc1fee..51fd26bf 100644 --- a/pkg/papi/rule_test.go +++ b/pkg/papi/rule_test.go @@ -301,8 +301,10 @@ func TestPapi_UpdateRuleTree(t *testing.T) { DryRun: true, ValidateMode: "fast", ValidateRules: false, + Comments: "version comment", Rules: RulesUpdate{ Rules: Rules{ + Comments: "default comment", Behaviors: []RuleBehavior{ { Name: "origin", @@ -380,8 +382,10 @@ func TestPapi_UpdateRuleTree(t *testing.T) { "propertyVersion": 2, "etag": "etag", "ruleFormat": "v2020-09-16", + "comments": "version comment", "rules": { "name": "default", + "comments": "default comment", "criteria": [], "children": [ { @@ -468,7 +472,9 @@ func TestPapi_UpdateRuleTree(t *testing.T) { PropertyVersion: 2, Etag: "etag", RuleFormat: "v2020-09-16", + Comments: "version comment", Rules: Rules{ + Comments: "default comment", Behaviors: []RuleBehavior{ { Name: "origin", From 3ae47529b96f3653444c9a608fadfcfdacbdac12 Mon Sep 17 00:00:00 2001 From: "St. Lawrence, Zachary" Date: Thu, 21 Jan 2021 22:08:58 -0500 Subject: [PATCH 02/16] RuleUpdate now carries a comment block to convey property version note --- pkg/papi/rule.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/papi/rule.go b/pkg/papi/rule.go index c231bad0..034f90f5 100644 --- a/pkg/papi/rule.go +++ b/pkg/papi/rule.go @@ -40,6 +40,7 @@ type ( Etag string `json:"etag"` RuleFormat string `json:"ruleFormat"` Rules Rules `json:"rules"` + Comments string `json:"comments,omitempty"` } // Rules contains Rule object @@ -90,7 +91,6 @@ type ( UpdateRulesRequest struct { PropertyID string PropertyVersion int - Comments string ContractID string DryRun bool GroupID string @@ -101,7 +101,8 @@ type ( // RulesUpdate is a wrapper for the request body of PUT /rules request RulesUpdate struct { - Rules Rules `json:"rules"` + Comments string `json:"comments,omitempty"` + Rules Rules `json:"rules"` } // UpdateRulesResponse contains data returned by performing PUT /rules request @@ -168,7 +169,8 @@ func (r UpdateRulesRequest) Validate() error { // Validate validates RulesUpdate struct func (r RulesUpdate) Validate() error { return validation.Errors{ - "Rules": validation.Validate(r.Rules), + "Rules": validation.Validate(r.Rules), + "Comments": validation.Validate(r.Comments), }.Filter() } @@ -181,6 +183,7 @@ func (r Rules) Validate() error { "Criteria": validation.Validate(r.Criteria), "Children": validation.Validate(r.Children), "Variables": validation.Validate(r.Variables), + "Comments": validation.Validate(r.Comments), }.Filter() } From 2af00e8d4e183d7299c839f08a03899f90fb2023 Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Thu, 28 Jan 2021 12:50:16 -0500 Subject: [PATCH 03/16] bug/DEVOPSPROV-1392_papi_client_validation_for_rule_behavior_sp_papi_branch:removed validation for RuleBehavior --- pkg/papi/rule.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/papi/rule.go b/pkg/papi/rule.go index 32b82497..8f54274c 100644 --- a/pkg/papi/rule.go +++ b/pkg/papi/rule.go @@ -185,8 +185,8 @@ func (r Rules) Validate() error { // Validate validates RuleBehavior struct func (b RuleBehavior) Validate() error { return validation.Errors{ - "Name": validation.Validate(b.Name, validation.Required), - "Options": validation.Validate(b.Options, validation.Required), + "Name": validation.Validate(b.Name), + "Options": validation.Validate(b.Options), }.Filter() } From cbf1b92dfa1a2026173a852fc483fc94ae17bdae Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Thu, 28 Jan 2021 15:23:21 -0500 Subject: [PATCH 04/16] bug/DEVOPSPROV-1392_papi_client_validation_for_rule_behavior_sp_papi_branch:added unit test for empty name in rule behavior --- pkg/papi/rule_test.go | 294 ++++++++++++++++++++++-------------------- 1 file changed, 152 insertions(+), 142 deletions(-) diff --git a/pkg/papi/rule_test.go b/pkg/papi/rule_test.go index 14e904d5..e72f8e99 100644 --- a/pkg/papi/rule_test.go +++ b/pkg/papi/rule_test.go @@ -343,6 +343,158 @@ func TestPapi_GetRuleTree(t *testing.T) { }, }, }, + "200 OK nested with empty name": { + params: GetRuleTreeRequest{ + PropertyID: "propertyID", + PropertyVersion: 2, + ContractID: "contract", + GroupID: "group", + ValidateMode: "fast", + ValidateRules: false, + }, + responseStatus: http.StatusOK, + responseBody: ` +{ + "accountId": "accountID", + "contractId": "contract", + "groupId": "group", + "propertyId": "propertyID", + "propertyVersion": 2, + "etag": "etag", + "ruleFormat": "v2020-09-16", + "rules": { + "name": "default", + "children": [{ + "criteria": [], + "children": [{ + "name": "Compress Text Content", + "criteria": [{ + "name": "contentType", + "options": { + "matchOperator": "IS_ONE_OF", + "matchWildcard": true, + "matchCaseSensitive": false, + "values": [ + "text/html*", + "text/css*", + "application/x-javascript*" + ] + } + }], + "behaviors": [] + }], + "options": { + "is_secure": false + } + }], + "behaviors": [{ + "name": "origin", + "options": { + "httpPort": 80, + "enableTrueClientIp": false, + "compress": true, + "cacheKeyHostname": "ORIGIN_HOSTNAME", + "forwardHostHeader": "REQUEST_HOST_HEADER", + "hostname": "origin.test.com", + "originType": "CUSTOMER" + } + }, + { + "name": "cpCode", + "options": { + "value": { + "id": 12345, + "name": "my CP code" + } + } + } + ], + "customOverride": { + "overrideId": "cbo_12345", + "name": "mdc" + }, + "variables": [{ + "name": "VAR_NAME", + "value": "default value", + "description": "This is a sample Property Manager variable.", + "hidden": false, + "sensitive": false + }] + } +}`, + expectedPath: "/papi/v1/properties/propertyID/versions/2/rules?contractId=contract&groupId=group&validateMode=fast&validateRules=false", + expectedResponse: &GetRuleTreeResponse{ + Response: Response{ + AccountID: "accountID", + ContractID: "contract", + GroupID: "group", + }, + PropertyID: "propertyID", + PropertyVersion: 2, + Etag: "etag", + RuleFormat: "v2020-09-16", + Rules: Rules{ + Behaviors: []RuleBehavior{ + { + Name: "origin", + Options: RuleOptionsMap{ + "httpPort": float64(80), + "enableTrueClientIp": false, + "compress": true, + "cacheKeyHostname": "ORIGIN_HOSTNAME", + "forwardHostHeader": "REQUEST_HOST_HEADER", + "hostname": "origin.test.com", + "originType": "CUSTOMER", + }, + }, + { + Name: "cpCode", + Options: RuleOptionsMap{ + "value": map[string]interface{}{ + "id": float64(12345), + "name": "my CP code", + }, + }, + }, + }, + Children: []Rules{ + { + Criteria: []RuleBehavior{}, + Children: []Rules{ + { + Behaviors: []RuleBehavior{}, + Criteria: []RuleBehavior{ + { + Locked: "", + Name: "contentType", + Options: RuleOptionsMap{ + "matchOperator": "IS_ONE_OF", + "matchWildcard": true, + "matchCaseSensitive": false, + "values": []interface{}{"text/html*", "text/css*", "application/x-javascript*"}, + }, + }, + }, + Name: "Compress Text Content"}, + }}}, + Name: "default", + Options: RuleOptions{IsSecure: false}, + CustomOverride: &RuleCustomOverride{ + OverrideID: "cbo_12345", + Name: "mdc", + }, + Variables: []RuleVariable{ + { + Description: "This is a sample Property Manager variable.", + Hidden: false, + Name: "VAR_NAME", + Sensitive: false, + Value: "default value", + }, + }, + }, + }, + }, "500 Internal Server Error": { params: GetRuleTreeRequest{ PropertyID: "propertyID", @@ -1132,148 +1284,6 @@ func TestPapi_UpdateRuleTree(t *testing.T) { assert.Contains(t, err.Error(), "Name") }, }, - "empty name in behavior": { - params: UpdateRulesRequest{ - PropertyID: "propertyID", - PropertyVersion: 2, - ContractID: "contract", - GroupID: "group", - DryRun: true, - ValidateMode: "test", - ValidateRules: false, - Rules: RulesUpdate{ - Rules: Rules{ - Behaviors: []RuleBehavior{ - { - Name: "", - Options: RuleOptionsMap{ - "httpPort": float64(80), - "enableTrueClientIp": false, - "compress": true, - "cacheKeyHostname": "ORIGIN_HOSTNAME", - "forwardHostHeader": "REQUEST_HOST_HEADER", - "hostname": "origin.test.com", - "originType": "CUSTOMER", - }, - }, - }, - Children: []Rules{ - { - Behaviors: []RuleBehavior{ - { - Name: "gzipResponse", - Options: RuleOptionsMap{ - "behavior": "ALWAYS", - }, - }, - }, - Criteria: []RuleBehavior{ - { - Locked: "", - Name: "contentType", - Options: RuleOptionsMap{ - "matchOperator": "IS_ONE_OF", - "matchWildcard": true, - "matchCaseSensitive": false, - "values": []interface{}{"text/html*", "text/css*", "application/x-javascript*"}, - }, - }, - }, - Name: "Compress Text Content", - }, - }, - Criteria: []RuleBehavior{}, - Name: "default", - Options: RuleOptions{IsSecure: false}, - CustomOverride: &RuleCustomOverride{ - OverrideID: "cbo_12345", - Name: "mdc", - }, - Variables: []RuleVariable{ - { - Description: "This is a sample Property Manager variable.", - Hidden: false, - Name: "VAR_NAME", - Sensitive: false, - Value: "default value", - }, - }, - }, - }, - }, - withError: func(t *testing.T, err error) { - want := ErrStructValidation - assert.True(t, errors.Is(err, want), "want: %s; got: %s", want, err) - assert.Contains(t, err.Error(), "Name") - }, - }, - "empty options in behavior": { - params: UpdateRulesRequest{ - PropertyID: "propertyID", - PropertyVersion: 2, - ContractID: "contract", - GroupID: "group", - DryRun: true, - ValidateMode: "test", - ValidateRules: false, - Rules: RulesUpdate{ - Rules: Rules{ - Behaviors: []RuleBehavior{ - { - Name: "origin", - Options: nil, - }, - }, - Children: []Rules{ - { - Behaviors: []RuleBehavior{ - { - Name: "gzipResponse", - Options: RuleOptionsMap{ - "behavior": "ALWAYS", - }, - }, - }, - Criteria: []RuleBehavior{ - { - Locked: "", - Name: "contentType", - Options: RuleOptionsMap{ - "matchOperator": "IS_ONE_OF", - "matchWildcard": true, - "matchCaseSensitive": false, - "values": []interface{}{"text/html*", "text/css*", "application/x-javascript*"}, - }, - }, - }, - Name: "Compress Text Content", - }, - }, - Criteria: []RuleBehavior{}, - Name: "default", - Options: RuleOptions{IsSecure: false}, - CustomOverride: &RuleCustomOverride{ - OverrideID: "cbo_12345", - Name: "mdc", - }, - Variables: []RuleVariable{ - { - Description: "This is a sample Property Manager variable.", - Hidden: false, - Name: "VAR_NAME", - Sensitive: false, - Value: "default value", - }, - }, - }, - }, - }, - withError: func(t *testing.T, err error) { - want := ErrStructValidation - assert.True(t, errors.Is(err, want), "want: %s; got: %s", want, err) - assert.Contains(t, err.Error(), "Options") - }, - }, "empty name in custom override": { params: UpdateRulesRequest{ PropertyID: "propertyID", From fd8f8b6d982c9368b14d0f91cd8fde965df1fbf1 Mon Sep 17 00:00:00 2001 From: "Narra, Vinnuth" Date: Wed, 17 Feb 2021 10:54:45 -0500 Subject: [PATCH 05/16] Changelog and fix broken unit test --- CHANGELOG.md | 4 ++++ pkg/papi/rule_test.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index daca0dfe..7e56860c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # EDGEGRID GOLANG RELEASE NOTES +## 2.1.2 (TBD, 2021) +* PAPI - Fixed issue with version and rule comments being dropped +* PAPI - Fixed client side validation to allow certain PAPI errors to passthrough + ## 2.1.1 (Feb 3, 2021) * PAPI - Fixed validation on empty rule behaviors causing some properties with nested behaviors to fail diff --git a/pkg/papi/rule_test.go b/pkg/papi/rule_test.go index 1b6e54d6..0dd48bce 100644 --- a/pkg/papi/rule_test.go +++ b/pkg/papi/rule_test.go @@ -608,8 +608,8 @@ func TestPapi_UpdateRuleTree(t *testing.T) { DryRun: true, ValidateMode: "fast", ValidateRules: false, - Comments: "version comment", Rules: RulesUpdate{ + Comments: "version comment", Rules: Rules{ Comments: "default comment", Behaviors: []RuleBehavior{ From 57337973a7a18d3b47379936a7823a8c984bae73 Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Fri, 19 Feb 2021 16:00:40 -0500 Subject: [PATCH 06/16] feature/DEVOPSPROV-1422_add_new_request_body_for_put_hostnames:added cert prov type in request --- pkg/papi/propertyhostname.go | 1 + pkg/papi/propertyhostname_test.go | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/papi/propertyhostname.go b/pkg/papi/propertyhostname.go index 92bf5f2d..e47e52e2 100644 --- a/pkg/papi/propertyhostname.go +++ b/pkg/papi/propertyhostname.go @@ -53,6 +53,7 @@ type ( EdgeHostnameID string `json:"edgeHostnameId,omitempty"` CnameFrom string `json:"cnameFrom"` CnameTo string `json:"cnameTo,omitempty"` + CertProvisioningType string `json:"certProvisioningType"` } // UpdatePropertyVersionHostnamesRequest contains parameters required to update the set of hostname entries for a property version diff --git a/pkg/papi/propertyhostname_test.go b/pkg/papi/propertyhostname_test.go index 133ed212..c992f730 100644 --- a/pkg/papi/propertyhostname_test.go +++ b/pkg/papi/propertyhostname_test.go @@ -165,14 +165,16 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { ContractID: "ctr_1-1TJZH5", Hostnames: []Hostname{ { - CnameType: "EDGE_HOSTNAME", - CnameFrom: "m.example.com", - CnameTo: "example.com.edgesuite.net", + CnameType: "EDGE_HOSTNAME", + CnameFrom: "m.example.com", + CnameTo: "example.com.edgesuite.net", + CertProvisioningType: "CPS_MANAGED", }, { - CnameType: "EDGE_HOSTNAME", - EdgeHostnameID: "ehn_895824", - CnameFrom: "example3.com", + CnameType: "EDGE_HOSTNAME", + EdgeHostnameID: "ehn_895824", + CnameFrom: "example3.com", + CertProvisioningType: "CPS_MANAGED", }, }, }, @@ -192,12 +194,14 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { "edgeHostnameId": "ehn_895822", "cnameFrom": "example.com", "cnameTo": "example.com.edgesuite.net" + "certProvisioningType: "CPS_MANAGED" }, { "cnameType": "EDGE_HOSTNAME", "edgeHostnameId": "ehn_895833", "cnameFrom": "m.example.com", "cnameTo": "m.example.com.edgesuite.net" + "certProvisioningType: "CPS_MANAGED" } ] } @@ -218,12 +222,14 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { EdgeHostnameID: "ehn_895822", CnameFrom: "example.com", CnameTo: "example.com.edgesuite.net", + CertProvisioningType: "CPS_MANAGED", }, { CnameType: "EDGE_HOSTNAME", EdgeHostnameID: "ehn_895833", CnameFrom: "m.example.com", CnameTo: "m.example.com.edgesuite.net", + CertProvisioningType: "CPS_MANAGED", }, }, }, From 5d4d442718925e49ffc5b16f6f898340bd484e5f Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Mon, 22 Feb 2021 13:40:10 -0500 Subject: [PATCH 07/16] feature/DEVOPSPROV-1422_add_new_request_body_for_put_hostnames:fixed failing unit test, added schema check unit test --- pkg/papi/propertyhostname_test.go | 42 ++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/pkg/papi/propertyhostname_test.go b/pkg/papi/propertyhostname_test.go index c992f730..7e051f00 100644 --- a/pkg/papi/propertyhostname_test.go +++ b/pkg/papi/propertyhostname_test.go @@ -193,15 +193,15 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { "cnameType": "EDGE_HOSTNAME", "edgeHostnameId": "ehn_895822", "cnameFrom": "example.com", - "cnameTo": "example.com.edgesuite.net" - "certProvisioningType: "CPS_MANAGED" + "cnameTo": "example.com.edgesuite.net", + "certProvisioningType": "CPS_MANAGED" }, { "cnameType": "EDGE_HOSTNAME", "edgeHostnameId": "ehn_895833", "cnameFrom": "m.example.com", - "cnameTo": "m.example.com.edgesuite.net" - "certProvisioningType: "CPS_MANAGED" + "cnameTo": "m.example.com.edgesuite.net", + "certProvisioningType": "CPS_MANAGED" } ] } @@ -434,6 +434,40 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { }, }, }, + "400 Hostnames cert type is invalid": { + params: UpdatePropertyVersionHostnamesRequest{ + PropertyID: "prp_175780", + PropertyVersion: 3, + GroupID: "grp_15225", + ContractID: "ctr_1-1TJZH5", + Hostnames: []Hostname{ + { + CnameType: "EDGE_HOSTNAME", + CnameFrom: "m.example.com", + CnameTo: "example.com.edgesuite.net", + CertProvisioningType: "INVALID_TYPE", + }, + }, + }, + responseStatus: http.StatusBadRequest, + responseBody: ` +{ + "type": "json-schema-invalid", + "title": "Invalid schema", + "detail": "Error updating hostnames", + "status": 400 +}`, + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=false", + withError: func(t *testing.T, err error) { + want := &Error{ + Type: "json-schema-invalid", + Title: "Invalid schema", + Detail: "Error updating hostnames", + StatusCode: http.StatusBadRequest, + } + assert.True(t, errors.Is(err, want), "want: %s; got: %s", want, err) + }, + }, "500 internal server status error": { params: UpdatePropertyVersionHostnamesRequest{ PropertyID: "prp_175780", From d1a8520835fb3bca3b06b43bef1195b7fffb0ede Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Tue, 23 Feb 2021 09:57:13 -0500 Subject: [PATCH 08/16] feature/DEVOPSPROV-1422_add_new_request_body_for_put_hostnames:added papi error in unit test assert --- pkg/papi/propertyhostname_test.go | 28 ++++++++++++++-------------- pkg/papi/rule_test.go | 1 - 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pkg/papi/propertyhostname_test.go b/pkg/papi/propertyhostname_test.go index 7e051f00..2851eeb5 100644 --- a/pkg/papi/propertyhostname_test.go +++ b/pkg/papi/propertyhostname_test.go @@ -218,17 +218,17 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { Hostnames: HostnameResponseItems{ Items: []Hostname{ { - CnameType: "EDGE_HOSTNAME", - EdgeHostnameID: "ehn_895822", - CnameFrom: "example.com", - CnameTo: "example.com.edgesuite.net", + CnameType: "EDGE_HOSTNAME", + EdgeHostnameID: "ehn_895822", + CnameFrom: "example.com", + CnameTo: "example.com.edgesuite.net", CertProvisioningType: "CPS_MANAGED", }, { - CnameType: "EDGE_HOSTNAME", - EdgeHostnameID: "ehn_895833", - CnameFrom: "m.example.com", - CnameTo: "m.example.com.edgesuite.net", + CnameType: "EDGE_HOSTNAME", + EdgeHostnameID: "ehn_895833", + CnameFrom: "m.example.com", + CnameTo: "m.example.com.edgesuite.net", CertProvisioningType: "CPS_MANAGED", }, }, @@ -452,17 +452,17 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { responseStatus: http.StatusBadRequest, responseBody: ` { - "type": "json-schema-invalid", - "title": "Invalid schema", - "detail": "Error updating hostnames", + "type": "https://problems.luna.akamaiapis.net/papi/v0/json-mapping-error", + "title": "Unable to interpret JSON", + "detail": "Your input could not be interpreted as the expected JSON format. Cannot deserialize value of type com.akamai.platformtk.entities.HostnameRelation$CertProvisioningType from String INVALID_TYPE: not one of the values accepted for Enum class: [DEFAULT, CPS_MANAGED]\n at [Source: (org.apache.catalina.connector.CoyoteInputStream); line: 6, column: 41] (through reference chain: java.util.ArrayList[0]->com.akamai.luna.papi.model.HostnameItem[certProvisioningType]).", "status": 400 }`, expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=false", withError: func(t *testing.T, err error) { want := &Error{ - Type: "json-schema-invalid", - Title: "Invalid schema", - Detail: "Error updating hostnames", + Type: "https://problems.luna.akamaiapis.net/papi/v0/json-mapping-error", + Title: "Unable to interpret JSON", + Detail: "Your input could not be interpreted as the expected JSON format. Cannot deserialize value of type com.akamai.platformtk.entities.HostnameRelation$CertProvisioningType from String INVALID_TYPE: not one of the values accepted for Enum class: [DEFAULT, CPS_MANAGED]\n at [Source: (org.apache.catalina.connector.CoyoteInputStream); line: 6, column: 41] (through reference chain: java.util.ArrayList[0]->com.akamai.luna.papi.model.HostnameItem[certProvisioningType]).", StatusCode: http.StatusBadRequest, } assert.True(t, errors.Is(err, want), "want: %s; got: %s", want, err) diff --git a/pkg/papi/rule_test.go b/pkg/papi/rule_test.go index 1b6e54d6..34521977 100644 --- a/pkg/papi/rule_test.go +++ b/pkg/papi/rule_test.go @@ -608,7 +608,6 @@ func TestPapi_UpdateRuleTree(t *testing.T) { DryRun: true, ValidateMode: "fast", ValidateRules: false, - Comments: "version comment", Rules: RulesUpdate{ Rules: Rules{ Comments: "default comment", From b908f9a4d26be809127c464821ab410fecf686e3 Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Tue, 23 Feb 2021 15:55:13 -0500 Subject: [PATCH 09/16] added response body and unit tests --- pkg/papi/propertyhostname.go | 26 ++++++++-- pkg/papi/propertyhostname_test.go | 80 +++++++++++++++++++++++-------- 2 files changed, 82 insertions(+), 24 deletions(-) diff --git a/pkg/papi/propertyhostname.go b/pkg/papi/propertyhostname.go index e47e52e2..21e0adf4 100644 --- a/pkg/papi/propertyhostname.go +++ b/pkg/papi/propertyhostname.go @@ -29,6 +29,7 @@ type ( ContractID string GroupID string ValidateHostnames bool + IncludeCertStatus bool } // GetPropertyVersionHostnamesResponse contains all property version hostnames associated to the given parameters @@ -54,6 +55,22 @@ type ( CnameFrom string `json:"cnameFrom"` CnameTo string `json:"cnameTo,omitempty"` CertProvisioningType string `json:"certProvisioningType"` + CertStatus CertStatusItem `json:"certStatus,omitempty"` + } + + CertStatusItem struct { + ValidationCname ValidationCname `json:"validationCname,omitempty"` + Staging []StatusItem `json:"staging"` + Production []StatusItem `json:"production"` + } + + ValidationCname struct { + Hostname string `json:"hostname,omitempty"` + Target string `json:"target,omitempty"` + } + + StatusItem struct { + Status string `json:"status,omitempty"` } // UpdatePropertyVersionHostnamesRequest contains parameters required to update the set of hostname entries for a property version @@ -63,6 +80,7 @@ type ( ContractID string GroupID string ValidateHostnames bool + IncludeCertStatus bool Hostnames []Hostname } @@ -116,12 +134,13 @@ func (p *papi) GetPropertyVersionHostnames(ctx context.Context, params GetProper logger.Debug("GetPropertyVersionHostnames") getURL := fmt.Sprintf( - "/papi/v1/properties/%s/versions/%d/hostnames?contractId=%s&groupId=%s&validateHostnames=%t", + "/papi/v1/properties/%s/versions/%d/hostnames?contractId=%s&groupId=%s&validateHostnames=%t&includeCertStatus=%t", params.PropertyID, params.PropertyVersion, params.ContractID, params.GroupID, - params.ValidateHostnames) + params.ValidateHostnames, + params.IncludeCertStatus) req, err := http.NewRequestWithContext(ctx, http.MethodGet, getURL, nil) if err != nil { @@ -149,12 +168,13 @@ func (p *papi) UpdatePropertyVersionHostnames(ctx context.Context, params Update logger.Debug("UpdatePropertyVersionHostnames") putURL := fmt.Sprintf( - "/papi/v1/properties/%s/versions/%v/hostnames?contractId=%s&groupId=%s&validateHostnames=%t", + "/papi/v1/properties/%s/versions/%v/hostnames?contractId=%s&groupId=%s&validateHostnames=%t&includeCertStatus=%t", params.PropertyID, params.PropertyVersion, params.ContractID, params.GroupID, params.ValidateHostnames, + params.IncludeCertStatus, ) req, err := http.NewRequestWithContext(ctx, http.MethodPut, putURL, nil) diff --git a/pkg/papi/propertyhostname_test.go b/pkg/papi/propertyhostname_test.go index 2851eeb5..3ab8cb83 100644 --- a/pkg/papi/propertyhostname_test.go +++ b/pkg/papi/propertyhostname_test.go @@ -26,6 +26,7 @@ func TestPapi_GetPropertyVersionHostnames(t *testing.T) { PropertyVersion: 3, GroupID: "grp_15225", ContractID: "ctr_1-1TJZH5", + IncludeCertStatus:false, }, responseStatus: http.StatusOK, responseBody: ` @@ -55,7 +56,7 @@ func TestPapi_GetPropertyVersionHostnames(t *testing.T) { } `, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=false", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&includeCertStatus=false&validateHostnames=false", expectedResponse: &GetPropertyVersionHostnamesResponse{ AccountID: "act_1-1TJZFB", ContractID: "ctr_1-1TJZH5", @@ -114,7 +115,7 @@ func TestPapi_GetPropertyVersionHostnames(t *testing.T) { "detail": "Error fetching hostnames", "status": 500 }`, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=&groupId=&validateHostnames=false", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=&groupId=&includeCertStatus=false&validateHostnames=false", withError: func(t *testing.T, err error) { want := &Error{ Type: "internal_error", @@ -163,12 +164,13 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { PropertyVersion: 3, GroupID: "grp_15225", ContractID: "ctr_1-1TJZH5", + IncludeCertStatus: true, Hostnames: []Hostname{ { CnameType: "EDGE_HOSTNAME", CnameFrom: "m.example.com", - CnameTo: "example.com.edgesuite.net", - CertProvisioningType: "CPS_MANAGED", + CnameTo: "example.com.edgekey.net", + CertProvisioningType: "DEFAULT", }, { CnameType: "EDGE_HOSTNAME", @@ -192,14 +194,30 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { { "cnameType": "EDGE_HOSTNAME", "edgeHostnameId": "ehn_895822", - "cnameFrom": "example.com", - "cnameTo": "example.com.edgesuite.net", - "certProvisioningType": "CPS_MANAGED" + "cnameFrom": "m.example.com", + "cnameTo": "example.com.edgekey.net", + "certProvisioningType": "DEFAULT", + "certStatus": { + "validationCname": { + "hostname": "_acme-challenge.www.example.com", + "target": "{token}.www.example.com.akamai-domain.com" + }, + "staging": [ + { + "status": "NEEDS_VALIDATION" + } + ], + "production": [ + { + "status": "NEEDS_VALIDATION" + } + ] + } }, { "cnameType": "EDGE_HOSTNAME", "edgeHostnameId": "ehn_895833", - "cnameFrom": "m.example.com", + "cnameFrom": "example3.com", "cnameTo": "m.example.com.edgesuite.net", "certProvisioningType": "CPS_MANAGED" } @@ -207,7 +225,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { } } `, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=false", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&includeCertStatus=true&validateHostnames=false", expectedResponse: &UpdatePropertyVersionHostnamesResponse{ AccountID: "act_1-1TJZFB", ContractID: "ctr_1-1TJZH5", @@ -220,14 +238,27 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { { CnameType: "EDGE_HOSTNAME", EdgeHostnameID: "ehn_895822", - CnameFrom: "example.com", - CnameTo: "example.com.edgesuite.net", - CertProvisioningType: "CPS_MANAGED", - }, + CnameFrom: "m.example.com", + CnameTo: "example.com.edgekey.net", + CertProvisioningType: "DEFAULT", + CertStatus:CertStatusItem{ + ValidationCname: ValidationCname{ + Hostname: "_acme-challenge.www.example.com", + Target: "{token}.www.example.com.akamai-domain.com", + }, + Staging: []StatusItem{{Status:"NEEDS_VALIDATION"}, + + }, + Production: []StatusItem{{Status:"NEEDS_VALIDATION"}, + + }, + }, + + }, { CnameType: "EDGE_HOSTNAME", EdgeHostnameID: "ehn_895833", - CnameFrom: "m.example.com", + CnameFrom: "example3.com", CnameTo: "m.example.com.edgesuite.net", CertProvisioningType: "CPS_MANAGED", }, @@ -241,6 +272,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { PropertyVersion: 3, GroupID: "grp_15225", ContractID: "ctr_1-1TJZH5", + IncludeCertStatus: true, Hostnames: []Hostname{{}}, }, responseStatus: http.StatusOK, @@ -258,7 +290,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { } `, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=false", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&includeCertStatus=true&validateHostnames=false", expectedResponse: &UpdatePropertyVersionHostnamesResponse{ AccountID: "act_1-1TJZFB", ContractID: "ctr_1-1TJZH5", @@ -278,6 +310,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { GroupID: "grp_15225", ContractID: "ctr_1-1TJZH5", ValidateHostnames: true, + IncludeCertStatus:true, Hostnames: []Hostname{{}}, }, responseStatus: http.StatusOK, @@ -295,7 +328,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { } } `, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=true", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&includeCertStatus=true&validateHostnames=true", expectedResponse: &UpdatePropertyVersionHostnamesResponse{ AccountID: "act_1-1TJZFB", ContractID: "ctr_1-1TJZH5", @@ -336,6 +369,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { PropertyVersion: 3, GroupID: "grp_15225", ContractID: "ctr_1-1TJZH5", + IncludeCertStatus: true, }, responseStatus: http.StatusOK, responseBody: ` @@ -351,7 +385,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { "items": [] } }`, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=false", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&includeCertStatus=true&validateHostnames=false", expectedResponse: &UpdatePropertyVersionHostnamesResponse{ AccountID: "act_1-1TJZFB", ContractID: "ctr_1-1TJZH5", @@ -371,6 +405,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { GroupID: "grp_15225", ContractID: "ctr_1-1TJZH5", Hostnames: nil, + IncludeCertStatus:true, }, responseStatus: http.StatusOK, responseBody: ` @@ -386,7 +421,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { "items": [] } }`, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=false", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&includeCertStatus=true&validateHostnames=false", expectedResponse: &UpdatePropertyVersionHostnamesResponse{ AccountID: "act_1-1TJZFB", ContractID: "ctr_1-1TJZH5", @@ -405,6 +440,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { PropertyVersion: 3, GroupID: "grp_15225", ContractID: "ctr_1-1TJZH5", + IncludeCertStatus: true, Hostnames: []Hostname{}, }, responseStatus: http.StatusOK, @@ -421,7 +457,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { "items": [] } }`, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=false", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&includeCertStatus=true&validateHostnames=false", expectedResponse: &UpdatePropertyVersionHostnamesResponse{ AccountID: "act_1-1TJZFB", ContractID: "ctr_1-1TJZH5", @@ -440,6 +476,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { PropertyVersion: 3, GroupID: "grp_15225", ContractID: "ctr_1-1TJZH5", + IncludeCertStatus: true, Hostnames: []Hostname{ { CnameType: "EDGE_HOSTNAME", @@ -457,7 +494,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { "detail": "Your input could not be interpreted as the expected JSON format. Cannot deserialize value of type com.akamai.platformtk.entities.HostnameRelation$CertProvisioningType from String INVALID_TYPE: not one of the values accepted for Enum class: [DEFAULT, CPS_MANAGED]\n at [Source: (org.apache.catalina.connector.CoyoteInputStream); line: 6, column: 41] (through reference chain: java.util.ArrayList[0]->com.akamai.luna.papi.model.HostnameItem[certProvisioningType]).", "status": 400 }`, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&validateHostnames=false", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=ctr_1-1TJZH5&groupId=grp_15225&includeCertStatus=true&validateHostnames=false", withError: func(t *testing.T, err error) { want := &Error{ Type: "https://problems.luna.akamaiapis.net/papi/v0/json-mapping-error", @@ -473,6 +510,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { PropertyID: "prp_175780", PropertyVersion: 3, Hostnames: []Hostname{{}}, + IncludeCertStatus: true, }, responseStatus: http.StatusInternalServerError, responseBody: ` @@ -482,7 +520,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { "detail": "Error updating hostnames", "status": 500 }`, - expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=&groupId=&validateHostnames=false", + expectedPath: "/papi/v1/properties/prp_175780/versions/3/hostnames?contractId=&groupId=&includeCertStatus=true&validateHostnames=false", withError: func(t *testing.T, err error) { want := &Error{ Type: "internal_error", From f149765236dd22a93f7e968edace428967a33e9c Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Tue, 23 Feb 2021 15:57:57 -0500 Subject: [PATCH 10/16] formatted file --- pkg/papi/propertyhostname.go | 20 +++---- pkg/papi/propertyhostname_test.go | 87 +++++++++++++++---------------- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/pkg/papi/propertyhostname.go b/pkg/papi/propertyhostname.go index 21e0adf4..00f57f46 100644 --- a/pkg/papi/propertyhostname.go +++ b/pkg/papi/propertyhostname.go @@ -50,23 +50,23 @@ type ( // Hostname contains information about each of the HostnameResponseItems Hostname struct { - CnameType HostnameCnameType `json:"cnameType"` - EdgeHostnameID string `json:"edgeHostnameId,omitempty"` - CnameFrom string `json:"cnameFrom"` - CnameTo string `json:"cnameTo,omitempty"` - CertProvisioningType string `json:"certProvisioningType"` - CertStatus CertStatusItem `json:"certStatus,omitempty"` + CnameType HostnameCnameType `json:"cnameType"` + EdgeHostnameID string `json:"edgeHostnameId,omitempty"` + CnameFrom string `json:"cnameFrom"` + CnameTo string `json:"cnameTo,omitempty"` + CertProvisioningType string `json:"certProvisioningType"` + CertStatus CertStatusItem `json:"certStatus,omitempty"` } CertStatusItem struct { ValidationCname ValidationCname `json:"validationCname,omitempty"` - Staging []StatusItem `json:"staging"` - Production []StatusItem `json:"production"` + Staging []StatusItem `json:"staging"` + Production []StatusItem `json:"production"` } ValidationCname struct { - Hostname string `json:"hostname,omitempty"` - Target string `json:"target,omitempty"` + Hostname string `json:"hostname,omitempty"` + Target string `json:"target,omitempty"` } StatusItem struct { diff --git a/pkg/papi/propertyhostname_test.go b/pkg/papi/propertyhostname_test.go index 3ab8cb83..f1422091 100644 --- a/pkg/papi/propertyhostname_test.go +++ b/pkg/papi/propertyhostname_test.go @@ -22,11 +22,11 @@ func TestPapi_GetPropertyVersionHostnames(t *testing.T) { }{ "200 OK": { params: GetPropertyVersionHostnamesRequest{ - PropertyID: "prp_175780", - PropertyVersion: 3, - GroupID: "grp_15225", - ContractID: "ctr_1-1TJZH5", - IncludeCertStatus:false, + PropertyID: "prp_175780", + PropertyVersion: 3, + GroupID: "grp_15225", + ContractID: "ctr_1-1TJZH5", + IncludeCertStatus: false, }, responseStatus: http.StatusOK, responseBody: ` @@ -160,10 +160,10 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { }{ "200 OK": { params: UpdatePropertyVersionHostnamesRequest{ - PropertyID: "prp_175780", - PropertyVersion: 3, - GroupID: "grp_15225", - ContractID: "ctr_1-1TJZH5", + PropertyID: "prp_175780", + PropertyVersion: 3, + GroupID: "grp_15225", + ContractID: "ctr_1-1TJZH5", IncludeCertStatus: true, Hostnames: []Hostname{ { @@ -241,20 +241,15 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { CnameFrom: "m.example.com", CnameTo: "example.com.edgekey.net", CertProvisioningType: "DEFAULT", - CertStatus:CertStatusItem{ + CertStatus: CertStatusItem{ ValidationCname: ValidationCname{ Hostname: "_acme-challenge.www.example.com", Target: "{token}.www.example.com.akamai-domain.com", }, - Staging: []StatusItem{{Status:"NEEDS_VALIDATION"}, - - }, - Production: []StatusItem{{Status:"NEEDS_VALIDATION"}, - - }, + Staging: []StatusItem{{Status: "NEEDS_VALIDATION"}}, + Production: []StatusItem{{Status: "NEEDS_VALIDATION"}}, }, - - }, + }, { CnameType: "EDGE_HOSTNAME", EdgeHostnameID: "ehn_895833", @@ -268,12 +263,12 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { }, "200 empty hostnames": { params: UpdatePropertyVersionHostnamesRequest{ - PropertyID: "prp_175780", - PropertyVersion: 3, - GroupID: "grp_15225", - ContractID: "ctr_1-1TJZH5", + PropertyID: "prp_175780", + PropertyVersion: 3, + GroupID: "grp_15225", + ContractID: "ctr_1-1TJZH5", IncludeCertStatus: true, - Hostnames: []Hostname{{}}, + Hostnames: []Hostname{{}}, }, responseStatus: http.StatusOK, responseBody: ` @@ -310,7 +305,7 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { GroupID: "grp_15225", ContractID: "ctr_1-1TJZH5", ValidateHostnames: true, - IncludeCertStatus:true, + IncludeCertStatus: true, Hostnames: []Hostname{{}}, }, responseStatus: http.StatusOK, @@ -365,10 +360,10 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { }, "200 Hostnames missing": { params: UpdatePropertyVersionHostnamesRequest{ - PropertyID: "prp_175780", - PropertyVersion: 3, - GroupID: "grp_15225", - ContractID: "ctr_1-1TJZH5", + PropertyID: "prp_175780", + PropertyVersion: 3, + GroupID: "grp_15225", + ContractID: "ctr_1-1TJZH5", IncludeCertStatus: true, }, responseStatus: http.StatusOK, @@ -400,12 +395,12 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { }, "200 Hostnames items missing": { params: UpdatePropertyVersionHostnamesRequest{ - PropertyID: "prp_175780", - PropertyVersion: 3, - GroupID: "grp_15225", - ContractID: "ctr_1-1TJZH5", - Hostnames: nil, - IncludeCertStatus:true, + PropertyID: "prp_175780", + PropertyVersion: 3, + GroupID: "grp_15225", + ContractID: "ctr_1-1TJZH5", + Hostnames: nil, + IncludeCertStatus: true, }, responseStatus: http.StatusOK, responseBody: ` @@ -436,12 +431,12 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { }, "200 Hostnames items empty": { params: UpdatePropertyVersionHostnamesRequest{ - PropertyID: "prp_175780", - PropertyVersion: 3, - GroupID: "grp_15225", - ContractID: "ctr_1-1TJZH5", + PropertyID: "prp_175780", + PropertyVersion: 3, + GroupID: "grp_15225", + ContractID: "ctr_1-1TJZH5", IncludeCertStatus: true, - Hostnames: []Hostname{}, + Hostnames: []Hostname{}, }, responseStatus: http.StatusOK, responseBody: ` @@ -472,10 +467,10 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { }, "400 Hostnames cert type is invalid": { params: UpdatePropertyVersionHostnamesRequest{ - PropertyID: "prp_175780", - PropertyVersion: 3, - GroupID: "grp_15225", - ContractID: "ctr_1-1TJZH5", + PropertyID: "prp_175780", + PropertyVersion: 3, + GroupID: "grp_15225", + ContractID: "ctr_1-1TJZH5", IncludeCertStatus: true, Hostnames: []Hostname{ { @@ -507,9 +502,9 @@ func TestPapi_UpdatePropertyVersionHostnames(t *testing.T) { }, "500 internal server status error": { params: UpdatePropertyVersionHostnamesRequest{ - PropertyID: "prp_175780", - PropertyVersion: 3, - Hostnames: []Hostname{{}}, + PropertyID: "prp_175780", + PropertyVersion: 3, + Hostnames: []Hostname{{}}, IncludeCertStatus: true, }, responseStatus: http.StatusInternalServerError, From a7f82b21b45d7e3af50ace451b0d77488dab0728 Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Tue, 23 Feb 2021 16:01:35 -0500 Subject: [PATCH 11/16] added omitempty for read only fields --- pkg/papi/propertyhostname.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/papi/propertyhostname.go b/pkg/papi/propertyhostname.go index 00f57f46..ff0330c9 100644 --- a/pkg/papi/propertyhostname.go +++ b/pkg/papi/propertyhostname.go @@ -60,8 +60,8 @@ type ( CertStatusItem struct { ValidationCname ValidationCname `json:"validationCname,omitempty"` - Staging []StatusItem `json:"staging"` - Production []StatusItem `json:"production"` + Staging []StatusItem `json:"staging,omitempty"` + Production []StatusItem `json:"production,omitempty"` } ValidationCname struct { From 616fe67714658f569f4216221d57ae3d854fabaa Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Fri, 26 Feb 2021 13:22:12 -0500 Subject: [PATCH 12/16] bug/DEVOPSPROV-1522_add_templateuuid_to_rule_behaviour_struct:added template uuid and unit test --- pkg/papi/rule.go | 1 + pkg/papi/rule_test.go | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/pkg/papi/rule.go b/pkg/papi/rule.go index dd6fce03..02b3f2a6 100644 --- a/pkg/papi/rule.go +++ b/pkg/papi/rule.go @@ -65,6 +65,7 @@ type ( Name string `json:"name"` Options RuleOptionsMap `json:"options"` UUID string `json:"uuid,omitempty"` + TemplateUuid string `json:"templateUuid,omitempty"` } // RuleCustomOverride represents customOverride field from Rule resource diff --git a/pkg/papi/rule_test.go b/pkg/papi/rule_test.go index 0dd48bce..aa965ae4 100644 --- a/pkg/papi/rule_test.go +++ b/pkg/papi/rule_test.go @@ -744,6 +744,17 @@ func TestPapi_UpdateRuleTree(t *testing.T) { "name": "my CP code" } } + }, + { + "name": "matchAdvanced", + "options": { + "value": { + "id": 12345, + "name": "my advanced match" + } + }, + "uuid": "fd6a63bc-120a-4891-a5f2-c479765d5553", + "templateUuid": "bedbac99-4ce1-43a3-96cc-b84c8cd30176" } ], "customOverride": { @@ -804,6 +815,17 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, }, }, + { + Name: "matchAdvanced", + Options: RuleOptionsMap{ + "value": map[string]interface{}{ + "id": float64(12345), + "name": "my advanced match", + }, + }, + UUID: "fd6a63bc-120a-4891-a5f2-c479765d5553", + TemplateUuid: "bedbac99-4ce1-43a3-96cc-b84c8cd30176", + }, }, Children: []Rules{ { From 16350ed35063733f429366c59678161fe74f87ee Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Fri, 26 Feb 2021 14:30:02 -0500 Subject: [PATCH 13/16] bug/DEVOPSPROV-1522_add_templateuuid_to_rule_behaviour_struct -> bug/DEVOPSPROV-1522_add_templateuuid_to_rule_behaviour_struct:added template link --- pkg/papi/rule.go | 1 + pkg/papi/rule_test.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/papi/rule.go b/pkg/papi/rule.go index 02b3f2a6..ce432db4 100644 --- a/pkg/papi/rule.go +++ b/pkg/papi/rule.go @@ -66,6 +66,7 @@ type ( Options RuleOptionsMap `json:"options"` UUID string `json:"uuid,omitempty"` TemplateUuid string `json:"templateUuid,omitempty"` + TemplateLink string `json:"templateLink,omitempty"` } // RuleCustomOverride represents customOverride field from Rule resource diff --git a/pkg/papi/rule_test.go b/pkg/papi/rule_test.go index aa965ae4..0f07009f 100644 --- a/pkg/papi/rule_test.go +++ b/pkg/papi/rule_test.go @@ -754,7 +754,8 @@ func TestPapi_UpdateRuleTree(t *testing.T) { } }, "uuid": "fd6a63bc-120a-4891-a5f2-c479765d5553", - "templateUuid": "bedbac99-4ce1-43a3-96cc-b84c8cd30176" + "templateUuid": "bedbac99-4ce1-43a3-96cc-b84c8cd30176", + "templateLink": "/platformtoolkit/service/ruletemplate/30582260/1?accountId=1-1TJZFB&gid=61726&ck=16.3.1.1" } ], "customOverride": { @@ -825,6 +826,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, UUID: "fd6a63bc-120a-4891-a5f2-c479765d5553", TemplateUuid: "bedbac99-4ce1-43a3-96cc-b84c8cd30176", + TemplateLink: "/platformtoolkit/service/ruletemplate/30582260/1?accountId=1-1TJZFB&gid=61726&ck=16.3.1.1", }, }, Children: []Rules{ From 726e3e83c620d031aa45ec9b375512082fabc83f Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Fri, 26 Feb 2021 16:20:24 -0500 Subject: [PATCH 14/16] bug/DEVOPSPROV-1522_add_templateuuid_to_rule_behaviour_struct:added template link and uuid inside rule --- pkg/papi/rule.go | 3 ++- pkg/papi/rule_test.go | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/papi/rule.go b/pkg/papi/rule.go index ce432db4..9732d00a 100644 --- a/pkg/papi/rule.go +++ b/pkg/papi/rule.go @@ -55,6 +55,8 @@ type ( Name string `json:"name"` Options RuleOptions `json:"options,omitempty"` UUID string `json:"uuid,omitempty"` + TemplateUuid string `json:"templateUuid,omitempty"` + TemplateLink string `json:"templateLink,omitempty"` Variables []RuleVariable `json:"variables,omitempty"` CriteriaMustSatisfy RuleCriteriaMustSatisfy `json:"criteriaMustSatisfy,omitempty"` } @@ -66,7 +68,6 @@ type ( Options RuleOptionsMap `json:"options"` UUID string `json:"uuid,omitempty"` TemplateUuid string `json:"templateUuid,omitempty"` - TemplateLink string `json:"templateLink,omitempty"` } // RuleCustomOverride represents customOverride field from Rule resource diff --git a/pkg/papi/rule_test.go b/pkg/papi/rule_test.go index 0f07009f..1489cc5a 100644 --- a/pkg/papi/rule_test.go +++ b/pkg/papi/rule_test.go @@ -754,14 +754,15 @@ func TestPapi_UpdateRuleTree(t *testing.T) { } }, "uuid": "fd6a63bc-120a-4891-a5f2-c479765d5553", - "templateUuid": "bedbac99-4ce1-43a3-96cc-b84c8cd30176", - "templateLink": "/platformtoolkit/service/ruletemplate/30582260/1?accountId=1-1TJZFB&gid=61726&ck=16.3.1.1" + "templateUuid": "bedbac99-4ce1-43a3-96cc-b84c8cd30176" } ], "customOverride": { "overrideId": "cbo_12345", "name": "mdc" }, + "templateUuid": "bedbac99-4ce1-43a3-96cc-b84c8cd30176", + "templateLink": "/platformtoolkit/service/ruletemplate/30582260/1?accountId=1-1TJZFB&gid=61726&ck=16.3.1.1", "variables": [ { "name": "VAR_NAME", @@ -826,7 +827,6 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, UUID: "fd6a63bc-120a-4891-a5f2-c479765d5553", TemplateUuid: "bedbac99-4ce1-43a3-96cc-b84c8cd30176", - TemplateLink: "/platformtoolkit/service/ruletemplate/30582260/1?accountId=1-1TJZFB&gid=61726&ck=16.3.1.1", }, }, Children: []Rules{ @@ -861,6 +861,8 @@ func TestPapi_UpdateRuleTree(t *testing.T) { OverrideID: "cbo_12345", Name: "mdc", }, + TemplateUuid: "bedbac99-4ce1-43a3-96cc-b84c8cd30176", + TemplateLink: "/platformtoolkit/service/ruletemplate/30582260/1?accountId=1-1TJZFB&gid=61726&ck=16.3.1.1", Variables: []RuleVariable{ { Description: "This is a sample Property Manager variable.", From 7b1ffe776daa0c36ebfd8b66dd02f061af7d144b Mon Sep 17 00:00:00 2001 From: Neha Ghate Date: Mon, 1 Mar 2021 11:56:25 -0500 Subject: [PATCH 15/16] bug/DEVOPSPROV-1522_add_templateuuid_to_rule_behaviour_struct:changed locked to be a boolean --- pkg/papi/rule.go | 2 +- pkg/papi/rule_test.go | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/pkg/papi/rule.go b/pkg/papi/rule.go index 9732d00a..5f988fbc 100644 --- a/pkg/papi/rule.go +++ b/pkg/papi/rule.go @@ -63,7 +63,7 @@ type ( // RuleBehavior contains data for both rule behaviors and rule criteria RuleBehavior struct { - Locked string `json:"locked,omitempty"` + Locked bool `json:"locked,omitempty"` Name string `json:"name"` Options RuleOptionsMap `json:"options"` UUID string `json:"uuid,omitempty"` diff --git a/pkg/papi/rule_test.go b/pkg/papi/rule_test.go index 1489cc5a..afcf78df 100644 --- a/pkg/papi/rule_test.go +++ b/pkg/papi/rule_test.go @@ -156,7 +156,7 @@ func TestPapi_GetRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -313,7 +313,7 @@ func TestPapi_GetRuleTree(t *testing.T) { Behaviors: []RuleBehavior{}, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -465,7 +465,7 @@ func TestPapi_GetRuleTree(t *testing.T) { Behaviors: []RuleBehavior{}, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -647,7 +647,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -753,6 +753,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { "name": "my advanced match" } }, + "locked": true, "uuid": "fd6a63bc-120a-4891-a5f2-c479765d5553", "templateUuid": "bedbac99-4ce1-43a3-96cc-b84c8cd30176" } @@ -825,6 +826,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { "name": "my advanced match", }, }, + Locked: true, UUID: "fd6a63bc-120a-4891-a5f2-c479765d5553", TemplateUuid: "bedbac99-4ce1-43a3-96cc-b84c8cd30176", }, @@ -841,7 +843,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -930,7 +932,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -1027,7 +1029,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -1110,7 +1112,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -1194,7 +1196,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -1278,7 +1280,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -1362,7 +1364,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -1446,7 +1448,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", @@ -1530,7 +1532,7 @@ func TestPapi_UpdateRuleTree(t *testing.T) { }, Criteria: []RuleBehavior{ { - Locked: "", + Locked: false, Name: "contentType", Options: RuleOptionsMap{ "matchOperator": "IS_ONE_OF", From bcfd7c787bda9ac308da9cd23ad042a9e5a9e75d Mon Sep 17 00:00:00 2001 From: "Narra, Vinnuth" Date: Fri, 19 Mar 2021 08:39:24 -0400 Subject: [PATCH 16/16] 2.4.0 changelog update --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 781afcc8..5d4e3dce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # EDGEGRID GOLANG RELEASE NOTES +## 2.4.0 (Mar 29, 2021) PAPI - Secure by default +*PAPI + * Support to provision default certs as part of hostnames request + * New cert status object in hostnames response if it exists + ## 2.3.0 (Mar 15, 2021) Network Lists Add support for the following operations in the Network Lists API v2: