diff --git a/test/integration/domains_test.go b/test/integration/domains_test.go index a559b9ec2..a480c0ca9 100644 --- a/test/integration/domains_test.go +++ b/test/integration/domains_test.go @@ -2,9 +2,11 @@ package integration import ( "context" + "strings" "testing" "github.com/linode/linodego/v2" + "github.com/stretchr/testify/require" ) var testDomainCreateOpts = linodego.DomainCreateOptions{ @@ -114,21 +116,22 @@ func TestDomain_Clone_smoke(t *testing.T) { t.Errorf("Error creating domain: %v", err) } + domainPrefix, topLevelDomain, found := strings.Cut(domainToClone.Domain, "-test") + require.True(t, found) + domain, err := client.CloneDomain(context.Background(), domainToClone.ID, linodego.DomainCloneOptions{ - Domain: "linodego-domain-clone.com", + Domain: domainPrefix + "-test-cloned" + topLevelDomain, }) if err != nil { t.Errorf("Error cloning domain, expected struct, got error %v", err) } - cloneTeardown := func() { + t.Cleanup(func() { if err := client.DeleteDomain(context.Background(), domain.ID); err != nil { t.Errorf("Expected to delete a domain, but got %v", err) } teardown() - } - - defer cloneTeardown() + }) // when comparing fixtures to random value Domain will differ if domain.SOAEmail != domainToClone.SOAEmail { diff --git a/test/integration/fixtures/TestDomain_Clone.yaml b/test/integration/fixtures/TestDomain_Clone.yaml index 42cb8a1d1..3c08f36f3 100644 --- a/test/integration/fixtures/TestDomain_Clone.yaml +++ b/test/integration/fixtures/TestDomain_Clone.yaml @@ -2,7 +2,7 @@ version: 1 interactions: - request: - body: '{"domain":"linodego-blue-test.com","type":"master","soa_email":"example@example.com","master_ips":null,"axfr_ips":null,"tags":null}' + body: '{"domain":"linodego-blue-245372-test.com","type":"master","soa_email":"example@example.com","master_ips":null,"axfr_ips":null,"tags":null}' form: {} headers: Accept: @@ -14,11 +14,11 @@ interactions: url: https://api.linode.com/v4beta/domains method: POST response: - body: '{"id": 3163304, "type": "master", "domain": "linodego-blue-test.com", "tags": - [], "group": "", "status": "active", "errors": "", "description": "", "soa_email": - "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips": [], "expire_sec": - 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05", "updated": - "2018-01-02T03:04:05"}' + body: '{"id": 3697372, "type": "master", "domain": "linodego-blue-245372-test.com", + "tags": [], "group": "", "status": "active", "errors": "", "description": "", + "soa_email": "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips": + [], "expire_sec": 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05", + "updated": "2018-01-02T03:04:05"}' headers: Access-Control-Allow-Credentials: - "true" @@ -37,13 +37,13 @@ interactions: Connection: - keep-alive Content-Length: - - "350" + - "357" Content-Security-Policy: - default-src 'none' Content-Type: - application/json Expires: - - Tue, 19 Nov 2024 15:25:43 GMT + - Wed, 21 Oct 2026 11:32:20 GMT Pragma: - no-cache Strict-Transport-Security: @@ -58,19 +58,16 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "1600" + - "1840" X-Xss-Protection: - 1; mode=block status: 200 OK code: 200 duration: "" - request: - body: '{"domain":"linodego-domain-clone.com"}' + body: '{"domain":"linodego-blue-245372-test-cloned.com"}' form: {} headers: Accept: @@ -79,10 +76,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3163304/clone + url: https://api.linode.com/v4beta/domains/3697372/clone method: POST response: - body: '{"id": 3163305, "type": "master", "domain": "linodego-domain-clone.com", + body: '{"id": 3697373, "type": "master", "domain": "linodego-blue-245372-test-cloned.com", "tags": [], "group": "", "status": "active", "errors": "", "description": "", "soa_email": "example@example.com", "retry_sec": 0, "master_ips": [], "axfr_ips": [], "expire_sec": 0, "refresh_sec": 0, "ttl_sec": 0, "created": "2018-01-02T03:04:05", @@ -105,13 +102,13 @@ interactions: Connection: - keep-alive Content-Length: - - "353" + - "364" Content-Security-Policy: - default-src 'none' Content-Type: - application/json Expires: - - Tue, 19 Nov 2024 15:25:45 GMT + - Wed, 21 Oct 2026 11:32:23 GMT Pragma: - no-cache Strict-Transport-Security: @@ -126,12 +123,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "1600" + - "1840" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -147,7 +141,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3163305 + url: https://api.linode.com/v4beta/domains/3697373 method: DELETE response: body: '{}' @@ -175,7 +169,7 @@ interactions: Content-Type: - application/json Expires: - - Tue, 19 Nov 2024 15:25:45 GMT + - Wed, 21 Oct 2026 11:32:24 GMT Pragma: - no-cache Strict-Transport-Security: @@ -190,12 +184,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "1600" + - "1840" X-Xss-Protection: - 1; mode=block status: 200 OK @@ -211,7 +202,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/domains/3163304 + url: https://api.linode.com/v4beta/domains/3697372 method: DELETE response: body: '{}' @@ -239,7 +230,7 @@ interactions: Content-Type: - application/json Expires: - - Tue, 19 Nov 2024 15:25:45 GMT + - Wed, 21 Oct 2026 11:32:24 GMT Pragma: - no-cache Strict-Transport-Security: @@ -254,12 +245,9 @@ interactions: - DENY - DENY X-Oauth-Scopes: - - account:read_write databases:read_write domains:read_write events:read_write - firewall:read_write images:read_write ips:read_write linodes:read_write lke:read_write - longview:read_write nodebalancers:read_write object_storage:read_write stackscripts:read_write - volumes:read_write vpc:read_write + - '*' X-Ratelimit-Limit: - - "1600" + - "1840" X-Xss-Protection: - 1; mode=block status: 200 OK