blob: 0c0ab8a1ed0e78cc47683a8bcafc418069c0535e [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
Ash Wilsonfef72b82014-10-24 15:46:45 -040020 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 Perritt33ed7412014-10-17 19:35:32 -050023 defer func() {
Ash Wilsonfef72b82014-10-24 15:46:45 -040024 deleteResult := raxContainers.Delete(raxClient, "gophercloud-test")
25 th.AssertNoErr(t, deleteResult.Err)
Jon Perritt33ed7412014-10-17 19:35:32 -050026 }()
27
Jon Perritt10a7ec12014-10-27 11:29:33 -050028 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 Perritt33ed7412014-10-17 19:35:32 -050031 defer func() {
Ash Wilsonfef72b82014-10-24 15:46:45 -040032 deleteResult := raxObjects.Delete(raxClient, "gophercloud-test", "test-object", nil)
33 th.AssertNoErr(t, deleteResult.Err)
Jon Perritt33ed7412014-10-17 19:35:32 -050034 }()
35
36 raxCDNClient, err := createClient(t, true)
37 th.AssertNoErr(t, err)
38
Jon Perritt65c81ec2015-02-16 11:07:11 -070039 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 Perritt33ed7412014-10-17 19:35:32 -050042
Jon Perritt65c81ec2015-02-16 11:07:11 -070043 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 Perritt33ed7412014-10-17 19:35:32 -050050}