Jon Perritt | 33ed741 | 2014-10-17 19:35:32 -0500 | [diff] [blame] | 1 | // +build acceptance rackspace objectstorage v1 |
| 2 | |
Jon Perritt | 8abd2c2 | 2014-10-16 20:28:51 -0500 | [diff] [blame] | 3 | package v1 |
Jon Perritt | 33ed741 | 2014-10-17 19:35:32 -0500 | [diff] [blame] | 4 | |
| 5 | import ( |
| 6 | "bytes" |
| 7 | "testing" |
| 8 | |
| 9 | raxCDNContainers "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdncontainers" |
| 10 | raxCDNObjects "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/cdnobjects" |
| 11 | raxContainers "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/containers" |
| 12 | raxObjects "github.com/rackspace/gophercloud/rackspace/objectstorage/v1/objects" |
| 13 | th "github.com/rackspace/gophercloud/testhelper" |
| 14 | ) |
| 15 | |
| 16 | func TestCDNObjects(t *testing.T) { |
| 17 | raxClient, err := createClient(t, false) |
| 18 | th.AssertNoErr(t, err) |
| 19 | |
Ash Wilson | fef72b8 | 2014-10-24 15:46:45 -0400 | [diff] [blame] | 20 | createContResult := raxContainers.Create(raxClient, "gophercloud-test", nil) |
| 21 | th.AssertNoErr(t, createContResult.Err) |
| 22 | t.Logf("Headers from Create Container request: %+v\n", createContResult.Header) |
Jon Perritt | 33ed741 | 2014-10-17 19:35:32 -0500 | [diff] [blame] | 23 | defer func() { |
Ash Wilson | fef72b8 | 2014-10-24 15:46:45 -0400 | [diff] [blame] | 24 | deleteResult := raxContainers.Delete(raxClient, "gophercloud-test") |
| 25 | th.AssertNoErr(t, deleteResult.Err) |
Jon Perritt | 33ed741 | 2014-10-17 19:35:32 -0500 | [diff] [blame] | 26 | }() |
| 27 | |
Jon Perritt | 10a7ec1 | 2014-10-27 11:29:33 -0500 | [diff] [blame] | 28 | header, err := raxObjects.Create(raxClient, "gophercloud-test", "test-object", bytes.NewBufferString("gophercloud cdn test"), nil).ExtractHeader() |
| 29 | th.AssertNoErr(t, err) |
| 30 | t.Logf("Headers from Create Object request: %+v\n", header) |
Jon Perritt | 33ed741 | 2014-10-17 19:35:32 -0500 | [diff] [blame] | 31 | defer func() { |
Ash Wilson | fef72b8 | 2014-10-24 15:46:45 -0400 | [diff] [blame] | 32 | deleteResult := raxObjects.Delete(raxClient, "gophercloud-test", "test-object", nil) |
| 33 | th.AssertNoErr(t, deleteResult.Err) |
Jon Perritt | 33ed741 | 2014-10-17 19:35:32 -0500 | [diff] [blame] | 34 | }() |
| 35 | |
| 36 | raxCDNClient, err := createClient(t, true) |
| 37 | th.AssertNoErr(t, err) |
| 38 | |
Jon Perritt | 65c81ec | 2015-02-16 11:07:11 -0700 | [diff] [blame] | 39 | enableHeader, err := raxCDNContainers.Enable(raxCDNClient, "gophercloud-test", raxCDNContainers.EnableOpts{CDNEnabled: true, TTL: 900}).Extract() |
| 40 | th.AssertNoErr(t, err) |
| 41 | t.Logf("Headers from Enable CDN Container request: %+v\n", enableHeader) |
Jon Perritt | 33ed741 | 2014-10-17 19:35:32 -0500 | [diff] [blame] | 42 | |
Jon Perritt | 65c81ec | 2015-02-16 11:07:11 -0700 | [diff] [blame] | 43 | objCDNURL, err := raxCDNObjects.CDNURL(raxCDNClient, "gophercloud-test", "test-object") |
| 44 | th.AssertNoErr(t, err) |
| 45 | t.Logf("%s CDN URL: %s\n", "test_object", objCDNURL) |
| 46 | |
| 47 | deleteHeader, err := raxCDNObjects.Delete(raxCDNClient, "gophercloud-test", "test-object", nil).Extract() |
| 48 | th.AssertNoErr(t, err) |
| 49 | t.Logf("Headers from Delete CDN Object request: %+v\n", deleteHeader) |
Jon Perritt | 33ed741 | 2014-10-17 19:35:32 -0500 | [diff] [blame] | 50 | } |