Skip to content

Commit

Permalink
test(product_enablement): Add test suites for all supported products. (
Browse files Browse the repository at this point in the history
…#563)

All supported products now have test suites which test 'get',
'enable', and 'disable' functionality. This requires using a Compute
service for testing as the Fanout product can only be enabled on
Compute services.

Additionally some small improvements were made in the core product
enablement code: unnecessary usage of 'fmt' was removed, and the
'enable' operation now sends the API call with a JSON body instead of
a www-form-urlencoded body.
  • Loading branch information
kpfleming authored Nov 7, 2024
1 parent 573f169 commit 1a09d78
Show file tree
Hide file tree
Showing 39 changed files with 1,637 additions and 80 deletions.
5 changes: 0 additions & 5 deletions fastly/fastly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@ var testStatsClient = NewRealtimeStatsClient()
var testDeliveryServiceID = deliveryServiceIDForTest()

// ID of the Compute service for testing.
//
//lint:ignore U1000 this will be used in an upcoming commit
var testComputeServiceID = computeServiceIDForTest()

// ID of the default Delivery service for testing.
var defaultDeliveryTestServiceID = "kKJb5bOFI47uHeBVluGfX1"

// ID of the default Compute service for testing.
//
//lint:ignore U1000 this will be used in an upcoming commit
var defaultComputeTestServiceID = "XsjdElScZGjmfCcTwsYRC1"

const (
Expand All @@ -51,7 +47,6 @@ func deliveryServiceIDForTest() string {
return defaultDeliveryTestServiceID
}

//lint:ignore U1000 this will be used in an upcoming commit
func computeServiceIDForTest() string {
if tsid := os.Getenv("FASTLY_TEST_COMPUTE_SERVICE_ID"); tsid != "" {
return tsid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interactions:
form: {}
headers:
User-Agent:
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.20.14)
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
url: https://api.fastly.com/enabled-products/bot_management/services/kKJb5bOFI47uHeBVluGfX1
method: DELETE
response:
Expand All @@ -19,7 +19,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 05 Nov 2024 20:38:55 GMT
- Wed, 06 Nov 2024 20:18:24 GMT
Pragma:
- no-cache
Server:
Expand All @@ -37,9 +37,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-chi-kigq8000069-CHI, cache-nyc-kteb1890025-NYC
- cache-chi-kigq8000069-CHI, cache-ewr-kewr1740064-EWR
X-Timer:
- S1730839134.821062,VS0,VE1506
- S1730924303.402314,VS0,VE1024
status: 204 No Content
code: 204
duration: ""
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interactions:
form: {}
headers:
User-Agent:
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.20.14)
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
url: https://api.fastly.com/enabled-products/brotli_compression/services/kKJb5bOFI47uHeBVluGfX1
method: DELETE
response:
Expand All @@ -19,7 +19,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 05 Nov 2024 20:38:22 GMT
- Wed, 06 Nov 2024 20:18:21 GMT
Pragma:
- no-cache
Server:
Expand All @@ -37,9 +37,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-chi-kigq8000119-CHI, cache-nyc-kteb1890054-NYC
- cache-chi-kigq8000119-CHI, cache-ewr-kewr1740064-EWR
X-Timer:
- S1730839103.536201,VS0,VE231
- S1730924302.575396,VS0,VE210
status: 204 No Content
code: 204
duration: ""
45 changes: 45 additions & 0 deletions fastly/fixtures/product_enablement/disable_domain_inspector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
url: https://api.fastly.com/enabled-products/domain_inspector/services/kKJb5bOFI47uHeBVluGfX1
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Wed, 06 Nov 2024 20:18:23 GMT
Pragma:
- no-cache
Server:
- control-gateway
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-chi-klot8100037-CHI, cache-ewr-kewr1740064-EWR
X-Timer:
- S1730924303.583736,VS0,VE990
status: 204 No Content
code: 204
duration: ""
45 changes: 45 additions & 0 deletions fastly/fixtures/product_enablement/disable_fanout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
url: https://api.fastly.com/enabled-products/fanout/services/XsjdElScZGjmfCcTwsYRC1
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Wed, 06 Nov 2024 20:18:23 GMT
Pragma:
- no-cache
Server:
- control-gateway
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-chi-kigq8000137-CHI, cache-ewr-kewr1740064-EWR
X-Timer:
- S1730924303.658245,VS0,VE520
status: 204 No Content
code: 204
duration: ""
45 changes: 45 additions & 0 deletions fastly/fixtures/product_enablement/disable_image_optimizer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
url: https://api.fastly.com/enabled-products/image_optimizer/services/kKJb5bOFI47uHeBVluGfX1
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Wed, 06 Nov 2024 20:18:25 GMT
Pragma:
- no-cache
Server:
- control-gateway
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-chi-kigq8000128-CHI, cache-ewr-kewr1740064-EWR
X-Timer:
- S1730924304.279790,VS0,VE1095
status: 204 No Content
code: 204
duration: ""
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interactions:
form: {}
headers:
User-Agent:
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.20.14)
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
url: https://api.fastly.com/enabled-products/log_explorer_insights/services/kKJb5bOFI47uHeBVluGfX1
method: DELETE
response:
Expand All @@ -19,7 +19,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 05 Nov 2024 20:38:43 GMT
- Wed, 06 Nov 2024 20:18:25 GMT
Pragma:
- no-cache
Server:
Expand All @@ -37,9 +37,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-chi-klot8100124-CHI, cache-nyc-kteb1890072-NYC
- cache-chi-klot8100124-CHI, cache-ewr-kewr1740064-EWR
X-Timer:
- S1730839122.120404,VS0,VE884
- S1730924305.931884,VS0,VE831
status: 204 No Content
code: 204
duration: ""
45 changes: 45 additions & 0 deletions fastly/fixtures/product_enablement/disable_origin_inspector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
url: https://api.fastly.com/enabled-products/origin_inspector/services/kKJb5bOFI47uHeBVluGfX1
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Wed, 06 Nov 2024 20:18:25 GMT
Pragma:
- no-cache
Server:
- control-gateway
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-chi-klot8100125-CHI, cache-ewr-kewr1740064-EWR
X-Timer:
- S1730924304.959599,VS0,VE1155
status: 204 No Content
code: 204
duration: ""
45 changes: 45 additions & 0 deletions fastly/fixtures/product_enablement/disable_websockets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
url: https://api.fastly.com/enabled-products/websockets/services/kKJb5bOFI47uHeBVluGfX1
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Wed, 06 Nov 2024 20:18:23 GMT
Pragma:
- no-cache
Server:
- control-gateway
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-chi-klot8100118-CHI, cache-ewr-kewr1740064-EWR
X-Timer:
- S1730924303.978744,VS0,VE427
status: 204 No Content
code: 204
duration: ""
20 changes: 9 additions & 11 deletions fastly/fixtures/product_enablement/enable_bot_management.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
version: 1
interactions:
- request:
body: ProductID=bot_management&ServiceID=kKJb5bOFI47uHeBVluGfX1
form:
ProductID:
- bot_management
ServiceID:
- kKJb5bOFI47uHeBVluGfX1
body: '{"ProductID":1,"ServiceID":"kKJb5bOFI47uHeBVluGfX1"}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/x-www-form-urlencoded
- application/json
User-Agent:
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.20.14)
- FastlyGo/9.11.0 (+github.com/fastly/go-fastly; go1.23.2)
url: https://api.fastly.com/enabled-products/bot_management/services/kKJb5bOFI47uHeBVluGfX1
method: PUT
response:
Expand All @@ -28,7 +26,7 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 05 Nov 2024 20:38:53 GMT
- Wed, 06 Nov 2024 20:18:23 GMT
Pragma:
- no-cache
Server:
Expand All @@ -46,9 +44,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-chi-kigq8000069-CHI, cache-nyc-kteb1890025-NYC
- cache-chi-kigq8000069-CHI, cache-ewr-kewr1740064-EWR
X-Timer:
- S1730839132.074411,VS0,VE1612
- S1730924301.146435,VS0,VE2136
status: 200 OK
code: 200
duration: ""
Loading

0 comments on commit 1a09d78

Please sign in to comment.