From 0d716585496133a6267dcc8570cb9003626d2cb3 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Mon, 4 Nov 2024 11:28:50 -0500 Subject: [PATCH] breaking(product_enablement): Remove support for NGWAF product. Enablement of NGWAF was added recently but never worked, because enablement of the product requires configuration information to be included and that was overlooked. Product configuration will be a significant addition. While this is technically a breaking change, since it never worked, and was only used by the Fastly CLI and the Fastly Terraform provider (both of which will also have NGWAF product enablement removed), there is no need for a major version number increase. Support for this product will be re-added in a future version where 'product configuration' is also added. --- .../product_enablement/disable_ngwaf.yaml | 43 ------- .../product_enablement/enable_ngwaf.yaml | 52 -------- .../get-disabled_ngwaf.yaml | 42 ------ .../product_enablement/get_ngwaf.yaml | 42 ------ fastly/product_enablement.go | 3 - fastly/product_enablement_ngwaf_test.go | 121 ------------------ 6 files changed, 303 deletions(-) delete mode 100644 fastly/fixtures/product_enablement/disable_ngwaf.yaml delete mode 100644 fastly/fixtures/product_enablement/enable_ngwaf.yaml delete mode 100644 fastly/fixtures/product_enablement/get-disabled_ngwaf.yaml delete mode 100644 fastly/fixtures/product_enablement/get_ngwaf.yaml delete mode 100644 fastly/product_enablement_ngwaf_test.go diff --git a/fastly/fixtures/product_enablement/disable_ngwaf.yaml b/fastly/fixtures/product_enablement/disable_ngwaf.yaml deleted file mode 100644 index b43213684..000000000 --- a/fastly/fixtures/product_enablement/disable_ngwaf.yaml +++ /dev/null @@ -1,43 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - User-Agent: - - FastlyGo/7.2.0 (+github.com/fastly/go-fastly; go1.18.5) - url: https://api.fastly.com/enabled-products/ngwaf/services/7i6HN3TK9wS159v2gPAZ8A - method: DELETE - response: - body: "" - headers: - Accept-Ranges: - - bytes - Content-Type: - - application/json - Date: - - Fri, 17 Feb 2023 15:08:02 GMT - Fastly-Ratelimit-Remaining: - - "998" - Fastly-Ratelimit-Reset: - - "1676649600" - Status: - - 204 No Content - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Accept-Encoding - Via: - - 1.1 varnish, 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Served-By: - - cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7368-LHR - X-Timer: - - S1676646482.821386,VS0,VE327 - status: 204 No Content - code: 204 - duration: "" diff --git a/fastly/fixtures/product_enablement/enable_ngwaf.yaml b/fastly/fixtures/product_enablement/enable_ngwaf.yaml deleted file mode 100644 index 736e96e55..000000000 --- a/fastly/fixtures/product_enablement/enable_ngwaf.yaml +++ /dev/null @@ -1,52 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: ProductID=ngwaf&ServiceID=7i6HN3TK9wS159v2gPAZ8A - form: - ProductID: - - ngwaf - ServiceID: - - 7i6HN3TK9wS159v2gPAZ8A - headers: - Content-Type: - - application/x-www-form-urlencoded - User-Agent: - - FastlyGo/7.2.0 (+github.com/fastly/go-fastly; go1.18.5) - url: https://api.fastly.com/enabled-products/ngwaf/services/7i6HN3TK9wS159v2gPAZ8A - method: PUT - response: - body: | - {"product":{"id":"ngwaf","object":"product"},"service":{"id":"7i6HN3TK9wS159v2gPAZ8A","object":"service"},"_links":{"self":"/enabled-products/ngwaf/services/7i6HN3TK9wS159v2gPAZ8A"}} - headers: - Accept-Ranges: - - bytes - Content-Length: - - "209" - Content-Type: - - application/json - Date: - - Fri, 17 Feb 2023 15:08:01 GMT - Fastly-Ratelimit-Remaining: - - "999" - Fastly-Ratelimit-Reset: - - "1676649600" - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Accept-Encoding - Via: - - 1.1 varnish, 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Served-By: - - cache-control-cp-aws-us-east-2-prod-1-CONTROL-AWS-UE2, cache-lhr7368-LHR - X-Timer: - - S1676646481.093534,VS0,VE491 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/fixtures/product_enablement/get-disabled_ngwaf.yaml b/fastly/fixtures/product_enablement/get-disabled_ngwaf.yaml deleted file mode 100644 index 76c330a28..000000000 --- a/fastly/fixtures/product_enablement/get-disabled_ngwaf.yaml +++ /dev/null @@ -1,42 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - User-Agent: - - FastlyGo/7.2.0 (+github.com/fastly/go-fastly; go1.18.5) - url: https://api.fastly.com/enabled-products/ngwaf/services/7i6HN3TK9wS159v2gPAZ8A - method: GET - response: - body: | - {"type":"","title":"no product on service","status":400,"errors":null,"detail":""} - headers: - Accept-Ranges: - - bytes - Content-Length: - - "83" - Content-Type: - - application/json - Date: - - Fri, 17 Feb 2023 15:08:02 GMT - Status: - - 400 Bad Request - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Accept-Encoding - Via: - - 1.1 varnish, 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Served-By: - - cache-control-cp-aws-us-east-2-prod-1-CONTROL-AWS-UE2, cache-lhr7368-LHR - X-Timer: - - S1676646482.180149,VS0,VE194 - status: 400 Bad Request - code: 400 - duration: "" diff --git a/fastly/fixtures/product_enablement/get_ngwaf.yaml b/fastly/fixtures/product_enablement/get_ngwaf.yaml deleted file mode 100644 index 6559a5fde..000000000 --- a/fastly/fixtures/product_enablement/get_ngwaf.yaml +++ /dev/null @@ -1,42 +0,0 @@ ---- -version: 1 -interactions: -- request: - body: "" - form: {} - headers: - User-Agent: - - FastlyGo/7.2.0 (+github.com/fastly/go-fastly; go1.18.5) - url: https://api.fastly.com/enabled-products/ngwaf/services/7i6HN3TK9wS159v2gPAZ8A - method: GET - response: - body: | - {"product":{"id":"ngwaf","object":"product"},"service":{"id":"7i6HN3TK9wS159v2gPAZ8A","object":"service"},"_links":{"self":"/enabled-products/ngwaf/services/7i6HN3TK9wS159v2gPAZ8A"}} - headers: - Accept-Ranges: - - bytes - Content-Length: - - "209" - Content-Type: - - application/json - Date: - - Fri, 17 Feb 2023 15:08:01 GMT - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - Vary: - - Accept-Encoding - Via: - - 1.1 varnish, 1.1 varnish - X-Cache: - - MISS, MISS - X-Cache-Hits: - - 0, 0 - X-Served-By: - - cache-control-cp-aws-us-east-2-prod-2-CONTROL-AWS-UE2, cache-lhr7368-LHR - X-Timer: - - S1676646482.611546,VS0,VE190 - status: 200 OK - code: 200 - duration: "" diff --git a/fastly/product_enablement.go b/fastly/product_enablement.go index d767f0fb6..1c2934d2b 100644 --- a/fastly/product_enablement.go +++ b/fastly/product_enablement.go @@ -30,8 +30,6 @@ func (p Product) String() string { return "image_optimizer" case ProductLogExplorerInsights: return "log_explorer_insights" - case ProductNGWAF: - return "ngwaf" case ProductOriginInspector: return "origin_inspector" case ProductWebSockets: @@ -50,7 +48,6 @@ const ( ProductFanout ProductImageOptimizer ProductLogExplorerInsights - ProductNGWAF ProductOriginInspector ProductWebSockets ) diff --git a/fastly/product_enablement_ngwaf_test.go b/fastly/product_enablement_ngwaf_test.go deleted file mode 100644 index a12b4e8ad..000000000 --- a/fastly/product_enablement_ngwaf_test.go +++ /dev/null @@ -1,121 +0,0 @@ -package fastly - -import ( - "testing" -) - -func TestClient_ProductEnablement_ngwaf(t *testing.T) { - t.Parallel() - - var err error - - // Enable Product - var pe *ProductEnablement - record(t, "product_enablement/enable_ngwaf", func(c *Client) { - pe, err = c.EnableProduct(&ProductEnablementInput{ - ProductID: ProductNGWAF, - ServiceID: testServiceID, - }) - }) - if err != nil { - t.Fatal(err) - } - - if *pe.Product.ProductID != ProductNGWAF.String() { - t.Errorf("bad feature_revision: %s", *pe.Product.ProductID) - } - - // Get Product status - var gpe *ProductEnablement - record(t, "product_enablement/get_ngwaf", func(c *Client) { - gpe, err = c.GetProduct(&ProductEnablementInput{ - ProductID: ProductNGWAF, - ServiceID: testServiceID, - }) - }) - if err != nil { - t.Fatal(err) - } - - if *gpe.Product.ProductID != ProductNGWAF.String() { - t.Errorf("bad feature_revision: %s", *gpe.Product.ProductID) - } - - // Disable Product - record(t, "product_enablement/disable_ngwaf", func(c *Client) { - err = c.DisableProduct(&ProductEnablementInput{ - ProductID: ProductNGWAF, - ServiceID: testServiceID, - }) - }) - if err != nil { - t.Fatal(err) - } - - // Get Product status again to check disabled - record(t, "product_enablement/get-disabled_ngwaf", func(c *Client) { - gpe, err = c.GetProduct(&ProductEnablementInput{ - ProductID: ProductNGWAF, - ServiceID: testServiceID, - }) - }) - - // The API returns a 400 if Product is not enabled. - // The API client returns an error if a non-2xx is returned from the API. - if err == nil { - t.Fatal("expected a 400 from the API but got a 2xx") - } -} - -func TestClient_GetProduct_validation_ngwaf(t *testing.T) { - var err error - - _, err = testClient.GetProduct(&ProductEnablementInput{ - ProductID: ProductNGWAF, - }) - if err != ErrMissingServiceID { - t.Errorf("bad error: %s", err) - } - - _, err = testClient.GetProduct(&ProductEnablementInput{ - ServiceID: "foo", - }) - if err != ErrMissingProductID { - t.Errorf("bad error: %s", err) - } -} - -func TestClient_EnableProduct_validation_ngwaf(t *testing.T) { - var err error - _, err = testClient.EnableProduct(&ProductEnablementInput{ - ProductID: ProductNGWAF, - }) - if err != ErrMissingServiceID { - t.Errorf("bad error: %s", err) - } - - _, err = testClient.EnableProduct(&ProductEnablementInput{ - ServiceID: "foo", - }) - if err != ErrMissingProductID { - t.Errorf("bad error: %s", err) - } -} - -func TestClient_DisableProduct_validation_ngwaf(t *testing.T) { - var err error - - err = testClient.DisableProduct(&ProductEnablementInput{ - ProductID: ProductNGWAF, - }) - if err != ErrMissingServiceID { - t.Errorf("bad error: %s", err) - } - - err = testClient.DisableProduct(&ProductEnablementInput{ - ServiceID: "foo", - }) - if err != ErrMissingProductID { - t.Errorf("bad error: %s", err) - } -}