From eff17ae0e357c713b9730a93dd4140b7662f78b2 Mon Sep 17 00:00:00 2001 From: Integralist Date: Tue, 30 May 2023 13:11:36 +0100 Subject: [PATCH 1/7] fix(tls_activation): close response body after creation --- fastly/custom_tls_activation.go | 1 + 1 file changed, 1 insertion(+) diff --git a/fastly/custom_tls_activation.go b/fastly/custom_tls_activation.go index 29da0955c..d0bff5e09 100644 --- a/fastly/custom_tls_activation.go +++ b/fastly/custom_tls_activation.go @@ -160,6 +160,7 @@ func (c *Client) CreateTLSActivation(i *CreateTLSActivationInput) (*TLSActivatio if err != nil { return nil, err } + defer r.Body.Close() var a TLSActivation if err := jsonapi.UnmarshalPayload(r.Body, &a); err != nil { From 8a1cfd24c95b56d190c3c1445b3d2acafe7b0731 Mon Sep 17 00:00:00 2001 From: Integralist Date: Tue, 30 May 2023 16:11:12 +0100 Subject: [PATCH 2/7] feat(mutual_authentication): implement feature and tests --- fastly/custom_tls_activation.go | 2 + fastly/errors.go | 4 + .../mutual_authentication/create-cert.yaml | 49 ++++ .../mutual_authentication/create-key.yaml | 49 ++++ .../mutual_authentication/create-tma.yaml | 49 ++++ .../mutual_authentication/delete-cert.yaml | 39 ++++ .../mutual_authentication/delete-key.yaml | 39 ++++ .../mutual_authentication/delete-tma.yaml | 39 ++++ .../fixtures/mutual_authentication/get.yaml | 46 ++++ .../fixtures/mutual_authentication/list.yaml | 48 ++++ .../mutual_authentication/update.yaml | 51 +++++ fastly/tls_mutual_authentication.go | 212 ++++++++++++++++++ fastly/tls_mutual_authentication_test.go | 207 +++++++++++++++++ 13 files changed, 834 insertions(+) create mode 100644 fastly/fixtures/mutual_authentication/create-cert.yaml create mode 100644 fastly/fixtures/mutual_authentication/create-key.yaml create mode 100644 fastly/fixtures/mutual_authentication/create-tma.yaml create mode 100644 fastly/fixtures/mutual_authentication/delete-cert.yaml create mode 100644 fastly/fixtures/mutual_authentication/delete-key.yaml create mode 100644 fastly/fixtures/mutual_authentication/delete-tma.yaml create mode 100644 fastly/fixtures/mutual_authentication/get.yaml create mode 100644 fastly/fixtures/mutual_authentication/list.yaml create mode 100644 fastly/fixtures/mutual_authentication/update.yaml create mode 100644 fastly/tls_mutual_authentication.go create mode 100644 fastly/tls_mutual_authentication_test.go diff --git a/fastly/custom_tls_activation.go b/fastly/custom_tls_activation.go index d0bff5e09..9e7da45d0 100644 --- a/fastly/custom_tls_activation.go +++ b/fastly/custom_tls_activation.go @@ -176,6 +176,8 @@ type UpdateTLSActivationInput struct { Certificate *CustomTLSCertificate `jsonapi:"relation,tls_certificate"` // Only ID of CustomTLSCertificate needs to be set. // ID is an aphanumeric string identifying a TLS activation. ID string `jsonapi:"primary,tls_activation"` + // MutualAuthentication is an alphanumeric string identifying a mutual authentication. + MutualAuthentication *TLSMutualAuthentication `jsonapi:"relation,mutual_authentication"` // Only ID of TLSMutualAuthentication needs to be set. } // UpdateTLSActivation updates the specified resource. diff --git a/fastly/errors.go b/fastly/errors.go index 5ad1845cb..af3314775 100644 --- a/fastly/errors.go +++ b/fastly/errors.go @@ -85,6 +85,10 @@ var ErrMissingBackend = NewFieldError("Backend") // requires a "CertBlob" key, but one was not set. var ErrMissingCertBlob = NewFieldError("CertBlob") +// ErrMissingCertBundle is an error that is returned when an input struct +// requires a "CertBundle" key, but one was not set. +var ErrMissingCertBundle = NewFieldError("CertBundle") + // ErrMissingContent is an error that is returned when an input struct // requires a "Content" key, but one was not set. var ErrMissingContent = NewFieldError("Content") diff --git a/fastly/fixtures/mutual_authentication/create-cert.yaml b/fastly/fixtures/mutual_authentication/create-cert.yaml new file mode 100644 index 000000000..e172e16a3 --- /dev/null +++ b/fastly/fixtures/mutual_authentication/create-cert.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"tls_certificate","attributes":{"cert_blob":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20x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j24BqDXJffv93qCsBGX7\n-----END CERTIFICATE-----","name":"My custom certificate"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/tls/certificates + method: POST + response: + body: '{"data":{"id":"X5RA1xMENhYI8pzA20ocn2","type":"tls_certificate","attributes":{"created_at":"2023-05-30T16:30:09.000Z","issued_to":"example.com","issuer":"example.com","name":"My + custom certificate","not_after":"2023-08-28T16:30:08.000Z","not_before":"2023-05-30T16:30:08.000Z","replace":false,"serial_number":"5577006791947779410","signature_algorithm":"SHA256-RSA","updated_at":"2023-05-30T16:30:09.000Z"},"relationships":{"tls_domains":{"data":[{"id":"example.com","type":"tls_domain"}]}}}}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - private + Content-Length: + - "492" + Content-Type: + - application/vnd.api+json + Date: + - Tue, 30 May 2023 16:30:10 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish, 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + X-Timer: + - S1685464209.486002,VS0,VE826 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/mutual_authentication/create-key.yaml b/fastly/fixtures/mutual_authentication/create-key.yaml new file mode 100644 index 000000000..a7a7b893e --- /dev/null +++ b/fastly/fixtures/mutual_authentication/create-key.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"","attributes":{"key":"-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDQ218Cqijo57c0\na8WVOMZGQfj6+ivMHsTHcwZQgCJ3GexNVgXYbuKGHCTdAww7vmi4rPFE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OffxdlCsyQE32WAl6qEoYC4DriBdA+HfOIhdqMRw7VFTmhEsxFTKVyz7A1Iu\nfKJtb37fQPejoBVpcpNi3F4MRoQff3Oc099klNhDL3r3WMSnx4Ct/TfFAoGBAOiM\n9rH4v9oQef3/Z110iwerwlKIdpKWYlJf4ZPDYfP3VCl/ocUJU7hKrGnK1sY4MBsB\n0BV77PNK5AMkleZYBanXkM3QhKH1gqB9aSnWmCFjvptsXvJf9I2sdOO7SM7AofPN\nh+9L3s7CtKStc18rXc5EUmomGilHtpKQdvkMnvMHAoGBAIzqNim+48mDrkhS3dZr\nUVpiclcajFbX8I9HWDWMOUt6WwKta+fweQ2QwkIG98UcVsZxGLZO9tVNP1FQl7Qv\nPdhOye4HmPv+I+pCsGcJSSkKR0SqUP6Uhq6gLcrBm5dC/d2QSw0T+SnLDU+otgP9\nu36H3395QJNx3OqpYvVrIKzL\n-----END PRIVATE KEY-----","name":"My private key"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/tls/private_keys + method: POST + response: + body: '{"data":{"id":"pCcAcTLFGz8qbKirYl8VV2","type":"tls_private_key","attributes":{"key_length":2048,"key_type":"RSA","name":"My + private key","created_at":null,"replace":false,"public_key_sha1":"92d8b726c475a135865da27b3e34d859875bda64"}}}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - private + Content-Length: + - "234" + Content-Type: + - application/vnd.api+json + Date: + - Tue, 30 May 2023 16:30:09 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish, 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7360-LHR + X-Timer: + - S1685464209.067484,VS0,VE395 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/mutual_authentication/create-tma.yaml b/fastly/fixtures/mutual_authentication/create-tma.yaml new file mode 100644 index 000000000..f060e988d --- /dev/null +++ b/fastly/fixtures/mutual_authentication/create-tma.yaml @@ -0,0 +1,49 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"mutual_authentication","attributes":{"cert_bundle":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMwMTYzMDA4WhcNMjMwODI4MTYzMDA4WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBANDbXwKqKOjntzRrxZU4xkZB+Pr6K8wexMdzBlCA\nIncZ7E1WBdhu4oYcJN0DDDu+aLis8UQ5GeeZgGcAZ2keO5RGnXRZXP1eng38GBDl\nRTzcmVLq82370c9D+ZjNOQbH420FJ5Ojw5QNgGlz62sW4be+8G46SX/66W8xr5nL\n20u03evQAD/puMqNxTeGikXyJDVgPNChkWWxVNW5/PuyUUXO8mlgANHhcWI4v3Fx\nyM9THd9v0nBD0vTK2Ey1WkWU090nE1k6szrLe1uWZ5w61aubekLM+qI0Eb6A0MaC\nfK3SzjEXmLF0mcPl/rRPzA5SZAR4cnnP2FI1RgOkkVk/UMkCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFDauwDsA5D49yAN5LOtvNx6OfubtMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCqFOQTRc9HbdGPst1x7elxp8vU\nKjmeQoh4Gv/y6cILOT6lSNwrGBSltI057uIvARgsxCeCt2X7T/axozrMG/RxPOyJ\nktDx8RG27P3264rvkC80m4sx5KoOirOyQXOy/V7Q4vub3N6Wy94i8aO7vTVKJIOZ\ny8StXdwKBv9HHN04pU0+poS9i8X4mhozOAXnxpqxudyXJiq9ilOTVjmweaA8Hsfq\nj4IZwfr84TiWGGlCR4V6J+l/dbh63xUwMKLVDIouwX5fGhuJeo445kAwZwwVmt6Y\nQZEEiZcK5CE3l00u4NFIMDZkAPh1g6mlal2Dntnlj24BqDXJffv93qCsBGX7\n-----END CERTIFICATE-----","name":"My mutual authentication"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/tls/mutual_authentications + method: POST + response: + body: '{"data":{"id":"ighDXgQbj0EH8utWHwfzn5","type":"mutual_authentication","attributes":{"created_at":"2023-05-30T16:30:10.000Z","enforced":true,"name":"My + mutual authentication","updated_at":"2023-05-30T16:30:10.000Z"},"relationships":{"tls_activations":{"data":[]}}}}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - private + Content-Length: + - "264" + Content-Type: + - application/vnd.api+json + Date: + - Tue, 30 May 2023 16:30:10 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish, 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + X-Timer: + - S1685464210.334028,VS0,VE195 + status: 201 Created + code: 201 + duration: "" diff --git a/fastly/fixtures/mutual_authentication/delete-cert.yaml b/fastly/fixtures/mutual_authentication/delete-cert.yaml new file mode 100644 index 000000000..2466435f2 --- /dev/null +++ b/fastly/fixtures/mutual_authentication/delete-cert.yaml @@ -0,0 +1,39 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/tls/certificates/X5RA1xMENhYI8pzA20ocn2 + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + Cache-Control: + - private + Date: + - Tue, 30 May 2023 16:30:11 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish, 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + X-Timer: + - S1685464212.516262,VS0,VE289 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/mutual_authentication/delete-key.yaml b/fastly/fixtures/mutual_authentication/delete-key.yaml new file mode 100644 index 000000000..246198fba --- /dev/null +++ b/fastly/fixtures/mutual_authentication/delete-key.yaml @@ -0,0 +1,39 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/tls/private_keys/pCcAcTLFGz8qbKirYl8VV2 + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + Cache-Control: + - private + Date: + - Tue, 30 May 2023 16:30:11 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish, 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-cp-aws-us-east-2-prod-4-CONTROL-AWS-UE2, cache-lhr7360-LHR + X-Timer: + - S1685464212.827593,VS0,VE161 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/mutual_authentication/delete-tma.yaml b/fastly/fixtures/mutual_authentication/delete-tma.yaml new file mode 100644 index 000000000..4505efa9d --- /dev/null +++ b/fastly/fixtures/mutual_authentication/delete-tma.yaml @@ -0,0 +1,39 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/tls/mutual_authentications/ighDXgQbj0EH8utWHwfzn5 + method: DELETE + response: + body: "" + headers: + Accept-Ranges: + - bytes + Cache-Control: + - private + Date: + - Tue, 30 May 2023 16:30:11 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Via: + - 1.1 varnish, 1.1 varnish + X-Cache: + - MISS, MISS + X-Cache-Hits: + - 0, 0 + X-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + X-Timer: + - S1685464211.229053,VS0,VE265 + status: 204 No Content + code: 204 + duration: "" diff --git a/fastly/fixtures/mutual_authentication/get.yaml b/fastly/fixtures/mutual_authentication/get.yaml new file mode 100644 index 000000000..95c72f8cc --- /dev/null +++ b/fastly/fixtures/mutual_authentication/get.yaml @@ -0,0 +1,46 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + User-Agent: + - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/tls/mutual_authentications/ighDXgQbj0EH8utWHwfzn5 + method: GET + response: + body: '{"data":{"id":"ighDXgQbj0EH8utWHwfzn5","type":"mutual_authentication","attributes":{"created_at":"2023-05-30T16:30:10.000Z","enforced":true,"name":"My + mutual authentication","updated_at":"2023-05-30T16:30:10.000Z"},"relationships":{"tls_activations":{"data":[]}}}}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - private + Content-Length: + - "264" + Content-Type: + - application/vnd.api+json + Date: + - Tue, 30 May 2023 16:30:10 GMT + Pragma: + - no-cache + 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-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + X-Timer: + - S1685464211.775420,VS0,VE152 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/mutual_authentication/list.yaml b/fastly/fixtures/mutual_authentication/list.yaml new file mode 100644 index 000000000..3e3c2ed6d --- /dev/null +++ b/fastly/fixtures/mutual_authentication/list.yaml @@ -0,0 +1,48 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/vnd.api+json + User-Agent: + - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/tls/mutual_authentications + method: GET + response: + body: '{"data":[{"id":"ighDXgQbj0EH8utWHwfzn5","type":"mutual_authentication","attributes":{"created_at":"2023-05-30T16:30:10.000Z","enforced":true,"name":"My + mutual authentication","updated_at":"2023-05-30T16:30:10.000Z"},"relationships":{"tls_activations":{"data":[]}}}],"links":{"self":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100","first":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100","prev":null,"next":null,"last":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100"},"meta":{"per_page":100,"current_page":1,"record_count":1,"total_pages":1}}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - private + Content-Length: + - "681" + Content-Type: + - application/vnd.api+json + Date: + - Tue, 30 May 2023 16:30:10 GMT + Pragma: + - no-cache + 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-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7360-LHR + X-Timer: + - S1685464211.568441,VS0,VE164 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/fixtures/mutual_authentication/update.yaml b/fastly/fixtures/mutual_authentication/update.yaml new file mode 100644 index 000000000..73b8ef9aa --- /dev/null +++ b/fastly/fixtures/mutual_authentication/update.yaml @@ -0,0 +1,51 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"type":"mutual_authentication","id":"ighDXgQbj0EH8utWHwfzn5","attributes":{"cert_bundle":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMwMTYzMDA4WhcNMjMwODI4MTYzMDA4WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBANDbXwKqKOjntzRrxZU4xkZB+Pr6K8wexMdzBlCA\nIncZ7E1WBdhu4oYcJN0DDDu+aLis8UQ5GeeZgGcAZ2keO5RGnXRZXP1eng38GBDl\nRTzcmVLq82370c9D+ZjNOQbH420FJ5Ojw5QNgGlz62sW4be+8G46SX/66W8xr5nL\n20u03evQAD/puMqNxTeGikXyJDVgPNChkWWxVNW5/PuyUUXO8mlgANHhcWI4v3Fx\nyM9THd9v0nBD0vTK2Ey1WkWU090nE1k6szrLe1uWZ5w61aubekLM+qI0Eb6A0MaC\nfK3SzjEXmLF0mcPl/rRPzA5SZAR4cnnP2FI1RgOkkVk/UMkCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFDauwDsA5D49yAN5LOtvNx6OfubtMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCqFOQTRc9HbdGPst1x7elxp8vU\nKjmeQoh4Gv/y6cILOT6lSNwrGBSltI057uIvARgsxCeCt2X7T/axozrMG/RxPOyJ\nktDx8RG27P3264rvkC80m4sx5KoOirOyQXOy/V7Q4vub3N6Wy94i8aO7vTVKJIOZ\ny8StXdwKBv9HHN04pU0+poS9i8X4mhozOAXnxpqxudyXJiq9ilOTVjmweaA8Hsfq\nj4IZwfr84TiWGGlCR4V6J+l/dbh63xUwMKLVDIouwX5fGhuJeo445kAwZwwVmt6Y\nQZEEiZcK5CE3l00u4NFIMDZkAPh1g6mlal2Dntnlj24BqDXJffv93qCsBGX7\n-----END CERTIFICATE-----","enforced":true,"name":"My mutual authentication updated"}}} + form: {} + headers: + Accept: + - application/vnd.api+json + Content-Type: + - application/vnd.api+json + User-Agent: + - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) + url: https://api.fastly.com/tls/mutual_authentications/ighDXgQbj0EH8utWHwfzn5 + method: PATCH + response: + body: '{"data":{"id":"ighDXgQbj0EH8utWHwfzn5","type":"mutual_authentication","attributes":{"created_at":"2023-05-30T16:30:10.000Z","enforced":true,"name":"My + mutual authentication updated","updated_at":"2023-05-30T16:30:11.000Z"},"relationships":{"tls_activations":{"data":[]}}}}' + headers: + Accept-Ranges: + - bytes + Cache-Control: + - private + Content-Length: + - "272" + Content-Type: + - application/vnd.api+json + Date: + - Tue, 30 May 2023 16:30:11 GMT + Pragma: + - no-cache + 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-Content-Type-Options: + - nosniff + X-Served-By: + - cache-control-cp-aws-us-east-2-prod-4-CONTROL-AWS-UE2, cache-lhr7360-LHR + X-Timer: + - S1685464211.945710,VS0,VE262 + status: 200 OK + code: 200 + duration: "" diff --git a/fastly/tls_mutual_authentication.go b/fastly/tls_mutual_authentication.go new file mode 100644 index 000000000..d02557705 --- /dev/null +++ b/fastly/tls_mutual_authentication.go @@ -0,0 +1,212 @@ +package fastly + +import ( + "fmt" + "reflect" + "strconv" + "time" + + "github.com/google/jsonapi" +) + +// TLSMutualAuthentication represents a mutual authentication certificate. +type TLSMutualAuthentication struct { + Activations []*TLSActivation `jsonapi:"relation,tls_activations"` + CreatedAt *time.Time `jsonapi:"attr,created_at,iso8601"` + Enforced bool `jsonapi:"attr,enforced"` + ID string `jsonapi:"primary,mutual_authentication"` + Name string `jsonapi:"attr,name"` + UpdatedAt *time.Time `jsonapi:"attr,updated_at,iso8601"` +} + +// ListTLSMutualAuthenticationsInput is used as input to the Client.ListTLSMutualAuthentication function. +type ListTLSMutualAuthenticationsInput struct { + // Include is a comma-separated list of related objects to include (optional). + Include string + // PageNumber is the required page index for pagination. + PageNumber int + // PageSize is the number of records per page. + PageSize int +} + +// formatFilters converts user input into query parameters for filtering. +func (i *ListTLSMutualAuthenticationsInput) formatFilters() map[string]string { + result := map[string]string{} + pairings := map[string]interface{}{ + "include": i.Include, + "page[size]": i.PageSize, + "page[number]": i.PageNumber, + } + + for key, value := range pairings { + switch t := reflect.TypeOf(value).String(); t { + case "string": + if value != "" { + result[key] = value.(string) + } + case "int": + if value != 0 { + result[key] = strconv.Itoa(value.(int)) + } + } + } + + return result +} + +// ListTLSMutualAuthentication retrieves all resources. +func (c *Client) ListTLSMutualAuthentication(i *ListTLSMutualAuthenticationsInput) ([]*TLSMutualAuthentication, error) { + p := "/tls/mutual_authentications" + filters := &RequestOptions{ + Params: i.formatFilters(), + Headers: map[string]string{ + "Accept": "application/vnd.api+json", // this is required otherwise the filters don't work + }, + } + + r, err := c.Get(p, filters) + if err != nil { + return nil, err + } + + data, err := jsonapi.UnmarshalManyPayload(r.Body, reflect.TypeOf(new(TLSMutualAuthentication))) + if err != nil { + return nil, err + } + + so := make([]*TLSMutualAuthentication, len(data)) + for i := range data { + typed, ok := data[i].(*TLSMutualAuthentication) + if !ok { + return nil, fmt.Errorf("unexpected response type: %T", data[i]) + } + so[i] = typed + } + + return so, nil +} + +// GetTLSMutualAuthenticationInput is used as input to the GetTLSMutualAuthentication function. +type GetTLSMutualAuthenticationInput struct { + // ID is an alphanumeric string identifying a mutual authentication (required). + ID string + // Include is a comma-separated list of related objects to include (optional). + Include string +} + +// GetTLSMutualAuthentication retrieves the specified resource. +func (c *Client) GetTLSMutualAuthentication(i *GetTLSMutualAuthenticationInput) (*TLSMutualAuthentication, error) { + if i.ID == "" { + return nil, ErrMissingID + } + + var ro *RequestOptions + if i.Include != "" { + ro = &RequestOptions{ + Params: map[string]string{ + "include": i.Include, + }, + } + } + + p := fmt.Sprintf("/tls/mutual_authentications/%s", i.ID) + + r, err := c.Get(p, ro) + if err != nil { + return nil, err + } + + var o TLSMutualAuthentication + if err := jsonapi.UnmarshalPayload(r.Body, &o); err != nil { + return nil, err + } + + return &o, nil +} + +// CreateTLSMutualAuthenticationInput is used as input to the CreateTLSMutualAuthentication function. +type CreateTLSMutualAuthenticationInput struct { + // CertBundle is one or more certificates. Enter each individual certificate blob on a new line. Must be PEM-formatted (required). + CertBundle string `jsonapi:"attr,cert_bundle"` + // ID should not be set (it's internally used to help marshal the JSONAPI request data). + ID string `jsonapi:"primary,mutual_authentication"` + // Name is a custom name for your mutual authentication (optional). + Name string `jsonapi:"attr,name,omitempty"` +} + +// CreateTLSMutualAuthentication creates a new resource. +func (c *Client) CreateTLSMutualAuthentication(i *CreateTLSMutualAuthenticationInput) (*TLSMutualAuthentication, error) { + if i.CertBundle == "" { + return nil, ErrMissingCertBundle + } + + p := "/tls/mutual_authentications" + + r, err := c.PostJSONAPI(p, i, nil) + if err != nil { + return nil, err + } + + var o TLSMutualAuthentication + if err := jsonapi.UnmarshalPayload(r.Body, &o); err != nil { + return nil, err + } + + return &o, nil +} + +// UpdateTLSMutualAuthenticationInput is used as input to the UpdateTLSMutualAuthentication function. +type UpdateTLSMutualAuthenticationInput struct { + // CertBundle is one or more certificates. Enter each individual certificate blob on a new line. Must be PEM-formatted (required). + CertBundle string `jsonapi:"attr,cert_bundle"` + // Enforced determines whether Mutual TLS will fail closed (enforced) or fail open. + Enforced bool `jsonapi:"attr,enforced"` + // ID is an alphanumeric string identifying a mutual authentication (required). + ID string `jsonapi:"primary,mutual_authentication"` + // Name is a custom name for your mutual authentication (optional). + Name string `jsonapi:"attr,name,omitempty"` +} + +// UpdateTLSMutualAuthentication updates the specified resource. +// +// By using this endpoint, the original certificate will cease to be used for future TLS handshakes. +// Thus, only SAN entries that appear in the replacement certificate will become TLS enabled. +// Any SAN entries that are missing in the replacement certificate will become disabled. +func (c *Client) UpdateTLSMutualAuthentication(i *UpdateTLSMutualAuthenticationInput) (*TLSMutualAuthentication, error) { + if i.CertBundle == "" { + return nil, ErrMissingCertBundle + } + if i.ID == "" { + return nil, ErrMissingID + } + + path := fmt.Sprintf("/tls/mutual_authentications/%s", i.ID) + resp, err := c.PatchJSONAPI(path, i, nil) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + var o TLSMutualAuthentication + if err := jsonapi.UnmarshalPayload(resp.Body, &o); err != nil { + return nil, err + } + return &o, nil +} + +// DeleteTLSMutualAuthenticationInput used for deleting a certificate. +type DeleteTLSMutualAuthenticationInput struct { + // ID is an alphanumeric string identifying a mutual authentication (required). + ID string +} + +// DeleteTLSMutualAuthentication deletes the specified resource. +func (c *Client) DeleteTLSMutualAuthentication(i *DeleteTLSMutualAuthenticationInput) error { + if i.ID == "" { + return ErrMissingID + } + + path := fmt.Sprintf("/tls/mutual_authentications/%s", i.ID) + _, err := c.Delete(path, nil) + return err +} diff --git a/fastly/tls_mutual_authentication_test.go b/fastly/tls_mutual_authentication_test.go new file mode 100644 index 000000000..8788e7fe8 --- /dev/null +++ b/fastly/tls_mutual_authentication_test.go @@ -0,0 +1,207 @@ +package fastly + +import ( + "testing" +) + +func TestClient_TLSMutualAuthentication(t *testing.T) { + t.Parallel() + + fixtureBase := "mutual_authentication/" + + privateKey, key, err := buildPrivateKey() + if err != nil { + t.Fatal(err) + } + + cert, err := buildCertificate(privateKey, "example.com") + if err != nil { + t.Fatal(err) + } + + // Create private key required to generate a custom certificate. + var pk *PrivateKey + record(t, fixtureBase+"create-key", func(c *Client) { + pk, err = c.CreatePrivateKey(&CreatePrivateKeyInput{ + Key: key, + Name: "My private key", + }) + }) + if err != nil { + t.Fatal(err) + } + + // Create a customer TLS certificate to pass to the mutual authentication endpoint. + var cc *CustomTLSCertificate + record(t, fixtureBase+"create-cert", func(c *Client) { + cc, err = c.CreateCustomTLSCertificate(&CreateCustomTLSCertificateInput{ + CertBlob: cert, + Name: "My custom certificate", + }) + }) + if err != nil { + t.Fatal(err) + } + + // Ensure deleted + defer func() { + _ = testClient.DeleteCustomTLSCertificate(&DeleteCustomTLSCertificateInput{ + ID: cc.ID, + }) + _ = testClient.DeletePrivateKey(&DeletePrivateKeyInput{ + ID: pk.ID, + }) + }() + + // Create mutual authentication using the custom TLS certificate above. + var tma *TLSMutualAuthentication + record(t, fixtureBase+"create-tma", func(c *Client) { + tma, err = c.CreateTLSMutualAuthentication(&CreateTLSMutualAuthenticationInput{ + CertBundle: cert, + Name: "My mutual authentication", + }) + }) + if err != nil { + t.Fatal(err) + } + + // Ensure deleted + defer func() { + _ = testClient.DeleteTLSMutualAuthentication(&DeleteTLSMutualAuthenticationInput{ + ID: tma.ID, + }) + }() + + // List + var tmas []*TLSMutualAuthentication + record(t, fixtureBase+"list", func(c *Client) { + tmas, err = c.ListTLSMutualAuthentication(&ListTLSMutualAuthenticationsInput{}) + }) + if err != nil { + t.Fatal(err) + } + if len(tmas) < 1 { + t.Errorf("failed to return any objects: %v", tmas) + } + + // Get + var gtma *TLSMutualAuthentication + record(t, fixtureBase+"get", func(c *Client) { + gtma, err = c.GetTLSMutualAuthentication(&GetTLSMutualAuthenticationInput{ + ID: tma.ID, + }) + }) + if err != nil { + t.Fatal(err) + } + if tma.ID != gtma.ID { + t.Errorf("bad ID: %q (%q)", tma.ID, gtma.ID) + } + + // Update + var utma *TLSMutualAuthentication + record(t, fixtureBase+"update", func(c *Client) { + utma, err = c.UpdateTLSMutualAuthentication(&UpdateTLSMutualAuthenticationInput{ + CertBundle: cert, + Enforced: true, + ID: tma.ID, + Name: "My mutual authentication updated", + }) + }) + if err != nil { + t.Fatal(err) + } + if tma.ID != utma.ID { + t.Errorf("bad ID: %q (%q)", tma.ID, utma.ID) + } + + // Delete + record(t, fixtureBase+"delete-tma", func(c *Client) { + err = c.DeleteTLSMutualAuthentication(&DeleteTLSMutualAuthenticationInput{ + ID: tma.ID, + }) + }) + if err != nil { + t.Fatal(err) + } + record(t, fixtureBase+"delete-cert", func(c *Client) { + err = c.DeleteCustomTLSCertificate(&DeleteCustomTLSCertificateInput{ + ID: cc.ID, + }) + }) + if err != nil { + t.Fatal(err) + } + record(t, fixtureBase+"delete-key", func(c *Client) { + err = c.DeletePrivateKey(&DeletePrivateKeyInput{ + ID: pk.ID, + }) + }) + if err != nil { + t.Fatal(err) + } +} + +func TestClient_CreateTLSMutualAuthentication_validation(t *testing.T) { + t.Parallel() + + var err error + _, err = testClient.CreateTLSMutualAuthentication(&CreateTLSMutualAuthenticationInput{ + Name: "My certificate", + }) + if err != ErrMissingCertBundle { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_DeleteTLSMutualAuthentication_validation(t *testing.T) { + t.Parallel() + + err := testClient.DeleteTLSMutualAuthentication(&DeleteTLSMutualAuthenticationInput{}) + if err != ErrMissingID { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_ListTLSMutualAuthentication_validation(t *testing.T) { + t.Parallel() + + var err error + record(t, "mutual_authentication/list", func(c *Client) { + _, err = c.ListTLSMutualAuthentication(&ListTLSMutualAuthenticationsInput{}) + }) + if err != nil { + t.Fatal(err) + } +} + +func TestClient_GetTLSMutualAuthentication_validation(t *testing.T) { + t.Parallel() + + var err error + _, err = testClient.GetCustomTLSCertificate(&GetCustomTLSCertificateInput{}) + if err != ErrMissingID { + t.Errorf("bad error: %s", err) + } +} + +func TestClient_UpdateTLSMutualAuthentication_validation(t *testing.T) { + t.Parallel() + + var err error + _, err = testClient.UpdateTLSMutualAuthentication(&UpdateTLSMutualAuthenticationInput{ + ID: "example", + Name: "My certificate", + }) + if err != ErrMissingCertBundle { + t.Errorf("bad error: %s", err) + } + + _, err = testClient.UpdateTLSMutualAuthentication(&UpdateTLSMutualAuthenticationInput{ + CertBundle: "example", + Name: "My certificate", + }) + if err != ErrMissingID { + t.Errorf("bad error: %s", err) + } +} From cf3084e364b06d078ff3b9c99229831e3fddeba4 Mon Sep 17 00:00:00 2001 From: Integralist Date: Wed, 31 May 2023 12:45:50 +0100 Subject: [PATCH 3/7] refactor(mutual_authentication): remove reflect from formatFilters and use slice for include property --- fastly/tls_mutual_authentication.go | 31 ++++++++++------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/fastly/tls_mutual_authentication.go b/fastly/tls_mutual_authentication.go index d02557705..bd2bffb21 100644 --- a/fastly/tls_mutual_authentication.go +++ b/fastly/tls_mutual_authentication.go @@ -4,6 +4,7 @@ import ( "fmt" "reflect" "strconv" + "strings" "time" "github.com/google/jsonapi" @@ -21,8 +22,8 @@ type TLSMutualAuthentication struct { // ListTLSMutualAuthenticationsInput is used as input to the Client.ListTLSMutualAuthentication function. type ListTLSMutualAuthenticationsInput struct { - // Include is a comma-separated list of related objects to include (optional). - Include string + // Include is a list of related objects to include (optional). + Include []string // PageNumber is the required page index for pagination. PageNumber int // PageSize is the number of records per page. @@ -32,25 +33,15 @@ type ListTLSMutualAuthenticationsInput struct { // formatFilters converts user input into query parameters for filtering. func (i *ListTLSMutualAuthenticationsInput) formatFilters() map[string]string { result := map[string]string{} - pairings := map[string]interface{}{ - "include": i.Include, - "page[size]": i.PageSize, - "page[number]": i.PageNumber, - } - - for key, value := range pairings { - switch t := reflect.TypeOf(value).String(); t { - case "string": - if value != "" { - result[key] = value.(string) - } - case "int": - if value != 0 { - result[key] = strconv.Itoa(value.(int)) - } - } + if len(i.Include) > 0 { + result["include"] = strings.Join(i.Include, ",") + } + if i.PageSize > 0 { + result["page[size]"] = strconv.Itoa(i.PageSize) + } + if i.PageNumber > 0 { + result["page[number]"] = strconv.Itoa(i.PageNumber) } - return result } From 04ab5307243e9ca21827a898acc513817ea9dcb4 Mon Sep 17 00:00:00 2001 From: Integralist Date: Wed, 31 May 2023 12:47:19 +0100 Subject: [PATCH 4/7] fix(mutual_authentication): add Accept header to GET --- fastly/tls_mutual_authentication.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fastly/tls_mutual_authentication.go b/fastly/tls_mutual_authentication.go index bd2bffb21..824f95ee4 100644 --- a/fastly/tls_mutual_authentication.go +++ b/fastly/tls_mutual_authentication.go @@ -97,6 +97,9 @@ func (c *Client) GetTLSMutualAuthentication(i *GetTLSMutualAuthenticationInput) Params: map[string]string{ "include": i.Include, }, + Headers: map[string]string{ + "Accept": "application/vnd.api+json", // this is required otherwise the filters don't work + }, } } From e06de0d353441c1411c51ccd4c0ec454baf95388 Mon Sep 17 00:00:00 2001 From: Integralist Date: Wed, 31 May 2023 12:47:43 +0100 Subject: [PATCH 5/7] docs(mutual_authentication): remove incorrect method annotation --- fastly/tls_mutual_authentication.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fastly/tls_mutual_authentication.go b/fastly/tls_mutual_authentication.go index 824f95ee4..8f783b8f7 100644 --- a/fastly/tls_mutual_authentication.go +++ b/fastly/tls_mutual_authentication.go @@ -162,10 +162,6 @@ type UpdateTLSMutualAuthenticationInput struct { } // UpdateTLSMutualAuthentication updates the specified resource. -// -// By using this endpoint, the original certificate will cease to be used for future TLS handshakes. -// Thus, only SAN entries that appear in the replacement certificate will become TLS enabled. -// Any SAN entries that are missing in the replacement certificate will become disabled. func (c *Client) UpdateTLSMutualAuthentication(i *UpdateTLSMutualAuthenticationInput) (*TLSMutualAuthentication, error) { if i.CertBundle == "" { return nil, ErrMissingCertBundle From 44fc87ce8d4f73c011324500a43abe91c8a8d8df Mon Sep 17 00:00:00 2001 From: Integralist Date: Wed, 31 May 2023 12:50:32 +0100 Subject: [PATCH 6/7] test(mutual_authentication): regenerate fixtures --- .../mutual_authentication/create-cert.yaml | 12 ++++++------ .../fixtures/mutual_authentication/create-key.yaml | 12 ++++++------ .../fixtures/mutual_authentication/create-tma.yaml | 12 ++++++------ .../mutual_authentication/delete-cert.yaml | 8 ++++---- .../fixtures/mutual_authentication/delete-key.yaml | 8 ++++---- .../fixtures/mutual_authentication/delete-tma.yaml | 8 ++++---- fastly/fixtures/mutual_authentication/get.yaml | 12 ++++++------ fastly/fixtures/mutual_authentication/list.yaml | 10 +++++----- fastly/fixtures/mutual_authentication/update.yaml | 14 +++++++------- 9 files changed, 48 insertions(+), 48 deletions(-) diff --git a/fastly/fixtures/mutual_authentication/create-cert.yaml b/fastly/fixtures/mutual_authentication/create-cert.yaml index e172e16a3..d7cf56e14 100644 --- a/fastly/fixtures/mutual_authentication/create-cert.yaml +++ b/fastly/fixtures/mutual_authentication/create-cert.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"tls_certificate","attributes":{"cert_blob":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMwMTYzMDA4WhcNMjMwODI4MTYzMDA4WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBANDbXwKqKOjntzRrxZU4xkZB+Pr6K8wexMdzBlCA\nIncZ7E1WBdhu4oYcJN0DDDu+aLis8UQ5GeeZgGcAZ2keO5RGnXRZXP1eng38GBDl\nRTzcmVLq82370c9D+ZjNOQbH420FJ5Ojw5QNgGlz62sW4be+8G46SX/66W8xr5nL\n20u03evQAD/puMqNxTeGikXyJDVgPNChkWWxVNW5/PuyUUXO8mlgANHhcWI4v3Fx\nyM9THd9v0nBD0vTK2Ey1WkWU090nE1k6szrLe1uWZ5w61aubekLM+qI0Eb6A0MaC\nfK3SzjEXmLF0mcPl/rRPzA5SZAR4cnnP2FI1RgOkkVk/UMkCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFDauwDsA5D49yAN5LOtvNx6OfubtMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCqFOQTRc9HbdGPst1x7elxp8vU\nKjmeQoh4Gv/y6cILOT6lSNwrGBSltI057uIvARgsxCeCt2X7T/axozrMG/RxPOyJ\nktDx8RG27P3264rvkC80m4sx5KoOirOyQXOy/V7Q4vub3N6Wy94i8aO7vTVKJIOZ\ny8StXdwKBv9HHN04pU0+poS9i8X4mhozOAXnxpqxudyXJiq9ilOTVjmweaA8Hsfq\nj4IZwfr84TiWGGlCR4V6J+l/dbh63xUwMKLVDIouwX5fGhuJeo445kAwZwwVmt6Y\nQZEEiZcK5CE3l00u4NFIMDZkAPh1g6mlal2Dntnlj24BqDXJffv93qCsBGX7\n-----END CERTIFICATE-----","name":"My custom certificate"}}} + {"data":{"type":"tls_certificate","attributes":{"cert_blob":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMxMTE0ODI2WhcNMjMwODI5MTE0ODI2WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBALcgLS9FIWYSRw7MLpEV/4nvmlDA95jlXZnejar9\nVbKXxWzEljZZVtp+CniP1ef6OBBwIph9bX9ig+96cMWR1GMlu7kddIisuSFhndPv\nQxCNW6r5Vlh0q9inuizXBdh48Ql4/xWWWHPfGBYFUzHhDaw1qlyH28E1RRp6LsfE\nVh0r5K+NuuL3ZAsXyRM1uzt62mczraVbKLHGjag/5vsgC48Yak9hLC4jUu6cPE9L\nsVX5xAbu21U7TuZslI4nerSsHAMu9463MJh4eTyKhQQiJABql+TiO7+jkDWu/InC\nOvmF3dasTq6HDEKj7Io2m6uTlWCZ0xSdyceWl6h+7OHBbTcCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFL3co7IUnrTsHPO6Xhq5e9IGUkfCMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCyKG37ZQbVFC2ATfcgYcJm9sfF\nraLcm0Ft206ZvWZ8++48G4pE6vSWcnMioMv6vffD/wRSo606Yur1GZ2TsrBok9VE\n7yNXQa+zT/pdvK7XheuCQOfX1PHS6Xe1VK657GMHTGAZZZsssTbb1PdbSkOoLR/w\nqdFf1qbwMUb5Nak4xlOlcInbUVljpSKxt0FcZJjWglINaMyVMG/B1IFFtQX3S8+c\nca7fXIvl9Vw1RO/7/HS9veQ9x1IZmuYW2VelwAkhn33qGdKcRBOAm8UOAdKQH4gT\nMrD7Hc0fqiqvwFDmBQIz5beWeUfxZWtBg+ivFmj739EfdmvkjuqK36kj3LtY\n-----END CERTIFICATE-----","name":"My custom certificate"}}} form: {} headers: Accept: @@ -15,8 +15,8 @@ interactions: url: https://api.fastly.com/tls/certificates method: POST response: - body: '{"data":{"id":"X5RA1xMENhYI8pzA20ocn2","type":"tls_certificate","attributes":{"created_at":"2023-05-30T16:30:09.000Z","issued_to":"example.com","issuer":"example.com","name":"My - custom certificate","not_after":"2023-08-28T16:30:08.000Z","not_before":"2023-05-30T16:30:08.000Z","replace":false,"serial_number":"5577006791947779410","signature_algorithm":"SHA256-RSA","updated_at":"2023-05-30T16:30:09.000Z"},"relationships":{"tls_domains":{"data":[{"id":"example.com","type":"tls_domain"}]}}}}' + body: '{"data":{"id":"vOJL3187my51i5ITgcr7H2","type":"tls_certificate","attributes":{"created_at":"2023-05-31T11:48:27.000Z","issued_to":"example.com","issuer":"example.com","name":"My + custom certificate","not_after":"2023-08-29T11:48:26.000Z","not_before":"2023-05-31T11:48:26.000Z","replace":false,"serial_number":"5577006791947779410","signature_algorithm":"SHA256-RSA","updated_at":"2023-05-31T11:48:27.000Z"},"relationships":{"tls_domains":{"data":[{"id":"example.com","type":"tls_domain"}]}}}}' headers: Accept-Ranges: - bytes @@ -27,7 +27,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 May 2023 16:30:10 GMT + - Wed, 31 May 2023 11:48:28 GMT Pragma: - no-cache Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + - cache-control-cp-aws-us-east-2-prod-4-CONTROL-AWS-UE2, cache-lhr7383-LHR X-Timer: - - S1685464209.486002,VS0,VE826 + - S1685533707.484825,VS0,VE1050 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/mutual_authentication/create-key.yaml b/fastly/fixtures/mutual_authentication/create-key.yaml index a7a7b893e..c7e5ba5b2 100644 --- a/fastly/fixtures/mutual_authentication/create-key.yaml +++ b/fastly/fixtures/mutual_authentication/create-key.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"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FeYdbFRG4XstoDNjF\nMjvh6j65hde+rgX0ef17+o4d+TiUqg6MP/autqi49PY6M5Lrqd/G0S32MZdRutOq\nkSrLJ5jvxwKBgCpm+sD4YBjmfMk1MH5rmzN5RSXJgJ5GNmYnWq9quZQpSetzd4l5\ncvxDOffxdlCsyQE32WAl6qEoYC4DriBdA+HfOIhdqMRw7VFTmhEsxFTKVyz7A1Iu\nfKJtb37fQPejoBVpcpNi3F4MRoQff3Oc099klNhDL3r3WMSnx4Ct/TfFAoGBAOiM\n9rH4v9oQef3/Z110iwerwlKIdpKWYlJf4ZPDYfP3VCl/ocUJU7hKrGnK1sY4MBsB\n0BV77PNK5AMkleZYBanXkM3QhKH1gqB9aSnWmCFjvptsXvJf9I2sdOO7SM7AofPN\nh+9L3s7CtKStc18rXc5EUmomGilHtpKQdvkMnvMHAoGBAIzqNim+48mDrkhS3dZr\nUVpiclcajFbX8I9HWDWMOUt6WwKta+fweQ2QwkIG98UcVsZxGLZO9tVNP1FQl7Qv\nPdhOye4HmPv+I+pCsGcJSSkKR0SqUP6Uhq6gLcrBm5dC/d2QSw0T+SnLDU+otgP9\nu36H3395QJNx3OqpYvVrIKzL\n-----END PRIVATE KEY-----","name":"My private key"}}} + {"data":{"type":"","attributes":{"key":"-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC3IC0vRSFmEkcO\nzC6RFf+J75pQwPeY5V2Z3o2q/VWyl8VsxJY2WVbafgp4j9Xn+jgQcCKYfW1/YoPv\nenDFkdRjJbu5HXSIrLkhYZ3T70MQjVuq+VZYdKvYp7os1wXYePEJeP8Vllhz3xgW\nBVMx4Q2sNapch9vBNUUaei7HxFYdK+Svjbri92QLF8kTNbs7etpnM62lWyixxo2o\nP+b7IAuPGGpPYSwuI1LunDxPS7FV+cQG7ttVO07mbJSOJ3q0rBwDLveOtzCYeHk8\nioUEIiQAapfk4ju/o5A1rvyJwjr5hd3WrE6uhwxCo+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Ut4aM32\n3Q8JRjEGXQKKaAlMOnAjL41B8vbzBGAu/8T4UFOtAoGAb3+vWxbDIGk6mMJmUp3c\nGEkZVvZEqTHI2seJ/lT+D+UOnuFWwzACkk1KjRmgkkrVXgwO8qrEfby06OEtxmMK\ntbVtOCK/mDFyddLxEP2i355ZA4606oNMSkpyur1UO740m1Qvy2XzzDk+I0ETQBku\nRTyVXNLXU0ELgTxPQF4Cx/0=\n-----END PRIVATE KEY-----","name":"My private key"}}} form: {} headers: Accept: @@ -15,8 +15,8 @@ interactions: url: https://api.fastly.com/tls/private_keys method: POST response: - body: '{"data":{"id":"pCcAcTLFGz8qbKirYl8VV2","type":"tls_private_key","attributes":{"key_length":2048,"key_type":"RSA","name":"My - private key","created_at":null,"replace":false,"public_key_sha1":"92d8b726c475a135865da27b3e34d859875bda64"}}}' + body: '{"data":{"id":"0LYME3yUMZpE0lKca6dGr2","type":"tls_private_key","attributes":{"key_length":2048,"key_type":"RSA","name":"My + private key","created_at":null,"replace":false,"public_key_sha1":"29e60e9152953916b47b48e5bc174930c304ddc3"}}}' headers: Accept-Ranges: - bytes @@ -27,7 +27,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 May 2023 16:30:09 GMT + - Wed, 31 May 2023 11:48:27 GMT Pragma: - no-cache Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7360-LHR + - cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7383-LHR X-Timer: - - S1685464209.067484,VS0,VE395 + - S1685533707.959293,VS0,VE488 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/mutual_authentication/create-tma.yaml b/fastly/fixtures/mutual_authentication/create-tma.yaml index f060e988d..236d69358 100644 --- a/fastly/fixtures/mutual_authentication/create-tma.yaml +++ b/fastly/fixtures/mutual_authentication/create-tma.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"mutual_authentication","attributes":{"cert_bundle":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMwMTYzMDA4WhcNMjMwODI4MTYzMDA4WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBANDbXwKqKOjntzRrxZU4xkZB+Pr6K8wexMdzBlCA\nIncZ7E1WBdhu4oYcJN0DDDu+aLis8UQ5GeeZgGcAZ2keO5RGnXRZXP1eng38GBDl\nRTzcmVLq82370c9D+ZjNOQbH420FJ5Ojw5QNgGlz62sW4be+8G46SX/66W8xr5nL\n20u03evQAD/puMqNxTeGikXyJDVgPNChkWWxVNW5/PuyUUXO8mlgANHhcWI4v3Fx\nyM9THd9v0nBD0vTK2Ey1WkWU090nE1k6szrLe1uWZ5w61aubekLM+qI0Eb6A0MaC\nfK3SzjEXmLF0mcPl/rRPzA5SZAR4cnnP2FI1RgOkkVk/UMkCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFDauwDsA5D49yAN5LOtvNx6OfubtMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCqFOQTRc9HbdGPst1x7elxp8vU\nKjmeQoh4Gv/y6cILOT6lSNwrGBSltI057uIvARgsxCeCt2X7T/axozrMG/RxPOyJ\nktDx8RG27P3264rvkC80m4sx5KoOirOyQXOy/V7Q4vub3N6Wy94i8aO7vTVKJIOZ\ny8StXdwKBv9HHN04pU0+poS9i8X4mhozOAXnxpqxudyXJiq9ilOTVjmweaA8Hsfq\nj4IZwfr84TiWGGlCR4V6J+l/dbh63xUwMKLVDIouwX5fGhuJeo445kAwZwwVmt6Y\nQZEEiZcK5CE3l00u4NFIMDZkAPh1g6mlal2Dntnlj24BqDXJffv93qCsBGX7\n-----END CERTIFICATE-----","name":"My mutual authentication"}}} + {"data":{"type":"mutual_authentication","attributes":{"cert_bundle":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMxMTE0ODI2WhcNMjMwODI5MTE0ODI2WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBALcgLS9FIWYSRw7MLpEV/4nvmlDA95jlXZnejar9\nVbKXxWzEljZZVtp+CniP1ef6OBBwIph9bX9ig+96cMWR1GMlu7kddIisuSFhndPv\nQxCNW6r5Vlh0q9inuizXBdh48Ql4/xWWWHPfGBYFUzHhDaw1qlyH28E1RRp6LsfE\nVh0r5K+NuuL3ZAsXyRM1uzt62mczraVbKLHGjag/5vsgC48Yak9hLC4jUu6cPE9L\nsVX5xAbu21U7TuZslI4nerSsHAMu9463MJh4eTyKhQQiJABql+TiO7+jkDWu/InC\nOvmF3dasTq6HDEKj7Io2m6uTlWCZ0xSdyceWl6h+7OHBbTcCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFL3co7IUnrTsHPO6Xhq5e9IGUkfCMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCyKG37ZQbVFC2ATfcgYcJm9sfF\nraLcm0Ft206ZvWZ8++48G4pE6vSWcnMioMv6vffD/wRSo606Yur1GZ2TsrBok9VE\n7yNXQa+zT/pdvK7XheuCQOfX1PHS6Xe1VK657GMHTGAZZZsssTbb1PdbSkOoLR/w\nqdFf1qbwMUb5Nak4xlOlcInbUVljpSKxt0FcZJjWglINaMyVMG/B1IFFtQX3S8+c\nca7fXIvl9Vw1RO/7/HS9veQ9x1IZmuYW2VelwAkhn33qGdKcRBOAm8UOAdKQH4gT\nMrD7Hc0fqiqvwFDmBQIz5beWeUfxZWtBg+ivFmj739EfdmvkjuqK36kj3LtY\n-----END CERTIFICATE-----","name":"My mutual authentication"}}} form: {} headers: Accept: @@ -15,8 +15,8 @@ interactions: url: https://api.fastly.com/tls/mutual_authentications method: POST response: - body: '{"data":{"id":"ighDXgQbj0EH8utWHwfzn5","type":"mutual_authentication","attributes":{"created_at":"2023-05-30T16:30:10.000Z","enforced":true,"name":"My - mutual authentication","updated_at":"2023-05-30T16:30:10.000Z"},"relationships":{"tls_activations":{"data":[]}}}}' + body: '{"data":{"id":"4tFjGkmDCvPr7f4I9RlDq5","type":"mutual_authentication","attributes":{"created_at":"2023-05-31T11:48:28.000Z","enforced":true,"name":"My + mutual authentication","updated_at":"2023-05-31T11:48:28.000Z"},"relationships":{"tls_activations":{"data":[]}}}}' headers: Accept-Ranges: - bytes @@ -27,7 +27,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 May 2023 16:30:10 GMT + - Wed, 31 May 2023 11:48:28 GMT Pragma: - no-cache Strict-Transport-Security: @@ -41,9 +41,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + - cache-control-cp-aws-us-east-2-prod-4-CONTROL-AWS-UE2, cache-lhr7383-LHR X-Timer: - - S1685464210.334028,VS0,VE195 + - S1685533709.558327,VS0,VE205 status: 201 Created code: 201 duration: "" diff --git a/fastly/fixtures/mutual_authentication/delete-cert.yaml b/fastly/fixtures/mutual_authentication/delete-cert.yaml index 2466435f2..c107e3a6e 100644 --- a/fastly/fixtures/mutual_authentication/delete-cert.yaml +++ b/fastly/fixtures/mutual_authentication/delete-cert.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) - url: https://api.fastly.com/tls/certificates/X5RA1xMENhYI8pzA20ocn2 + url: https://api.fastly.com/tls/certificates/vOJL3187my51i5ITgcr7H2 method: DELETE response: body: "" @@ -17,7 +17,7 @@ interactions: Cache-Control: - private Date: - - Tue, 30 May 2023 16:30:11 GMT + - Wed, 31 May 2023 11:48:30 GMT Pragma: - no-cache Strict-Transport-Security: @@ -31,9 +31,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + - cache-control-cp-aws-us-east-2-prod-2-CONTROL-AWS-UE2, cache-lhr7383-LHR X-Timer: - - S1685464212.516262,VS0,VE289 + - S1685533710.169246,VS0,VE309 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/mutual_authentication/delete-key.yaml b/fastly/fixtures/mutual_authentication/delete-key.yaml index 246198fba..15e928841 100644 --- a/fastly/fixtures/mutual_authentication/delete-key.yaml +++ b/fastly/fixtures/mutual_authentication/delete-key.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) - url: https://api.fastly.com/tls/private_keys/pCcAcTLFGz8qbKirYl8VV2 + url: https://api.fastly.com/tls/private_keys/0LYME3yUMZpE0lKca6dGr2 method: DELETE response: body: "" @@ -17,7 +17,7 @@ interactions: Cache-Control: - private Date: - - Tue, 30 May 2023 16:30:11 GMT + - Wed, 31 May 2023 11:48:30 GMT Pragma: - no-cache Strict-Transport-Security: @@ -31,9 +31,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-cp-aws-us-east-2-prod-4-CONTROL-AWS-UE2, cache-lhr7360-LHR + - cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7383-LHR X-Timer: - - S1685464212.827593,VS0,VE161 + - S1685533710.499519,VS0,VE181 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/mutual_authentication/delete-tma.yaml b/fastly/fixtures/mutual_authentication/delete-tma.yaml index 4505efa9d..fc6d18328 100644 --- a/fastly/fixtures/mutual_authentication/delete-tma.yaml +++ b/fastly/fixtures/mutual_authentication/delete-tma.yaml @@ -7,7 +7,7 @@ interactions: headers: User-Agent: - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) - url: https://api.fastly.com/tls/mutual_authentications/ighDXgQbj0EH8utWHwfzn5 + url: https://api.fastly.com/tls/mutual_authentications/4tFjGkmDCvPr7f4I9RlDq5 method: DELETE response: body: "" @@ -17,7 +17,7 @@ interactions: Cache-Control: - private Date: - - Tue, 30 May 2023 16:30:11 GMT + - Wed, 31 May 2023 11:48:30 GMT Pragma: - no-cache Strict-Transport-Security: @@ -31,9 +31,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + - cache-control-cp-aws-us-east-2-prod-2-CONTROL-AWS-UE2, cache-lhr7383-LHR X-Timer: - - S1685464211.229053,VS0,VE265 + - S1685533710.907186,VS0,VE239 status: 204 No Content code: 204 duration: "" diff --git a/fastly/fixtures/mutual_authentication/get.yaml b/fastly/fixtures/mutual_authentication/get.yaml index 95c72f8cc..814fb5a0d 100644 --- a/fastly/fixtures/mutual_authentication/get.yaml +++ b/fastly/fixtures/mutual_authentication/get.yaml @@ -7,11 +7,11 @@ interactions: headers: User-Agent: - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) - url: https://api.fastly.com/tls/mutual_authentications/ighDXgQbj0EH8utWHwfzn5 + url: https://api.fastly.com/tls/mutual_authentications/4tFjGkmDCvPr7f4I9RlDq5 method: GET response: - body: '{"data":{"id":"ighDXgQbj0EH8utWHwfzn5","type":"mutual_authentication","attributes":{"created_at":"2023-05-30T16:30:10.000Z","enforced":true,"name":"My - mutual authentication","updated_at":"2023-05-30T16:30:10.000Z"},"relationships":{"tls_activations":{"data":[]}}}}' + body: '{"data":{"id":"4tFjGkmDCvPr7f4I9RlDq5","type":"mutual_authentication","attributes":{"created_at":"2023-05-31T11:48:28.000Z","enforced":true,"name":"My + mutual authentication","updated_at":"2023-05-31T11:48:28.000Z"},"relationships":{"tls_activations":{"data":[]}}}}' headers: Accept-Ranges: - bytes @@ -22,7 +22,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 May 2023 16:30:10 GMT + - Wed, 31 May 2023 11:48:29 GMT Pragma: - no-cache Strict-Transport-Security: @@ -38,9 +38,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-cp-aws-us-east-2-prod-5-CONTROL-AWS-UE2, cache-lhr7360-LHR + - cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7383-LHR X-Timer: - - S1685464211.775420,VS0,VE152 + - S1685533709.110117,VS0,VE314 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/mutual_authentication/list.yaml b/fastly/fixtures/mutual_authentication/list.yaml index 3e3c2ed6d..93cc43c26 100644 --- a/fastly/fixtures/mutual_authentication/list.yaml +++ b/fastly/fixtures/mutual_authentication/list.yaml @@ -12,8 +12,8 @@ interactions: url: https://api.fastly.com/tls/mutual_authentications method: GET response: - body: '{"data":[{"id":"ighDXgQbj0EH8utWHwfzn5","type":"mutual_authentication","attributes":{"created_at":"2023-05-30T16:30:10.000Z","enforced":true,"name":"My - mutual authentication","updated_at":"2023-05-30T16:30:10.000Z"},"relationships":{"tls_activations":{"data":[]}}}],"links":{"self":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100","first":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100","prev":null,"next":null,"last":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100"},"meta":{"per_page":100,"current_page":1,"record_count":1,"total_pages":1}}' + body: '{"data":[{"id":"4tFjGkmDCvPr7f4I9RlDq5","type":"mutual_authentication","attributes":{"created_at":"2023-05-31T11:48:28.000Z","enforced":true,"name":"My + mutual authentication","updated_at":"2023-05-31T11:48:28.000Z"},"relationships":{"tls_activations":{"data":[]}}}],"links":{"self":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100","first":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100","prev":null,"next":null,"last":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100"},"meta":{"per_page":100,"current_page":1,"record_count":1,"total_pages":1}}' headers: Accept-Ranges: - bytes @@ -24,7 +24,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 May 2023 16:30:10 GMT + - Wed, 31 May 2023 11:48:29 GMT Pragma: - no-cache Strict-Transport-Security: @@ -40,9 +40,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7360-LHR + - cache-control-cp-aws-us-east-2-prod-6-CONTROL-AWS-UE2, cache-lhr7383-LHR X-Timer: - - S1685464211.568441,VS0,VE164 + - S1685533709.786855,VS0,VE299 status: 200 OK code: 200 duration: "" diff --git a/fastly/fixtures/mutual_authentication/update.yaml b/fastly/fixtures/mutual_authentication/update.yaml index 73b8ef9aa..a64a3c3ec 100644 --- a/fastly/fixtures/mutual_authentication/update.yaml +++ b/fastly/fixtures/mutual_authentication/update.yaml @@ -3,7 +3,7 @@ version: 1 interactions: - request: body: | - {"data":{"type":"mutual_authentication","id":"ighDXgQbj0EH8utWHwfzn5","attributes":{"cert_bundle":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMwMTYzMDA4WhcNMjMwODI4MTYzMDA4WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBANDbXwKqKOjntzRrxZU4xkZB+Pr6K8wexMdzBlCA\nIncZ7E1WBdhu4oYcJN0DDDu+aLis8UQ5GeeZgGcAZ2keO5RGnXRZXP1eng38GBDl\nRTzcmVLq82370c9D+ZjNOQbH420FJ5Ojw5QNgGlz62sW4be+8G46SX/66W8xr5nL\n20u03evQAD/puMqNxTeGikXyJDVgPNChkWWxVNW5/PuyUUXO8mlgANHhcWI4v3Fx\nyM9THd9v0nBD0vTK2Ey1WkWU090nE1k6szrLe1uWZ5w61aubekLM+qI0Eb6A0MaC\nfK3SzjEXmLF0mcPl/rRPzA5SZAR4cnnP2FI1RgOkkVk/UMkCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFDauwDsA5D49yAN5LOtvNx6OfubtMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCqFOQTRc9HbdGPst1x7elxp8vU\nKjmeQoh4Gv/y6cILOT6lSNwrGBSltI057uIvARgsxCeCt2X7T/axozrMG/RxPOyJ\nktDx8RG27P3264rvkC80m4sx5KoOirOyQXOy/V7Q4vub3N6Wy94i8aO7vTVKJIOZ\ny8StXdwKBv9HHN04pU0+poS9i8X4mhozOAXnxpqxudyXJiq9ilOTVjmweaA8Hsfq\nj4IZwfr84TiWGGlCR4V6J+l/dbh63xUwMKLVDIouwX5fGhuJeo445kAwZwwVmt6Y\nQZEEiZcK5CE3l00u4NFIMDZkAPh1g6mlal2Dntnlj24BqDXJffv93qCsBGX7\n-----END CERTIFICATE-----","enforced":true,"name":"My mutual authentication updated"}}} + {"data":{"type":"mutual_authentication","id":"4tFjGkmDCvPr7f4I9RlDq5","attributes":{"cert_bundle":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMxMTE0ODI2WhcNMjMwODI5MTE0ODI2WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBALcgLS9FIWYSRw7MLpEV/4nvmlDA95jlXZnejar9\nVbKXxWzEljZZVtp+CniP1ef6OBBwIph9bX9ig+96cMWR1GMlu7kddIisuSFhndPv\nQxCNW6r5Vlh0q9inuizXBdh48Ql4/xWWWHPfGBYFUzHhDaw1qlyH28E1RRp6LsfE\nVh0r5K+NuuL3ZAsXyRM1uzt62mczraVbKLHGjag/5vsgC48Yak9hLC4jUu6cPE9L\nsVX5xAbu21U7TuZslI4nerSsHAMu9463MJh4eTyKhQQiJABql+TiO7+jkDWu/InC\nOvmF3dasTq6HDEKj7Io2m6uTlWCZ0xSdyceWl6h+7OHBbTcCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFL3co7IUnrTsHPO6Xhq5e9IGUkfCMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCyKG37ZQbVFC2ATfcgYcJm9sfF\nraLcm0Ft206ZvWZ8++48G4pE6vSWcnMioMv6vffD/wRSo606Yur1GZ2TsrBok9VE\n7yNXQa+zT/pdvK7XheuCQOfX1PHS6Xe1VK657GMHTGAZZZsssTbb1PdbSkOoLR/w\nqdFf1qbwMUb5Nak4xlOlcInbUVljpSKxt0FcZJjWglINaMyVMG/B1IFFtQX3S8+c\nca7fXIvl9Vw1RO/7/HS9veQ9x1IZmuYW2VelwAkhn33qGdKcRBOAm8UOAdKQH4gT\nMrD7Hc0fqiqvwFDmBQIz5beWeUfxZWtBg+ivFmj739EfdmvkjuqK36kj3LtY\n-----END CERTIFICATE-----","enforced":true,"name":"My mutual authentication updated"}}} form: {} headers: Accept: @@ -12,11 +12,11 @@ interactions: - application/vnd.api+json User-Agent: - FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5) - url: https://api.fastly.com/tls/mutual_authentications/ighDXgQbj0EH8utWHwfzn5 + url: https://api.fastly.com/tls/mutual_authentications/4tFjGkmDCvPr7f4I9RlDq5 method: PATCH response: - body: '{"data":{"id":"ighDXgQbj0EH8utWHwfzn5","type":"mutual_authentication","attributes":{"created_at":"2023-05-30T16:30:10.000Z","enforced":true,"name":"My - mutual authentication updated","updated_at":"2023-05-30T16:30:11.000Z"},"relationships":{"tls_activations":{"data":[]}}}}' + body: '{"data":{"id":"4tFjGkmDCvPr7f4I9RlDq5","type":"mutual_authentication","attributes":{"created_at":"2023-05-31T11:48:28.000Z","enforced":true,"name":"My + mutual authentication updated","updated_at":"2023-05-31T11:48:29.000Z"},"relationships":{"tls_activations":{"data":[]}}}}' headers: Accept-Ranges: - bytes @@ -27,7 +27,7 @@ interactions: Content-Type: - application/vnd.api+json Date: - - Tue, 30 May 2023 16:30:11 GMT + - Wed, 31 May 2023 11:48:29 GMT Pragma: - no-cache Strict-Transport-Security: @@ -43,9 +43,9 @@ interactions: X-Content-Type-Options: - nosniff X-Served-By: - - cache-control-cp-aws-us-east-2-prod-4-CONTROL-AWS-UE2, cache-lhr7360-LHR + - cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7383-LHR X-Timer: - - S1685464211.945710,VS0,VE262 + - S1685533709.447637,VS0,VE333 status: 200 OK code: 200 duration: "" From 056d8f56f89022f2eeda6b4b926cea38aa6fd478 Mon Sep 17 00:00:00 2001 From: Integralist Date: Wed, 31 May 2023 15:37:45 +0100 Subject: [PATCH 7/7] fix(mutual_authentication): add missing body close --- fastly/tls_mutual_authentication.go | 1 + 1 file changed, 1 insertion(+) diff --git a/fastly/tls_mutual_authentication.go b/fastly/tls_mutual_authentication.go index 8f783b8f7..a0b190afe 100644 --- a/fastly/tls_mutual_authentication.go +++ b/fastly/tls_mutual_authentication.go @@ -140,6 +140,7 @@ func (c *Client) CreateTLSMutualAuthentication(i *CreateTLSMutualAuthenticationI if err != nil { return nil, err } + defer r.Body.Close() var o TLSMutualAuthentication if err := jsonapi.UnmarshalPayload(r.Body, &o); err != nil {