blob: 2d816f065cee3c9296416bab825c7cc232288a9e [file] [log] [blame]
Jon Perritt33ed7412014-10-17 19:35:32 -05001// +build acceptance rackspace objectstorage v1
2
Jon Perritt8abd2c22014-10-16 20:28:51 -05003package v1
Jon Perritt33ed7412014-10-17 19:35:32 -05004
5import (
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
16func TestCDNObjects(t *testing.T) {
17 raxClient, err := createClient(t, false)
18 th.AssertNoErr(t, err)
19
20 headers, err := raxContainers.Create(raxClient, "gophercloud-test", nil).ExtractHeaders()
21 th.AssertNoErr(t, err)
22 t.Logf("Headers from Create Container request: %+v\n", headers)
23 defer func() {
24 _, err := raxContainers.Delete(raxClient, "gophercloud-test").ExtractHeaders()
25 th.AssertNoErr(t, err)
26 }()
27
28 headers, err = raxObjects.Create(raxClient, "gophercloud-test", "test-object", bytes.NewBufferString("gophercloud cdn test"), nil).ExtractHeaders()
29 th.AssertNoErr(t, err)
30 t.Logf("Headers from Create Object request: %+v\n", headers)
31 defer func() {
32 _, err := raxObjects.Delete(raxClient, "gophercloud-test", "test-object", nil).ExtractHeaders()
33 th.AssertNoErr(t, err)
34 }()
35
36 raxCDNClient, err := createClient(t, true)
37 th.AssertNoErr(t, err)
38
39 headers, err = raxCDNContainers.Enable(raxCDNClient, "gophercloud-test", raxCDNContainers.EnableOpts{CDNEnabled: true, TTL: 900}).ExtractHeaders()
40 th.AssertNoErr(t, err)
41 t.Logf("Headers from Enable CDN Container request: %+v\n", headers)
42
43 headers, err = raxCDNObjects.Delete(raxCDNClient, "gophercloud-test", "test-object", nil).ExtractHeaders()
44 th.AssertNoErr(t, err)
45 t.Logf("Headers from Delete CDN Object request: %+v\n", headers)
46}