Skip to content

Commit

Permalink
Merge pull request #145 from akamai/release/v2.9.1
Browse files Browse the repository at this point in the history
Release/v2.9.1 (Feb. 7, 2022)
  • Loading branch information
robertolopezlopez authored Feb 7, 2022
2 parents 62ead42 + a48ab7a commit f2b7513
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 52 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# EDGEGRID GOLANG RELEASE NOTES

## 2.9.1 (Feb. 7, 2022)

#### FEATURES/ENHANCEMENTS:

* APPSEC
* Remove deprecation notes for individual policy protection methods

#### BUG FIXES:

* CLOUDLETS
* Fixed validation for ALB version DataCenter percent

## 2.9.0 (Jan. 24, 2022)

#### FEATURES/ENHANCEMENTS:
Expand Down
2 changes: 0 additions & 2 deletions pkg/appsec/api_constraints_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type (
// The APIConstraintsProtection interface supports retrieving and updating API request constraints
// for a configuration and policy.
//
// Deprecated: this interface will be removed in a future release. Use the PolicyProtections interface instead.
//
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#protections
APIConstraintsProtection interface {
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#getapirequestconstraints
Expand Down
20 changes: 9 additions & 11 deletions pkg/appsec/ip_geo_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type (
// The IPGeoProtection interface supports retrieving and modifying the protections for a policy,
// and whether each is enabled or disabled.
//
// Deprecated: this interface will be removed in a future release. Use the PolicyProtections interface instead.
//
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#protections
IPGeoProtection interface {
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#getprotections
Expand Down Expand Up @@ -64,7 +62,15 @@ type (
ApplySlowPostControls bool `json:"applySlowPostControls,omitempty"`
}

// UpdateIPGeoProtectionResponse is used to modify the IPGeo protection settings.
// UpdateIPGeoProtectionRequest is used to modify the IPGeo protection settings.
UpdateIPGeoProtectionRequest struct {
ConfigID int `json:"-"`
Version int `json:"-"`
PolicyID string `json:"-"`
ApplyNetworkLayerControls bool `json:"applyNetworkLayerControls"`
}

// UpdateIPGeoProtectionResponse is returned from a call to UpdateIPGeoProtection.
UpdateIPGeoProtectionResponse struct {
ApplyAPIConstraints bool `json:"applyApiConstraints"`
ApplyApplicationLayerControls bool `json:"applyApplicationLayerControls"`
Expand All @@ -74,14 +80,6 @@ type (
ApplyReputationControls bool `json:"applyReputationControls"`
ApplySlowPostControls bool `json:"applySlowPostControls"`
}

// UpdateIPGeoProtectionRequest is returned from a call to UpdateIPGeoProtection.
UpdateIPGeoProtectionRequest struct {
ConfigID int `json:"-"`
Version int `json:"-"`
PolicyID string `json:"-"`
ApplyNetworkLayerControls bool `json:"applyNetworkLayerControls"`
}
)

// Validate validates a GetIPGeoProtectionRequest.
Expand Down
2 changes: 0 additions & 2 deletions pkg/appsec/network_layer_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
type (
// The NetworkLayerProtection interface supports retrieving, modifying and removing network layer protection.
//
// Deprecated: this interface will be removed in a future release. Use the PolicyProtections interface instead.
//
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#protections
NetworkLayerProtection interface {
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#getprotections
Expand Down
2 changes: 0 additions & 2 deletions pkg/appsec/reputation_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type (
// The ReputationProtection interface supports retrieving, modifying and removing reputation
// protection.
//
// Deprecated: this interface will be removed in a future release. Use the PolicyProtections interface instead.
//
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#protections
ReputationProtection interface {
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#getprotections
Expand Down
2 changes: 0 additions & 2 deletions pkg/appsec/slowpost_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type (
// The SlowPostProtection interface supports retrieving and updating slow post protection
// for a configuration and policy.
//
// Deprecated: this interface will be removed in a future release. Use the PolicyProtections interface instead.
//
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#slowpostprotection
SlowPostProtection interface {
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#getprotections
Expand Down
2 changes: 0 additions & 2 deletions pkg/appsec/waf_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type (
// The WAFProtection interface supports retrieving, modifying and removing protections for a
// security policy.
//
// Deprecated: this interface will be removed in a future release. Use the PolicyProtections interface instead.
//
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#protections
WAFProtection interface {
// https://developer.akamai.com/api/cloud_security/application_security/v1.html#getprotections
Expand Down
14 changes: 7 additions & 7 deletions pkg/cloudlets/loadbalancer_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ type (
Continent string `json:"continent"`
Country string `json:"country"`
Hostname string `json:"hostname,omitempty"`
Latitude float64 `json:"latitude"`
Latitude *float64 `json:"latitude"`
LivenessHosts []string `json:"livenessHosts,omitempty"`
Longitude float64 `json:"longitude"`
Longitude *float64 `json:"longitude"`
OriginID string `json:"originId"`
Percent float64 `json:"percent"`
Percent *float64 `json:"percent"`
StateOrProvince *string `json:"stateOrProvince,omitempty"`
}

Expand Down Expand Up @@ -143,11 +143,11 @@ func (v DataCenter) Validate() error {
fmt.Sprintf("value '%s' is invalid. Must be one of: 'AF', 'AS', 'EU', 'NA', 'OC', 'OT' or 'SA'", (&v).Continent))),
"Country": validation.Validate(v.Country, validation.Required, validation.Length(2, 2)),
"Hostname": validation.Validate(v.Hostname, validation.Length(0, 256)),
"Latitude": validation.Validate(v.Latitude, validation.Required, validation.Min(-180.0), validation.Max(180.0)),
"LivenessHosts": validation.Validate(v.LivenessHosts, validation.Length(1, 0)), // max is 0, it means there is no upper bound for the length
"Longitude": validation.Validate(v.Longitude, validation.Required, validation.Min(-180.0), validation.Max(180.0)),
"Latitude": validation.Validate(v.Latitude, validation.NotNil, validation.Min(-180.0), validation.Max(180.0)),
"LivenessHosts": validation.Validate(v.LivenessHosts, validation.Required, validation.Length(1, 0)), // max is 0, it means there is no upper bound for the length
"Longitude": validation.Validate(v.Longitude, validation.NotNil, validation.Min(-180.0), validation.Max(180.0)),
"OriginID": validation.Validate(v.OriginID, validation.Required, validation.Length(1, 128)),
"Percent": validation.Validate(v.Percent, validation.Required, validation.Min(0.0), validation.Max(100.0)),
"Percent": validation.Validate(v.Percent, validation.NotNil, validation.Min(0.0), validation.Max(100.0)),
}.Filter()
}

Expand Down
111 changes: 87 additions & 24 deletions pkg/cloudlets/loadbalancer_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http/httptest"
"testing"

"github.com/akamai/AkamaiOPEN-edgegrid-golang/v2/pkg/cloudlets/tools"
validation "github.com/go-ozzo/ozzo-validation/v4"

"github.com/stretchr/testify/require"
Expand All @@ -35,12 +36,12 @@ func TestCreateLoadBalancerVersion(t *testing.T) {
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: 102.78108,
Longitude: -116.07064,
Latitude: tools.Float64Ptr(102.78108),
Longitude: tools.Float64Ptr(-116.07064),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: 100.0,
Percent: tools.Float64Ptr(100.0),
},
},
Deleted: false,
Expand Down Expand Up @@ -122,12 +123,12 @@ func TestCreateLoadBalancerVersion(t *testing.T) {
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: 102.78108,
Longitude: -116.07064,
Latitude: tools.Float64Ptr(102.78108),
Longitude: tools.Float64Ptr(-116.07064),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: 100.0,
Percent: tools.Float64Ptr(100.0),
},
},
Deleted: false,
Expand Down Expand Up @@ -264,6 +265,68 @@ func TestCreateLoadBalancerVersion(t *testing.T) {
}
}

func TestDataCenterValidate(t *testing.T) {
tests := map[string]struct {
DataCenter
withError error
}{
"valid data center": {
DataCenter: DataCenter{
CloudService: false,
Hostname: "clorigin.example.com",
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: tools.Float64Ptr(102.78108),
Longitude: tools.Float64Ptr(-116.07064),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: tools.Float64Ptr(100.0),
},
},
"longitude, latitude and percent can be 0": {
DataCenter: DataCenter{
CloudService: false,
Hostname: "clorigin.example.com",
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: tools.Float64Ptr(0),
Longitude: tools.Float64Ptr(0),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: tools.Float64Ptr(0),
},
},
"missing all required parameters error": {
DataCenter: DataCenter{},
withError: validation.Errors{
"Continent": validation.ErrRequired,
"Country": validation.ErrRequired,
"Latitude": validation.ErrNotNilRequired,
"LivenessHosts": validation.ErrRequired,
"Longitude": validation.ErrNotNilRequired,
"OriginID": validation.ErrRequired,
"Percent": validation.ErrNotNilRequired,
},
},
}

for name, test := range tests {
t.Run(name, func(t *testing.T) {
err := test.DataCenter.Validate()
if test.withError != nil {
require.Error(t, err)
assert.Equal(t, test.withError.Error(), err.Error(), "want: %s; got %s", test.withError, err)
return
}
require.NoError(t, err)
})
}
}

func TestLivenessSettingsValidate(t *testing.T) {
tests := map[string]struct {
LivenessSettings *LivenessSettings
Expand Down Expand Up @@ -366,12 +429,12 @@ func TestGetLoadBalancerVersion(t *testing.T) {
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: 102.78108,
Longitude: -116.07064,
Latitude: tools.Float64Ptr(102.78108),
Longitude: tools.Float64Ptr(-116.07064),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: 100.0,
Percent: tools.Float64Ptr(100.0),
},
},
Deleted: false,
Expand Down Expand Up @@ -461,12 +524,12 @@ func TestUpdateLoadBalancerVersion(t *testing.T) {
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: 102.78108,
Longitude: -116.07064,
Latitude: tools.Float64Ptr(102.78108),
Longitude: tools.Float64Ptr(-116.07064),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: 100.0,
Percent: tools.Float64Ptr(100.0),
},
},
Deleted: false,
Expand Down Expand Up @@ -539,12 +602,12 @@ func TestUpdateLoadBalancerVersion(t *testing.T) {
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: 102.78108,
Longitude: -116.07064,
Latitude: tools.Float64Ptr(102.78108),
Longitude: tools.Float64Ptr(-116.07064),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: 100.0,
Percent: tools.Float64Ptr(100.0),
},
},
Deleted: false,
Expand Down Expand Up @@ -579,12 +642,12 @@ func TestUpdateLoadBalancerVersion(t *testing.T) {
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: 102.78108,
Longitude: -116.07064,
Latitude: tools.Float64Ptr(102.78108),
Longitude: tools.Float64Ptr(-116.07064),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: 100.0,
Percent: tools.Float64Ptr(100.0),
},
},
Description: "Test load balancing configuration.",
Expand Down Expand Up @@ -739,12 +802,12 @@ func TestListLoadBalancerVersions(t *testing.T) {
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: 102.78108,
Longitude: -116.07064,
Latitude: tools.Float64Ptr(102.78108),
Longitude: tools.Float64Ptr(-116.07064),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: 100.0,
Percent: tools.Float64Ptr(100.0),
},
},
Deleted: false,
Expand All @@ -770,12 +833,12 @@ func TestListLoadBalancerVersions(t *testing.T) {
LivenessHosts: []string{
"clorigin3.www.example.com",
},
Latitude: 102.78108,
Longitude: -116.07064,
Latitude: tools.Float64Ptr(102.78108),
Longitude: tools.Float64Ptr(-116.07064),
Continent: "NA",
Country: "US",
OriginID: "clorigin3",
Percent: 100.0,
Percent: tools.Float64Ptr(100.0),
},
},
Deleted: false,
Expand Down

0 comments on commit f2b7513

Please sign in to comment.